c++ - Rotation performed correctly only when Model-View-Projection multiplication is performed on the shader -


i'm using glm opengl 3.3. have code setup draw shape , using glm create projection, view , model matrices so:

glm::mat4 view = glm::lookat(         glm::vec3(1.2f, 1.2f, 1.2f),         glm::vec3(0.0f, 0.0f, 0.0f),         glm::vec3(0.0f, 0.0f, 1.0f) );  glm::mat4 proj = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 1.0f, 10.0f);  glm::mat4 model; // during main loop model = glm::rotate(model, time*glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)); 

and sending them shader with:

gluniformmatrix4fv(mvp, 1, gl_true, glm::value_ptr(proj * view * model)); 

and in vertex shader:

gl_position = mvp * vec4(position, 0.0, 1.0); 

but shape not displayed correcly, not rotating around center should, instead translated bit center , it's rotating around middle of screen.

though if send 3 matrices shader uniforms , perform calculation position there:

gl_position = model * view * projection * vec4(position, 0.0, 1.0); 

it work expected. tried possible combinations proj x view x model (even though correct order), tried assigning multiplication final matrix , passing shader, etc.

can point out missing?


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -