PDA

View Full Version : Reading the stencil buffer



10-24-2001, 06:09 AM
Hello,

I am having some trouble reading what is in the stencil buffer.

Here is a small section of my code:
GLVoid* pixels;

glReadPixels(
mpoint.x,
mpoint.y,
pixwidth,
pixwidth,
GL_STENCIL_INDEX,
GL_FLOAT,pixels);

mpoint is set with a mouseclick
pixwidth is 100

The damn thing crashes every time.

Does anyone have an example of reading what is in the stencil buffer and outputting it into a file?

Rob The Bloke
10-26-2001, 06:34 AM
I hope you allocate memory to hold the pixels! From what you've posted it does seem as though that may be the cause. You cant get a pointer to any of the buffers, and have to provide an array to copy the data into.

You may also want to grab the data as unsigned bytes rather than floats....(bit quicker, 75% less data to transfer, more accurate, no time spent changing the internal format to floats....)

10-27-2001, 05:35 PM
Thanx,

I will try allocating beforehand.