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 3 of 3

Thread: glm::ortho problem [SOLVED]

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Location
    Halle/Saale, Saxony Anhalt, Germany
    Posts
    6

    glm::ortho problem [SOLVED]

    Hello!

    I have a problem setting up an orthographic projection matrix with glm:rtho(). The object is a simple quad build by two triangles. The triangles are in the xy-plane with z=0. Using glm:erspective() everything is shown correct.

    perspective:
    Code :
    P = glm::perspective(60.0f, (float)windowWidth / (float)windowHeight, 0.1f, 100.0f);

    ortho:
    Code :
    P = glm::ortho(0.0f, (float)windowWidth,(float)windowHeight,0.0f, 0.1f, 100.0f);

    matrix multiplication:
    Code :
    V = glm::lookAt( glm::vec3( 0.f, 0.f, 2.0f ),glm::vec3( 0.f, 0.f, 0.f ),glm::vec3( 0.0f, 1.0f, 0.0f ) );    
    glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f, 0.0f, 0.0f));
    glm::mat4 Rx = glm::rotate(T,  rotation_x, glm::vec3(1.0f, 0.0f, 0.0f));
    glm::mat4 Ry = glm::rotate(Rx, rotation_y, glm::vec3(0.0f, 1.0f, 0.0f));
    glm::mat4 M = glm::rotate(Ry, rotation_z, glm::vec3(0.0f, 0.0f, 1.0f));
    glm::mat4 MVP	= P*V*M;

    As I said, using glm:erspective everything works fine. So can anyone help me?

    greetz caaso





  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985

    Re: glm::ortho problem

    Your code seems correct, though you did not stated what is the problem in case you use orto? You don't see the primitive? How big is your quad? Be careful that in case you set up the orto projection this way, a one unit wide and high quad will occupy only a single pixel on the screen.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2011
    Location
    Halle/Saale, Saxony Anhalt, Germany
    Posts
    6

    Re: glm::ortho problem

    ok thank you aqnuep. You solved my problem. I did not realize the problem with the size of the quad in relation to the pixels.

Posting Permissions

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