static void CALLBACK Paint(void) { glViewport(0,0,windW,windH); glDisable(GL_SCISSOR_TEST); glPushAttrib(GL_COLOR_BUFFER_BIT); glColorMask(1,1,1,1); glIndexMask((GLuint)~0); glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glPopAttrib(); if(mode1)glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); if(mode2)glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); else glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); Viewport(0,0); Point(); Viewport(0,1); Lines(); Viewport(0,2); LineStrip(); Viewport(0,3); LineLoop(); Viewport(1,0); Bitmap(); Viewport(1,1); TriangleFan(); Viewport(1,2); Triangles(); Viewport(1,3); TriangleStrip(); Viewport(2,0); Rect(); Viewport(2,1); xPolygon(); Viewport(2,2); Quads(); Viewport(2,3); QuadStrip(); glFlush(); if(doubleBuffer)auxSwapBuffers(); }
static void RotateColorMask(void) { static GLint rotation=0; rotation=(rotation+1)&0x3; switch(rotation) { case 0: glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glIndexMask(0xff); break; case 1: glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glIndexMask(0xFE); break; case 2: glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glIndexMask(0xfd); break; case 3: glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glIndexMask(0xfb); break; } }
static void hugsprim_glIndexMask_1(HugsStackPtr hugs_root) { HsWord32 arg1; arg1 = hugs->getWord32(); glIndexMask(arg1); hugs->returnIO(hugs_root,0); }
/////////////////////////////////////////////////////////////////////////////// // runOne: Run a single test case /////////////////////////////////////////////////////////////////////////////// void ReadPixSanityTest::runOne(ReadPixSanityResult& r, GLEAN::Window& w) { // Many (if not most) other tests need to read the contents of // the framebuffer to determine if the correct image has been // drawn. Obviously this is a waste of time if the basic // functionality of glReadPixels isn't working. // // This test does a "sanity" check of glReadPixels. Using as // little of the GL as practicable, it writes a random value // in the framebuffer, reads it, and compares the value read // with the value written. glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE); glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE); glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_SKIP_ROWS, 0); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelTransferi(GL_MAP_COLOR, GL_FALSE); glPixelTransferi(GL_MAP_STENCIL, GL_FALSE); glPixelTransferi(GL_INDEX_SHIFT, 0); glPixelTransferi(GL_INDEX_OFFSET, 0); glPixelTransferf(GL_RED_SCALE, 1.0); glPixelTransferf(GL_GREEN_SCALE, 1.0); glPixelTransferf(GL_BLUE_SCALE, 1.0); glPixelTransferf(GL_ALPHA_SCALE, 1.0); glPixelTransferf(GL_DEPTH_SCALE, 1.0); glPixelTransferf(GL_RED_BIAS, 0.0); glPixelTransferf(GL_GREEN_BIAS, 0.0); glPixelTransferf(GL_BLUE_BIAS, 0.0); glPixelTransferf(GL_ALPHA_BIAS, 0.0); glPixelTransferf(GL_DEPTH_BIAS, 0.0); glDisable(GL_SCISSOR_TEST); glDisable(GL_DITHER); glIndexMask(~0); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); glStencilMask(~0); if (r.config->canRGBA) checkRGBA(r, w); if (r.config->z) checkDepth(r, w); if (r.config->s) checkStencil(r, w); r.pass = r.passRGBA & r.passDepth & r.passStencil & r.passIndex; } // ReadPixSanityTest::runOne
static void Draw(EGLDisplay dpy, EGLSurface surf) { glViewport(0, 0, windW, windH); glDisable(GL_SCISSOR_TEST); glPushAttrib(GL_COLOR_BUFFER_BIT); glColorMask(1, 1, 1, 1); glIndexMask(~0); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glPopAttrib(); if (mode1) { glShadeModel(GL_SMOOTH); } else { glShadeModel(GL_FLAT); } if (mode2) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } else { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } Viewport(0, 0); Point(); Viewport(0, 1); Lines(); Viewport(0, 2); LineStrip(); Viewport(0, 3); LineLoop(); Viewport(1, 0); Bitmap(); Viewport(1, 1); TriangleFan(); Viewport(1, 2); Triangles(); Viewport(1, 3); TriangleStrip(); Viewport(2, 0); Rect(); Viewport(2, 1); PolygonFunc(); Viewport(2, 2); Quads(); Viewport(2, 3); QuadStrip(); glFlush(); if (doubleBuffer) { eglSwapBuffers(dpy, surf); } }
/////////////////////////////////////////////////////////////////////////////// // runOne: Run a single test case /////////////////////////////////////////////////////////////////////////////// void MaskedClearTest::runOne(BasicResult& r, Window&) { bool passed = true; // GL init, just to be safe glDisable(GL_SCISSOR_TEST); // only test front/back-left buffers, quad-buffer stereo in the future const GLint numBuffers = r.config->db ? 2 : 1; for (GLint buffer = 0; buffer < numBuffers && passed; buffer++) { if (buffer == 0) { glReadBuffer(GL_FRONT); glDrawBuffer(GL_FRONT); } else { glReadBuffer(GL_BACK); glDrawBuffer(GL_BACK); } if (r.config->canRGBA) { const GLint numChannels = (r.config->a > 0) ? 4 : 3; for (GLint chan = 0; chan < numChannels && passed; chan++) { // clear to black glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); // select one channel to "clear" to 1.0 glColorMask(chan == 0, chan == 1, chan == 2, chan == 3); // try to clear surface to white glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); // read 1x1 image at (x,y)=(4,4) GLfloat pixel[4]; glReadPixels(4, 4, 1, 1, GL_RGBA, GL_FLOAT, pixel); // test results for (GLint comp = 0; comp < numChannels && passed; comp++) { if (comp == chan) { // component should be 1.0 if (pixel[comp] < 0.5) { passed = false; failRGB(r, comp, 1.0, pixel[comp], buffer); } } else { // component should be 0.0 if (pixel[comp] > 0.5) { passed = false; failRGB(r, comp, 0.0, pixel[comp], buffer); } } } } } else { const GLint indexBits = r.config->bufSize; // We just run <indexBits> tests rather than 2^indexBits for (GLint bit = 0; bit < indexBits && passed; bit++) { // clear to 0 glIndexMask(~0); glClearIndex(0); glClear(GL_COLOR_BUFFER_BIT); // select one bit to "clear" to 1 glIndexMask(1 << bit); // try to clear surface to ~0 glClearIndex(~0); glClear(GL_COLOR_BUFFER_BIT); // read 1x1 image at (x,y)=(4,4) GLuint pixel; glReadPixels(4, 4, 1, 1, GL_COLOR_INDEX, GL_UNSIGNED_INT, &pixel); // test results if (pixel != (1U << bit)) { passed = false; failCI(r, 1 << bit, pixel, buffer); } } } } if (passed && r.config->z > 0) { // clear depth buffer to zero glDepthMask(GL_TRUE); glClearDepth(0.0); glClear(GL_DEPTH_BUFFER_BIT); // disable Z writes, try to clear to one glDepthMask(GL_FALSE); glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT); // read 1x1 image at (x,y)=(4,4); GLfloat depth; glReadPixels(4, 4, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); // test result if (depth != 0.0) { passed = false; failZ(r, 0.0, depth); } } if (passed && r.config->s > 0) { const GLint stencilBits = r.config->s; // We just run <stencilBits> tests rather than 2^stencilBits for (GLint bit = 0; bit < stencilBits && passed; bit++) { // clear to 0 glStencilMask(~0); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); // select one bit to "clear" to 1 glStencilMask(1 << bit); // try to clear stencil buffer to ~0 glClearStencil(~0); glClear(GL_STENCIL_BUFFER_BIT); // read 1x1 image at (x,y)=(4,4) GLuint stencil; glReadPixels(4, 4, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_INT, &stencil); // test results if (stencil != (1U << bit)) { passed = false; failStencil(r, 1 << bit, stencil); } } } r.pass = passed; } // MaskedClearTest::runOne
M(void, glIndexMask, jint mask) { glIndexMask(mask); }
void __glXDisp_IndexMask(GLbyte *pc) { glIndexMask( *(GLuint *)(pc + 0) ); }