How do I do 2D opengl? I need to be able to put stuff up on the screen so that it is not rendered in three dimensions, and I need the 3d stuff to still be 3d behind it.

within the main display loop you can simply change the projection to orthographic. A tidy way is to input a class that has the code neccessary code to generate the 2D projection matrix and neccessary screen co-ordinates. you can then write the commands to draw the objects in this class. In the main loop you then just call this function (it should only take a few lines in the main display keeping it tidy).

The projection can swap from a 2D to 3D projection mode without any noticable artifacts or problems. This works well for interfaces, buttons, heads up displays etc.

Actually, you should just render it as though it's 3D, just keep the z plane constant.

In OpenGL, there really is no difference between 2D and 3D, all the mathematics are the same :)

If you're attempting to render the UI, there are two ways, one is to switch the context as mentioned above and the other is to use render textures on the status z plane in 3D mode.

Edited 5 Years Ago by Ketsuekiame: n/a

you dont lose your 3D by changing projection type just make sure you do it before the frame switchs (it just goes next to your 3D code). You can also just texture or draw flat in 3D as other people have said. I personally just prefer to change to 2D to help keep everything seperate and prevent errors or problems when drawing multiple 3D objects and avoiding potential issues such as hidden surface removal. Realistically i don't think these problems arise much so just so which one you feel most comfortable with to start with and once happy try the other method.

This question has already been answered. Start a new discussion instead.