I’ve ran across a weird thing that is in fact very cool, or perhaps is it me? Here it is…
I created a frag and vertex shader (test.fs & text.vs) and link compile and everything. use gluseprogram and all works well.
Here’s the trick…
On ATI, if I don’t use gluseprogram, well, everything is just doll and only the color (not textures) on my triangles as shown. glLights don’t work etc. as expected?
On NVIdia, ah, it’s beautiful, it calls my shader without first calling gluseprogram, but not only that, glLights work, background image and whatever opengl calls I did are integrated with my shader output! not suppose to?
So is it me or is it that it’s possible to have the shader working along side without calling gluseprogram? From what I’ve read, when you call gluseprogram, you need to do everything in your shader, lights and all.
I used OpenGL to draw a background, shade with a few glLights and also used a shadowmap. On NVidia, it calls my shader for final touch up, which I can confirm because my shader shade the faces with an extra light (not glLigh) in red, all this without first calling gluseprogram.
What do you think?
Please log in or register to post a reply.
If it’s using your shader without ever calling glUseProgram, that’s definitely not supposed to happen. And if the objects rendered with your shader are really getting lit (without you having coded that into the program), that’s borderline impossible to believe.
Are you really sure it’s using your shader, but neither you, nor any framework code you might be using, is calling glUseProgram (or any other alias for it, like glUseProgramARB? Note that if you use the shader for a little while and then un-set it with glUseProgram(0), that could be undefined behavior depending on what version/profile of GL you’re using, so it might continue using the previous shader if you do further rendering after that. Basically, trying to mix fixed-function rendering and shader rendering in the same scene is an iffy proposition.
Yes I’m sure. I do not call glUseProgram at all, I made sure of it. When I do, then only my red light (from the shader code) shade the model, if I don’t, my red light shades the model + the glLights and everything else. The way I test both is compile with glUseProgram and then compile again with glUseProgram commented to make sure it’s not residue from the last display call.
On the ATI however, it won’t work at all that way. If I glUseProgram, then only my red light works. If I don’t gluseProgram, then my red light isn’t working at all but the glLights will.
Make me wonder, since NVidia is capable of doing this, they should actually make it a feature. It’s nice to be able to do both rather than one or the other. Some stuff is simpler and easier to do in GL and others in shaders, but it seems that ATI only let you do one but not both like NVidia.
Maybe it was an unintentional in the part or NVidia, but sometime, a bug can be a discovery of a new feature!