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.