Changeset 13041 for OpenSceneGraph/trunk/src/osg/TextureCubeMap.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/TextureCubeMap.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/TextureCubeMap.cpp
r11808 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 */ … … 63 63 _modifiedCount[5].setAllElementsTo(0); 64 64 65 } 65 } 66 66 67 67 … … 82 82 if (noImages && _images[n].valid()) noImages = false; 83 83 if (noImages && rhs._images[n].valid()) noImages = false; 84 84 85 85 if (_images[n]!=rhs._images[n]) // smart pointer comparison. 86 86 { … … 94 94 else 95 95 { 96 return 1; // valid lhs._image is greater than null. 96 return 1; // valid lhs._image is greater than null. 97 97 } 98 98 } 99 else if (rhs._images[n].valid()) 100 { 101 return -1; // valid rhs._image is greater than null. 99 else if (rhs._images[n].valid()) 100 { 101 return -1; // valid rhs._image is greater than null. 102 102 } 103 103 } … … 185 185 void TextureCubeMap::computeInternalFormat() const 186 186 { 187 if (imagesValid()) computeInternalFormatWithImage(*_images[0]); 187 if (imagesValid()) computeInternalFormatWithImage(*_images[0]); 188 188 else computeInternalFormatType(); 189 189 } … … 191 191 void TextureCubeMap::apply(State& state) const 192 192 { 193 // get the contextID (user defined ID of 0 upwards) for the 193 // get the contextID (user defined ID of 0 upwards) for the 194 194 // current OpenGL context. 195 195 const unsigned int contextID = state.getContextID(); … … 287 287 textureObject = generateTextureObject( 288 288 this, contextID,GL_TEXTURE_CUBE_MAP,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0); 289 289 290 290 textureObject->bind(); 291 291 … … 318 318 TextureCubeMap* non_const_this = const_cast<TextureCubeMap*>(this); 319 319 for (int n=0; n<6; n++) 320 { 320 { 321 321 if (_images[n].valid() && _images[n]->getDataVariance()==STATIC) 322 322 { … … 325 325 } 326 326 } 327 327 328 328 } 329 329 else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_internalFormat!=0) ) … … 331 331 _textureObjectBuffer[contextID] = textureObject = generateTextureObject( 332 332 this, contextID,GL_TEXTURE_CUBE_MAP,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0); 333 333 334 334 textureObject->bind(); 335 335 … … 337 337 338 338 for (int n=0; n<6; n++) 339 { 339 { 340 340 // no image present, but dimensions at set so less create the texture 341 341 glTexImage2D( faceTarget[n], 0, _internalFormat, … … 343 343 _sourceFormat ? _sourceFormat : _internalFormat, 344 344 _sourceType ? _sourceType : GL_UNSIGNED_BYTE, 345 0); 346 } 347 345 0); 346 } 347 348 348 } 349 349 else … … 380 380 // create texture object. 381 381 apply(state); 382 382 383 383 textureObject = getTextureObject(contextID); 384 384 385 385 if (!textureObject) 386 386 { … … 389 389 return; 390 390 } 391 391 392 392 } 393 393 394 394 GLenum target = faceTarget[face]; 395 395 396 396 if (textureObject) 397 397 { 398 398 // we have a valid image 399 399 textureObject->bind(); 400 400 401 401 applyTexParameters(GL_TEXTURE_CUBE_MAP, state); 402 402 … … 433 433 // get the texture object for the current contextID. 434 434 TextureObject* textureObject = getTextureObject(contextID); 435 435 436 436 if (textureObject && _textureWidth != 0 && _textureHeight != 0) 437 437 { … … 447 447 width >>= 1; 448 448 height >>= 1; 449 449 450 450 for( GLsizei k = 1; k < numMipmapLevels && (width || height); k++) 451 451 { … … 463 463 0); 464 464 } 465 465 466 466 width >>= 1; 467 467 height >>= 1; 468 468 } 469 469 470 470 // inform state that this texture is the current one bound. 471 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 471 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 472 472 } 473 473 }
