- Timestamp:
- 10/16/09 18:26:27 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgvertexattributes/osgvertexattributes.cpp
r10641 r10642 32 32 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) 33 33 { 34 _manualVertexAliasing = false; 35 34 36 // mappings taken from http://www.opengl.org/registry/specs/NV/vertex_program.txt 35 37 _vertexAlias = AttributeAlias(0, "osg_Vertex"); … … 58 60 { 59 61 source.insert(0, declarationPrefix + alias.second + std::string(";\n")); 60 bindAttribute(program, alias);62 if (_manualVertexAliasing) bindAttribute(program, alias); 61 63 } 62 64 } … … 77 79 replace(source, "ftransform()", "gl_ModelViewProjectionMatrix * gl_Vertex"); 78 80 81 #if 1 79 82 replaceAndBindAttrib(program, source, "gl_Normal", _normalAlias, "attribute vec3 "); 80 83 replaceAndBindAttrib(program, source, "gl_Vertex", _vertexAlias, "attribute vec4 "); … … 91 94 replaceAndBindAttrib(program, source, "gl_MultiTexCoord6", _texCoordAlias[6], "attribute vec4 "); 92 95 replaceAndBindAttrib(program, source, "gl_MultiTexCoord7", _texCoordAlias[7], "attribute vec4 "); 93 94 95 #if 0 96 // replace the modelview and project matrices 97 replace(source, "gl_ModelViewMatrix", "osg_ModeViewMatrix"); 98 replace(source, "gl_ModelViewProjectionMatrix", "osg_ModelViewProjectionMatrix"); 99 replace(source, "gl_ProjectionMatrix", "osg_ProjectionMatrix"); 100 #else 96 #endif 97 98 #if 1 101 99 // replace built in uniform 102 100 replaceBuiltInUniform(source, "gl_ModelViewMatrix", "osg_ModeViewMatrix", "uniform mat4 "); … … 187 185 _visited.insert(&stateset); 188 186 187 return; 188 189 189 osg::notify(osg::NOTICE)<<"Found stateset "<<&stateset<<std::endl; 190 190 osg::Program* program = dynamic_cast<osg::Program*>(stateset.getAttribute(osg::StateAttribute::PROGRAM)); … … 204 204 geom.setUseDisplayList(false); 205 205 206 if (!_manualVertexAliasing) return; 207 206 208 osg::notify(osg::NOTICE)<<"Found geometry "<<&geom<<std::endl; 207 209 if (geom.getVertexArray()) … … 213 215 if (geom.getNormalArray()) 214 216 { 215 setVertexAttrib(geom, _normalAlias, geom.getNormalArray(), false, geom.getNormalBinding());217 setVertexAttrib(geom, _normalAlias, geom.getNormalArray(), true, geom.getNormalBinding()); 216 218 geom.setNormalArray(0); 217 219 } … … 232 234 { 233 235 // should we normalize the FogCoord array? Don't think so... 234 setVertexAttrib(geom, _fogCoordAlias, geom.getFogCoordArray(), false, geom.get SecondaryColorBinding());236 setVertexAttrib(geom, _fogCoordAlias, geom.getFogCoordArray(), false, geom.getFogCoordBinding()); 235 237 geom.setFogCoordArray(0); 236 238 } … … 272 274 Visited _visited; 273 275 276 bool _manualVertexAliasing; 274 277 AttributeAlias _vertexAlias; 275 278 AttributeAlias _normalAlias; … … 335 338 viewer.realize(); 336 339 337 // switch on the uniforms that track the modelview and projection matrices 338 osgViewer::Viewer::Windows windows; 339 viewer.getWindows(windows); 340 for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); 341 itr != windows.end(); 342 ++itr) 343 { 344 (*itr)->getState()->setUseModelViewAndProjectionUniforms(true); 340 341 if (runConvertToVertexAttributes) 342 { 343 // switch on the uniforms that track the modelview and projection matrices 344 osgViewer::Viewer::Windows windows; 345 viewer.getWindows(windows); 346 for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); 347 itr != windows.end(); 348 ++itr) 349 { 350 (*itr)->getState()->setUseModelViewAndProjectionUniforms(true); 351 (*itr)->getState()->setUseVertexAttributeAliasing(true); 352 } 345 353 } 346 354
