diff options
Diffstat (limited to 'src/mbgl/util/offscreen_texture.cpp')
-rw-r--r-- | src/mbgl/util/offscreen_texture.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/mbgl/util/offscreen_texture.cpp b/src/mbgl/util/offscreen_texture.cpp index 56ef60b15c..e719ac566e 100644 --- a/src/mbgl/util/offscreen_texture.cpp +++ b/src/mbgl/util/offscreen_texture.cpp @@ -14,12 +14,13 @@ public: void bind() { if (!framebuffer) { - texture = context.createTexture(size); + texture = context.createTexture(size, gl::TextureFormat::RGBA); framebuffer = context.createFramebuffer(*texture); } else { context.bindFramebuffer = framebuffer->framebuffer; } + context.activeTexture = 0; context.viewport = { 0, 0, size }; } @@ -36,6 +37,20 @@ public: return size; } + void bindRenderbuffers(gl::TextureUnit unit) { + if (!framebuffer) { + texture = context.createTexture(size, gl::TextureFormat::RGBA, unit); + gl::Renderbuffer<gl::RenderbufferType::DepthComponent> depthTarget = context.createRenderbuffer<gl::RenderbufferType::DepthComponent>(size); + framebuffer = context.createFramebuffer(*texture, depthTarget); + + } else { + context.bindFramebuffer = framebuffer->framebuffer; + } + + context.activeTexture = unit; + context.viewport = { 0, 0, size }; + } + private: gl::Context& context; const Size size; @@ -66,4 +81,8 @@ const Size& OffscreenTexture::getSize() const { return impl->getSize(); } +void OffscreenTexture::bindRenderbuffers(gl::TextureUnit unit) { + impl->bindRenderbuffers(unit); +} + } // namespace mbgl |