c++ - OpenGL vertex shader: weird matrix translation -


i'm trying move triangle based on time using matrix. weird stuff:

what should do: move on x-axis

what does: top point of triangle fixed , other points seem move around in circular movement , scale on x, z axis (i'm still in 2d don't have depth).

my c++ code:

    ...     glfloat timevalue = glfwgettime();     glfloat offset = (sin(timevalue  * 4) / 2);      glfloat matrix[16] = {         1, 0, 0, offset,         0, 1, 0, 0,         0, 0, 1, 0,         0, 0, 0, 1     };      gluint uniform_m_transform = glgetuniformlocation(shader_program, "m_transform");     gluniformmatrix4fv(uniform_m_transform, 1, gl_false, matrix);     ... 

my vertex shader:

#version 330 core  layout (location = 0) in vec3 position;  layout (location = 1) in vec3 color;   out vec3 ourcolor;  uniform mat4 m_transform;   void main()  {      ourcolor = color;      gl_position = m_transform * vec4(position, 1.0);  } 

i don't know did wrong, according tutorial matrix attribute i've set offset should change x-translation.

do know what's mistake?

you providing row-major matrix, need specify transpose:

gluniformmatrix4fv(uniform_m_transform, 1, gl_true, matrix); 

reference: gluniform, check transpose parameter.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -