Hi all, The following code renders the square in red (fixed pipeline) rather green (shaders), I guess the shaders are not used.
Code: #define GLSL330(program) "#version 150\n" #program const char* vertSource = GLSL330 ( void main(void) { gl_Position = ftransform(); } ); const char* fragSource = GLSL330 ( void main(void) { gl_FragColor = vec4(0,1,0,1); } ); //////////////////////////////////////////////////////////////////////////////// osg::ref_ptr<osg::Geode> SetupNurbsSurface() { osg::ref_ptr<osg::Geode> geode = new osg::Geode(); assert(geode); osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry(); assert(geometry); osg::ref_ptr<osg::Vec3Array> vertices_osg = new osg::Vec3Array(); assert(vertices_osg); osg::ref_ptr<osg::Vec3Array> normals_osg = new osg::Vec3Array(); assert(normals_osg); osg::ref_ptr<osg::DrawElementsUInt> triangles_osg = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0); assert(triangles_osg); osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(); assert(colors); // Setup. geode->addDrawable(geometry); geometry->setVertexArray(vertices_osg); geometry->setNormalArray(normals_osg); geometry->addPrimitiveSet(triangles_osg); geometry->setColorArray(colors); // Vertices. vertices_osg->push_back(osg::Vec3(-1.0f, 0.0f, 1.0f)); vertices_osg->push_back(osg::Vec3(-1.0f, 0.0f, 2.0f)); vertices_osg->push_back(osg::Vec3(-1.0f, -1.0f, 2.0f)); vertices_osg->push_back(osg::Vec3(-1.0f, -1.0f, 1.0f)); // Triangles (primitive sets). triangles_osg->push_back(0); triangles_osg->push_back(1); triangles_osg->push_back(2); triangles_osg->push_back(0); triangles_osg->push_back(2); triangles_osg->push_back(3); // Colors. colors->setBinding(osg::Array::BIND_OVERALL); colors->push_back(osg::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)); // Normals. normals_osg->setBinding(osg::Array::BIND_PER_VERTEX); normals_osg->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); normals_osg->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); normals_osg->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); normals_osg->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); normals_osg->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); normals_osg->push_back(osg::Vec3(1.0f, 0.0f, 0.0f)); // State. osg::ref_ptr<osg::Shader> vertShader = new osg::Shader( osg::Shader::VERTEX, vertSource ); osg::ref_ptr<osg::Shader> fragShader = new osg::Shader( osg::Shader::FRAGMENT, fragSource ); osg::ref_ptr<osg::Program> program = new osg::Program; program->addShader( vertShader.get() ); program->addShader( fragShader.get() ); osg::ref_ptr<osg::StateSet> state = geode->getOrCreateStateSet(); assert(state); state->setAttributeAndModes( program.get(), osg::StateAttribute::ON ); // state->addUniform("TODO"); return geode; } Any idea of what is going on? Thanks! Regards, Antoine[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72803#72803 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org