开发者

opengl stencil buffer not initialized with zero?

开发者 https://www.devze.com 2023-03-28 06:30 出处:网络
I work under MS WindowsXP,my video card is itel GMA4500, my code: glClearS开发者_StackOverflowtencil(0);

I work under MS WindowsXP,my video card is itel GMA4500, my code:

glClearS开发者_StackOverflowtencil(0);
glClear(GL_STENCIL_BUFFER_BIT);

unsigned char* data = new unsigned char[width*height];
glPixelStorei(GL_PACK_ALIGNMENT,1);
glReadPixels(0,0,width,height,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE,data);

but when i checked the data buffer, i can see that the bytes are not all zero, so what's the problem?


YES, I'm sure i have a stencil buffer, and after call glReadPixels, i checked glGetError,there's no error. i also tried memset to fill data buffer with zero, but the result didn't changed.


Do you actually have a stencil buffer? If not, glReadPixels will raise an error (check glGetError(…)) and leave the target buffer's contents unchanged.


Did you mean to use

glPixelStorei(GL_UNPACK_ALIGNMENT,1);

since you are trying to get the contents FROM the stencil buffer?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号