comparison Framework/Scene2D/Internals/OpenGLColorTextureRenderer.cpp @ 947:1091b2adeb5a toa2019081001

Fixed animation frame stopping when returning false + big work on the OpenGL objects to make them lost context-safe + debug code to forcefully tag a context as lost + debug macros
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 10 Aug 2019 13:07:31 +0200
parents 6e888cf6a48b
children 2d8ab34c8c91
comparison
equal deleted inserted replaced
946:dbe3e1e47019 947:1091b2adeb5a
25 { 25 {
26 namespace Internals 26 namespace Internals
27 { 27 {
28 void OpenGLColorTextureRenderer::LoadTexture(const ColorTextureSceneLayer& layer) 28 void OpenGLColorTextureRenderer::LoadTexture(const ColorTextureSceneLayer& layer)
29 { 29 {
30 context_.MakeCurrent(); 30 if (!context_.IsContextLost())
31 texture_.reset(new OpenGL::OpenGLTexture); 31 {
32 texture_->Load(layer.GetTexture(), layer.IsLinearInterpolation()); 32 context_.MakeCurrent();
33 layerTransform_ = layer.GetTransform(); 33 texture_.reset(new OpenGL::OpenGLTexture(context_));
34 texture_->Load(layer.GetTexture(), layer.IsLinearInterpolation());
35 layerTransform_ = layer.GetTransform();
36 }
34 } 37 }
35 38
36 39
37 OpenGLColorTextureRenderer::OpenGLColorTextureRenderer(OpenGL::IOpenGLContext& context, 40 OpenGLColorTextureRenderer::OpenGLColorTextureRenderer(OpenGL::IOpenGLContext& context,
38 OpenGLColorTextureProgram& program, 41 OpenGLColorTextureProgram& program,
39 const ColorTextureSceneLayer& layer) : 42 const ColorTextureSceneLayer& layer) :
40 context_(context), 43 context_(context),
41 program_(program) 44 program_(program)
46 49
47 void OpenGLColorTextureRenderer::Render(const AffineTransform2D& transform, 50 void OpenGLColorTextureRenderer::Render(const AffineTransform2D& transform,
48 unsigned int canvasWidth, 51 unsigned int canvasWidth,
49 unsigned int canvasHeight) 52 unsigned int canvasHeight)
50 { 53 {
51 if (texture_.get() != NULL) 54 if (!context_.IsContextLost() && texture_.get() != NULL)
52 { 55 {
53 program_.Apply(*texture_, AffineTransform2D::Combine(transform, layerTransform_), true); 56 program_.Apply(*texture_, AffineTransform2D::Combine(transform, layerTransform_), true);
54 } 57 }
55 } 58 }
56 59