diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-06-01 21:32:26 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-06-13 13:37:41 +0300 |
commit | a05f060153497e1be6515120b65f580f4551f9e0 (patch) | |
tree | b736fe12eebe4bfdac0154c4e45d4dbf26207b57 /src/mbgl/gl | |
parent | 28eb2e635417c7fb8d746a9ed1d76774066098b3 (diff) | |
download | qtlocation-mapboxgl-a05f060153497e1be6515120b65f580f4551f9e0.tar.gz |
[core] Added Backend::{assume,set}ScissorTest
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/context.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/gl/value.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/gl/value.hpp | 7 |
4 files changed, 22 insertions, 2 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 6a68c3ff69..2a36100dfd 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -468,8 +468,8 @@ void Context::reset() { } void Context::setDirtyState() { - // Note: does not set viewport/bindFramebuffer to dirty since they are handled separately in - // the view object. + // Note: does not set viewport/scissorTest/bindFramebuffer to dirty + // since they are handled separately in the view object. stencilFunc.setDirty(); stencilMask.setDirty(); stencilTest.setDirty(); diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 56c0618989..9086b8c955 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -199,6 +199,7 @@ public: State<value::ActiveTexture> activeTexture; State<value::BindFramebuffer> bindFramebuffer; State<value::Viewport> viewport; + State<value::ScissorTest> scissorTest; std::array<State<value::BindTexture>, 2> texture; State<value::BindVertexArray, const Context&> vertexArrayObject { *this }; State<value::Program> program; diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp index c081c941f5..32c632d101 100644 --- a/src/mbgl/gl/value.cpp +++ b/src/mbgl/gl/value.cpp @@ -267,6 +267,18 @@ Viewport::Type Viewport::Get() { { static_cast<uint32_t>(viewport[2]), static_cast<uint32_t>(viewport[3]) } }; } +const constexpr ScissorTest::Type ScissorTest::Default; + +void ScissorTest::Set(const Type& value) { + MBGL_CHECK_ERROR(value ? glEnable(GL_SCISSOR_TEST) : glDisable(GL_SCISSOR_TEST)); +} + +ScissorTest::Type ScissorTest::Get() { + Type scissorTest; + MBGL_CHECK_ERROR(scissorTest = glIsEnabled(GL_SCISSOR_TEST)); + return scissorTest; +} + const constexpr BindFramebuffer::Type BindFramebuffer::Default; void BindFramebuffer::Set(const Type& value) { diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp index aa5cca6fec..b8656db5b0 100644 --- a/src/mbgl/gl/value.hpp +++ b/src/mbgl/gl/value.hpp @@ -182,6 +182,13 @@ struct Viewport { static Type Get(); }; +struct ScissorTest { + using Type = bool; + static const constexpr Type Default = false; + static void Set(const Type&); + static Type Get(); +}; + constexpr bool operator!=(const Viewport::Type& a, const Viewport::Type& b) { return a.x != b.x || a.y != b.y || a.size != b.size; } |