I want to draw a string of text with a single draw call (Instancing). I am reading a bitmap for each character texture. I want to pass the texture coordinates for each vertex of a quad (a single character). Now these texture coordinates are supposed to be updated for each vertex processed by the vertex shader because I set the glVertexAttribDivisor()
to 0 which means it should be. But it's not happening.
Here's the source code where I am sending the data to the GPU...
//TEXTURE COORDS
glBindBuffer(GL_ARRAY_BUFFER, mVBOTexCoords);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec2)*mTexCoords.size(), mTexCoords.data(), GL_STATIC_DRAW);
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 0, 0);
glVertexAttribDivisor(3,0);
and the vertex shader...
#version 400
out vec2 tex_coords;
layout(location = 0) in vec2 pos;
layout(location = 1) in vec2 offset;
layout(location = 2) in vec2 scale;
layout(location = 3) in vec2 tex;
uniform mat4 projection;
void main()
{
tex_coords = tex;
vec4 position = vec4(pos,0.0f,1.0f);
position.xy*=scale;
position.xy+=offset;
gl_Position = projection*position;
}
Sorry for the mess. I hope you get it. I am not getting why its not updating the texture coordninates for each vertex.
glGetError
calls, to see if the driver reports any issues? $\endgroup$