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! :wink:

Cheers :slight_smile:

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 :stuck_out_tongue:

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.

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 :wink:

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.

Thankyou both for your help.

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

gluOrtho2D(xMin, xMax, yMin, yMax);


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 :wink:

Thanks again :slight_smile: