diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-10-10 17:16:37 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-10-25 13:52:36 -0700 |
commit | a4d259c33f9bb890bba97fd89552720e3e0ec09b (patch) | |
tree | 342ecc27a6993c48f3a2e1d739fce890350bc44d /test/util/offscreen_texture.test.cpp | |
parent | 5cc390d694fc7510d445310d8eb9e32429a5e67b (diff) | |
download | qtlocation-mapboxgl-a4d259c33f9bb890bba97fd89552720e3e0ec09b.tar.gz |
[core] move gl::Context to Backend and refactor View
Diffstat (limited to 'test/util/offscreen_texture.test.cpp')
-rw-r--r-- | test/util/offscreen_texture.test.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/test/util/offscreen_texture.test.cpp b/test/util/offscreen_texture.test.cpp index e281a3d65b..bd4eab69a8 100644 --- a/test/util/offscreen_texture.test.cpp +++ b/test/util/offscreen_texture.test.cpp @@ -2,7 +2,7 @@ #include <mbgl/gl/context.hpp> #include <mbgl/platform/default/headless_backend.hpp> -#include <mbgl/platform/default/headless_view.hpp> +#include <mbgl/platform/default/offscreen_view.hpp> #include <mbgl/gl/gl.hpp> #include <mbgl/util/offscreen_texture.hpp> @@ -11,7 +11,7 @@ using namespace mbgl; TEST(OffscreenTexture, EmptyRed) { HeadlessBackend backend; - HeadlessView view(1.0f, 512, 256); + OffscreenView view(backend.getContext(), {{ 512, 256 }}); view.bind(); MBGL_CHECK_ERROR(glClearColor(1.0f, 0.0f, 0.0f, 1.0f)); @@ -68,10 +68,7 @@ struct Buffer { TEST(OffscreenTexture, RenderToTexture) { HeadlessBackend backend; - HeadlessView view(1.0f, 512, 256); - view.bind(); - gl::Context context; - context.viewport.setDefaultValue(gl::value::Viewport::Get()); + auto& context = backend.getContext(); MBGL_CHECK_ERROR(glEnable(GL_BLEND)); MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); @@ -109,14 +106,17 @@ void main() { // Make sure the texture gets destructed before we call context.reset(); { + OffscreenView view(context, {{ 512, 256 }}); + // First, draw red to the bound FBO. context.clearColor = { 1, 0, 0, 1 }; + view.bind(); MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT)); // Then, create a texture, bind it, and render yellow to that texture. This should not // affect the originally bound FBO. - OffscreenTexture texture; - texture.bind(context, {{ 128, 128 }}); + OffscreenTexture texture(context, {{ 128, 128 }}); + texture.bind(); context.clearColor = { 0, 0, 0, 0 }; MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT)); @@ -128,12 +128,10 @@ void main() { glVertexAttribPointer(paintShader.a_pos, 2, GL_FLOAT, GL_FALSE, 0, nullptr)); MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 3)); - auto image = view.readStillImage(texture.getSize()); + auto image = texture.readStillImage(); test::checkImage("test/fixtures/offscreen_texture/render-to-texture", image, 0, 0); // Now reset the FBO back to normal and retrieve the original (restored) framebuffer. - context.resetState(); - context.bindFramebuffer.setDirty(); view.bind(); image = view.readStillImage(); |