From ae4bc5c53d1ff8f360e63419e511ef635280a5b8 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Sun, 26 Aug 2007 19:47:18 +0000 Subject: [PATCH] - Call GLTexture ctor - Adjust texture lod bias after texture's been created (it's not created in init()) svn path=/trunk/KDE/kdebase/workspace/; revision=704983 --- scene_opengl.cpp | 20 +++++++++++--------- scene_opengl.h | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 11c69c28cb..77cbfdeb29 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -732,12 +732,12 @@ void SceneOpenGL::windowOpacityChanged( Toplevel* ) // SceneOpenGL::Texture //**************************************** -SceneOpenGL::Texture::Texture() +SceneOpenGL::Texture::Texture() : GLTexture() { init(); } -SceneOpenGL::Texture::Texture( const Pixmap& pix, const QSize& size, int depth ) +SceneOpenGL::Texture::Texture( const Pixmap& pix, const QSize& size, int depth ) : GLTexture() { init(); load( pix, size, depth ); @@ -749,14 +749,18 @@ SceneOpenGL::Texture::~Texture() void SceneOpenGL::Texture::init() { - bind(); bound_glxpixmap = None; + } + +void SceneOpenGL::Texture::createTexture() + { + glGenTextures( 1, &mTexture ); + glBindTexture( mTarget, mTexture ); if( hasGLVersion( 1, 4, 0 )) { // Lod bias makes the trilinear-filtered texture look a bit sharper glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.0f ); } - unbind(); } void SceneOpenGL::Texture::discard() @@ -851,7 +855,7 @@ bool SceneOpenGL::Texture::load( const Pixmap& pix, const QSize& size, if( tfp_mode ) { // tfp mode, simply bind the pixmap to texture if( mTexture == None ) - glGenTextures( 1, &mTexture ); + createTexture(); // when the pixmap is bound to the texture, they share the same data, so the texture // updates automatically - no need to do anything in such case if( bound_glxpixmap == None ) @@ -890,8 +894,7 @@ bool SceneOpenGL::Texture::load( const Pixmap& pix, const QSize& size, findTarget(); if( mTexture == None ) { - glGenTextures( 1, &mTexture ); - glBindTexture( mTarget, mTexture ); + createTexture(); y_inverted = false; glTexImage2D( mTarget, 0, depth == 32 ? GL_RGBA : GL_RGB, mSize.width(), mSize.height(), 0, @@ -942,8 +945,7 @@ bool SceneOpenGL::Texture::load( const Pixmap& pix, const QSize& size, glDrawBuffer( GL_FRONT ); if( mTexture == None ) { - glGenTextures( 1, &mTexture ); - glBindTexture( mTarget, mTexture ); + createTexture(); y_inverted = false; glCopyTexImage2D( mTarget, 0, depth == 32 ? GL_RGBA : GL_RGB, diff --git a/scene_opengl.h b/scene_opengl.h index ca2e3a0e43..71fc2a5ba5 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -104,6 +104,7 @@ class SceneOpenGL::Texture protected: void findTarget(); QRegion optimizeBindDamage( const QRegion& reg, int limit ); + void createTexture(); private: void init();