glOrtho versus gluPerspective and glPixels...

Member
Posts: 321
Joined: 2004.10
Post: #1
Is the glReadPixels(), glCopyPixels(), glDrawPixels() only meant
to be used with the glOrtho view volume or can it work with
gluPerspective as well? The Red Book propgram examples only seem
to show glOrtho().

Currently, I've got a gluPerspective() program which takes snapshots
of the window (700x900) via the glReadPixels and then writes the data to a file.

Then another program using glOrtho() reads in the data and does a glDrawPixels
to a (700x900) window. Interestingly, the image is garbage. However, if
glPixelZoom is set to 0.5 for both the x and y dimensions, the image is
properly displayed. The only explaination I can come up with is maybe the
gluPerspective in the image creation is causing this distortion.

Any comments will be appreciated.
thankl.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
gl*Pixels are unaffected by the projection (or view).

I can vouch for the workingness of glReadPixels and glDrawPixels (at least on ATI hardware), so I suspect you have another bug at work here. As to what that might be... I don't have any useful suggestions, sorry.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
gl*Pixel functions are affected by the glPixelMap, glPixelTransfer, glPixelStore, and some other imaging state. You probably have different state in your two programs between read and draw.

glPixelZoom affects copy and draw, but not read.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #4
Thanks for all the information. I had a major breakthru today (not
the original problem) but a side issue. At the risk of stating the
obvious, here goes:

I was using glRaster2i(x, y) for both glOrtho() and gluPerspective()
programs. With glRaster2i(x,y) and glOrtho() I was thinking in terms
of pixels. When I used glRaster2i(x,y) with glPerspective() my
image rectangles kept disapperaring when I tried moving them. I
finally realized that I should be using glRaster2f( xFloat, yFloat) and
using much smaller delta increments to xFloat and yFloat; Like .01 or
even .001
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #5
Seems that OpenGL's gl{Read/Draw/Copy}Pixels commands want
true 2 dimensional arrays. I was using dynamically allocated 2 dimensional
arrays. The compiler was giving any errors or warnings (not that it should
have) which did not help matters.
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #6
WhatMeWorry Wrote:Seems that OpenGL's gl{Read/Draw/Copy}Pixels commands want
true 2 dimensional arrays. I was using dynamically allocated 2 dimensional
arrays. The compiler was giving any errors or warnings (not that it should
have) which did not help matters.
for properly dynamically allocating 2 dimensional arrays, I suggest you see here: http://www.idevgames.com/forum/showpost....ostcount=8
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
Read/Draw take GLvoid *. As in, "a pointer to memory". Not a "pointer to another array".
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #8
Thanks for the link! However, when I go there all I see is

code:
(and any empty box)

Is there something I need to change in my configuration? I've been
poking around my User Control Panel (and iDec FAQ) for about an hour to no avail.
Down below it is telling me that vB code = On, Smilies = On, and [img]
code = On. HTML code = Off however.


I did see the GLvoid * in the function prototype. But (and I'm splitting hairs here)
doesn't void * mean pointer to anything?

Also, I was curious if one could use a one dimensional array here.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #9
Yes, just use a 1D array.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #10
WhatMeWorry Wrote:Thanks for the link! However, when I go there all I see is

code:
(and any empty box)

Is there something I need to change in my configuration?
Yes, you need to stop using Internet Explorer! Wink

You're encountering the bug I mentioned in this thread. Hopefully we'll be able to fix it shortly.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Small error with glViewport and gluPerspective? cjcaufield 1 3,363 Sep 20, 2009 01:10 AM
Last Post: DoG
  HELP!!! Simple glOrtho problem! Marvin 3 3,907 Jun 27, 2007 10:23 AM
Last Post: Marvin
  SDL key presses versus key states WhatMeWorry 1 4,548 Oct 2, 2006 08:09 AM
Last Post: Nickolei
  OpenGL Texture in relation to GL orientation, and... glOrtho help. Jones 6 4,907 Jun 30, 2006 07:18 PM
Last Post: arekkusu
  glOrtho setup for rendering "impostors" into a texture. TomorrowPlusX 22 8,721 May 22, 2006 07:21 AM
Last Post: TomorrowPlusX