Advertisement
Guest User

Untitled

a guest
May 13th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.92 KB | None | 0 0
  1. # OpenGL example using glut
  2.  
  3. import opengl/glut
  4. import opengl
  5. import opengl/glu
  6.  
  7. proc display() {.cdecl.} =
  8.   glClear(GL_COLOR_BUFFER_BIT)
  9.   glMatrixMode(GL_MODELVIEW)
  10.   glLoadIdentity()                 # Reset the model-view matrix
  11.  
  12.   glBegin(GL_TRIANGLES)        # Begin drawing of triangles
  13.  
  14.   glColor3f(0.0, 1.0, 0.0)
  15.   glVertex3f( -0.5, -0.5, 0.0)
  16.   glColor3f(1.0, 0.0, 0.0)
  17.   glVertex3f(0, 0.5, 0.0)
  18.   glColor3f(0.0, 0.0, 1.0)
  19.   glVertex3f(0.5, -0.5, 0.0)
  20.  
  21.   glEnd()  # End of drawing
  22.  
  23.   glutSwapBuffers() # Swap the front and back frame buffers (double buffering)
  24.  
  25. var argc: cint = 0
  26. glutInit()
  27.  
  28. glutInitDisplayMode(GLUT_DOUBLE)
  29. glutInitWindowSize(640, 480)
  30. glutInitWindowPosition(50, 50)
  31. discard glutCreateWindow("Modern OpenGL Example")
  32.  
  33. glutDisplayFunc(display)
  34.  
  35. loadExtensions()
  36.  
  37. glClearColor(0.0, 0.0, 0.0, 1.0)                   # Set background color to black and opaque
  38.  
  39. glutMainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement