// Copyright (C) 2002-2003 Gideon May (gideon@computer.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. #include #include #include #include #include #include #include #include "held_ptr.hpp" using namespace boost::python; namespace { void osgStateSet_setAttribute(osg::StateSet * self, osg::StateAttribute * attribute) { self->setAttribute(attribute); } void osgStateSet_setAttribute_2(osg::StateSet * self, osg::StateAttribute * attribute, int mode) { self->setAttribute(attribute, mode); } void osgStateSet_setAttributeAndModes(osg::StateSet * self, osg::StateAttribute * attribute, osg::StateAttribute::GLModeValue value) { self->setAttributeAndModes(attribute, value); } void osgStateSet_setAttributeAndModes_2(osg::StateSet * self, osg::StateAttribute * attribute) { self->setAttributeAndModes(attribute); } void osgStateSet_setTextureAttributeAndModes(osg::StateSet * self, int unit, osg::StateAttribute *attribute, int value) { self->setTextureAttributeAndModes(unit, attribute, osg::StateAttribute::GLModeValue(value)); } void osgStateSet_setRenderBinDetails(osg::StateSet * self, int binNum, const std::string& binName) { self->setRenderBinDetails(binNum, binName); } void osgStateSet_setTextureAttribute(osg::StateSet * self, unsigned int unit,osg::StateAttribute *attribute) { self->setTextureAttribute(unit, attribute); } std::string __str__(osg::StateSet& self) { const osg::StateSet::ModeList& modeList = self.getModeList(); std::ostringstream ost; ost << "StateSet :\n"; for(osg::StateSet::ModeList::const_iterator itr=modeList.begin(); itr!=modeList.end(); ++itr) { ost << " Mode " << itr->first << " " << itr->second << std::endl; } return ost.str(); } } // namespace namespace PyOSG { void init_StateSet() { class_, bases, boost::noncopyable > stateset("StateSet", no_init); scope stateset_scope(stateset); stateset.def(init<>()) .def("setGlobalDefaults", &osg::StateSet::setGlobalDefaults) .def("setMode", (void (osg::StateSet::*) (osg::StateAttribute::GLMode , osg::StateAttribute::GLModeValue )) &osg::StateSet::setMode) .def("getMode", (osg::StateAttribute::GLModeValue (osg::StateSet::*)(osg::StateAttribute::GLMode ) const) &osg::StateSet::getMode) .def("setAttribute", &osgStateSet_setAttribute) .def("setAttribute", &osgStateSet_setAttribute_2) .def("setAttributeAndModes", &osgStateSet_setAttributeAndModes) .def("setAttributeAndModes", &osgStateSet_setAttributeAndModes_2) .def("getAttribute", (osg::StateAttribute *(osg::StateSet::*)(osg::StateAttribute::Type, unsigned int))&osg::StateSet::getAttribute, return_value_policy()) .def("setTextureMode", &osg::StateSet::setTextureMode) //.def("setTextureModeToInherit", &osg::StateSet::setTextureModeToInherit) .def("setTextureAttribute", &osg::StateSet::setTextureAttribute) .def("getTextureAttribute", (osg::StateAttribute *(osg::StateSet::*)(unsigned int, osg::StateAttribute::Type)) &osg::StateSet::getTextureAttribute, return_value_policy()) .def("setTextureAttribute", &osgStateSet_setTextureAttribute) .def("setTextureAttributeAndModes", &osg::StateSet::setTextureAttributeAndModes) .def("setTextureAttributeAndModes", &osgStateSet_setTextureAttributeAndModes) .def("setRenderingHint", &osg::StateSet::setRenderingHint) .def("getRenderingHint", &osg::StateSet::getRenderingHint) .def("setRenderBinDetails", &osgStateSet_setRenderBinDetails) .def("setRenderBinToInherit", &osg::StateSet::setRenderBinToInherit) .def("getRenderBinMode", &osg::StateSet::getRenderBinMode) .def("useRenderBinDetails", &osg::StateSet::useRenderBinDetails) .def("getBinNumber", &osg::StateSet::getBinNumber) .def("getBinName", &osg::StateSet::getBinName, return_value_policy()) .def("compileGLObjects", &osg::StateSet::compileGLObjects) .def("releaseGLObjects", &osg::StateSet::releaseGLObjects) .def("__str__", &__str__) ; # define OSG_ENUM_HINT(VALUE) \ (hint.value(#VALUE, osg::StateSet::VALUE), \ stateset.def(#VALUE, object(osg::StateSet::VALUE))) enum_ hint("RenderingHint"); OSG_ENUM_HINT(DEFAULT_BIN); OSG_ENUM_HINT(OPAQUE_BIN); OSG_ENUM_HINT(TRANSPARENT_BIN); # define OSG_ENUM_MODE(VALUE) \ (mode.value(#VALUE, osg::StateSet::VALUE), \ stateset.def(#VALUE, object(osg::StateSet::VALUE))) enum_ mode("RenderBinMode"); OSG_ENUM_MODE(INHERIT_RENDERBIN_DETAILS); OSG_ENUM_MODE(USE_RENDERBIN_DETAILS); OSG_ENUM_MODE(OVERRIDE_RENDERBIN_DETAILS); #if ((OSG_VERSION_MAJOR==1) & (OSG_VERSION_MINOR < 1)) OSG_ENUM_MODE(ENCLOSE_RENDERBIN_DETAILS); #endif } }