Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:02:42+00:00 2026-06-17T22:02:42+00:00

I am just starting the opengl study, I am going to post a segment

  • 0

I am just starting the opengl study, I am going to post a segment of code, and explains my understanding, could you follow my explanation and point out any problems?

glMatrixMode(GL_MODELVIEW); 
glLoadIdentity();   //start with an identity matrix

glPushMatrix();  
//push the current identity matrix onto the stack, and start with a new identity matrix as 
  the transformation matrix

    glPushMatrix();  
    //copy the current matrix which is the identity as the new transformation matrix and then push the current transformation matrix onto stack

        glScalef(10, 10, 1.0);
        **Question 1**
        //I feels like the order which the image is built is kinda reversed
        //It's like drawSquare happens first, then color, then scale
        //can anyone clarify?
        //Second, the drawsquare defines the 4 vertices around the origin(+/-0.5,+/-0.5)
        //is the origin located at the center of the window by default?
        //what happen when it is scaled? does point (0.5,0.5) scaled to (5,5)?
        glColor3f(0.0, 1.0, 0.0);
        drawSquare(1.0);
    glPopMatrix(); 
    //forget the current transformation matrix, pop out the one on top of the stack
    //which is the identity matrix

    //In the code below:
    //my understanding is 4 vertices is defined around origin, but is this the same origin?
    //then the unit square is moved just below the X-axis
    //and the 4 vertices are scaled one by one?
    //ex: (0.5,0) -> (1,0)  (0.5,-1) -> (1,-2)
    glScalef(2, 2, 1.0);
    glTranslatef(0.0, -0.5, 0.0);
    glColor3f(1.0, 0.0, 0.0);
    drawSquare(1.0);
    //last question, if I want to make the second square rotate at a point along z-axis
    //do I have to specify it here? 
    //for example: add glRotatef(rotate_degree, 0.0, 0.0, 1.0); above the glScalef(2, 2, 1.0);
    //such that later i can change the value in the rotate_degree?

glPopMatrix(); //forget about the current transformation matrix, pop out the top matrix on the stack.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:02:44+00:00Added an answer on June 17, 2026 at 10:02 pm

    That the order of operations seems inverted comes from the fact that matrices are non-commutative and right associative when multiplied with column vectors. Say you have a position column vector ↑p in model space. To bring it into world space you multiply it with matrix M, i.e

    ↑p_world = M · ↑p

    Note that you can not change the order of operations! Column vectors match like a key into matrices and the key fits into the matrix-lock from the right.

    In the next step you want to transform into view space, using matrix V so you write

    ↑p_view = V · ↑p_world

    but this you can substitute with

    ↑p_view = V · M · ↑p

    But of course if you have a lot of ↑p-s you’d want to save on computations, so you contract those two matrices M and V into a single matrix you call modelview. And when you build modelview with OpenGL you build it like this:

    MV = 1
    MV = MV · V
    MV = MV · M
    

    Due to the right associativity of column order matrix multiplication the first transformation applied to a vector is the last one multiplied onto the stack.


    Note that by using row order matrix math, things become left associative, i.e. things happen in the order you write them. But column order right associativity is incredibly usefull, as it makes building branching transformation hierachies much, much easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting out teaching myself openGL and now adding openAL to the mix.
I was just starting a new opengl project in xcode. When I was going
I am just starting out with OpenGL coding, and tried running an example that
Hey - just starting out trying to get some openGL into my iphone app
Just starting out with shopfiy and this is my first ever stack post! I'm
I'm just starting out learning OpenCL. I'm trying to get a feel for what
Just starting with Modelica and having trouble understanding how it works. In the below
Just starting out in python on a pendrive 12.04 Kubuntu environment. I had to
Just starting out with subversion, have set up repos for 3 current projects and
Just starting out, this should be a simple one but I haven't been able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.