Changeset 10924
- Timestamp:
- 01/07/10 13:14:47 (3 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 12 modified
-
include/osg/Image (modified) (2 diffs)
-
include/osg/ImageSequence (modified) (2 diffs)
-
src/osg/Image.cpp (modified) (1 diff)
-
src/osg/ImageSequence.cpp (modified) (1 diff)
-
src/osg/Texture1D.cpp (modified) (3 diffs)
-
src/osg/Texture2D.cpp (modified) (3 diffs)
-
src/osg/Texture2DArray.cpp (modified) (4 diffs)
-
src/osg/Texture3D.cpp (modified) (3 diffs)
-
src/osg/TextureCubeMap.cpp (modified) (4 diffs)
-
src/osg/TextureRectangle.cpp (modified) (3 diffs)
-
src/osgWrappers/osg/Image.cpp (modified) (3 diffs)
-
src/osgWrappers/osg/ImageSequence.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/Image
r10866 r10924 20 20 #include <osg/Vec4> 21 21 #include <osg/FrameStamp> 22 #include <osg/StateAttribute> 22 23 23 24 #include <string> … … 321 322 /** Get the const PixelBufferObject.*/ 322 323 const PixelBufferObject* getPixelBufferObject() const { return dynamic_cast<const PixelBufferObject*>(_bufferObject.get()); } 323 324 325 /** return whether the update(NodeVisitor* nv) should be required on each frame to enable proper working of osg::Image.*/ 326 virtual bool requiresUpdateCall() const { return false; } 327 328 /** update method for osg::Image subclasses that update themselves during the update traversal.*/ 324 329 virtual void update(NodeVisitor* /*nv*/) {} 330 331 /** convience update callback class that can be attached to StateAttribute (such as Textures) to ensure 332 * that the Image::update(NodeVisitor*) method is called during the update traversal. This callback 333 * is automatically attached when Image::requiresUpdateCall() is true (it's false by default.) 334 */ 335 struct OSG_EXPORT UpdateCallback : public osg::StateAttributeCallback 336 { 337 virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv); 338 }; 325 339 326 340 /** method for sending pointer events to images that are acting as front ends to interactive surfaces such as a vnc or browser window. Return true if handled. */ -
OpenSceneGraph/trunk/include/osg/ImageSequence
r10671 r10924 17 17 #include <OpenThreads/Mutex> 18 18 #include <osg/ImageStream> 19 #include <osg/StateAttribute>20 19 21 20 #include <list> … … 102 101 Images& getImages() { return _images; } 103 102 const Images& getImages() const { return _images; } 104 105 103 104 /** ImageSequence requires a call to update(NodeVisitor*) during the update traversal so return true.*/ 105 virtual bool requiresUpdateCall() const { return true; } 106 107 /** update method for osg::Image subclasses that update themselves during the update traversal.*/ 106 108 virtual void update(NodeVisitor* nv); 107 108 struct OSG_EXPORT UpdateCallback : public osg::StateAttributeCallback109 {110 virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);111 };112 109 113 110 protected: -
OpenSceneGraph/trunk/src/osg/Image.cpp
r10866 r10924 63 63 using namespace osg; 64 64 using namespace std; 65 66 void Image::UpdateCallback::operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv) 67 { 68 osg::Texture* texture = attr ? attr->asTexture() : 0; 69 70 // osg::notify(osg::NOTICE)<<"ImageSequence::UpdateCallback::"<<texture<<std::endl; 71 if (texture) 72 { 73 for(unsigned int i=0; i<texture->getNumImages(); ++i) 74 { 75 texture->getImage(i)->update(nv); 76 } 77 } 78 } 65 79 66 80 Image::Image() -
OpenSceneGraph/trunk/src/osg/ImageSequence.cpp
r9062 r10924 23 23 using namespace osg; 24 24 25 void ImageSequence::UpdateCallback::operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv)26 {27 osg::Texture* texture = attr ? attr->asTexture() : 0;28 29 // osg::notify(osg::NOTICE)<<"ImageSequence::UpdateCallback::"<<texture<<std::endl;30 if (texture)31 {32 for(unsigned int i=0; i<texture->getNumImages(); ++i)33 {34 texture->getImage(i)->update(nv);35 }36 }37 }38 39 25 ImageSequence::ImageSequence() 40 26 { -
OpenSceneGraph/trunk/src/osg/Texture1D.cpp
r10867 r10924 13 13 #include <osg/GLExtensions> 14 14 #include <osg/Texture1D> 15 #include <osg/ImageSequence>16 15 #include <osg/State> 17 16 #include <osg/GLU> … … 98 97 if (_image == image) return; 99 98 100 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))99 if (_image.valid() && _image->requiresUpdateCall()) 101 100 { 102 101 setUpdateCallback(0); … … 110 109 _modifiedCount.setAllElementsTo(0); 111 110 112 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))113 { 114 setUpdateCallback(new Image Sequence::UpdateCallback());111 if (_image.valid() && _image->requiresUpdateCall()) 112 { 113 setUpdateCallback(new Image::UpdateCallback()); 115 114 setDataVariance(osg::Object::DYNAMIC); 116 115 } -
OpenSceneGraph/trunk/src/osg/Texture2D.cpp
r10865 r10924 14 14 #include <osg/GLExtensions> 15 15 #include <osg/Texture2D> 16 #include <osg/ImageSequence>17 16 #include <osg/State> 18 17 #include <osg/Notify> … … 111 110 if (_image == image) return; 112 111 113 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))112 if (_image.valid() && _image->requiresUpdateCall()) 114 113 { 115 114 setUpdateCallback(0); … … 119 118 _image = image; 120 119 _modifiedCount.setAllElementsTo(0); 121 122 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))123 { 124 setUpdateCallback(new Image Sequence::UpdateCallback());120 121 if (_image.valid() && _image->requiresUpdateCall()) 122 { 123 setUpdateCallback(new Image::UpdateCallback()); 125 124 setDataVariance(osg::Object::DYNAMIC); 126 125 } -
OpenSceneGraph/trunk/src/osg/Texture2DArray.cpp
r10867 r10924 14 14 #include <osg/Texture2DArray> 15 15 #include <osg/State> 16 #include <osg/ImageSequence>17 16 #include <osg/Notify> 18 17 … … 114 113 if (_images[layer] == image) return; 115 114 116 unsigned numImage SequencesBefore = 0;115 unsigned numImageRequireUpdateBefore = 0; 117 116 for (unsigned int i=0; i<getNumImages(); ++i) 118 117 { 119 osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 120 if (is) ++numImageSequencesBefore; 118 if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateBefore; 121 119 } 122 120 … … 125 123 _modifiedCount[layer].setAllElementsTo(0); 126 124 127 // find out if we need to reset the update callback to handle the animation of ImageSequence128 unsigned numImage SequencesAfter = 0;125 // find out if we need to reset the update callback to handle the animation of image 126 unsigned numImageRequireUpdateAfter = 0; 129 127 for (unsigned int i=0; i<getNumImages(); ++i) 130 128 { 131 osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 132 if (is) ++numImageSequencesAfter; 133 } 134 135 if (numImageSequencesBefore>0) 136 { 137 if (numImageSequencesAfter==0) 129 if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateAfter; 130 } 131 132 if (numImageRequireUpdateBefore>0) 133 { 134 if (numImageRequireUpdateAfter==0) 138 135 { 139 136 setUpdateCallback(0); … … 141 138 } 142 139 } 143 else if (numImage SequencesAfter>0)144 { 145 setUpdateCallback(new Image Sequence::UpdateCallback());140 else if (numImageRequireUpdateAfter>0) 141 { 142 setUpdateCallback(new Image::UpdateCallback()); 146 143 setDataVariance(osg::Object::DYNAMIC); 147 144 } -
OpenSceneGraph/trunk/src/osg/Texture3D.cpp
r10867 r10924 14 14 #include <osg/Texture3D> 15 15 #include <osg/State> 16 #include <osg/ImageSequence>17 16 #include <osg/GLU> 18 17 #include <osg/Notify> … … 110 109 if (_image == image) return; 111 110 112 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))111 if (_image.valid() && _image->requiresUpdateCall()) 113 112 { 114 113 setUpdateCallback(0); … … 122 121 123 122 _image = image; 124 125 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))126 { 127 setUpdateCallback(new Image Sequence::UpdateCallback());123 124 if (_image.valid() && _image->requiresUpdateCall()) 125 { 126 setUpdateCallback(new Image::UpdateCallback()); 128 127 setDataVariance(osg::Object::DYNAMIC); 129 128 } -
OpenSceneGraph/trunk/src/osg/TextureCubeMap.cpp
r10867 r10924 16 16 #include <osg/State> 17 17 #include <osg/TextureCubeMap> 18 #include <osg/ImageSequence>19 18 #include <osg/Notify> 20 19 … … 132 131 if (_images[face] == image) return; 133 132 134 unsigned numImage SequencesBefore = 0;133 unsigned numImageRequireUpdateBefore = 0; 135 134 for (unsigned int i=0; i<getNumImages(); ++i) 136 135 { 137 osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 138 if (is) ++numImageSequencesBefore; 136 if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateBefore; 139 137 } 140 138 … … 143 141 144 142 145 // find out if we need to reset the update callback to handle the animation of ImageSequence146 unsigned numImage SequencesAfter = 0;143 // find out if we need to reset the update callback to handle the animation of image 144 unsigned numImageRequireUpdateAfter = 0; 147 145 for (unsigned int i=0; i<getNumImages(); ++i) 148 146 { 149 osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get()); 150 if (is) ++numImageSequencesAfter; 151 } 152 153 if (numImageSequencesBefore>0) 154 { 155 if (numImageSequencesAfter==0) 147 if (_images[i].valid() && _images[i]->requiresUpdateCall()) ++numImageRequireUpdateAfter; 148 } 149 150 if (numImageRequireUpdateBefore>0) 151 { 152 if (numImageRequireUpdateAfter==0) 156 153 { 157 154 setUpdateCallback(0); … … 159 156 } 160 157 } 161 else if (numImage SequencesAfter>0)162 { 163 setUpdateCallback(new Image Sequence::UpdateCallback());158 else if (numImageRequireUpdateAfter>0) 159 { 160 setUpdateCallback(new Image::UpdateCallback()); 164 161 setDataVariance(osg::Object::DYNAMIC); 165 162 } -
OpenSceneGraph/trunk/src/osg/TextureRectangle.cpp
r10867 r10924 14 14 #include <osg/GLExtensions> 15 15 #include <osg/TextureRectangle> 16 #include <osg/ImageSequence>17 16 #include <osg/State> 18 17 #include <osg/GLU> … … 127 126 if (_image == image) return; 128 127 129 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))128 if (_image.valid() && _image->requiresUpdateCall()) 130 129 { 131 130 setUpdateCallback(0); … … 137 136 138 137 _image = image; 139 140 if ( dynamic_cast<osg::ImageSequence*>(_image.get()))141 { 142 setUpdateCallback(new Image Sequence::UpdateCallback());138 139 if (_image.valid() && _image->requiresUpdateCall()) 140 { 141 setUpdateCallback(new Image::UpdateCallback()); 143 142 setDataVariance(osg::Object::DYNAMIC); 144 143 } -
OpenSceneGraph/trunk/src/osgWrappers/osg/Image.cpp
r10876 r10924 17 17 #include <osg/NodeVisitor> 18 18 #include <osg/Object> 19 #include <osg/StateAttribute> 19 20 #include <osg/Vec2> 20 21 #include <osg/Vec3> … … 376 377 "Get the const PixelBufferObject. ", 377 378 ""); 379 I_Method0(bool, requiresUpdateCall, 380 Properties::VIRTUAL, 381 __bool__requiresUpdateCall, 382 "return whether the update(NodeVisitor* nv) should be required on each frame to enable proper working of osg::Image. ", 383 ""); 378 384 I_Method1(void, update, IN, osg::NodeVisitor *, x, 379 385 Properties::VIRTUAL, 380 386 __void__update__NodeVisitor_P1, 381 " ",387 "update method for osg::Image subclasses that update themselves during the update traversal. ", 382 388 ""); 383 389 I_Method3(bool, sendPointerEvent, IN, int, x, IN, int, x, IN, int, x, … … 499 505 END_REFLECTOR 500 506 507 BEGIN_OBJECT_REFLECTOR(osg::Image::UpdateCallback) 508 I_DeclaringFile("osg/Image"); 509 I_BaseType(osg::StateAttributeCallback); 510 I_Constructor0(____UpdateCallback, 511 "", 512 ""); 513 END_REFLECTOR 514 501 515 STD_VECTOR_REFLECTOR(std::vector< unsigned int >) 502 516 -
OpenSceneGraph/trunk/src/osgWrappers/osg/ImageSequence.cpp
r10863 r10924 16 16 #include <osg/NodeVisitor> 17 17 #include <osg/Object> 18 #include <osg/StateAttribute>19 18 20 19 // Must undefine IN and OUT macros defined in Windows headers … … 207 206 "", 208 207 ""); 208 I_Method0(bool, requiresUpdateCall, 209 Properties::VIRTUAL, 210 __bool__requiresUpdateCall, 211 "ImageSequence requires a call to update(NodeVisitor*) during the update traversal so return true. ", 212 ""); 209 213 I_Method1(void, update, IN, osg::NodeVisitor *, nv, 210 214 Properties::VIRTUAL, 211 215 __void__update__NodeVisitor_P1, 212 " ",216 "update method for osg::Image subclasses that update themselves during the update traversal. ", 213 217 ""); 214 218 I_ProtectedMethod0(void, applyLoopingMode, … … 270 274 END_REFLECTOR 271 275 272 BEGIN_OBJECT_REFLECTOR(osg::ImageSequence::UpdateCallback)273 I_DeclaringFile("osg/ImageSequence");274 I_BaseType(osg::StateAttributeCallback);275 I_Constructor0(____UpdateCallback,276 "",277 "");278 END_REFLECTOR279 280 276 BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::Image >) 281 277 I_DeclaringFile("osg/ref_ptr");
