Changeset 13041 for OpenSceneGraph/trunk/src/osg/State.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/State.cpp (modified) (35 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/State.cpp
r12974 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 58 58 _useModelViewAndProjectionUniforms = true; 59 59 _useVertexAttributeAliasing = true; 60 #else 60 #else 61 61 _useModelViewAndProjectionUniforms = false; 62 62 _useVertexAttributeAliasing = false; 63 63 #endif 64 64 65 65 _modelViewMatrixUniform = new Uniform(Uniform::FLOAT_MAT4,"osg_ModelViewMatrix"); 66 66 _projectionMatrixUniform = new Uniform(Uniform::FLOAT_MAT4,"osg_ProjectionMatrix"); … … 110 110 } 111 111 112 _abortRenderingPtr = NULL; 112 _abortRenderingPtr = NULL; 113 113 114 114 _checkGLErrors = ONCE_PER_FRAME; … … 135 135 _isVertexBufferObjectSupportResolved = false; 136 136 _isVertexBufferObjectSupported = false; 137 137 138 138 _lastAppliedProgramObject = 0; 139 139 … … 187 187 const Program::PerContextProgram* ppcp = reinterpret_cast<const Program::PerContextProgram*>(object); 188 188 AppliedProgramObjectSet::iterator itr = _appliedProgramObjectSet.find(ppcp); 189 if (itr != _appliedProgramObjectSet.end()) 189 if (itr != _appliedProgramObjectSet.end()) 190 190 { 191 191 // OSG_NOTICE<<"Removing _appliedProgramObjectSet entry "<<ppcp<<std::endl; … … 206 206 ms.last_applied_value = !ms.global_default_value; 207 207 ms.changed = true; 208 } 208 } 209 209 #else 210 210 _modeMap.clear(); … … 213 213 _modeMap[GL_DEPTH_TEST].global_default_value = true; 214 214 _modeMap[GL_DEPTH_TEST].changed = true; 215 215 216 216 // go through all active StateAttribute's, setting to change to force update, 217 217 // the idea is to leave only the global defaults left. … … 226 226 as.changed = true; 227 227 } 228 228 229 229 // we can do a straight clear, we arn't interested in GL_DEPTH_TEST defaults in texture modes. 230 230 for(TextureModeMapList::iterator tmmItr=_textureModeMapList.begin(); … … 255 255 256 256 _stateStateStack.clear(); 257 257 258 258 _modelView = _identity; 259 259 _projection = _identity; 260 260 261 261 dirtyAllVertexArrays(); 262 262 263 263 #if 0 264 264 // reset active texture unit values and call OpenGL 265 265 // note, this OpenGL op precludes the use of State::reset() without a 266 // valid graphics context, therefore the new implementation below 266 // valid graphics context, therefore the new implementation below 267 267 // is preferred. 268 268 setActiveTextureUnit(0); … … 285 285 (*apitr)->removeObserver(this); 286 286 } 287 287 288 288 _appliedProgramObjectSet.clear(); 289 290 289 290 291 291 // what about uniforms??? need to clear them too... 292 292 // go through all active Unfirom's, setting to change to force update, … … 333 333 pushModeList(_modeMap,dstate->getModeList()); 334 334 335 // iterator through texture modes. 335 // iterator through texture modes. 336 336 unsigned int unit; 337 337 const StateSet::TextureModeList& ds_textureModeList = dstate->getTextureModeList(); … … 361 361 362 362 while (!_stateStateStack.empty()) popStateSet(); 363 363 364 364 applyProjectionMatrix(0); 365 365 applyModelViewMatrix(0); 366 366 367 367 _lastAppliedProgramObject = 0; 368 368 } … … 373 373 374 374 if (_stateStateStack.empty()) return; 375 376 375 376 377 377 const StateSet* dstate = _stateStateStack.back(); 378 378 … … 382 382 popModeList(_modeMap,dstate->getModeList()); 383 383 384 // iterator through texture modes. 384 // iterator through texture modes. 385 385 unsigned int unit; 386 386 const StateSet::TextureModeList& ds_textureModeList = dstate->getTextureModeList(); … … 402 402 403 403 } 404 404 405 405 // remove the top draw state from the stack. 406 406 _stateStateStack.pop_back(); … … 410 410 { 411 411 StateSetStack tempStack; 412 412 413 413 // first pop the StateSet above the position we need to insert at 414 414 while (_stateStateStack.size()>pos) … … 420 420 // push our new stateset 421 421 pushStateSet(dstate); 422 422 423 423 // push back the original ones 424 424 for(StateSetStack::reverse_iterator itr = tempStack.rbegin(); … … 438 438 return; 439 439 } 440 440 441 441 // record the StateSet above the one we intend to remove 442 442 StateSetStack tempStack; … … 447 447 } 448 448 449 // remove the intended StateSet as well 449 // remove the intended StateSet as well 450 450 popStateSet(); 451 451 … … 463 463 // empty the stateset first. 464 464 stateset.clear(); 465 465 466 466 for(ModeMap::const_iterator mitr=_modeMap.begin(); 467 467 mitr!=_modeMap.end(); … … 474 474 stateset.setMode(mitr->first,ms.valueVec.back()); 475 475 } 476 } 476 } 477 477 478 478 for(AttributeMap::const_iterator aitr=_attributeMap.begin(); … … 485 485 stateset.setAttribute(const_cast<StateAttribute*>(as.attributeVec.back().first)); 486 486 } 487 } 487 } 488 488 489 489 } … … 571 571 // go through all active StateAttribute's, applying where appropriate. 572 572 applyAttributeMap(_attributeMap); 573 573 574 574 unsigned int unit; 575 575 unsigned int unitMax = maximum(_textureModeMapList.size(),_textureAttributeMapList.size()); … … 702 702 703 703 // will need to disable this mode on next apply so set it to changed. 704 ms.changed = true; 704 ms.changed = true; 705 705 } 706 706 … … 715 715 716 716 // will need to disable this mode on next apply so set it to changed. 717 ms.changed = true; 717 ms.changed = true; 718 718 } 719 719 … … 734 734 void State::haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member) 735 735 { 736 736 737 737 AttributeMap::iterator itr = attributeMap.find(StateAttribute::TypeMemberPair(type,member)); 738 738 if (itr!=attributeMap.end()) … … 782 782 ModeStack& ms = mitr->second; 783 783 ms.last_applied_value = !ms.last_applied_value; 784 ms.changed = true; 785 786 } 784 ms.changed = true; 785 786 } 787 787 788 788 for(TextureModeMapList::iterator tmmItr=_textureModeMapList.begin(); … … 796 796 ModeStack& ms = mitr->second; 797 797 ms.last_applied_value = !ms.last_applied_value; 798 ms.changed = true; 799 800 } 798 ms.changed = true; 799 800 } 801 801 } 802 802 } … … 812 812 as.changed = true; 813 813 } 814 814 815 815 816 816 for(TextureAttributeMapList::iterator tamItr=_textureAttributeMapList.begin(); … … 1032 1032 * note, only updates values that change.*/ 1033 1033 void State::setVertexAttribPointer( unsigned int index, 1034 GLint size, GLenum type, GLboolean normalized, 1034 GLint size, GLenum type, GLboolean normalized, 1035 1035 GLsizei stride, const GLvoid *ptr ) 1036 1036 { … … 1058 1058 eap._dirty = false; 1059 1059 } 1060 } 1060 } 1061 1061 1062 1062 /** wrapper around DisableVertexAttribArrayARB(index); … … 1077 1077 } 1078 1078 } 1079 } 1079 } 1080 1080 1081 1081 void State::disableVertexAttribPointersAboveAndIncluding( unsigned int index ) … … 1288 1288 1289 1289 OSG_INFO<<"++Before Converted source "<<std::endl<<source<<std::endl<<"++++++++"<<std::endl; 1290 1290 1291 1291 // replace ftransform as it only works with built-ins 1292 1292 State_Utils::replace(source, "ftransform()", "gl_ModelViewProjectionMatrix * gl_Vertex"); … … 1426 1426 { 1427 1427 // OSG_NOTICE<<"State::drawQuads("<<first<<", "<<count<<")"<<std::endl; 1428 1428 1429 1429 unsigned int array = first % 4; 1430 1430 unsigned int offsetFirst = ((first-array) / 4) * 6; … … 1432 1432 unsigned int numIndices = numQuads * 6; 1433 1433 unsigned int endOfIndices = offsetFirst+numIndices; 1434 1434 1435 1435 if (endOfIndices<65536) 1436 1436 {
