3 # Port of http
://glfw
.sourceforge
.net
/tutorials
/lesson01
/lesson01
.html
13 size
:= glfwGetWindowSize
15 # Make sure that height is non
-zero to avoid division by zero
16 if(size height
< 1, size
setHeight(1))
19 glViewport( 0, 0, size width
, size height
)
21 # Clear color
and depth buffers
22 glClearColor( 0, 0, 0, 0 )
23 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
)
25 # Set up projection matrix
26 glMatrixMode( GL_PROJECTION
) # Select projection matrix
27 glLoadIdentity
# Start with an identity matrix
28 gluPerspective( # Set perspective view
29 65, # Field of view
= 65 degrees
30 size width
/ size height
, # Window
aspect (assumes square pixels
)
31 1, # Near Z clipping plane
32 100 # Far Z clippling plane
35 # Set up modelview matrix
36 glMatrixMode( GL_MODELVIEW
) # Select modelview matrix
37 glLoadIdentity
# Start with an identity matrix
38 gluLookAt( # Set camera position
and orientation
39 0, 0, 10, # Camera
position (x
,y
,z
)
40 0, 0, 0, # View
point (x
,y
,z
)
41 0, 1, 0 # Up
-vector (x
,y
,z
)
44 # Here is where actual
OpenGL rendering calls would begin
...
50 640, 480, # Width
and height of window
51 8, 8, 8, # Number of red
, green
, and blue bits
for color buffer
52 8, # Number of bits
for alpha buffer
53 24, # Number of bits
for depth
buffer (Z
-buffer
)
54 0, # Number of bits
for stencil buffer
55 GLFW_WINDOW
# We want a desktop
window (could be GLFW_FULLSCREEN
)
58 glfwSetWindowTitle( "My OpenGL program" )
59 glfwEnable( GLFW_STICKY_KEYS
)
61 while(glfwGetKey(GLFW_KEY_ESC
) == 0 and glfwGetWindowParam(GLFW_OPENED
) != 0,