-
// main.c
void shaders_set_mat4(uint shader_id, char *name, mat4 val) {
glUniform4fv(glGetUniformLocation(shader_id, name), 1, val);
}
void main() {
mat4 trans = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
shaders_set_mat4(shader_id, "trans", trans);
} // vertex.glsl
#version 330 core
layout(location = 0) in vec3 vPos;
layout(location = 1) in vec2 textureCoord;
out vec2 texCoord;
uniform mat4 trans;
void main() {
gl_Position = vec4((trans * vec4(vPos, 1.0)).xyz, 1.0);
texCoord = textureCoord;
}
I'm pretty sure that's all the code that's relevant. It's all worked without the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
try |
Beta Was this translation helpful? Give feedback.
-
See https://cglm.readthedocs.io/en/latest/opengl.html cglm matrices and vectors are aligned by default to increase speed if you didn't disable it (see https://cglm.readthedocs.io/en/latest/opt.html), aliged data may cause wrong bytes to transfer OpenGL maybe (size of matrix may not be same as packed data), I'm not sure yet. You can disable alignment or you can copy aligned data to packed temp variable then pass it to OpenGL... EDIT1: You can also check the way you build the matrix because the transform matrix itself may be wrong because of wrong order of multiplication... EDIT2: You also throw the gl_Position = trans * vec4(vPos, 1.0); |
Beta Was this translation helpful? Give feedback.
-
Issue solved! If anyone wondering, I failed to realize I had to call |
Beta Was this translation helpful? Give feedback.
try
glUniformMatrix4fv
instead