Results 1 to 4 of 4

Thread: resizing window with glOrtho problem

  1. #1
    Newbie Newbie
    Join Date
    Oct 2016
    Posts
    2

    resizing window with glOrtho problem

    Hi, I am new to openGL and wondering how to redimension a window in opengl without resizing objects in it (for example a quad drawn in opengl). I currently have a simple C++ function such as :

    void ProjectionOrtho::redimensionWindow(int width, int height)
    {
    glViewport(0, 0, width, height);
    glOrtho(0, width, height, 0, -1.0, 1.0);
    }

    Here is an image illustrating the problem : Ahjkd.jpg

    I would like that if i redimension my window, the quad keeps its initial position and doesnt redimension, and what we would see on the expanded window is the rest of the universe. For instance if i translate my quad to the right i want to be able to see it on the right.

    What i have right now : the quad keeps redimensionnig with the window, so if the window gets to ex: 1000*1000 the quad will still occupy lets say 95% of the space.. the quad resizes with the window resize, which is not the intended result.

    Thank you very much for your insights I've been stuck with this issue for quite a while now.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,109
    Quote Originally Posted by clarenced View Post
    I would like that if i redimension my window, the quad keeps its initial position and doesnt redimension, and what we would see on the expanded window is the rest of the universe. For instance if i translate my quad to the right i want to be able to see it on the right.
    Your existing function does exactly that (assuming that width and height are the window dimensions).

    Quote Originally Posted by clarenced View Post
    What i have right now : the quad keeps redimensionnig with the window, so if the window gets to ex: 1000*1000 the quad will still occupy lets say 95% of the space.. the quad resizes with the window resize, which is not the intended result.
    In that case, either the settings made in your redimensionWindow() function aren't being used (e.g. they're being overridden elsewhere), or you're changing the object-space space coordinates of the quad's vertices.

    I note that you don't call glMatrixMode(GL_PROJECTION). That isn't necessarily a problem; if you aren't using lighting, it's reasonable to use only a single matrix (projection or model-view) and leave the other as the identity matrix. But I'm wondering if you're overriding the glOrtho() call with e.g. a glLoadIdentity() call elsewhere.

  3. #3
    Newbie Newbie
    Join Date
    Oct 2016
    Posts
    2

    glortho still not working

    Ok I've tried the following :

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glOrtho(0, width, height, 0, -1000.0, 1000.0);
    //glMatrixMode(GL_MODELVIEW); *when i uncomment that line the quad disapears..

    However, it seems that glOrtho is just not applied, no matter what parameters i pass in. What could be the cause?

    I can also validate that height and width are ok.

    Also,

    My four quads are drawn with the following code :
    glBegin(GL_QUADS);
    glColor3f(1.0f, 1.0f, 1.0f);

    glVertex3f(0, 0, 0); //pointCenter
    glVertex3f(0.9, 0, 0); //pointCenterRight
    glVertex3f(0.9, 0.9, 0); //pointUpRight
    glVertex3f(0, 0.9, 0); //pointUpCenter
    //quad en bas a gauche
    glVertex3f(0, 0, 0); //pointCentre
    glVertex3f(-0.9,0,0); //pointCenterLeft
    glVertex3f(-0.9, -0.9, 0); //pointBottomLeft
    glVertex3f(0, -0.9, 0); //pointBottomCenter

    glVertex3f(0, 0, 0); //pointCenter
    glVertex3f(0, 0.9, 0); //pointUpCenter
    glVertex3f(...)
    glVertex3f(...)

    glVertex3f(0,0,0);
    glVertex3f(...);
    glVertex3f(...);
    glVertex3f(...);

    glEnd();

    Also, I have 3d objects (loaded from .obj files) sitting on top of the quad, which redimension as well as the multiple quads.

    I dont use any lighting or any special effects.

    I have also tried glLoadIdentity before the glOrtho call, and it doesnt seem to work either. (i see no change, quad and other objects still take about 95% of the space instead of just keeping their initial size)

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    459
    Code :
    glOrtho(0, width, height, 0, -1000.0, 1000.0);
    Are you sure about the values you are giving to glOrtho ?

Similar Threads

  1. Window Resizing
    By sidenelen in forum OpenGL: Basic Coding
    Replies: 14
    Last Post: 08-17-2011, 02:01 AM
  2. problem with window resizing (function reshape)
    By Rotiv in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-18-2010, 03:30 PM
  3. Window Resizing
    By Brennan in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-02-2005, 01:52 PM
  4. window resizing problem - help please
    By pmr2004pmr in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-31-2004, 01:21 PM
  5. Resizing a window
    By gregs in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-28-2002, 09:57 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