summaryrefslogtreecommitdiff
path: root/vcl/opengl/texture.cxx
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-28 14:56:08 -0500
committerJan Holesovsky <kendy@collabora.com>2014-12-02 11:58:45 +0100
commit99ade27b04d3d492648eadb620cda8ea9909bf45 (patch)
tree45a9221e508acc90e73db3ad998eeaa819099686 /vcl/opengl/texture.cxx
parent0d4233ef90a4350d63da0c9d1b98ced64b773ce0 (diff)
vcl: Only load OpenGL shaders once for each context
Change-Id: Idbf9026c5e64ef41d4c913153dfddf36923ff7de
Diffstat (limited to 'vcl/opengl/texture.cxx')
-rw-r--r--vcl/opengl/texture.cxx29
1 files changed, 20 insertions, 9 deletions
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index c8f46848e6d6..7618c04d6471 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -188,6 +188,24 @@ void OpenGLTexture::GetCoord( GLfloat* pCoord, const SalTwoRect& rPosAry, bool b
}
}
+void OpenGLTexture::GetWholeCoord( GLfloat* pCoord ) const
+{
+ if( GetWidth() != mpImpl->mnWidth || GetHeight() != mpImpl->mnHeight )
+ {
+ pCoord[0] = pCoord[2] = maRect.Left() / (double) mpImpl->mnWidth;
+ pCoord[4] = pCoord[6] = maRect.Right() / (double) mpImpl->mnWidth;
+ pCoord[3] = pCoord[5] = 1.0f - maRect.Top() / (double) mpImpl->mnHeight;
+ pCoord[1] = pCoord[7] = 1.0f - maRect.Bottom() / (double) mpImpl->mnHeight;
+ }
+ else
+ {
+ pCoord[0] = pCoord[2] = 0;
+ pCoord[4] = pCoord[6] = 1;
+ pCoord[1] = pCoord[7] = 0;
+ pCoord[3] = pCoord[5] = 1;
+ }
+}
+
GLenum OpenGLTexture::GetFilter() const
{
if( mpImpl )
@@ -226,7 +244,7 @@ void OpenGLTexture::Unbind()
bool OpenGLTexture::Draw()
{
GLfloat aPosition[8] = { -1, -1, -1, 1, 1, 1, 1, -1 };
- GLfloat aTexCoord[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };
+ GLfloat aTexCoord[8];
if( mpImpl == NULL )
{
@@ -235,15 +253,8 @@ bool OpenGLTexture::Draw()
}
SAL_INFO( "vcl.opengl", "Drawing texture " << Id() << " [" << maRect.Left() << "," << maRect.Top() << "] " << GetWidth() << "x" << GetHeight() );
- if( GetWidth() != mpImpl->mnWidth || GetHeight() != mpImpl->mnHeight )
- {
- // FIXME: lfrb: check math
- aTexCoord[0] = aTexCoord[2] = maRect.Left() / (double) mpImpl->mnWidth;
- aTexCoord[4] = aTexCoord[6] = maRect.Right() / (double) mpImpl->mnWidth;
- aTexCoord[1] = aTexCoord[7] = maRect.Top() / (double) mpImpl->mnHeight;
- aTexCoord[3] = aTexCoord[5] = maRect.Bottom() / (double) mpImpl->mnHeight;
- }
+ GetWholeCoord( aTexCoord );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, mpImpl->mnTexture );
glEnableVertexAttribArray( 0 );