// 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 "StateAttribute.hpp" #include "held_ptr.hpp" using namespace boost::python; namespace { osg::VertexProgram * asVertexProgram(osg::StateAttribute * self) { return dynamic_cast(self); } void glGenPrograms(osg::VertexProgram::Extensions& self, tuple prog) { GLsizei n; GLuint * programs; n = len(prog); programs = new GLuint[n]; for (int i = 0; i(prog[i]); } self.glGenPrograms(n, programs); delete[] programs; } void glDeletePrograms(osg::VertexProgram::Extensions& self, tuple prog) { GLsizei n; GLuint * programs; n = len(prog); programs = new GLuint[n]; for (int i = 0; i(prog[i]); } self.glDeletePrograms(n, programs); delete[] programs; } void glProgramLocalParameter4fv(osg::VertexProgram::Extensions& self, int index, tuple par) { GLsizei n; n = len(par); if (n != 4) { PyErr_SetString(PyExc_ValueError, "Bad element size"); throw_error_already_set(); } else { GLfloat params[4]; for (int i=0; i<4; i++) { params[i] = extract(par[i]); } self.glProgramLocalParameter4fv(n, index, params); } } void glProgramString(osg::VertexProgram::Extensions& self, unsigned int target, unsigned int format, unsigned int len, const char * string) { self.glProgramString(target, format, len, string); } } namespace PyOSG { void init_VertexProgram() { register_castStateAttribute("asVertexProgram", &asVertexProgram); class_, bases, boost::noncopyable > vertex_program("VertexProgram", no_init); scope vertex_program_scope(vertex_program); vertex_program .def(init<>()) .def("setVertexProgram", (void (osg::VertexProgram::*)( const std::string& )) &osg::VertexProgram::setVertexProgram) .def("getVertexProgram", &osg::VertexProgram::getVertexProgram, return_internal_reference<>()) .def("setProgramLocalParameter", &osg::VertexProgram::setProgramLocalParameter) .def("setMatrix", &osg::VertexProgram::setMatrix) .def("dirtyVertexProgramObject", &osg::VertexProgram::dirtyVertexProgramObject) .def("deleteVertexProgramObject", &osg::VertexProgram::deleteVertexProgramObject) .def("flushDeletedVertexProgramObjects", &osg::VertexProgram::flushDeletedVertexProgramObjects) .def("getExtensions", &osg::VertexProgram::getExtensions, return_value_policy()) .staticmethod("getExtensions") .def("setExtensions", &osg::VertexProgram::setExtensions) .staticmethod("setExtensions") ; class_, bases, boost::noncopyable > extensions("Extensions", no_init); extensions .def(init()) .def("setupGLExtenions", &osg::VertexProgram::Extensions::setupGLExtenions) .def("setVertexProgramSupported", &osg::VertexProgram::Extensions::setVertexProgramSupported) .def("isVertexProgramSupported", &osg::VertexProgram::Extensions::isVertexProgramSupported) .def("glBindProgram", &osg::VertexProgram::Extensions::glBindProgram) .def("glGenPrograms", &glGenPrograms) .def("glDeletePrograms", &glDeletePrograms) .def("glProgramString", &glProgramString) .def("glProgramLocalParameter4fv", &glProgramLocalParameter4fv) ; } }