简体   繁体   中英

Opengl, 2d stationary shapes, in a 3d scene with a moving camera

I have a 3d scene drawn out in Opengl, the camera is allowed to pan around the scene. How do I go about adding 2d shapes to the window that will be unaffected by the camera moving?

Generally this is done by drawing in two steps. Assuming that you would like the 2D shapes to always be "on top" of scene like a GUI, I would render your 3D scene, then use glOrtho2D and draw your shapes. You'll probably want to also disable depth testing. Be sure to set back up for your 3D each frame.

After drawing the scene, you can set the camera matrix to an orthographic view, and draw the 2D overlay.

If the outline of your 2d overlay is free-form in any way, you can use an alpha mask to implement it.

You can use another toolkit and embed the OpenGL frame. SDL is popular and portable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM