Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Orthographic projection upside down

698 views
Skip to first unread message

Mike Kenny

unread,
Jan 10, 2000, 3:00:00 AM1/10/00
to

Hi, I've a small problem with orthographic projection on Win98 under MESA
and MS OGL

My entire viewport and hence visual image is rendered upside down (which is
not what you'd call optimal). *8-(

if I do something akin to

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 0, 480, -1, 1);

and

glViewport( 0, 0, 640, 480 );

I would have thought in windows, my viewport would map onto the windows
coordinate system
of (0,0) window upper left and (640,480) window lower right. Unfortunately
for me, this maps
on to (0,0) window lower left and (640,480) window upper right.

After which executing things like

glDrawPixels()

will draw bitmaps correctly according to the coordinate system (but visually
upside down).

Can anyone recommend a solution to this?

I've tried applying glScaled(1.0,-1.0,1.0) but this does not solve the
problem rather strangely as
you'd imagine a post application of this would reflect the projected
coordinates within the canonical
clip volume of (-1,-1,-1, 1,1,1) about the x axis, hence you'd get on
rasterisation through the viewport
the correct result.
Unfortunately the result is nothing is rendered.
Strangely this flip does not occur on perspective projections though why
that is so beats the heck out of me.

Yours in hope,

- Mike Kenny

Lars Birkemose

unread,
Jan 10, 2000, 3:00:00 AM1/10/00
to
Im pretty sure you can map you ortho view as you like.
Ex
glOrtho(0,width,0,height)
and
glOrtho(0,width,-height,0)
should swap your drawings y wise

Lars

Mike Kenny <mi...@tdv.com> wrote in message
news:947527351.22768.0...@news.demon.co.uk...

Mike Kenny

unread,
Jan 10, 2000, 3:00:00 AM1/10/00
to
Almost!

instead of

glOrtho( left, right, bottom, top, near, far )

change the call logically to

glOrtho( left, right, top, bottom, near, far )


as simple as that.....

Sadly though, I still have a major problem

glDrawPixels()

This call (renders bitmaps) ignores the reversal of y so your images still
rasterise from their (now correct) plot origins upwards, rather than in the
expected downwards scanline direction as you look at the window. Hence I
think they must be ignoring the reversal applied to the coordinate system
through glOrtho().

Any suggestions anyone?

As an aside, I also tried glLoadMatrixf() with a hand build orthographic
matrix with column 1 (i.e. y multiplier) negated which also works in the
same way as glOrtho( left, right, top, bottom, near, far )

- Mike

Lars Birkemose <Larsmose._REMOVE@THIS_post4.tele.dk> wrote in message
news:85d9vk$c07$1...@news.inet.tele.dk...

Mike Kenny

unread,
Jan 10, 2000, 3:00:00 AM1/10/00
to
Aha!

glPixelZoom(1.0, -1.0);

Now there's a fine thing....

To get your bitmaps the right way up do

glPixelZoom(1.0,-1.0);
glDrawPixels(.....);
glPixelZoom(1.0,1.0);

- Mike


Mike Kenny <mi...@tdv.com> wrote in message

news:947532946.26105.0...@news.demon.co.uk...

Andrew F. Vesper

unread,
Jan 10, 2000, 3:00:00 AM1/10/00
to
Mike Kenny wrote:

> Sadly though, I still have a major problem
>
> glDrawPixels()
>
> This call (renders bitmaps) ignores the reversal of y so your images still
> rasterise from their (now correct) plot origins upwards, rather than in the
> expected downwards scanline direction as you look at the window. Hence I
> think they must be ignoring the reversal applied to the coordinate system
> through glOrtho().

The raster position is still set with glRasterPos and represents the origin
of the pixel data. The normal operation is to render the image to the
right and up. You can call glPixelZoom to turn it upside down.


--
Andy V (OpenGL Alpha Geek)
"In order to make progress, one must leave the door to the unknown ajar."
Richard P. Feynman, quoted by Jagdish Mehra in _The Beat of a Different Drum_.

Timo K Suoranta

unread,
Jan 12, 2000, 3:00:00 AM1/12/00
to
Andrew F. Vesper <ave...@wn.net> wrote:
> The raster position is still set with glRasterPos and represents the origin
> of the pixel data. The normal operation is to render the image to the
> right and up. You can call glPixelZoom to turn it upside down.

glDrawPixels() is unacceptable slow in most implementations, and
specifying PixelZoom to anything else than default may even further
degrade the performance.

Instead of glDrawPixels() using textured quads with ortho projection
usually gives better results.


-- Timo Suoranta -- tksu...@cc.helsinki.fi --

0 new messages