caaso

11-14-2011, 06:24 AM

Hello!

I have a problem setting up an orthographic projection matrix with glm::ortho(). The object is a simple quad build by two triangles. The triangles are in the xy-plane with z=0. Using glm::perspective() everything is shown correct.

perspective:

P = glm::perspective(60.0f, (float)windowWidth / (float)windowHeight, 0.1f, 100.0f);

ortho:

P = glm::ortho(0.0f, (float)windowWidth,(float)windowHeight,0.0f, 0.1f, 100.0f);

matrix multiplication:

V = glm::lookAt( glm::vec3( 0.f, 0.f, 2.0f ),glm::vec3( 0.f, 0.f, 0.f ),glm::vec3( 0.0f, 1.0f, 0.0f ) );

glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, 0.0f));

glm::mat4 Rx = glm::rotate(T, rotation_x, glm::vec3(1.0f, 0.0f, 0.0f));

glm::mat4 Ry = glm::rotate(Rx, rotation_y, glm::vec3(0.0f, 1.0f, 0.0f));

glm::mat4 M = glm::rotate(Ry, rotation_z, glm::vec3(0.0f, 0.0f, 1.0f));

glm::mat4 MVP = P*V*M;

As I said, using glm::perspective everything works fine. So can anyone help me?

greetz caaso

I have a problem setting up an orthographic projection matrix with glm::ortho(). The object is a simple quad build by two triangles. The triangles are in the xy-plane with z=0. Using glm::perspective() everything is shown correct.

perspective:

P = glm::perspective(60.0f, (float)windowWidth / (float)windowHeight, 0.1f, 100.0f);

ortho:

P = glm::ortho(0.0f, (float)windowWidth,(float)windowHeight,0.0f, 0.1f, 100.0f);

matrix multiplication:

V = glm::lookAt( glm::vec3( 0.f, 0.f, 2.0f ),glm::vec3( 0.f, 0.f, 0.f ),glm::vec3( 0.0f, 1.0f, 0.0f ) );

glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, 0.0f));

glm::mat4 Rx = glm::rotate(T, rotation_x, glm::vec3(1.0f, 0.0f, 0.0f));

glm::mat4 Ry = glm::rotate(Rx, rotation_y, glm::vec3(0.0f, 1.0f, 0.0f));

glm::mat4 M = glm::rotate(Ry, rotation_z, glm::vec3(0.0f, 0.0f, 1.0f));

glm::mat4 MVP = P*V*M;

As I said, using glm::perspective everything works fine. So can anyone help me?

greetz caaso