Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.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 |
---|---|
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 void OpenGLTextProgram::Apply(OpenGL::OpenGLTexture& fontTexture, | 182 void OpenGLTextProgram::Apply(OpenGL::OpenGLTexture& fontTexture, |
183 const Data& data, | 183 const Data& data, |
184 const AffineTransform2D& transform) | 184 const AffineTransform2D& transform, |
185 unsigned int canvasWidth, | |
186 unsigned int canvasHeight) | |
185 { | 187 { |
186 if (!context_.IsContextLost() && !data.IsEmpty()) | 188 if (!context_.IsContextLost() && !data.IsEmpty()) |
187 { | 189 { |
188 context_.MakeCurrent(); | 190 context_.MakeCurrent(); |
189 program_->Use(); | 191 program_->Use(); |
198 transform.Apply(x, y); | 200 transform.Apply(x, y); |
199 | 201 |
200 const AffineTransform2D t = AffineTransform2D::CreateOffset(x + dx, y + dy); | 202 const AffineTransform2D t = AffineTransform2D::CreateOffset(x + dx, y + dy); |
201 | 203 |
202 float m[16]; | 204 float m[16]; |
203 t.ConvertToOpenGLMatrix(m, context_.GetCanvasWidth(), context_.GetCanvasHeight()); | 205 t.ConvertToOpenGLMatrix(m, canvasWidth, canvasHeight); |
204 | 206 |
205 fontTexture.Bind(program_->GetUniformLocation("u_texture")); | 207 fontTexture.Bind(program_->GetUniformLocation("u_texture")); |
206 glUniformMatrix4fv(program_->GetUniformLocation("u_matrix"), 1, GL_FALSE, m); | 208 glUniformMatrix4fv(program_->GetUniformLocation("u_matrix"), 1, GL_FALSE, m); |
207 glUniform3f(program_->GetUniformLocation("u_color"), | 209 glUniform3f(program_->GetUniformLocation("u_color"), |
208 data.GetRed(), data.GetGreen(), data.GetBlue()); | 210 data.GetRed(), data.GetGreen(), data.GetBlue()); |