Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (bGameLoopRunning)
- {
- SDL_Event e;
- if ( SDL_PollEvent(&e) )
- {
- if (e.type == SDL_QUIT)
- {
- bGameLoopRunning = false;
- }
- else
- {
- if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_ESCAPE)
- {
- bGameLoopRunning = false;
- }
- }
- }
- glClearColor(0.0,0.0,0.0,0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- /* drawing code in here! */
- glUseProgram(theShaderProgram);
- glBindBuffer(GL_ARRAY_BUFFER, triangleBufferObject); //bind the buffer we're applying attributes to
- glEnableVertexAttribArray(0); //0 is our index, refer to "location = 0" in the vertex shader
- glEnableVertexAttribArray(1); //attribute 1 is for vertex color data
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); //tell gl (shader!) how to interpret our vertex data
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (void*)48); //color data is 48 bytes in to the array
- glDrawArrays(GL_TRIANGLES, 0, 3);
- glDisableVertexAttribArray(0);
- glDisableVertexAttribArray(1);
- glUseProgram(0);
- /* drawing code above here! */
- SDL_GL_SwapWindow(window);
- //SDL_Delay(20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement