Introduced Camera::resizeAttachments(int width, int height) to resize all the Texture and Image assigned the the Camera attachments.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14810 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -112,25 +112,7 @@ public:
|
||||
{
|
||||
camera->setViewport(0, 0, width, height);
|
||||
|
||||
osg::Camera::BufferAttachmentMap& cbam = camera->getBufferAttachmentMap();
|
||||
for(osg::Camera::BufferAttachmentMap::iterator itr = cbam.begin();
|
||||
itr != cbam.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Camera::Attachment& attachment = itr->second;
|
||||
if (attachment._texture.get())
|
||||
{
|
||||
osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(attachment._texture.get());
|
||||
if (texture2D)
|
||||
{
|
||||
OSG_NOTICE<<"Resetting Texture size"<<std::endl;
|
||||
texture2D->setTextureSize(width, height);
|
||||
texture2D->dirtyTextureObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
camera->dirtyAttachmentMap();
|
||||
camera->resizeAttachments(width, height);
|
||||
}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
|
||||
|
||||
@@ -159,6 +159,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
Viewport* getViewport() { return _viewport.get(); }
|
||||
|
||||
|
||||
|
||||
enum TransformOrder
|
||||
{
|
||||
PRE_MULTIPLY,
|
||||
@@ -425,6 +426,9 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
/** Get the AttachmentMapModifiedCount. */
|
||||
unsigned int getAttachmentMapModifiedCount() const { return _attachmentMapModifiedCount; }
|
||||
|
||||
/** Resize the image and textures in the AttachementMap.*/
|
||||
void resizeAttachments(int width, int height);
|
||||
|
||||
|
||||
/** Explicit control over implicit allocation of buffers when using FBO.
|
||||
Implicit buffers are automatically substituted when user have not attached such buffer.
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
*/
|
||||
#include <osg/Camera>
|
||||
#include <osg/RenderInfo>
|
||||
#include <osg/Texture1D>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Texture3D>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/TextureCubeMap>
|
||||
#include <osg/Texture2DArray>
|
||||
#include <osg/Notify>
|
||||
|
||||
using namespace osg;
|
||||
@@ -408,6 +414,73 @@ void Camera::inheritCullSettings(const CullSettings& settings, unsigned int inhe
|
||||
}
|
||||
}
|
||||
|
||||
void Camera::resizeAttachments(int width, int height)
|
||||
{
|
||||
bool modified = false;
|
||||
for(BufferAttachmentMap::iterator itr = _bufferAttachmentMap.begin();
|
||||
itr != _bufferAttachmentMap.end();
|
||||
++itr)
|
||||
{
|
||||
Attachment& attachment = itr->second;
|
||||
if (attachment._texture.valid())
|
||||
{
|
||||
{
|
||||
osg::Texture1D* texture = dynamic_cast<osg::Texture1D*>(attachment._texture.get());
|
||||
if (texture && (texture->getTextureWidth()!=width))
|
||||
{
|
||||
modified = true;
|
||||
texture->setTextureWidth(width);
|
||||
texture->dirtyTextureObject();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
osg::Texture2D* texture = dynamic_cast<osg::Texture2D*>(attachment._texture.get());
|
||||
if (texture && ((texture->getTextureWidth()!=width) || (texture->getTextureHeight()!=height)))
|
||||
{
|
||||
modified = true;
|
||||
texture->setTextureSize(width, height);
|
||||
texture->dirtyTextureObject();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
osg::Texture3D* texture = dynamic_cast<osg::Texture3D*>(attachment._texture.get());
|
||||
if (texture && ((texture->getTextureWidth()!=width) || (texture->getTextureHeight()!=height)))
|
||||
{
|
||||
modified = true;
|
||||
texture->setTextureSize(width, height, texture->getTextureDepth());
|
||||
texture->dirtyTextureObject();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
osg::Texture2DArray* texture = dynamic_cast<osg::Texture2DArray*>(attachment._texture.get());
|
||||
if (texture && ((texture->getTextureWidth()!=width) || (texture->getTextureHeight()!=height)))
|
||||
{
|
||||
modified = true;
|
||||
texture->setTextureSize(width, height, texture->getTextureDepth());
|
||||
texture->dirtyTextureObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attachment._image.valid() && (attachment._image->s()!=width || attachment._image->s()!=height) )
|
||||
{
|
||||
modified = true;
|
||||
osg::Image* image = attachment._image.get();
|
||||
image->allocateImage(width, height, image->r(),
|
||||
image->getPixelFormat(), image->getDataType(),
|
||||
image->getPacking());
|
||||
}
|
||||
}
|
||||
|
||||
if (modified)
|
||||
{
|
||||
dirtyAttachmentMap();
|
||||
}
|
||||
}
|
||||
|
||||
void Camera::createCameraThread()
|
||||
{
|
||||
if (!_cameraThread)
|
||||
|
||||
Reference in New Issue
Block a user