Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your above code really doesn't do anything that would be visible because you don't render anything after altering the currently active matrix. The effect of the following code segment is as follows (assume the current stack is <code>MODELVIEW</code>):</p> <pre><code>glPushMatrix(); // push the stack down one matrix and copy the current matrix glRotatef(90,1,0,0); // multiply the current matrix M by a rotation matrix R -&gt; M' = M * R // usually you would render stuff here using the current model-view matrix glPopMatrix(); // pop the top matrix off the stack </code></pre> <p>As you can see, by pushing a new matrix onto the stack, you preserve what ever matrix was on top before the push. Then you manipulate the current top matrix in some way, render stuff, and pop the top matrix off to restore the previous state.</p> <p>I think you can see now why your above code does absolutely nothing of essence - except cause unnecessary overhead.</p> <p>Using the matrix stack, if you insist on using legacy GL, is generally correct here, because you don't want your modifications affecting subsequently rendered geometry. However, what you really want is simple matrix concatenation. Assuming you want to perform and <em>extrinsic rotation</em>, i.e. a rotation about the fixed basis of <code>world-space</code> in <code>z-y-x</code>, you need to do the following:</p> <pre><code>glPushMatrix(); glRotatef(90,1,0,0); glRotatef(90,0,1,0); glRotatef(90,0,0,1); // render camera glPopMatrix(); </code></pre> <p>The above is mathematically equivalent to calculation a rotation matrix <code>R</code> by concatenating the individual rotations <code>R_z</code>, <code>R_y</code> and <code>R_x</code>: <code>R' = R_x * R_y * R_z</code>.</p> <p>I suggest you also read <a href="http://en.wikipedia.org/wiki/Euler_angles" rel="nofollow">this</a> and to better understand what you're doing and potential problems with rotations in general.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload