PDA

View Full Version : Turning off the programming pipeline/drawing text



chachacha
01-01-2016, 02:58 AM
I need to add labels to my scene and thought easiest to turn off the programmable pipeline and use GLUT calls. Running into problems I now have two questions:

(1) Tried


glUseProgram(program)
... regular code
glUseProgram(0)
... GLUT text calls

in the drawing routine but it doesn't work. What might be the problem and what is the correct way to transition
in/out of the programmable pipeline?

(2) What's the best practice for drawing text in the programmable pipeline?

Thanks in advance.

GClements
01-01-2016, 03:49 AM
(1) Tried


glUseProgram(program)
... regular code
glUseProgram(0)
... GLUT text calls

in the drawing routine but it doesn't work. What might be the problem

It might be any number of things; it's almost impossible to say without more information.

Most of the likely possibilities boil down to forgetting to set up the necessary fixed-function state (e.g. model-view or projection matrices), because it wasn't relevant when using a shader.


and what is the correct way to transition in/out of the programmable pipeline?
glUseProgram().


(2) What's the best practice for drawing text in the programmable pipeline?
glBitmap() does actually work with shaders, but you can't use any user-defined variables in the interface between the vertex shader and the fragment shader. glRasterPos() and glWindowPos() invoke the vertex shader, but only store pre-defined variables such as gl_Position, not user-defined variables. Any user-defined variables will be undefined when the fragment shader is invoked by glBitmap(). At least, that's how it's supposed to work, although it's a sufficiently uncommon case that implementation bugs could easily go unnoticed.

If you're concerned with the core profile rather than with shaders per se, you need to use textured "quads" (i.e. triangle pairs) instead of bitmaps. Or you can use stroke fonts.

chachacha
01-01-2016, 09:16 AM
Thanks much.