void ogles_validate_transform_impl(ogles_context_t* c, uint32_t want) { int dirty = c->transforms.dirty & want; // Validate the modelview if (dirty & transform_state_t::MODELVIEW) { c->transforms.modelview.validate(); } // Validate the projection stack (in fact, it's never needed) if (dirty & transform_state_t::PROJECTION) { c->transforms.projection.validate(); } // Validate the viewport transformation if (dirty & transform_state_t::VIEWPORT) { vp_transform_t& vpt = c->transforms.vpt; vpt.transform.matrix.load(vpt.matrix); vpt.transform.picker(); } // We need to update the mvp (used to transform each vertex) if (dirty & transform_state_t::MVP) { c->transforms.update_mvp(); // invalidate perspective (divide by W) and view volume clipping ogles_invalidate_perspective(c); } // Validate the mvui (for normal transformation) if (dirty & transform_state_t::MVUI) { c->transforms.update_mvui(); ogles_invalidate_lighting_mvui(c); } // Validate the texture stack if (dirty & transform_state_t::TEXTURE) { for (int i=0; i<GGL_TEXTURE_UNIT_COUNT ; i++) c->transforms.texture[i].validate(); } // Validate the mvit4 (user-clip planes) if (dirty & transform_state_t::MVIT) { c->transforms.update_mvit(); } c->transforms.dirty &= ~want; }
static void enable_disable(ogles_context_t* c, GLenum cap, int enabled) { if ((cap >= GL_LIGHT0) && (cap<GL_LIGHT0+OGLES_MAX_LIGHTS)) { c->lighting.lights[cap-GL_LIGHT0].enable = enabled; c->lighting.enabledLights &= ~(1<<(cap-GL_LIGHT0)); c->lighting.enabledLights |= (enabled<<(cap-GL_LIGHT0)); return; } switch (cap) { case GL_POINT_SMOOTH: c->point.smooth = enabled; break; case GL_LINE_SMOOTH: c->line.smooth = enabled; break; case GL_POLYGON_OFFSET_FILL: c->polygonOffset.enable = enabled; break; case GL_CULL_FACE: c->cull.enable = enabled; break; case GL_LIGHTING: c->lighting.enable = enabled; break; case GL_COLOR_MATERIAL: c->lighting.colorMaterial.enable = enabled; break; case GL_NORMALIZE: case GL_RESCALE_NORMAL: c->transforms.rescaleNormals = enabled ? cap : 0; // XXX: invalidate mvit break; case GL_CLIP_PLANE0: case GL_CLIP_PLANE1: case GL_CLIP_PLANE2: case GL_CLIP_PLANE3: case GL_CLIP_PLANE4: case GL_CLIP_PLANE5: c->clipPlanes.enable &= ~(1<<(cap-GL_CLIP_PLANE0)); c->clipPlanes.enable |= (enabled<<(cap-GL_CLIP_PLANE0)); ogles_invalidate_perspective(c); break; case GL_FOG: case GL_DEPTH_TEST: ogles_invalidate_perspective(c); // fall-through... case GL_BLEND: case GL_SCISSOR_TEST: case GL_ALPHA_TEST: case GL_COLOR_LOGIC_OP: case GL_DITHER: case GL_STENCIL_TEST: case GL_TEXTURE_2D: // these need to fall through into the rasterizer c->rasterizer.procs.enableDisable(c, cap, enabled); break; case GL_MULTISAMPLE: case GL_SAMPLE_ALPHA_TO_COVERAGE: case GL_SAMPLE_ALPHA_TO_ONE: case GL_SAMPLE_COVERAGE: // not supported in this implementation break; default: ogles_error(c, GL_INVALID_ENUM); return; } }