Reading the stencil buffer

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?

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…)

Thanx,

I will try allocating beforehand.