diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-12-04 16:22:46 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-07 14:16:57 +0000 |
commit | 612ebb3a545c4886d0123326abcdb951432dc4f2 (patch) | |
tree | a112269b929ef3207758c31b005fc6521f9f3338 | |
parent | e91104ee1654b104a0a9a75c3e0147549f3a3325 (diff) |
coverity#1256664 Division or modulo by float zero
and
coverity#1256664 Division or modulo by float zero
Change-Id: I62c923aad9a21b517f6422365ccf94311e0709b6
-rw-r--r-- | vcl/opengl/program.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx index 8b92c4bebb26..46552fd2dc34 100644 --- a/vcl/opengl/program.cxx +++ b/vcl/opengl/program.cxx @@ -217,14 +217,19 @@ void OpenGLProgram::SetTransform( const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY ) { + auto nTexWidth = rTexture.GetWidth(); + auto nTexHeight = rTexture.GetHeight(); + if (nTexWidth == 0 || nTexHeight == 0) + return; + GLuint nUniform = GetUniformLocation( rName ); const basegfx::B2DVector aXRel = rX - rNull; const basegfx::B2DVector aYRel = rY - rNull; const float aValues[] = { - (float) aXRel.getX()/rTexture.GetWidth(), (float) aXRel.getY()/rTexture.GetWidth(), 0, 0, - (float) aYRel.getX()/rTexture.GetHeight(), (float) aYRel.getY()/rTexture.GetHeight(), 0, 0, - 0, 0, 1, 0, - (float) rNull.getX(), (float) rNull.getY(), 0, 1 }; + (float) aXRel.getX()/nTexWidth, (float) aXRel.getY()/nTexWidth, 0, 0, + (float) aYRel.getX()/nTexHeight, (float) aYRel.getY()/nTexHeight, 0, 0, + 0, 0, 1, 0, + (float) rNull.getX(), (float) rNull.getY(), 0, 1 }; glm::mat4 mMatrix = glm::make_mat4( aValues ); glUniformMatrix4fv( nUniform, 1, GL_FALSE, glm::value_ptr( mMatrix ) ); } |