// 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 "StateAttribute.hpp" #include "held_ptr.hpp" using namespace boost::python; namespace { osg::Program * asProgram(osg::StateAttribute * self) { return dynamic_cast(self); } dict getAttribBindingList(osg::Program& self) { dict binding; const osg::Program::AttribBindingList& list = self.getAttribBindingList(); for (osg::Program::AttribBindingList::const_iterator iter = list.begin(); iter != list.end(); iter ++) { binding.setdefault(iter->first, iter->second); } return binding; } tuple getGLProgramInfoLog(osg::Program & self, unsigned int contextID) { std::string log; bool ret = self.getGlProgramInfoLog(contextID, log); return make_tuple(ret, log); } } namespace PyOSG { void init_Program() { register_castStateAttribute("asProgram", &asProgram); class_, bases >("Program", no_init) .def(init<>()) .def("dirtyProgram", &osg::Program::dirtyProgram, "Mark our PCSOs as needing relink") .def("addShader", &osg::Program::addShader, "Attach an osg::Shader to this osg::Program.\n" "Mark Program as needing relink. Return true for success") .def("getNumShaders", &osg::Program::getNumShaders) .def("getShader", (osg::Shader * (osg::Program::*)(unsigned int)) &osg::Program::getShader, return_value_policy()) .def("removeShader", &osg::Program::removeShader, "Remove osg::Shader from this osg::Program.\n" "Mark Program as needing relink. Return true for success") .def("addBindAttribLocation", &osg::Program::addBindAttribLocation, "Add an attribute location binding.") .def("removeBindAttribLocation", &osg::Program::removeBindAttribLocation, "Remove an attribute location binding.") .def("getAttribBindingList", &getAttribBindingList) .def("isFixedFunction", &osg::Program::isFixedFunction) .def("getGLProgramInfoLog", &getGLProgramInfoLog, "Query InfoLog from a glProgram") ; } } #if 0 /** Query InfoLog from a glProgram */ bool getGlProgramInfoLog(unsigned int contextID, std::string& log) const; typedef std::map< std::string, std::pair > NameInfoMap; const NameInfoMap& getActiveUniforms(unsigned int contextID) const; const NameInfoMap& getActiveAttribs(unsigned int contextID) const; #endif