Advertisement
Guest User

Untitled

a guest
Aug 19th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. while (bGameLoopRunning)
  2. {
  3. SDL_Event e;
  4. if ( SDL_PollEvent(&e) )
  5. {
  6. if (e.type == SDL_QUIT)
  7. {
  8. bGameLoopRunning = false;
  9. }
  10. else
  11. {
  12. if (e.type == SDL_KEYUP && e.key.keysym.sym == SDLK_ESCAPE)
  13. {
  14. bGameLoopRunning = false;
  15. }
  16. }
  17. }
  18.  
  19. glClearColor(0.0,0.0,0.0,0.0);
  20. glClear(GL_COLOR_BUFFER_BIT);
  21.  
  22. /* drawing code in here! */
  23. glUseProgram(theShaderProgram);
  24. glBindBuffer(GL_ARRAY_BUFFER, triangleBufferObject); //bind the buffer we're applying attributes to
  25. glEnableVertexAttribArray(0); //0 is our index, refer to "location = 0" in the vertex shader
  26. glEnableVertexAttribArray(1); //attribute 1 is for vertex color data
  27. glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); //tell gl (shader!) how to interpret our vertex data
  28. glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (void*)48); //color data is 48 bytes in to the array
  29. glDrawArrays(GL_TRIANGLES, 0, 3);
  30.  
  31. glDisableVertexAttribArray(0);
  32. glDisableVertexAttribArray(1);
  33. glUseProgram(0);
  34. /* drawing code above here! */
  35.  
  36. SDL_GL_SwapWindow(window);
  37. //SDL_Delay(20);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement