-void Context::setCap(GLenum cap, bool enabled)
-{
- switch (cap)
- {
- case GL_CULL_FACE: setCullFace(enabled); break;
- case GL_POLYGON_OFFSET_FILL: setPolygonOffsetFill(enabled); break;
- case GL_SAMPLE_ALPHA_TO_COVERAGE: setSampleAlphaToCoverage(enabled); break;
- case GL_SAMPLE_COVERAGE: setSampleCoverage(enabled); break;
- case GL_SCISSOR_TEST: setScissorTest(enabled); break;
- case GL_STENCIL_TEST: setStencilTest(enabled); break;
- case GL_DEPTH_TEST: setDepthTest(enabled); break;
- case GL_BLEND: setBlend(enabled); break;
- case GL_DITHER: setDither(enabled); break;
- case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED(); break;
- case GL_RASTERIZER_DISCARD: setRasterizerDiscard(enabled); break;
- default: UNREACHABLE();
- }
-}
-
-bool Context::getCap(GLenum cap)
-{
- switch (cap)
- {
- case GL_CULL_FACE: return isCullFaceEnabled();
- case GL_POLYGON_OFFSET_FILL: return isPolygonOffsetFillEnabled();
- case GL_SAMPLE_ALPHA_TO_COVERAGE: return isSampleAlphaToCoverageEnabled();
- case GL_SAMPLE_COVERAGE: return isSampleCoverageEnabled();
- case GL_SCISSOR_TEST: return isScissorTestEnabled();
- case GL_STENCIL_TEST: return isStencilTestEnabled();
- case GL_DEPTH_TEST: return isDepthTestEnabled();
- case GL_BLEND: return isBlendEnabled();
- case GL_DITHER: return isDitherEnabled();
- case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED(); return false;
- case GL_RASTERIZER_DISCARD: return isRasterizerDiscardEnabled();
- default: UNREACHABLE(); return false;
- }
-}
-
-void Context::setClearColor(float red, float green, float blue, float alpha)
-{
- mState.colorClearValue.red = red;
- mState.colorClearValue.green = green;
- mState.colorClearValue.blue = blue;
- mState.colorClearValue.alpha = alpha;
-}
-
-void Context::setClearDepth(float depth)
-{
- mState.depthClearValue = depth;
-}
-
-void Context::setClearStencil(int stencil)
-{
- mState.stencilClearValue = stencil;
-}
-
-void Context::setRasterizerDiscard(bool enabled)
-{
- mState.rasterizer.rasterizerDiscard = enabled;
-}
-
-bool Context::isRasterizerDiscardEnabled() const
-{
- return mState.rasterizer.rasterizerDiscard;
-}
-
-void Context::setCullFace(bool enabled)
-{
- mState.rasterizer.cullFace = enabled;
-}
-
-bool Context::isCullFaceEnabled() const
-{
- return mState.rasterizer.cullFace;
-}
-
-void Context::setCullMode(GLenum mode)
-{
- mState.rasterizer.cullMode = mode;
-}
-
-void Context::setFrontFace(GLenum front)
-{
- mState.rasterizer.frontFace = front;
-}
-
-void Context::setDepthTest(bool enabled)
-{
- mState.depthStencil.depthTest = enabled;
-}
-
-bool Context::isDepthTestEnabled() const
-{
- return mState.depthStencil.depthTest;
-}
-
-void Context::setDepthFunc(GLenum depthFunc)
-{
- mState.depthStencil.depthFunc = depthFunc;
-}
-
-void Context::setDepthRange(float zNear, float zFar)
-{
- mState.zNear = zNear;
- mState.zFar = zFar;
-}
-
-void Context::setBlend(bool enabled)
-{
- mState.blend.blend = enabled;
-}
-
-bool Context::isBlendEnabled() const
-{
- return mState.blend.blend;
-}
-
-void Context::setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha)
-{
- mState.blend.sourceBlendRGB = sourceRGB;
- mState.blend.destBlendRGB = destRGB;
- mState.blend.sourceBlendAlpha = sourceAlpha;
- mState.blend.destBlendAlpha = destAlpha;
-}
-
-void Context::setBlendColor(float red, float green, float blue, float alpha)
-{
- mState.blendColor.red = red;
- mState.blendColor.green = green;
- mState.blendColor.blue = blue;
- mState.blendColor.alpha = alpha;
-}
-
-void Context::setBlendEquation(GLenum rgbEquation, GLenum alphaEquation)
-{
- mState.blend.blendEquationRGB = rgbEquation;
- mState.blend.blendEquationAlpha = alphaEquation;
-}
-
-void Context::setStencilTest(bool enabled)
-{
- mState.depthStencil.stencilTest = enabled;
-}
-
-bool Context::isStencilTestEnabled() const
-{
- return mState.depthStencil.stencilTest;
-}
-
-void Context::setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask)
-{
- mState.depthStencil.stencilFunc = stencilFunc;
- mState.stencilRef = (stencilRef > 0) ? stencilRef : 0;
- mState.depthStencil.stencilMask = stencilMask;
-}
-
-void Context::setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask)
-{
- mState.depthStencil.stencilBackFunc = stencilBackFunc;
- mState.stencilBackRef = (stencilBackRef > 0) ? stencilBackRef : 0;
- mState.depthStencil.stencilBackMask = stencilBackMask;
-}
-
-void Context::setStencilWritemask(GLuint stencilWritemask)
-{
- mState.depthStencil.stencilWritemask = stencilWritemask;
-}
-
-void Context::setStencilBackWritemask(GLuint stencilBackWritemask)
-{
- mState.depthStencil.stencilBackWritemask = stencilBackWritemask;
-}
-
-void Context::setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass)
-{
- mState.depthStencil.stencilFail = stencilFail;
- mState.depthStencil.stencilPassDepthFail = stencilPassDepthFail;
- mState.depthStencil.stencilPassDepthPass = stencilPassDepthPass;
-}
-
-void Context::setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass)
-{
- mState.depthStencil.stencilBackFail = stencilBackFail;
- mState.depthStencil.stencilBackPassDepthFail = stencilBackPassDepthFail;
- mState.depthStencil.stencilBackPassDepthPass = stencilBackPassDepthPass;
-}
-
-void Context::setPolygonOffsetFill(bool enabled)
-{
- mState.rasterizer.polygonOffsetFill = enabled;
-}
-
-bool Context::isPolygonOffsetFillEnabled() const
-{
- return mState.rasterizer.polygonOffsetFill;
-}
-
-void Context::setPolygonOffsetParams(GLfloat factor, GLfloat units)
-{
- // An application can pass NaN values here, so handle this gracefully
- mState.rasterizer.polygonOffsetFactor = factor != factor ? 0.0f : factor;
- mState.rasterizer.polygonOffsetUnits = units != units ? 0.0f : units;
-}
-
-void Context::setSampleAlphaToCoverage(bool enabled)
-{
- mState.blend.sampleAlphaToCoverage = enabled;
-}
-
-bool Context::isSampleAlphaToCoverageEnabled() const
-{
- return mState.blend.sampleAlphaToCoverage;
-}
-
-void Context::setSampleCoverage(bool enabled)
-{
- mState.sampleCoverage = enabled;
-}
-
-bool Context::isSampleCoverageEnabled() const
-{
- return mState.sampleCoverage;
-}
-
-void Context::setSampleCoverageParams(GLclampf value, bool invert)
-{
- mState.sampleCoverageValue = value;
- mState.sampleCoverageInvert = invert;
-}
-
-void Context::setScissorTest(bool enabled)
-{
- mState.scissorTest = enabled;
-}
-
-bool Context::isScissorTestEnabled() const
-{
- return mState.scissorTest;
-}
-
-void Context::setDither(bool enabled)
-{
- mState.blend.dither = enabled;
-}
-
-bool Context::isDitherEnabled() const
-{
- return mState.blend.dither;
-}
-
-void Context::setLineWidth(GLfloat width)
-{
- mState.lineWidth = width;
-}
-
-void Context::setGenerateMipmapHint(GLenum hint)
-{
- mState.generateMipmapHint = hint;
-}
-
-void Context::setFragmentShaderDerivativeHint(GLenum hint)
-{
- mState.fragmentShaderDerivativeHint = hint;
- // TODO: Propagate the hint to shader translator so we can write
- // ddx, ddx_coarse, or ddx_fine depending on the hint.
- // Ignore for now. It is valid for implementations to ignore hint.
-}
-
-void Context::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- mState.viewport.x = x;
- mState.viewport.y = y;
- mState.viewport.width = width;
- mState.viewport.height = height;
-}
-
-void Context::setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- mState.scissor.x = x;
- mState.scissor.y = y;
- mState.scissor.width = width;
- mState.scissor.height = height;
-}
-
-void Context::getScissorParams(GLint *x, GLint *y, GLsizei *width, GLsizei *height)
-{
- *x = mState.scissor.x;
- *y = mState.scissor.y;
- *width = mState.scissor.width;
- *height = mState.scissor.height;
-}
-
-void Context::setColorMask(bool red, bool green, bool blue, bool alpha)
-{
- mState.blend.colorMaskRed = red;
- mState.blend.colorMaskGreen = green;
- mState.blend.colorMaskBlue = blue;
- mState.blend.colorMaskAlpha = alpha;
-}
-
-void Context::setDepthMask(bool mask)
-{
- mState.depthStencil.depthMask = mask;
-}
-
-void Context::setActiveSampler(unsigned int active)
-{
- mState.activeSampler = active;
-}
-
-GLuint Context::getReadFramebufferHandle() const
-{
- return mState.readFramebuffer;
-}
-
-GLuint Context::getDrawFramebufferHandle() const
-{
- return mState.drawFramebuffer;
-}
-
-GLuint Context::getRenderbufferHandle() const
-{
- return mState.renderbuffer.id();
-}
-
-GLuint Context::getVertexArrayHandle() const
-{
- return mState.vertexArray;
-}
-
-GLuint Context::getSamplerHandle(GLuint textureUnit) const
-{
- ASSERT(textureUnit < ArraySize(mState.samplers));
- return mState.samplers[textureUnit];
-}
-
-unsigned int Context::getActiveSampler() const
-{
- return mState.activeSampler;
-}
-
-GLuint Context::getArrayBufferHandle() const
-{
- return mState.arrayBuffer.id();
-}
-
-bool Context::isQueryActive() const
-{
- for (State::ActiveQueryMap::const_iterator i = mState.activeQueries.begin();
- i != mState.activeQueries.end(); i++)
- {
- if (i->second.get() != NULL)
- {
- return true;
- }
- }
-
- return false;
-}
-
-const Query *Context::getActiveQuery(GLenum target) const
-{
- // All query types should already exist in the activeQueries map
- ASSERT(mState.activeQueries.find(target) != mState.activeQueries.end());
-
- return mState.activeQueries.at(target).get();
-}
-
-GLuint Context::getActiveQueryId(GLenum target) const
-{
- const Query *query = getActiveQuery(target);
- return (query ? query->id() : 0u);
-}
-
-void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
-{
- getCurrentVertexArray()->enableAttribute(attribNum, enabled);
-}
-
-const VertexAttribute &Context::getVertexAttribState(unsigned int attribNum) const
-{
- return getCurrentVertexArray()->getVertexAttribute(attribNum);
-}
-
-const VertexAttribCurrentValueData &Context::getVertexAttribCurrentValue(unsigned int attribNum) const
-{
- ASSERT(attribNum < MAX_VERTEX_ATTRIBS);
- return mState.vertexAttribCurrentValues[attribNum];
-}
-
-void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, bool normalized,
- bool pureInteger, GLsizei stride, const void *pointer)
-{
- getCurrentVertexArray()->setAttributeState(attribNum, boundBuffer, size, type, normalized, pureInteger, stride, pointer);
-}
-
-const void *Context::getVertexAttribPointer(unsigned int attribNum) const
-{
- return getCurrentVertexArray()->getVertexAttribute(attribNum).mPointer;
-}
-
-void Context::setPackAlignment(GLint alignment)
-{
- mState.pack.alignment = alignment;
-}
-
-GLint Context::getPackAlignment() const
-{
- return mState.pack.alignment;
-}
-
-void Context::setUnpackAlignment(GLint alignment)
-{
- mState.unpack.alignment = alignment;
-}
-
-GLint Context::getUnpackAlignment() const
-{
- return mState.unpack.alignment;
-}
-
-void Context::setPackReverseRowOrder(bool reverseRowOrder)
-{
- mState.pack.reverseRowOrder = reverseRowOrder;
-}
-
-bool Context::getPackReverseRowOrder() const
-{
- return mState.pack.reverseRowOrder;
-}
-
-const PixelUnpackState &Context::getUnpackState() const
-{
- return mState.unpack;
-}
-
-const PixelPackState &Context::getPackState() const
-{
- return mState.pack;
-}
-