diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-02 14:11:37 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-05-28 16:11:05 +0200 |
commit | 7f9274035bad30980e03574c315904ab7a85fe83 (patch) | |
tree | 7b9cd0f2e2883d6da22611eaa68fae07bb7245b6 /src/mbgl/gl | |
parent | 33ee7e23de24bd3c076eafef819029cf45451d23 (diff) | |
download | qtlocation-mapboxgl-7f9274035bad30980e03574c315904ab7a85fe83.tar.gz |
[core] refactor program object creation
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/context.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/gl/renderer_backend.cpp | 32 |
2 files changed, 15 insertions, 19 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 436e1f6a61..626e1f4b66 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -50,7 +50,7 @@ static_assert(underlying_type(UniformDataType::Sampler2D) == GL_SAMPLER_2D, "Ope static_assert(underlying_type(UniformDataType::SamplerCube) == GL_SAMPLER_CUBE, "OpenGL type mismatch"); Context::Context(RendererBackend& backend_) - : gfx::Context(gfx::ContextType::OpenGL, [] { + : gfx::Context([] { GLint value; MBGL_CHECK_ERROR(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value)); return value; diff --git a/src/mbgl/gl/renderer_backend.cpp b/src/mbgl/gl/renderer_backend.cpp index 9da6ceb589..fe0ca4b5b2 100644 --- a/src/mbgl/gl/renderer_backend.cpp +++ b/src/mbgl/gl/renderer_backend.cpp @@ -21,50 +21,46 @@ std::unique_ptr<gfx::Context> RendererBackend::createContext() { return std::move(result); } -gl::Context& RendererBackend::getGLContext() { - return static_cast<gl::Context&>(getContext()); -} - PremultipliedImage RendererBackend::readFramebuffer(const Size& size) { - return getGLContext().readFramebuffer<PremultipliedImage>(size); + return getContext<gl::Context>().readFramebuffer<PremultipliedImage>(size); } void RendererBackend::assumeFramebufferBinding(const gl::FramebufferID fbo) { - getGLContext().bindFramebuffer.setCurrentValue(fbo); + getContext<gl::Context>().bindFramebuffer.setCurrentValue(fbo); if (fbo != ImplicitFramebufferBinding) { - assert(gl::value::BindFramebuffer::Get() == getGLContext().bindFramebuffer.getCurrentValue()); + assert(gl::value::BindFramebuffer::Get() == getContext<gl::Context>().bindFramebuffer.getCurrentValue()); } } void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) { - getGLContext().viewport.setCurrentValue({ x, y, size }); - assert(gl::value::Viewport::Get() == getGLContext().viewport.getCurrentValue()); + getContext<gl::Context>().viewport.setCurrentValue({ x, y, size }); + assert(gl::value::Viewport::Get() == getContext<gl::Context>().viewport.getCurrentValue()); } void RendererBackend::assumeScissorTest(bool enabled) { - getGLContext().scissorTest.setCurrentValue(enabled); - assert(gl::value::ScissorTest::Get() == getGLContext().scissorTest.getCurrentValue()); + getContext<gl::Context>().scissorTest.setCurrentValue(enabled); + assert(gl::value::ScissorTest::Get() == getContext<gl::Context>().scissorTest.getCurrentValue()); } bool RendererBackend::implicitFramebufferBound() { - return getGLContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; + return getContext<gl::Context>().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; } void RendererBackend::setFramebufferBinding(const gl::FramebufferID fbo) { - getGLContext().bindFramebuffer = fbo; + getContext<gl::Context>().bindFramebuffer = fbo; if (fbo != ImplicitFramebufferBinding) { - assert(gl::value::BindFramebuffer::Get() == getGLContext().bindFramebuffer.getCurrentValue()); + assert(gl::value::BindFramebuffer::Get() == getContext<gl::Context>().bindFramebuffer.getCurrentValue()); } } void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) { - getGLContext().viewport = { x, y, size }; - assert(gl::value::Viewport::Get() == getGLContext().viewport.getCurrentValue()); + getContext<gl::Context>().viewport = { x, y, size }; + assert(gl::value::Viewport::Get() == getContext<gl::Context>().viewport.getCurrentValue()); } void RendererBackend::setScissorTest(bool enabled) { - getGLContext().scissorTest = enabled; - assert(gl::value::ScissorTest::Get() == getGLContext().scissorTest.getCurrentValue()); + getContext<gl::Context>().scissorTest = enabled; + assert(gl::value::ScissorTest::Get() == getContext<gl::Context>().scissorTest.getCurrentValue()); } RendererBackend::~RendererBackend() = default; |