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?

You say that you only posted part of your code, so you may already be doing the following things.
[ol]

[li]You didn’t allocate any memory in your example, glReadPixels fills the array pointed to by the last parameter, so if is an illegal pointer that may be your problem[/li]
[li]Don’t read stencil bits as floats, it may not be a problem, but they make no sense as floats so…[/li][/ol]
I hope that helped you

Cheers
John

Thnx for the reply…

I thought that pixels would be filled by the function call…guess not. I will try allocating memory beforehand…

later

Jeremy