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

  • Home
  • SEARCH
  • 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 7994735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:12:29+00:00 2026-06-04T14:12:29+00:00

I’ve read much about vectors, buffer objects etc., and reviewed much of example application

  • 0

I’ve read much about vectors, buffer objects etc., and reviewed much of example application implementing old/new opengl operations. My app, including object loading, transformations and vertex/fragment shaders works, in general, I understand how to pass various type of variables to shaders, and how to draw arrays and elements arrays, everything goes fine so far.

But there’s one thing I don’t understand – final gl_Position matrix used matrix I generated, passed to vertex shader, as some result of some mathematical operations ( actually I use SDL, glew and glm’s functions like lookAt, translate, rotate etc. ).

what I do is
shader

#version ...
uniform mvp..
main ..
{
   gl_Position = mvp * ...;
}

cpp

load_object_vertices_indexes_etc;
install_shaders;
bind_buffers;
buffer_data;
enable_vertex_array_elements_etc;
mat4 aaa_proj = perspective(persp_params);
mat4 bbb_view = lookAt(look_params);
mat4 ccc_model = translate(translate_params);
mat4 ddd_anim = rotate(rotate_params);
/* then I do matrix multiply */
mat4 some_final = ..proj * ...view * ..model * anim;
glUniformMatrix4fv(location_in_shader, 1, GL_FALSE, ..val_pointer_of_some_final)
glClear(appropriate_bitfield);

glDraw...(spec);

The point is, that, actually, final matrix I can, of course, generate by any combination. Shader calls gl_Position with valid result matrix, no matter how it was generated.
Now, where exactly do I switch from projection to view to model to anim? Of course matrix names doesn’t matter, is there a switching somewhere inside perspective, lookAt, translate and rotate? I mean – if the stack contains actually four stages, each one of these stages can be translated, rotated, scaled, etc. As I understand it by now, actions I take would not matter, if there would be only one stage of matrix stack.

Theoretically, inside 3d scene, I should be able to get similar effect if I ( rotate view 45 degrees left, and then rotate model 45 degrees right ), or if I ( rotate view 45 right and then rotate model 45 degress left).

When I stand physically in front of teapot, I can turn it right 45 and walk around the table (translate and rotate myself) to left 45 to see it from the front – or turn it left 45 and walk 45 to right to see it from the front. It will differ for the rest of the world ( I will see left or right room wall behind teapot ), but obviously I will end seeing the front of the pot.

So, to conclude, if I would like to implement two routines – A( obj_turn_left, me_turn_right ) and B (obj_turn_right, me_turn_left), both rotating model first, and myself (eye, camera) later, how do I specify to which matrix mode particular rotation or transformation applies? Should I use glMatrixMode(APPROPRIATE_CONST) to force going a particular stage when I want? glMatrixMode isn’t used in my code so far.

  • 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-04T14:12:30+00:00Added an answer on June 4, 2026 at 2:12 pm

    There is no switching at all happening. You multiply the whole transformation chain into one single compound matrix.

    For the sake of making things easier when it comes to advanced stuff you normally separate the transformation into modelview and projection, so that you can perform e.g. lighting calculations in view space. But this is not a switch it’s just an intermediary step.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.