#include #include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init (void) { int i; GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; glClearColor (0.0, 0.0, 0.0, 1.0); glColor4fv (white); glDisable (GL_DITHER); if (!strstr(glGetString(GL_EXTENSIONS), "GL_EXT_packed_depth_stencil")) { printf("GL_EXT_packed_depth_stencil not support\n"); } else { printf("GL_EXT_packed_depth_stencil supported\n"); } } static void test (void) { GLuint depthstencil[4]; static const GLuint image[4] = { 0x00000000, 0x00000012, 0x12345678, 0xffffffff }; int i; int depthBits, stencilBits; glGetIntegerv(GL_DEPTH_BITS, &depthBits); glGetIntegerv(GL_STENCIL_BITS, &stencilBits); printf("depthBits = %d\n", depthBits); printf("stencilBits = %d\n", stencilBits); glWindowPos2iARB(0, 0); glDrawPixels (2, 2, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, image); glReadPixels(0, 0, 2, 2, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, depthstencil); for (i = 0; i < 4; i++) { printf("depthstencil[%d] = %x\n", i, depthstencil[i]); if (image[i] != depthstencil[i]) printf("wrong readback\n"); } } void display (void) { glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (0, WINDSIZEX, 0, WINDSIZEY, 0, -1.0); test (); } int main (int argc, char **argv) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize (WINDSIZEX, WINDSIZEY); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc (display); glutMainLoop (); return 0; }