Frag shader doesn’t appear to function

Hello, I seem to be having a problem running a very simple shader program. I’ve found in some cases the frag shader doesn’t seem to kick in and I’d like to understand why.

The fragment shader using glsl 1.2 simply sets gl_FragColor = vec4(1,1,1,1)

While I can get the shader to function rendering a simple test scene. I am unable to get the shader to function with scene rendered from a third party library using OpenGL 2.1. While the third party library does render the scene to the frame-buffer which can be blitz to the back buffer, I am puzzled why my fragment shader hasn’t affected the scene.

Any thoughts would be greatly appreciated.

There’s no way to know why without actually seeing the code. Generally speaking however, if a library is doing something which is complex enough to be described as “render the scene”, then odds are good that it is also going to be using its own shaders.

If a program is using its own shaders, then it is using its own shaders, not yours. And you (generally) can’t force it to use your stuff unless it is specifically designed to allow you to provide shaders. And if it is, then that would generally be part of the library’s API.

I do have the source code for the library, I had wondered if there was another shader involved but I am confident there isn’t.

Could it be possible that a difference in model/projection matrices used by my app and the third party cause issues with the shader?

As the library is using the same glBegin/glEnd routines to define the group of vertices, as I have done for my test scene, is it possible to add a counter in the vertex shader to determine the number of times it was invoked while rendering a single frame? Are uniform variables static?

You could use an atomic counter if you have OpenGL 4.2 or the ARB_shader_atomic_counters extension.

Uniform variables cannot be modified by shaders.

Turned out that the third-party library had a plugin which was using its own shader.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.