Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: What is the idea of this code

  1. #1
    Newbie Newbie
    Join Date
    May 2017
    Posts
    6

    What is the idea of this code

    Hey guys,

    I have here a very simple code in openGL and i don't understand what does:

    Code cpp:
    void reshape(int x, int y)
        {
        glViewport(0, 0, x, y);
     
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
     
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
        }

    I have read on the internet about glMatrixMode but i have not understand very well how this works.
    Also if i delete

    Code cpp:
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

    The final scene doesn't change.
    Thank you in advance.
    Last edited by Dark Photon; 05-19-2017 at 05:44 AM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,123
    Understanding how matrix transforms work and how to use modeling, viewing, projection, and viewport transforms work is pretty key to rendering with OpenGL. You should definitely spend some quality time reading up on this. You'll be glad you did.

    The OpenGL Programming Guide at one time had a very good description of how these transformations work and how to think about them (it may still in recent versions, but I don't know for sure). If you can buy or borrow one, it's worth your time. Failing that, there's some older versions on-line that may be more appropriate for you since you're using the old built-in matrix operations (here's one example.

    Also if I delete ... The final scene doesn't change.
    Which would suggest either 1) your program isn't using the MODELVIEW transform setting, or 2) the MODELVIEW transform was already set to the identity transform.

  3. #3
    Intern Contributor
    Join Date
    Dec 2016
    Posts
    53
    I bought that book, and gave it initially bad reviews, because it doesn't really walk you through step by step startup in Windows with Visual Studio Community. However, if you are already programming in OpenGL and understand how to compile a simple program, then it's a great read, I've read through it now, and am working on slowly mastering the concepts brought out in each chapter.

    Plus, it comes with examples (which weren't updated when the book was initially released, and is another reason for my initial bad review), which they recently updated and released on the web site.

    Cheers,
    Jeff

    P.S. Also in the wake of the things that I needed to get started in OpenGL, it motivated me to start a series of YouTube videos covering startup and a few of the concepts that I've learned so far from the book and other sources.

    This is a link to my youtube channel:
    https://www.youtube.com/channel/UCzx...ELz5h1dfCdkdfg

    And a link to a great online tutorial, which can be downloaded in PDF format:
    https://learnopengl.com/

  4. #4
    Newbie Newbie
    Join Date
    May 2017
    Posts
    6
    Thanks. i will start reading

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •