Need help with glReadPixles

BlitzMax Forums/OpenGL Module/Need help with glReadPixles

DJ Scantron(Posted 2006) [#1]
Basicly, I have a cube, with each face a different color.

I'm trying to use glReadPixels to read the color of a set point on the screen, so I know wich face is facing twoard the camera.

I dont really need to know that the returned value is any given color, all that really matters is that there are six different values(one for each face of the cube).

However I'm not quite sure what the last argument in hte function means. Does it need a pointer to a float?

I've never used pointer so any help would be appreciated.


degac(Posted 2006) [#2]
Local pix:Byte[4]
glReadPixels ( screenx, screeny,1,1,GL_RGB, GL_UNSIGNED_BYTE, byte ptr pix )

pix then will have r,g,b in pix[0] pix[1] and pix[2]

The pointer is a BYTE to an array PIX[]

Is something I found on this forum time ago.

byez


Chris C(Posted 2006) [#3]
you might want to check out the nehe tutorial that used the selection buffer can remember which one it was but they are hidden (and a bit out of date) in the showcase forum


ImaginaryHuman(Posted 2006) [#4]
its a Byte Pointer pointing to the memory area where you want the pixels to be grabbed to - ie the memory buffer of a Pixmap for example, or a memory bank, or even the address of a variable if you're only reading one pixel.

You can use PixmapPtr() I think