3
在Khronos OpenGL 2.1規範中,他們說glStencilMask應該會影響glClear的操作,但是,在我的機器上,這似乎並不正確。glClear和glStencilMask沒有按預期運行
目前我得到的輸出是:
Stencil value: (0,0) 0xff
我期望的輸出是:
Stencil value: (0,0) 0xf0
這裏是我的代碼:
void renderScene(void) {
unsigned char pix;
int i [4];
/* Clear the stencil buffer initially */
glClearStencil(0x0);
glClear(GL_STENCIL_BUFFER_BIT);
/* Applies the following: 1111 0000 & 1111 1111 */
glStencilMask(0xF0);
glClearStencil(0xFF);
glClear(GL_STENCIL_BUFFER_BIT);
glFlush();
glReadPixels(0,0,1,1,GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &pix);
printf("Stencil value (0,0): %x\n",pix);
}
int main(int argc, char **argv) {
// init GLUT and create Window
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_STENCIL);
glutInitWindowPosition(500,500);
glutInitWindowSize(320, 320);
glutCreateWindow("Trial");
// register callbacks
glutDisplayFunc(renderScene);
// enter GLUT event processing cycle
glutMainLoop();
return 1;
}
(很明顯,我正在執行各種其他圖紙等牛逼這表明我看到它)
GL_STENCIL_INDEX
Stencil values are read from the stencil buffer.
Each index is converted to fixed point, shifted left or right
depending on the value and sign of GL_INDEX_SHIFT,
and added to GL_INDEX_OFFSET. If GL_MAP_STENCIL is GL_TRUE,
indices are replaced by their mappings in the table GL_PIXEL_MAP_S_TO_S.
您可能要檢查GL_INDEX_SHIFT和GL_INDEX_OFFSET均爲零致電
glPixelTransferi(GL_INDEX_SHIFT, 0);
glPixelTransferi(GL_INDEX_OFFSET, 0);
也許問題)
什麼是您的機器/操作系統/圖形卡?司機是最新的嗎? – Shahbaz 2012-07-25 16:30:40
使用你的可視化配置,模板緩衝區有多少位? – Luca 2012-07-25 17:22:41
我正在Lenovo 7522P1U上運行Windows XP Professional,並配有英特爾G41 Express芯片組。並且有8個模板位平面。 – Luke 2012-07-25 18:00:17