diff --git a/examples/osgshaders/GL2Scene.cpp b/examples/osgshaders/GL2Scene.cpp index 07fcf8a03..e1318f17d 100644 --- a/examples/osgshaders/GL2Scene.cpp +++ b/examples/osgshaders/GL2Scene.cpp @@ -1,4 +1,4 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield * Copyright (C) 2003-2005 3Dlabs Inc. Ltd. * * This application is open source and may be redistributed and/or modified @@ -10,8 +10,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ -/* file: examples/osgglsl/GL2Scene.cpp - * author: Mike Weiblen 2005-04-13 +/* file: examples/osgshaders/GL2Scene.cpp + * author: Mike Weiblen 2005-04-15 * * Compose a scene of several instances of a model, with a different * OpenGL Shading Language shader applied to each. @@ -292,6 +292,7 @@ GL2Scene::buildScene() { osg::StateSet* ss = ModelInstance(); osg::Program* program = new osg::Program; + program->setName( "microshader" ); _programList.push_back( program ); program->addShader( new osg::Shader( osg::Shader::VERTEX, microshaderVertSource ) ); program->addShader( new osg::Shader( osg::Shader::FRAGMENT, microshaderFragSource ) ); @@ -302,6 +303,7 @@ GL2Scene::buildScene() { osg::StateSet* ss = ModelInstance(); BlockyProgram = new osg::Program; + BlockyProgram->setName( "blocky" ); _programList.push_back( BlockyProgram ); BlockyVertObj = new osg::Shader( osg::Shader::VERTEX ); BlockyFragObj = new osg::Shader( osg::Shader::FRAGMENT ); @@ -315,6 +317,7 @@ GL2Scene::buildScene() osg::StateSet* ss = ModelInstance(); ss->setTextureAttribute(TEXUNIT_NOISE, noiseTexture); ErodedProgram = new osg::Program; + ErodedProgram->setName( "eroded" ); _programList.push_back( ErodedProgram ); ErodedVertObj = new osg::Shader( osg::Shader::VERTEX ); ErodedFragObj = new osg::Shader( osg::Shader::FRAGMENT ); @@ -333,6 +336,7 @@ GL2Scene::buildScene() ss->setTextureAttribute(TEXUNIT_NOISE, noiseTexture); ss->setTextureAttribute(TEXUNIT_SINE, sineTexture); MarbleProgram = new osg::Program; + MarbleProgram->setName( "marble" ); _programList.push_back( MarbleProgram ); MarbleVertObj = new osg::Shader( osg::Shader::VERTEX ); MarbleFragObj = new osg::Shader( osg::Shader::FRAGMENT ); @@ -340,8 +344,8 @@ GL2Scene::buildScene() MarbleProgram->addShader( MarbleVertObj ); ss->setAttributeAndModes(MarbleProgram, osg::StateAttribute::ON); - ss->addUniform( new osg::Uniform("Noise", TEXUNIT_NOISE) ); - ss->addUniform( new osg::Uniform("Sine", TEXUNIT_SINE) ); + ss->addUniform( new osg::Uniform("NoiseTex", TEXUNIT_NOISE) ); + ss->addUniform( new osg::Uniform("SineTex", TEXUNIT_SINE) ); } #ifdef INTERNAL_3DLABS //[ diff --git a/src/osg/Program.cpp b/src/osg/Program.cpp index 2dc7dc3bb..217fa1359 100644 --- a/src/osg/Program.cpp +++ b/src/osg/Program.cpp @@ -13,7 +13,7 @@ */ /* file: src/osg/Program.cpp - * author: Mike Weiblen 2005-04-06 + * author: Mike Weiblen 2005-04-15 */ #include @@ -2133,6 +2133,11 @@ void Program::PerContextProgram::linkProgram() if( ! _needsLink ) return; _needsLink = false; + osg::notify(osg::INFO) + << "Linking osg::Program \"" << _program->getName() << "\"" + << " id=" << _glProgramHandle + << std::endl; + // set any explicit vertex attribute bindings const AttribBindingList& bindlist = _program->getAttribBindingList(); for( AttribBindingList::const_iterator itr = bindlist.begin(); @@ -2155,7 +2160,7 @@ void Program::PerContextProgram::linkProgram() return; } - // build ActiveUniformList + // build _uniformLocationMap GLint numUniforms = 0; GLsizei maxLen = 0; _extensions->glGetProgramiv( _glProgramHandle, GL_ACTIVE_UNIFORMS, &numUniforms ); @@ -2176,12 +2181,18 @@ void Program::PerContextProgram::linkProgram() if( loc != -1 ) { _uniformLocationMap[name] = loc; + + osg::notify(osg::INFO) + << "\tUniform \"" << name << "\"" + << " loc="<< loc + << " type=" << Uniform::getTypename((Uniform::Type)type) + << std::endl; } } delete [] name; } - // build ActiveUniformList + // build _attribLocationMap GLint numAttrib = 0; _extensions->glGetProgramiv( _glProgramHandle, GL_ACTIVE_ATTRIBUTES, &numAttrib ); _extensions->glGetProgramiv( _glProgramHandle, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxLen ); @@ -2201,10 +2212,16 @@ void Program::PerContextProgram::linkProgram() if( loc != -1 ) { _attribLocationMap[name] = loc; + + osg::notify(osg::INFO) + << "\tAttrib \"" << name << "\"" + << " loc=" << loc + << std::endl; } } delete [] name; } + osg::notify(osg::INFO) << std::endl; } void Program::PerContextProgram::getInfoLog( std::string& infoLog ) const