I’m wondering what would be the preferred way to draw a 2d ui overlay on top of a 3d game. Some ideas I’ve seen online or am considering are:
- draw the 3d frame, set projection/view uniform matrices to Identity, draw UI
- draw 3d frame, set some uniform boolean value that tell shaders to skip the matrix transformations, draw ui, reset the boolean
- draw 3d frame, switch to another shaderProgram, draw UI, switch back to 3d shaderProgram.
I’m not sure how expensive switching shader programs (3), but https://www.opengl.org/discussion_boards/showthread.php/173818-Best-way-to-handle-multiple-shaders suggests it shouldn’t be a problem. Likewise, not sure how expensive checking a uniform boolean value for every single vertex (2) would be?