18.07.2014 Views

An Interactive Introduction to OpenGL Programming

An Interactive Introduction to OpenGL Programming

An Interactive Introduction to OpenGL Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>An</strong> <strong>OpenGL</strong> Program<br />

(cont’d.)<br />

void init( void )<br />

{<br />

glClearColor( 0, 0, 0, 1 );<br />

gluLookAt( 2, 2, 2, 0, 0, 0, 0, 1, 0 );<br />

glEnable( GL_DEPTH_TEST );<br />

}<br />

Set up some initial<br />

<strong>OpenGL</strong> state<br />

void reshape( int width, int height )<br />

{<br />

glViewport( 0, 0, width, height );<br />

glMatrixMode( GL_PROJECTION );<br />

Handle when the<br />

glLoadIdentity();<br />

user resizes the<br />

gluPerspective( 60, (GLdouble) width / height, window<br />

1.0, 10.0 );<br />

glMatrixMode( GL_MODELVIEW );<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!