Nvidia calls uniform samplerExternalOES as "tex" but glGetUniformLocation it as "texSampler"?

I’m reading code from NVIDIA where it uses the following fragment shader:

    #extension GL_OES_EGL_image_external : require
    precision mediump float;
    varying vec2 interp_tc; 
    uniform samplerExternalOES tex;
    void main() {
    gl_FragColor = texture2D(tex, interp_tc);
    };

it then fills the tex uniform as this:

    glActiveTexture(GL_TEXTURE0);
    glUniform1i(glGetUniformLocation(program, "texSampler"), 0);

How is this possible that it works, if the name of the uniform is tex, not texSampler? I’m trying in my code and I cannot find “tex” using “texSampler”, but with “tex” it works (however filling the uniform gives me an error).

What is happening?

(full code here: https://github.com/lucaszanella/orwell/blob/master/deps/tegra_multimedia_api/samples/common/classes/NvEglRenderer.cpp#L663)

If someone could explain to me what a samplerExternalOES is I’d be glad too

tex is correct here.

Print the value returned from glGetUniformLocation(program, "texSampler"), and I think you’ll find it’s -1, which means it doesn’t exist. Then change the query to get the location of "tex".

indeed only “tex” works; However, I cannot set its value:

                        texLocation = glGetUniformLocation(program->get_id(), "tex");
			if (glGetError() != GL_NO_ERROR)
				printf("Got gl error as 296, %i\n", glGetError());
			printf("texLocation: %i\n", texLocation);
			glUniform1i(texLocation, 0);
			if (glGetError() != GL_NO_ERROR)
				printf("Got gl error as 300, %i\n", glGetError());

gives “Got gl error as 300, 0”

I tried gluniform1i, gluniform1f, gluniform1ui, all them gave this error. Do you have any idea?

I solved it. I needed to use the program before setting the uniform!

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