PDA

View Full Version : Drawing in ortho help



01-07-2002, 10:02 PM
Yes friends, I am back. This time, my problem is when I wish to draw in my ortho view, say at (0,0) (this is top left screen as posted in other message)
and I want to put down 64 width and 32 height graphic, I use:



gltranslatef(0,0,0);
glBegin(GL_QUADS);
glvertex2f(32,16);
glvertex2f(-32,16);
glvertex2f(-32,-16);
glvertex2f(32,-16);
glEnd();

but as you can see, this no make it draw at 0,0, but it draw in the negativie area since I use -32, and -16.
What is a way to make rectangle of 64x32 (will be 64x128 later)?
I try many changes to get it to display, but seems I need negative values no matter?

I try making 32 & 16 all positive, this no help, I think I do this wrong way?

Please, tips needed!

01-07-2002, 10:18 PM
I forget to add I also try:
glvertex2f(64,32)
glvertex2f(0,32)
glvertex2f(0,0)
glvertex2f(64,0)

so that is +32 to x, and +16 to y, but this no work either, it no make rectangle correct.

This why I am stuck!

JLawson
01-08-2002, 05:35 AM
Remember that when you are switching to orthographic view you are defining the four corners of a rectangle.

glOrtho(minx, maxx, miny, maxy, minz, maxz);

If you are trying to do what you want, it sounds like you want to define a vew frustrum that looks like a fliped rectangle. If that is the case, the I see you are trying to reverse the rectange.

It sounds like to dont want to use the standard method of having the 0, coordinates at the bottom left of your screen. Have you tried

glOrtho(0.0, 50.0, 0.0, -50.0, -1.0, 1.0);

It's just a thought...

Besides everything else, I'm not sure whether or not you can do what you want.


You could always just try to translate along the x and y axis so that you align your axis' up with the top corner of your screen.

01-08-2002, 09:17 AM
Yes, I use glOrtho(-0.5, width-0.5, height-0.5, -0.5, -1, 1);
which makes it screen coordinates.

Then use scale() to flip texture so it look OK.

I think should be possible to do this?