Questions about shader programs and their implication

Started by poo2thegeek, July 03, 2013, 17:19:44

Previous topic - Next topic

poo2thegeek

I have recently been learning GLSL for shaders, but I have come up with some problems when using them with lwjgl.
The main problem is that when the program is active any text in my game gets turned into a black block of colour. This lead me to try and find ways of pausing the use of a shader program so that I can only have it active while drawing objects that need it applied to them. So is there a way of doing this?

Thank you!

quew8

Bind the default shader (ie the fixed function pipeline), draw what doesn't need your shader, rebind your shader, draw everything else. If possible, minimize the number of times you bind shaders per frame.

glUseProgram( 0 );
//Draw text
glUseProgram( yourShaderProgramId );
//Draw everything else.

poo2thegeek

Ah right! Thank you! I didn't realize that the program 0 was the default program, and I assumed there was a way of just turning programs off. Thakyou!

quew8

As far as I know, this is the same for all OpenGL objects - VBOS (0 is no buffer), framebuffers ( 0 is the default framebuffer) etc.