Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/Internals/OpenGLTextureProgram.cpp @ 1576:92fca2b3ba3d
sanitizing the handling of canvas size
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Sep 2020 16:40:30 +0200 |
parents | 244ad1e4e76a |
children | 4fb8fdf03314 |
comparison
equal
deleted
inserted
replaced
1575:e4a52cbbdd70 | 1576:92fca2b3ba3d |
---|---|
43 namespace OrthancStone | 43 namespace OrthancStone |
44 { | 44 { |
45 namespace Internals | 45 namespace Internals |
46 { | 46 { |
47 void OpenGLTextureProgram::InitializeExecution(OpenGL::OpenGLTexture& texture, | 47 void OpenGLTextureProgram::InitializeExecution(OpenGL::OpenGLTexture& texture, |
48 const AffineTransform2D& transform) | 48 const AffineTransform2D& transform, |
49 unsigned int canvasWidth, | |
50 unsigned int canvasHeight) | |
49 { | 51 { |
50 if (!context_.IsContextLost()) | 52 if (!context_.IsContextLost()) |
51 { | 53 { |
52 context_.MakeCurrent(); | 54 context_.MakeCurrent(); |
53 program_->Use(); | 55 program_->Use(); |
56 (texture.GetWidth(), texture.GetHeight()); | 58 (texture.GetWidth(), texture.GetHeight()); |
57 | 59 |
58 AffineTransform2D t = AffineTransform2D::Combine(transform, scale); | 60 AffineTransform2D t = AffineTransform2D::Combine(transform, scale); |
59 | 61 |
60 float m[16]; | 62 float m[16]; |
61 t.ConvertToOpenGLMatrix(m, context_.GetCanvasWidth(), context_.GetCanvasHeight()); | 63 t.ConvertToOpenGLMatrix(m, canvasWidth, canvasHeight); |
62 | 64 |
63 texture.Bind(program_->GetUniformLocation("u_texture")); | 65 texture.Bind(program_->GetUniformLocation("u_texture")); |
64 glUniformMatrix4fv(program_->GetUniformLocation("u_matrix"), 1, GL_FALSE, m); | 66 glUniformMatrix4fv(program_->GetUniformLocation("u_matrix"), 1, GL_FALSE, m); |
65 | 67 |
66 glBindBuffer(GL_ARRAY_BUFFER, buffers_[0]); | 68 glBindBuffer(GL_ARRAY_BUFFER, buffers_[0]); |