LWJGL Forum

Programming => OpenGL => Topic started by: poo2thegeek on July 03, 2013, 17:19:44

Title: Questions about shader programs and their implication
Post by: poo2thegeek on July 03, 2013, 17:19:44
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!
Title: Re: Questions about shader programs and their implication
Post by: quew8 on July 03, 2013, 22:13:25
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.
Title: Re: Questions about shader programs and their implication
Post by: poo2thegeek on July 05, 2013, 16:54:29
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!
Title: Re: Questions about shader programs and their implication
Post by: quew8 on July 06, 2013, 06:37:53
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.