开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜