# Thread: Rotating the projection matrix

1. ## Rotating the projection matrix

Hi,

Not sure whether I'm thinking wrongly about my problem or whether I just not haven't found the right way to do it yet, but here it is.

What I want to do is apply a rotation to the projection matrix and then apply glOrtho. Why do I want to do that? Because the objects I draw are given to me in another referential. Of course I could just rotate the modelview before drawing the objects (and this works) but I don't understand why the rotation of the projection matrix does not work.

Code :
```	glMatrixMode(GL_PROJECTION);
// where I would like to insert some glRotatef
glOrtho(-150, 150, -100, 200, 1, 10000);
glMatrixMode(GL_MODELVIEW);
gluLookAt(-300, 0, 300, 0.0f, 0.0f, .0f, 0.0, 1.0, 0.0);
glRotatef(-90.0f, 1.0, .0f,  .0f);
glRotatef(180.0f,  .0, .0f, 1.0f);
// draw my objects here```

Now what I would like to do is get the same effect but by rotating the projection matrix (where I put the comment in the code). If I rotate around the z axis, the objects are drawn correctly, just with another orientation. But if I apply a rotation of 90 degrees on x, than the object get completely crushed on one of the side of the viewport.

Any advice / light shed on this would be really welcome!!

2. ## Re: Rotating the projection matrix

What exactly is it that you expect to have happen when you apply a rotation to post-orthographic projected points? What effect are you trying to achieve?

3. ## Re: Rotating the projection matrix

I'm trying to rotate the referential by -90 degrees on x and 180 degrees on z. My goal is to change my existing referential so that it matches the one of the objects that I'm trying to draw. Does it make sense?

4. ## Re: Rotating the projection matrix

You really should do it with the modelview matrix.

Rotating -90° around x makes x unchanged, y maps to -z, and z maps to y. Rotating the result of 180° around z will then make x maps to -x, y maps to z and z maps to y.

So, a matrix like this one might help:

Code :
```-1  0  0  0
0   0  1  0
0   1  0  0
0   0  0  1```

5. ## Re: Rotating the projection matrix

OK thanks! That's what I wasn't sure of (using the proj. vs. the MV matrix).

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•