Results 1 to 5 of 5

Thread: changing the arguments to gluOrtho2D during execution

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2004
    Location
    UK
    Posts
    3

    changing the arguments to gluOrtho2D during execution

    Is this actually possible?

    I've created a program that generates the Herter-Heighway Dragon fractal. However, the fractal changes position for each iteration and I need to change the display coordinates of the window dynamically, so to speak, as it changes.

    I'm using gluOrtho2D() to set the coordinates initially but calling it again with the updates coordinates doesn't work - in fact the screen goes completely blank.

    Any ideas? I've considered using the gluLookAt() function but since its a 2D program it seems somewhat unnecessary.

    I'm sure there's a simple solution, I just don't know what it is!

    Cheers

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: changing the arguments to gluOrtho2D during execution

    Maybe glOrtho is better, not sure about this.

    It should work correctly, double check the doc, maybe put a glLoadIdentity before it ?

    If you still have problems, post your gl tviwport and transforma code.

    well, sorry, too much wine this evening

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2004
    Location
    UK
    Posts
    3

    Re: changing the arguments to gluOrtho2D during execution

    Tried glOrtho, no change - think gluOrtho2D is the same anyway, it just puts in the near and far values as -1 and 1.

    Tried glFrustum as well, but no difference. Its a real puzzler :s

    I'm prob just missing something simple out.

    Not using glViewport (except in the reshape function, which i haven't implemented yet), because i'm using local coordinates rather than image coordinates, so to speak.

    http://www.math.umass.edu/~mconnors/...te/dragon.html

    That link shows how the fractal grows through each iteration. Its hard to see it but after the first few iterations the fractal moves steadily in the (x, -y) direction. Just so gives you a clearer idea of what i'm on about!

    I can email the code to anyone who's interested and i'll copy some in here later if I'm still stuck.

    Basically I have four variables, xMin, xMax, yMin, yMax, that I use with gluOrtho2D() at the start of the program.

    For each iteration, I calculate the centre of the dragon, which is simple enough (its the last vertex of the previous iteration) and adjust the values of xMin, xMax, yMin, and yMax i.e.

    xMin += centreX;
    xMax += centreX;
    yMin += centreY;
    yMax += centreY;

    However if i then call gluOrtho2D again with the updated variables, the screen goes black for some reason. I just assumed u could only call gluOrtho2D once and needed to use another function if u needed to change it during execution.

    Maybe i'm just too tired, or too stupid

  4. #4
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: changing the arguments to gluOrtho2D during execution

    You should read the post more carefully, I'm pretty sure zbuffer got it right when he mentioned calling glLoadIdentity. The ortho routines multiply their projection with whatever is already on the projection stack.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2004
    Location
    UK
    Posts
    3

    Re: changing the arguments to gluOrtho2D during execution

    Thankyou both for your help.

    I was being a dumbass in multiple areas Yes, needed to use glLoadIdentity. Just put:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(xMin, xMax, yMin, yMax);

    glMatrixMode(GL_MODELVIEW);
    ...
    ...

    at the start of my display function..

    Of course, ironically when I ran the program the fractal wandered off to the left instead of staying in the middle of the damn window, but you can't have everything all at once can you

    Thanks again

Similar Threads

  1. Changing states vs Changing context
    By Yossi Koren in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 10-08-2017, 01:56 PM
  2. From gluOrtho2D to 3D
    By Henry90 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-11-2014, 09:58 AM
  3. gluOrtho2D
    By mikeglaz in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-11-2010, 10:29 AM
  4. gluOrtho2D?
    By nurulfaiz in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-14-2004, 08:30 AM
  5. No gluOrtho2D?!
    By riisXIV in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-30-2000, 04:23 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