| 88 | } |
| 89 | |
| 90 | static void draw_screen( void ) |
| 91 | { |
| 92 | /* Our angle of rotation. */ |
| 93 | static float angle = 0.0f; |
| 94 | |
| 95 | /* |
| 96 | * EXERCISE: |
| 97 | * Replace this awful mess with vertex |
| 98 | * arrays and a call to glDrawElements. |
| 99 | * |
| 100 | * EXERCISE: |
| 101 | * After completing the above, change |
| 102 | * it to use compiled vertex arrays. |
| 103 | * |
| 104 | * EXERCISE: |
| 105 | * Verify my windings are correct here ;). |
| 106 | */ |
| 107 | static GLfloat v0[] = { -1.0f, -1.0f, 1.0f }; |
| 108 | static GLfloat v1[] = { 1.0f, -1.0f, 1.0f }; |
| 109 | static GLfloat v2[] = { 1.0f, 1.0f, 1.0f }; |
| 110 | static GLfloat v3[] = { -1.0f, 1.0f, 1.0f }; |
| 111 | static GLfloat v4[] = { -1.0f, -1.0f, -1.0f }; |
| 112 | static GLfloat v5[] = { 1.0f, -1.0f, -1.0f }; |
| 113 | static GLfloat v6[] = { 1.0f, 1.0f, -1.0f }; |
| 114 | static GLfloat v7[] = { -1.0f, 1.0f, -1.0f }; |
| 115 | static GLubyte red[] = { 255, 0, 0, 255 }; |
| 116 | static GLubyte green[] = { 0, 255, 0, 255 }; |
| 117 | static GLubyte blue[] = { 0, 0, 255, 255 }; |
| 118 | static GLubyte white[] = { 255, 255, 255, 255 }; |
| 119 | static GLubyte yellow[] = { 0, 255, 255, 255 }; |
| 120 | static GLubyte black[] = { 0, 0, 0, 255 }; |
| 121 | static GLubyte orange[] = { 255, 255, 0, 255 }; |
| 122 | static GLubyte purple[] = { 255, 0, 255, 0 }; |
| 123 | |
| 124 | /* Clear the color and depth buffers. */ |
| 125 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); |
| 126 | |
| 127 | /* We don't want to modify the projection matrix. */ |
| 128 | glMatrixMode( GL_MODELVIEW ); |
| 129 | glLoadIdentity( ); |
| 130 | |
| 131 | /* Move down the z-axis. */ |
| 132 | glTranslatef( 0.0, 0.0, -5.0 ); |
| 133 | |
| 134 | /* Rotate. */ |
| 135 | glRotatef( angle, 0.0, 1.0, 0.0 ); |
| 136 | |
| 137 | if( should_rotate ) { |
| 138 | |
| 139 | if( ++angle > 360.0f ) { |
| 140 | angle = 0.0f; |
| 141 | } |
| 142 | |
| 143 | } |
| 144 | |
| 145 | /* Send our triangle data to the pipeline. */ |
| 146 | glBegin( GL_TRIANGLES ); |
| 147 | |