Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As SuperMaximo93 says, it's important to separate your transformation matrices, so that all objects are drawn with their own unique transformation. <code>glPushMatrix()</code> is a relatively easy way to handle this.</p> <p>I should add that it's also important that you call your transformation functions (glTranslatef/Rotatef/Scalef/etc) in the correct order.</p> <p>OpenGL multiplies transformation matrices in post-order (as opposed to <em>pre</em>-order). So when you call <code>glRotatef()</code>, the current matrix, <em>C</em>, is multiplied by the rotation matrix representing the <code>glRotate()</code> call, <em>M</em>, in the following way:</p> <p><em>C x M</em></p> <p>and a position (or vector), <em>v</em> transformed by the call is transformed in the following way:</p> <p><em>C x M x v</em></p> <p>This forces you to call the transformation functions in an order which may seem reverse of what should be accomplished. For example:</p> <pre><code>glTranslatef(0.0f, 1.0f, 0.0f); glRotatef(30.0f, 0.0f, 0.0f, 1.0f); drawMyObject(); </code></pre> <p>The effect of the code above would be that the object drawn will <em>first</em> be rotated 30 degrees CCW, <em>then</em> translated upwards on the screen by 1.0 (assuming positive is up on the y-axis), as opposed to first being translated up, then being rotated along the center of the screen by 30 degrees CCW.</p> <p>Also see <a href="http://www.opengl.org/sdk/docs/man/xhtml/glMultMatrix.xml" rel="nofollow">http://www.opengl.org/sdk/docs/man/xhtml/glMultMatrix.xml</a> for more documentation on this.</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.
    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