#pragma once #include #include #include #include namespace mbgl { namespace gl { template class Value { public: void operator=(const typename T::Type& value) { if (dirty || current != value) { dirty = false; current = value; T::Set(current); } } void reset() { dirty = true; current = T::Default; T::Set(current); } void setDirty() { dirty = true; } typename T::Type getCurrent() { return current; } bool getDirty() { return dirty; } private: typename T::Type current = T::Default; bool dirty = false; }; class Config { public: void reset() { stencilFunc.reset(); stencilMask.reset(); stencilTest.reset(); stencilOp.reset(); depthRange.reset(); depthMask.reset(); depthTest.reset(); depthFunc.reset(); blend.reset(); blendFunc.reset(); colorMask.reset(); clearDepth.reset(); clearColor.reset(); clearStencil.reset(); program.reset(); lineWidth.reset(); activeTexture.reset(); #ifndef GL_ES_VERSION_2_0 pixelZoom.reset(); rasterPos.reset(); #endif // GL_ES_VERSION_2_0 } void setDirty() { stencilFunc.setDirty(); stencilMask.setDirty(); stencilTest.setDirty(); stencilOp.setDirty(); depthRange.setDirty(); depthMask.setDirty(); depthTest.setDirty(); depthFunc.setDirty(); blend.setDirty(); blendFunc.setDirty(); colorMask.setDirty(); clearDepth.setDirty(); clearColor.setDirty(); clearStencil.setDirty(); program.setDirty(); lineWidth.setDirty(); activeTexture.setDirty(); #ifndef GL_ES_VERSION_2_0 pixelZoom.setDirty(); rasterPos.setDirty(); #endif // GL_ES_VERSION_2_0 } Value stencilFunc; Value stencilMask; Value stencilTest; Value stencilOp; Value depthRange; Value depthMask; Value depthTest; Value depthFunc; Value blend; Value blendFunc; Value colorMask; Value clearDepth; Value clearColor; Value clearStencil; Value program; Value lineWidth; Value activeTexture; #ifndef GL_ES_VERSION_2_0 Value pixelZoom; Value rasterPos; #endif // GL_ES_VERSION_2_0 }; } // namespace gl } // namespace mbgl