Attempting to make a C++ TOP a filter

So I’ve been taking apart the example OpenGLTOP and I just want to try and build a filter TOP from that. I’m currently getting the “uniform location could not be found” error when running the DLL and was wondering why that might be.

I’m creating an extra 2 attributes in the vertex array which are to be my UV values and adjusting the stride as necessary. With a uniform white shader I get the correct coordinates coming out so I then change that to a uniform sampler2D as my texture…so my Shaders look a bit like this:

[code]static const char *vertexShader = “#version 330\n
in vec3 P;
in vec2 UV;
out vec2 TexCoord;
uniform mat4 uModelView;
void main() {
gl_Position = vec4(P, 1) * uModelView;
}”;

static const char *fragmentShader = “#version 330\n
in vec2 TexCoord;
out vec4 finalColor;
uniform sampler2D uTexture;
void main() {
finalColor = texture(uTexture, TexCoord);
}”;[/code]

In SetupGL I setup my attributes like so:

GLint vertAttribLocation = glGetAttribLocation(myProgram.getName(), "P");
GLint texAttribLocation = glGetAttribLocation(myProgram.getName(), "UV");
myModelViewUniform = glGetUniformLocation(myProgram.getName(), "uModelView");
GLInt myTexSampler = glGetUniformLocation(myProgram.getName(), "uTexture");

I’m then setting my sampler2D in execute by getting the inputs textureindex (OP_TOPInput)

glUniform1i(myTexSampler, input.textureIndex);

And in the Shape class where I bind the array I’m setting the following in setup:

 glEnableVertexAttribArray(attrib);
	glEnableVertexAttribArray(uv);
    glVertexAttribPointer(attrib, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid *)0);
	glVertexAttribPointer(uv, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));

Have I completely missed something here? I am not the best at this openGL malarky but the above stuff seems to work ok in my own GLFW app setup.

So, not related to the error you are saying you see, but the uniform for a sampler needs to be set to it’s texture bind point, not the texture index itself. You use glClientActiveTexture to select the current bind point, and then glBindTexture to bind the texture index to that particular bind point. I.e, glUniform1i generally is set to a value 0-32 or so, and isn’t the GLuint texture ID.

Aha I’ll have a noodle about with that then and see where I get to. Thanks Malcolm.

Sorry it’s glActiveTexture you are looking for, not glClientActiveTexture

my two cents,
Why your stride size is different?
(vertex byte size).

glVertexAttribPointer(attrib, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid *)0); glVertexAttribPointer(uv, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (GLvoid *)(3 * sizeof(GLfloat)));

docs.gl/gl3/glVertexAttribPointer

the position and the uv not in the same array ?