opengl 模板缓冲区未初始化为零?
我在MS WindowsXP下工作,我的显卡是itel GMA4500, 我的代码:
glClearStencil(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);
但是当我检查数据缓冲区时,我可以看到字节不全为零, 那么问题出在哪里呢?
是的,我确定我有一个模板缓冲区,并且在调用 glReadPixels 后,我检查了 glGetError,没有错误。我还尝试使用 memset 将数据缓冲区填充为零,但结果没有改变。
I work under MS WindowsXP,my video card is itel GMA4500,
my code:
glClearStencil(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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你真的有模板缓冲区吗?如果不是,glReadPixels将引发错误(检查glGetError(…))并保持目标缓冲区的内容不变。
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
since you are trying to get the contents FROM the stencil buffer?