// 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 { tuple getGLShaderInfoLog(osg::Shader & self, unsigned int contextID) { std::string log; bool ret = self.getGlShaderInfoLog(contextID, log); return make_tuple(ret, log); } } namespace PyOSG { void init_Shader() { class_, bases > shader("Shader", no_init); shader .def(init<>()) .def(init()) .def(init()) .def("setType", &osg::Shader::setType) .def("setShaderSource", &osg::Shader::setShaderSource, "Load the Shader's source code text from a string.") .def("readShaderFile", &osg::Shader::readShaderFile, return_value_policy(), "Read shader source from file and then constructor shader of specified type.\n" "Return the resulting Shader or 0 if no valid shader source code be read.") .staticmethod("readShaderFile") .def("loadShaderSourceFromFile", &osg::Shader::loadShaderSourceFromFile, "Load the Shader's source code text from a file.") .def("getShaderSource", &osg::Shader::getShaderSource, return_value_policy(), "Query the shader's source code text" ) .def("getType", &osg::Shader::getType, "Get the Shader type as an enum.") .def("getTypename", &osg::Shader::getTypename, "Get the Shader type as a descriptive string.") .def("dirtyShader", &osg::Shader::dirtyShader, "Mark our PCSs as needing recompilation.\n" "Also mark Programs that depend on us as needing relink") .def("compileShader", &osg::Shader::compileShader, "If needed, compile the PCS's glShader") .def("attachShader", &osg::Shader::attachShader, "For a given GL context, attach a glShader to a glProgram") .def("getGLShaderInfoLog", &getGLShaderInfoLog, "Query InfoLog from a glShader") .def("getTypeId", &osg::Shader::getTypeId) .staticmethod("getTypeId") ; enum_ type("Type"); # define OSG_ENUM(VALUE) \ (type.value(#VALUE, osg::Shader::VALUE), \ shader.def(#VALUE, object(osg::Shader::VALUE))) OSG_ENUM(VERTEX); OSG_ENUM(FRAGMENT); OSG_ENUM(UNDEFINED); } }