Results 1 to 2 of 2

Thread: Questions On The Matrix Stack

  1. #1
    Senior Member Regular Contributor
    Join Date
    Apr 2012
    Los Angeles

    Questions On The Matrix Stack

    I'm working with the old classic GL. Have questions about the matrix stack. Let's say I have 6 transformations in the stack applied to my model which is made up of 50,000 vertices. Is the matrix stack resolved BEFORE application to the model? By 'resolved' I mean all 6 matrices in the stack are reduced to one via matrix multiplication. This would make sense because only one matrix would have to be applied to the 50,000 vertices of my model. Could it be that the 6 transformations are applied to the model one at a time? That would seem much slower to me.

    Assuming the stack is reduced to one matrix before application to the model, how often is this done? Is it done every time I refresh the screen - even if nothing in the stack has changed? Is GL smart enough to know that it doesn't have to reduce the stack again if none of the transformations have changed. Put another way - does it save this 'resolved' matrix and only update it if one of the transformations on the stack has changed? Or does it simply do all the matrix multiplications every time I render a frame?


  2. #2
    Member Newbie
    Join Date
    Dec 2013
    It's neither. You start out with only an identity matrix on the stack, and any matrix functions are applied to that matrix; i.e. glTransform, glRotate, and glScale all multiply their "matrix" with the matrix on the stack currently. Then, when you call glPushMatrix, it duplicates the current matrix and puts it on top. That way, you can apply operations to it, and then restore it with a glPopMatrix. A glLoadIdentity loads the identity matrix on the current matrix.

    So, OpenGL doesn't have to do anything to the matrix when you draw stuff. Since all matrix operations affect the current matrix, all OpenGL needs to use is the current matrix.

Similar Threads

  1. Using matrix stack - my code seems to modify the whole stack
    By chromosom in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-04-2014, 03:12 AM
  2. Evaluate matrix stack
    By Oliver Demetz in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 03-13-2008, 02:46 PM
  3. Matrix stack
    By hwj_just in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-30-2005, 11:14 AM
  4. matrix stack
    By stim in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-04-2001, 04:51 AM
  5. matrix stack help
    By hoshi55 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-10-2001, 10:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean