Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.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 OpenGLInfoPanelRenderer::LoadTexture(const InfoPanelSceneLayer& layer) | 28 void OpenGLInfoPanelRenderer::LoadTexture(const InfoPanelSceneLayer& 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 anchor_ = layer.GetAnchor(); | 33 texture_.reset(new OpenGL::OpenGLTexture(context_)); |
34 texture_->Load(layer.GetTexture(), layer.IsLinearInterpolation()); | |
35 anchor_ = layer.GetAnchor(); | |
36 } | |
34 } | 37 } |
35 | |
36 | 38 |
37 OpenGLInfoPanelRenderer::OpenGLInfoPanelRenderer(OpenGL::IOpenGLContext& context, | 39 OpenGLInfoPanelRenderer::OpenGLInfoPanelRenderer(OpenGL::IOpenGLContext& context, |
38 OpenGLColorTextureProgram& program, | 40 OpenGLColorTextureProgram& program, |
39 const InfoPanelSceneLayer& layer) : | 41 const InfoPanelSceneLayer& layer) : |
40 context_(context), | 42 context_(context), |
41 program_(program) | 43 program_(program), |
44 anchor_(BitmapAnchor_TopLeft) | |
42 { | 45 { |
43 LoadTexture(layer); | 46 LoadTexture(layer); |
44 } | 47 } |
45 | 48 |
46 | 49 |
47 void OpenGLInfoPanelRenderer::Render(const AffineTransform2D& transform, | 50 void OpenGLInfoPanelRenderer::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 int dx, dy; | 56 int dx = 0, dy = 0; |
54 InfoPanelSceneLayer::ComputeAnchorLocation( | 57 InfoPanelSceneLayer::ComputeAnchorLocation( |
55 dx, dy, anchor_, texture_->GetWidth(), texture_->GetHeight(), | 58 dx, dy, anchor_, texture_->GetWidth(), texture_->GetHeight(), |
56 canvasWidth, canvasHeight); | 59 canvasWidth, canvasHeight); |
57 | 60 |
58 // The position of this type of layer is layer: Ignore the | 61 // The position of this type of layer is layer: Ignore the |