Last active
August 29, 2015 14:02
-
-
Save jaen/e4a0ff557f63b84bbb46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Draw (void) | |
{ | |
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer | |
glLoadIdentity (); // Reset The Modelview Matrix | |
// Get FPS | |
if( GetTickCount() - g_dwLastFPS >= 1000 ) // When A Second Has Passed... | |
{ | |
g_dwLastFPS = GetTickCount(); // Update Our Time Variable | |
g_nFPS = g_nFrames; // Save The FPS | |
g_nFrames = 0; // Reset The FPS Counter | |
char szTitle[256]={0}; // Build The Title String | |
sprintf( szTitle, "Lesson 45: NeHe & Paul Frazee's VBO Tut - %d Triangles, %d FPS", g_pMesh->m_nVertexCount / 3, g_nFPS ); | |
if( g_fVBOSupported ) // Include A Notice About VBOs | |
strcat( szTitle, ", Using VBOs" ); | |
else | |
strcat( szTitle, ", Not Using VBOs" ); | |
SetWindowText( g_window->hWnd, szTitle ); // Set The Title | |
} | |
g_nFrames++; // Increment Our FPS Counter | |
// Move The Camera | |
glTranslatef( 0.0f, -220.0f, 0.0f ); // Move Above The Terrain | |
glRotatef( 10.0f, 1.0f, 0.0f, 0.0f ); // Look Down Slightly | |
glRotatef( g_flYRot, 0.0f, 1.0f, 0.0f ); // Rotate The Camera | |
// Enable Pointers | |
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays | |
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays | |
// Set Pointers To Our Data | |
if( g_fVBOSupported ) | |
{ | |
glBindBufferARB( GL_ARRAY_BUFFER_ARB, g_pMesh->m_nVBOVertices ); | |
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL ); // Set The Vertex Pointer To The Vertex Buffer | |
glBindBufferARB( GL_ARRAY_BUFFER_ARB, g_pMesh->m_nVBOTexCoords ); | |
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // Set The TexCoord Pointer To The TexCoord Buffer | |
} else | |
{ | |
glVertexPointer( 3, GL_FLOAT, 0, g_pMesh->m_pVertices ); // Set The Vertex Pointer To Our Vertex Data | |
glTexCoordPointer( 2, GL_FLOAT, 0, g_pMesh->m_pTexCoords ); // Set The Vertex Pointer To Our TexCoord Data | |
} | |
// Render | |
glDrawArrays( GL_TRIANGLES, 0, g_pMesh->m_nVertexCount ); // Draw All Of The Triangles At Once | |
// Disable Pointers | |
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays | |
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quicksort :: Ord a => [a] -> [a] | |
quicksort [] = [] | |
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater) | |
where | |
lesser = filter (< p) xs | |
greater = filter (>= p) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment