I'm working on creating shaders to be used for displaying text in my openGL programs but am having trouble. I want to be able to scale the text but I don't want to use a uniform ( I want different strings of text to be able to be scaled differently ) so I'm using an in variable. I'm not sure how to use a VBO with a mat4 so instead i've been using a vec2 and trying to convert it to a mat4 in glsl before multiplying it with the position. The problem is that when I run my program, my text isn't scaled; it's just partially missing (the part that is there is about the same size). My vertex shader for this is:
#version 140
in vec2 Position;
in vec4 VertexColor;
in vec2 TexCoord;
in vec2 Scale;
out vec4 Color;
out vec2 UV;
void main()
{
mat4 Scale_Matrix;
for ( int x = 0; x < 4; x++ )
for ( int y = 0; y < 4; y++ )
if ( x == y && x < 2 )
Scale_Matrix[x][y] = Scale[y];
elseif ( x == y )
Scale_Matrix[x][y] = 1;
else
Scale_Matrix[x][y] = 0;
gl_Position = Scale_Matrix * vec4( Position, 0, 1);
UV = TexCoord;
Color = VertexColor;
}
Also, correct me if I'm wrong but a scaling matrix should look like this:
| x, 0, 0, 0 |
| 0, y, 0, 0 |
| 0, 0, z, 0 |
| 0, 0, 0, 1 |
with z = 1 for 2d scaling, right?
Since it doesn't look like the problem is with the shader, I'm gonna look at the my c++ code instead to see if I find any mistakes.
@Disch
I posted an image here: http://tinypic.com/r/2i08byr/5
@xerzi
I changed that in my shader know but nothings changed
Edit:
Nvm. I know what happened, it was a stupid mistake on my part. Among other things, the problem was caused by the positioning of the text, and how the handled the coordinates before sending them to the shader.