Fixed RenderToTexture bug which occured when the viewport dimensions where

different than the texture being written to.
This commit is contained in:
Robert Osfield
2006-08-03 15:57:39 +00:00
parent de9ce1e85f
commit 174e3b3dc3
9 changed files with 113 additions and 26 deletions

View File

@@ -256,6 +256,27 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
_face(0),
_mipMapGeneration(false) {}
int width() const
{
if (_texture.valid()) return _texture->getTextureWidth();
if (_image.valid()) return _image->s();
return 0;
};
int height() const
{
if (_texture.valid()) return _texture->getTextureHeight();
if (_image.valid()) return _image->t();
return 0;
};
int depth() const
{
if (_texture.valid()) return _texture->getTextureDepth();
if (_image.valid()) return _image->r();
return 0;
};
GLenum _internalFormat;
ref_ptr<Image> _image;
ref_ptr<Texture> _texture;

View File

@@ -220,6 +220,10 @@ class OSG_EXPORT Texture : public osg::StateAttribute
return true;
}
virtual int getTextureWidth() const { return 0; }
virtual int getTextureHeight() const { return 0; }
virtual int getTextureDepth() const { return 0; }
enum WrapParameter {
WRAP_S,
WRAP_T,

View File

@@ -74,7 +74,9 @@ class OSG_EXPORT Texture1D : public Texture
inline void setTextureWidth(int width) const { _textureWidth = width; }
/** Gets the texture width. */
inline int getTextureWidth() const { return _textureWidth; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return 1; }
virtual int getTextureDepth() const { return 1; }
class OSG_EXPORT SubloadCallback : public Referenced

View File

@@ -78,10 +78,11 @@ class OSG_EXPORT Texture2D : public Texture
}
void setTextureWidth(int width) { _textureWidth=width; }
int getTextureWidth() const { return _textureWidth; }
void setTextureHeight(int height) { _textureHeight=height; }
int getTextureHeight() const { return _textureHeight; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return 1; }
class OSG_EXPORT SubloadCallback : public Referenced
{

View File

@@ -85,13 +85,12 @@ class OSG_EXPORT Texture3D : public Texture
}
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; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return _textureDepth; }
class OSG_EXPORT SubloadCallback : public Referenced

View File

@@ -86,10 +86,11 @@ class OSG_EXPORT TextureCubeMap : public Texture
}
void setTextureWidth(int width) { _textureWidth=width; }
int getTextureWidth() const { return _textureWidth; }
void setTextureHeight(int height) { _textureHeight=height; }
int getTextureHeight() const { return _textureHeight; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return 1; }
class OSG_EXPORT SubloadCallback : public Referenced
{

View File

@@ -85,10 +85,11 @@ class OSG_EXPORT TextureRectangle : public Texture
}
void setTextureWidth(int width) { _textureWidth=width; }
int getTextureWidth() const { return _textureWidth; }
void setTextureHeight(int height) { _textureHeight=height; }
int getTextureHeight() const { return _textureHeight; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return 1; }
class SubloadCallback : public Referenced
{