diff --git a/include/osg/Texture1D b/include/osg/Texture1D index 912290665..800f8f0a8 100644 --- a/include/osg/Texture1D +++ b/include/osg/Texture1D @@ -71,16 +71,10 @@ class OSG_EXPORT Texture1D : public Texture /** Sets the texture width. If width is zero, calculate the value * from the source image width. */ - inline void setTextureSize(int width) const - { - _textureWidth = width; - } + inline void setTextureWidth(int width) const { _textureWidth = width; } - /** Gets the texture subload width. */ - inline void getTextureSize(int& width) const - { - width = _textureWidth; - } + /** Gets the texture width. */ + inline int getTextureWidth() const { return _textureWidth; } class OSG_EXPORT SubloadCallback : public Referenced diff --git a/include/osg/Texture3D b/include/osg/Texture3D index f09ffe361..acfbf1639 100644 --- a/include/osg/Texture3D +++ b/include/osg/Texture3D @@ -84,6 +84,15 @@ class OSG_EXPORT Texture3D : public Texture depth = _textureDepth; } + void setTextureWidth(int width) { _textureWidth=width; } + int getTextureWidth() const { return _textureWidth; } + + void setTextureHeight(int height) { _textureHeight=height; } + int getTextureHeight() const { return _textureHeight; } + + void setTextureDepth(int depth) { _textureDepth=depth; } + int getTextureDepth() const { return _textureDepth; } + class OSG_EXPORT SubloadCallback : public Referenced { diff --git a/include/osg/TextureCubeMap b/include/osg/TextureCubeMap index 6ee9f25f2..d4509f51d 100644 --- a/include/osg/TextureCubeMap +++ b/include/osg/TextureCubeMap @@ -85,13 +85,11 @@ class OSG_EXPORT TextureCubeMap : public Texture _textureHeight = height; } - /** Get the texture subload width. */ - inline void getTextureSize(int& width, int& height) const - { - width = _textureWidth; - height = _textureHeight; - } + void setTextureWidth(int width) { _textureWidth=width; } + int getTextureWidth() const { return _textureWidth; } + void setTextureHeight(int height) { _textureHeight=height; } + int getTextureHeight() const { return _textureHeight; } class OSG_EXPORT SubloadCallback : public Referenced { diff --git a/include/osg/TextureRectangle b/include/osg/TextureRectangle index eef352c1c..7d8ac5c7f 100644 --- a/include/osg/TextureRectangle +++ b/include/osg/TextureRectangle @@ -84,12 +84,11 @@ class OSG_EXPORT TextureRectangle : public Texture _textureHeight = height; } - /** Get the texture subload width. */ - inline void getTextureSize(int& width, int& height) const - { - width = _textureWidth; - height = _textureHeight; - } + void setTextureWidth(int width) { _textureWidth=width; } + int getTextureWidth() const { return _textureWidth; } + + void setTextureHeight(int height) { _textureHeight=height; } + int getTextureHeight() const { return _textureHeight; } class SubloadCallback : public Referenced { diff --git a/src/osg/CameraNode.cpp b/src/osg/CameraNode.cpp index 47f156ad1..99f9f733f 100644 --- a/src/osg/CameraNode.cpp +++ b/src/osg/CameraNode.cpp @@ -62,12 +62,12 @@ void CameraNode::setRenderTargetImplementation(RenderTargetImplementation impl) void CameraNode::setRenderTargetImplementation(RenderTargetImplementation impl, RenderTargetImplementation fallback) { - if (impl_image = 0; } } + else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_internalFormat!=0) ) + { + _textureObjectBuffer[contextID] = textureObject = generateTextureObject( + contextID,GL_TEXTURE_RECTANGLE,0,_internalFormat,_textureWidth,_textureHeight,1,0); + + textureObject->bind(); + + applyTexParameters(GL_TEXTURE_RECTANGLE,state); + + // no image present, but dimensions at set so lets create the texture + glTexImage2D( GL_TEXTURE_RECTANGLE, 0, _internalFormat, + _textureWidth, _textureHeight, _borderWidth, + _internalFormat, + GL_UNSIGNED_BYTE, + 0); + + if (_readPBuffer.valid()) + { + _readPBuffer->bindPBufferToTexture(GL_FRONT); + } + + } else { glBindTexture(GL_TEXTURE_RECTANGLE, 0); diff --git a/src/osgPlugins/ive/TextureCubeMap.cpp b/src/osgPlugins/ive/TextureCubeMap.cpp index 659f8095b..8f94ecd38 100644 --- a/src/osgPlugins/ive/TextureCubeMap.cpp +++ b/src/osgPlugins/ive/TextureCubeMap.cpp @@ -32,10 +32,8 @@ void TextureCubeMap::write(DataOutputStream* out){ // Write TextureCubeMap's properties. // Write texture size - int width,height; - getTextureSize(width, height); - out->writeInt(width); - out->writeInt(height); + out->writeInt(getTextureWidth()); + out->writeInt(getTextureHeight()); // Write number of mipmap levels out->writeInt(getNumMipmapLevels()); diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index 29eaacaec..ca9548c87 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -184,7 +184,54 @@ void RenderStage::runCameraSetUp(osg::State& state) _imageReadPixelFormat = pixelFormat; _imageReadPixelDataType = dataType; - setImage(itr->second._image.get()); + setImage(itr->second._image.get()); + } + + if (itr->second._texture.valid()) + { + osg::Texture* texture = itr->second._texture.get(); + osg::Texture1D* texture1D = 0; + osg::Texture2D* texture2D = 0; + osg::Texture3D* texture3D = 0; + osg::TextureCubeMap* textureCubeMap = 0; + osg::TextureRectangle* textureRectangle = 0; + if (0 != (texture1D=dynamic_cast(texture))) + { + if (texture1D->getTextureWidth()==0) + { + texture1D->setTextureWidth(_viewport->width()); + } + } + else if (0 != (texture2D = dynamic_cast(texture))) + { + if (texture2D->getTextureWidth()==0 || texture2D->getTextureHeight()==0) + { + texture2D->setTextureSize(_viewport->width(),_viewport->height()); + } + } + else if (0 != (texture3D = dynamic_cast(texture))) + { + if (texture3D->getTextureWidth()==0 || texture3D->getTextureHeight()==0 || texture3D->getTextureDepth()==0 ) + { + // note we dont' have the depth here, so we'll heave to assume that height and depth are the same.. + texture3D->setTextureSize(_viewport->width(),_viewport->height(),_viewport->height()); + } + } + else if (0 != (textureCubeMap = dynamic_cast(texture))) + { + if (textureCubeMap->getTextureWidth()==0 || textureCubeMap->getTextureHeight()==0) + { + textureCubeMap->setTextureSize(_viewport->width(),_viewport->height()); + } + } + else if (0 != (textureRectangle = dynamic_cast(texture))) + { + if (textureRectangle->getTextureWidth()==0 || textureRectangle->getTextureHeight()==0) + { + textureRectangle->setTextureSize(_viewport->width(),_viewport->height()); + } + } + } } diff --git a/src/osgWrappers/osg/Texture1D.cpp b/src/osgWrappers/osg/Texture1D.cpp index 88cb8ad15..6a315cef8 100644 --- a/src/osgWrappers/osg/Texture1D.cpp +++ b/src/osgWrappers/osg/Texture1D.cpp @@ -44,8 +44,8 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Texture1D) I_Method1(osg::Image *, getImage, IN, unsigned, int); I_Method1(const osg::Image *, getImage, IN, unsigned, int); I_Method0(unsigned int, getNumImages); - I_Method1(void, setTextureSize, IN, int, width); - I_Method1(void, getTextureSize, IN, int &, width); + I_Method1(void, setTextureWidth, IN, int, width); + I_Method0(int, getTextureWidth); I_Method1(void, setSubloadCallback, IN, osg::Texture1D::SubloadCallback *, cb); I_Method0(osg::Texture1D::SubloadCallback *, getSubloadCallback); I_Method0(const osg::Texture1D::SubloadCallback *, getSubloadCallback); @@ -57,8 +57,8 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Texture1D) I_Property(osg::Image *, Image); I_WriteOnlyProperty(unsigned int, NumMipmapLevels); I_Property(osg::Texture1D::SubloadCallback *, SubloadCallback); - I_WriteOnlyProperty(int, TextureSize); I_ReadOnlyProperty(GLenum, TextureTarget); + I_Property(int, TextureWidth); I_ReadOnlyProperty(osg::StateAttribute::Type, Type); END_REFLECTOR diff --git a/src/osgWrappers/osg/Texture3D.cpp b/src/osgWrappers/osg/Texture3D.cpp index 23c2cecd0..8e5ac4840 100644 --- a/src/osgWrappers/osg/Texture3D.cpp +++ b/src/osgWrappers/osg/Texture3D.cpp @@ -46,6 +46,12 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Texture3D) I_Method0(unsigned int, getNumImages); I_Method3(void, setTextureSize, IN, int, width, IN, int, height, IN, int, depth); I_Method3(void, getTextureSize, IN, int &, width, IN, int &, height, IN, int &, depth); + I_Method1(void, setTextureWidth, IN, int, width); + I_Method0(int, getTextureWidth); + I_Method1(void, setTextureHeight, IN, int, height); + I_Method0(int, getTextureHeight); + I_Method1(void, setTextureDepth, IN, int, depth); + I_Method0(int, getTextureDepth); I_Method1(void, setSubloadCallback, IN, osg::Texture3D::SubloadCallback *, cb); I_Method0(osg::Texture3D::SubloadCallback *, getSubloadCallback); I_Method0(const osg::Texture3D::SubloadCallback *, getSubloadCallback); @@ -56,7 +62,10 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Texture3D) I_Property(osg::Image *, Image); I_WriteOnlyProperty(unsigned int, NumMipmapLevels); I_Property(osg::Texture3D::SubloadCallback *, SubloadCallback); + I_Property(int, TextureDepth); + I_Property(int, TextureHeight); I_ReadOnlyProperty(GLenum, TextureTarget); + I_Property(int, TextureWidth); I_ReadOnlyProperty(osg::StateAttribute::Type, Type); END_REFLECTOR diff --git a/src/osgWrappers/osg/TextureCubeMap.cpp b/src/osgWrappers/osg/TextureCubeMap.cpp index 051fe9000..79497af3f 100644 --- a/src/osgWrappers/osg/TextureCubeMap.cpp +++ b/src/osgWrappers/osg/TextureCubeMap.cpp @@ -51,7 +51,10 @@ BEGIN_OBJECT_REFLECTOR(osg::TextureCubeMap) I_Method0(unsigned int, getNumImages); I_Method2(unsigned int &, getModifiedCount, IN, unsigned int, face, IN, unsigned int, contextID); I_Method2(void, setTextureSize, IN, int, width, IN, int, height); - I_Method2(void, getTextureSize, IN, int &, width, IN, int &, height); + I_Method1(void, setTextureWidth, IN, int, width); + I_Method0(int, getTextureWidth); + I_Method1(void, setTextureHeight, IN, int, height); + I_Method0(int, getTextureHeight); I_Method1(void, setSubloadCallback, IN, osg::TextureCubeMap::SubloadCallback *, cb); I_Method0(osg::TextureCubeMap::SubloadCallback *, getSubloadCallback); I_Method0(const osg::TextureCubeMap::SubloadCallback *, getSubloadCallback); @@ -62,7 +65,9 @@ BEGIN_OBJECT_REFLECTOR(osg::TextureCubeMap) I_ArrayProperty_G(osg::Image *, Image, Images, unsigned int, void); I_WriteOnlyProperty(unsigned int, NumMipmapLevels); I_Property(osg::TextureCubeMap::SubloadCallback *, SubloadCallback); + I_Property(int, TextureHeight); I_ReadOnlyProperty(GLenum, TextureTarget); + I_Property(int, TextureWidth); I_ReadOnlyProperty(osg::StateAttribute::Type, Type); END_REFLECTOR diff --git a/src/osgWrappers/osg/TextureRectangle.cpp b/src/osgWrappers/osg/TextureRectangle.cpp index 2239d8b1e..346890895 100644 --- a/src/osgWrappers/osg/TextureRectangle.cpp +++ b/src/osgWrappers/osg/TextureRectangle.cpp @@ -46,7 +46,10 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::TextureRectangle) I_Method1(const osg::Image *, getImage, IN, unsigned, int); I_Method0(unsigned int, getNumImages); I_Method2(void, setTextureSize, IN, int, width, IN, int, height); - I_Method2(void, getTextureSize, IN, int &, width, IN, int &, height); + I_Method1(void, setTextureWidth, IN, int, width); + I_Method0(int, getTextureWidth); + I_Method1(void, setTextureHeight, IN, int, height); + I_Method0(int, getTextureHeight); I_Method1(void, setSubloadCallback, IN, osg::TextureRectangle::SubloadCallback *, cb); I_Method0(osg::TextureRectangle::SubloadCallback *, getSubloadCallback); I_Method0(const osg::TextureRectangle::SubloadCallback *, getSubloadCallback); @@ -55,7 +58,9 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::TextureRectangle) I_Method1(void, apply, IN, osg::State &, state); I_Property(osg::Image *, Image); I_Property(osg::TextureRectangle::SubloadCallback *, SubloadCallback); + I_Property(int, TextureHeight); I_ReadOnlyProperty(GLenum, TextureTarget); + I_Property(int, TextureWidth); I_ReadOnlyProperty(osg::StateAttribute::Type, Type); END_REFLECTOR