C ++ opengl: how can I combine 2 different types of projection for 3D graphics and 2-dimensional menus?

I would like to use the Oblique projection for the menu and perspective projection for the 3d scene. is there any way to combine between these two projections?

In general, I ask how to create a menu in opengl for my 3d scene.

Programming using the C ++ language.

Thanks!

+4
source share
2 answers

No problems. Just draw your 3D scene with suitable loaded models and projection matrices. Then load, align the 2D matrices, turn off the depth check and menu. Here is an example of how it might look.

glEnable(GL_DEPTH_TEST) glMatrixMode(GL_MODELVIEW); --code to load my Perspective Modelview Matrix glMatrixMode(GL_PROJECTION); --code to load my Perspective Projection Matrix --code to draw my 3D scene glMatrixMode(GL_MODELVIEW) glLoadIdentity() glMatrixMode(GL_PROJECTION); --code to setup my "menu" coords, probably something like gluOrtho2D glDisable(GL_DEPTH_TEST) --code to draw the menus 
+7
source
  • Draw your 3D scene.
  • Click the projection matrix.
  • (Perhaps clear the depth buffer).
  • 2D projection setup.
  • Draw your 2D menu.
  • Rotate the projection matrix.
+3
source

Source: https://habr.com/ru/post/1306476/


All Articles