// Copyright (C) 2002-2003 Brett Hartshorn (bhartshorn@opart.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. // // Updated for OSG 0.9.7-rc1 by brett hartshorn #include #include #include #include #include "Image.hpp" #include "held_ptr.hpp" using namespace boost::python; namespace { DEFINE_IMAGE_CAST(ImageStream) class ImageStreamBase : public osg::ImageStream { public: ImageStreamBase() : osg::ImageStream() {} }; class ImageStreamBase_imp : public ImageStreamBase { public: ImageStreamBase_imp(PyObject * self): ImageStreamBase(), _self(self) { Py_XINCREF(_self); } ~ImageStreamBase_imp() { Py_XDECREF(_self); } virtual void link(osg::Image& from) { _s = from.s(); _t = from.t(); _r = from.r(); _data = from.data(); _fileName = from.getFileName(); _internalTextureFormat = from.getInternalTextureFormat(); _pixelFormat = from.getPixelFormat(); _dataType = from.getDataType(); _packing = from.getPacking(); _allocationMode = from.getAllocationMode(); ++_modifiedCount; } virtual void update() { try { call_method(_self, "update"); } catch(...) { handle_exception(); PyErr_Print(); throw_error_already_set(); } } private: PyObject * _self; }; } namespace PyOSG { void init_ImageStream() { REGISTER_IMAGE_CAST(ImageStream) { class_, bases, boost::noncopyable> imagestream("ImageStream", no_init); imagestream .def("play", &osg::ImageStream::play) .def("pause", &osg::ImageStream::pause) .def("rewind", &osg::ImageStream::rewind) .def("quit", &osg::ImageStream::quit) .def("getStatus", &osg::ImageStream::getStatus) .def("setReferenceTime", &osg::ImageStream::setReferenceTime) .def("getReferenceTime", &osg::ImageStream::getReferenceTime) .def("setTimeMultiplier", &osg::ImageStream::setTimeMultiplier) .def("getTimeMultiplier", &osg::ImageStream::getTimeMultiplier) .def("update", &osg::ImageStream::update) ; } { class_, bases, boost::noncopyable> imagestream("ImageStream_base", no_init); imagestream .def(init<>()) .def("link", &ImageStreamBase_imp::link); ; } } } //name space