SilverTES

Opengl: 2d HUD over 3D

Aug 30th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1.     ...After Drawing 3d Stuff...
  2.  
  3. glMatrixMode(GL_PROJECTION);
  4. glPushMatrix();
  5. glLoadIdentity();
  6. glOrtho(0.0, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0, -1.0, 10.0);
  7. glMatrixMode(GL_MODELVIEW);
  8. //glPushMatrix();        ----Not sure if I need this
  9. glLoadIdentity();
  10. glDisable(GL_CULL_FACE);
  11.  
  12. glClear(GL_DEPTH_BUFFER_BIT);
  13.  
  14. glBegin(GL_QUADS);
  15.     glColor3f(1.0f, 0.0f, 0.0);
  16.     glVertex2f(0.0, 0.0);
  17.     glVertex2f(10.0, 0.0);
  18.     glVertex2f(10.0, 10.0);
  19.     glVertex2f(0.0, 10.0);
  20. glEnd();
  21.  
  22. // Making sure we can render 3d again
  23. glMatrixMode(GL_PROJECTION);
  24. glPopMatrix();
  25. glMatrixMode(GL_MODELVIEW);
  26. //glPopMatrix();        ----and this?
  27.  
  28. ...Then swap buffers...
Advertisement
Add Comment
Please, Sign In to add comment