Hi, I ported my program from mingw and Code Blocks to Visual Studio 2010 Express and found that I couldn't get uniform arrays to work. Has anyone experienced this? I'm new to Visual Studio so I might have missed something.
I made a small test program that works on my old system but not on my new system: (sorry for the weird symbols and that the include dirs fell off) Code: #include <osg/Group> #include <osgDB/ReadFile> #include <osgViewer/Viewer> #include <osgGA/TrackballManipulator> int main( int argc, char **argv ) { osg::setNotifyLevel( osg::WARN ); osg::Group *root = new osg::Group; std::string url = "cow.osg"; osg::Node* modelNode = osgDB::readNodeFile( url ); //setup shaders osg::Shader *vertshader = new osg::Shader( osg::Shader::VERTEX ); vertshader->loadShaderSourceFromFile( "uniformarray.vert" ); osg::Shader *fragshader = new osg::Shader( osg::Shader::FRAGMENT ); fragshader->loadShaderSourceFromFile( "uniformarray.frag" ); osg::Program *shaderprog = new osg::Program(); shaderprog->addShader( vertshader ); shaderprog->addShader( fragshader ); modelNode->getOrCreateStateSet()->setAttributeAndModes( shaderprog ); // Array uniform osg::Uniform *arrayUFM = new osg::Uniform( osg::Uniform::FLOAT, "array", 2 ); arrayUFM->setElement( 0, 0.5f ); arrayUFM->setElement( 1, 1.0f ); modelNode->getOrCreateStateSet()->addUniform( arrayUFM ); root->addChild( modelNode ); // Graphics Context and Traits osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; traits->x = 10; traits->y = 10; traits->width = 800; traits->height = 600; traits->doubleBuffer = true; const std::string version( "3.1" ); traits->glContextVersion = version; osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext( traits.get() ); // Viewer osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(); viewer->getCamera()->setGraphicsContext( gc.get() ); viewer->getCamera()->setViewport( new osg::Viewport( 0, 0, traits->width, traits->height ) ); viewer->setSceneData( root ); viewer->setCameraManipulator( new osgGA::TrackballManipulator() ); viewer->run(); return 0; } Vertex shader: Code: #version 140 uniform mat4 osg_ModelViewProjectionMatrix; in vec4 osg_Vertex; void main() { gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; }; Fragment shader using the array: Code: #version 140 uniform float array[2]; out vec4 fragData; void main() { fragData = vec4( 1.0, array[0], array[1], 1.0 ); } Old system: OSG 3.0 (revision 12753) MinGW and Code Blocks NVIDIA GEFORCE 260 WIN 7 New system OSG 3.0.1 (stable release) Visual C++ 2010 Express NVIDIA GEFORCE 680 WIN 7 Thank you! Cheers, David[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50756#50756 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org