From 60cecb89592bcb177c17196f3a1e44a3e51e7e8c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 25 Mar 2005 11:07:48 +0000 Subject: [PATCH] Added State::getActiveUnit and usage of it in the glTexCopyImage*() implementations --- include/osg/State | 16 +++++++++++----- src/osg/Texture1D.cpp | 4 ++-- src/osg/Texture2D.cpp | 4 ++-- src/osg/Texture3D.cpp | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/osg/State b/include/osg/State index 10defa9cf..e0c2f0909 100644 --- a/include/osg/State +++ b/include/osg/State @@ -617,16 +617,22 @@ class SG_EXPORT State : public Referenced } } + + /** Set the current texture unit, return true if selected, + * false if selection failed such as when multitexturing is not supported. + * note, only updates values that change.*/ + bool setActiveTextureUnit( unsigned int unit ); + + /** Get the current texture unit.*/ + unsigned int getActiveTextureUnit() const { return _currentActiveTextureUnit; } + /** Set the current tex coord array texture unit, return true if selected, * false if selection failed such as when multitexturing is not supported. * note, only updates values that change.*/ bool setClientActiveTextureUnit( unsigned int unit ); - - /** set the current texture unit, return true if selected, - * false if selection failed such as when multitexturing is not supported. - * note, only updates values that change.*/ - bool setActiveTextureUnit( unsigned int unit ); + /** Get the current tex coord array texture unit.*/ + unsigned int getClientActiveTextureUnit() const { return _currentClientActiveTextureUnit; } /** wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(..); * note, only updates values that change.*/ diff --git a/src/osg/Texture1D.cpp b/src/osg/Texture1D.cpp index a723641c7..645f83887 100644 --- a/src/osg/Texture1D.cpp +++ b/src/osg/Texture1D.cpp @@ -324,7 +324,7 @@ void Texture1D::copyTexImage1D(State& state, int x, int y, int width) textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,1,1,0); // inform state that this texture is the current one bound. - state.haveAppliedAttribute(this); + state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); } void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int width) @@ -344,7 +344,7 @@ void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int w glCopyTexSubImage1D( GL_TEXTURE_1D, 0, xoffset, x, y, width); // inform state that this texture is the current one bound. - state.haveAppliedAttribute(this); + state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); } else diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 4afe001be..54c60f835 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -293,7 +293,7 @@ void Texture2D::copyTexImage2D(State& state, int x, int y, int width, int height // inform state that this texture is the current one bound. - state.haveAppliedAttribute(this); + state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); } void Texture2D::copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, int y, int width, int height ) @@ -336,7 +336,7 @@ void Texture2D::copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, if (hardwareMipMapOn) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE); // inform state that this texture is the current one bound. - state.haveAppliedAttribute(this); + state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); } else diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index 9792e0edf..e7e0e24eb 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -369,7 +369,7 @@ void Texture3D::copyTexSubImage3D(State& state, int xoffset, int yoffset, int zo //glBindTexture( GL_TEXTURE_3D, handle ); // inform state that this texture is the current one bound. - state.haveAppliedAttribute(this); + state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); } else