Changeset 13041 for OpenSceneGraph/trunk/src/osg/Texture2D.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/Texture2D.cpp (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/Texture2D.cpp
r12986 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 */ … … 67 67 else 68 68 { 69 return 1; // valid lhs._image is greater than null. 69 return 1; // valid lhs._image is greater than null. 70 70 } 71 71 } 72 else if (rhs._image.valid()) 73 { 74 return -1; // valid rhs._image is greater than null. 72 else if (rhs._image.valid()) 73 { 74 return -1; // valid rhs._image is greater than null. 75 75 } 76 76 } … … 91 91 92 92 // compare each parameter in turn against the rhs. 93 #if 1 93 #if 1 94 94 if (_textureWidth != 0 && rhs._textureWidth != 0) 95 95 { … … 151 151 //state.setReportGLErrors(true); 152 152 153 // get the contextID (user defined ID of 0 upwards) for the 153 // get the contextID (user defined ID of 0 upwards) for the 154 154 // current OpenGL context. 155 155 const unsigned int contextID = state.getContextID(); … … 197 197 applyTexImage2D_subload(state,GL_TEXTURE_2D,_image.get(), 198 198 _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels); 199 199 200 200 // update the modified tag to show that it is up to date. 201 201 getModifiedCount(contextID) = _image->getModifiedCount(); 202 202 203 203 } 204 204 else if (_readPBuffer.valid()) … … 217 217 218 218 _subloadCallback->load(*this,state); 219 219 220 220 textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,_borderWidth); 221 221 … … 278 278 // perhaps it is the first glBind which is not required... 279 279 //glBindTexture( GL_TEXTURE_2D, handle ); 280 280 281 281 } 282 282 else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_internalFormat!=0) ) … … 284 284 _textureObjectBuffer[contextID] = textureObject = generateTextureObject( 285 285 this, contextID,GL_TEXTURE_2D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,_borderWidth); 286 286 287 287 textureObject->bind(); 288 288 … … 294 294 _sourceFormat ? _sourceFormat : _internalFormat, 295 295 _sourceType ? _sourceType : GL_UNSIGNED_BYTE, 296 0); 297 296 0); 297 298 298 if (_readPBuffer.valid()) 299 299 { 300 300 _readPBuffer->bindPBufferToTexture(GL_FRONT); 301 301 } 302 302 303 303 } 304 304 else … … 316 316 void Texture2D::computeInternalFormat() const 317 317 { 318 if (_image.valid()) computeInternalFormatWithImage(*_image); 318 if (_image.valid()) computeInternalFormatWithImage(*_image); 319 319 else computeInternalFormatType(); 320 320 } … … 323 323 { 324 324 const unsigned int contextID = state.getContextID(); 325 325 326 326 if (_internalFormat==0) _internalFormat=GL_RGBA; 327 327 328 328 // get the globj for the current contextID. 329 329 TextureObject* textureObject = getTextureObject(contextID); 330 330 331 331 if (textureObject) 332 332 { … … 341 341 } 342 342 // the relevent texture object is not of the right size so 343 // needs to been deleted 344 // remove previously bound textures. 343 // needs to been deleted 344 // remove previously bound textures. 345 345 dirtyTextureObject(); 346 346 // note, dirtyTextureObject() dirties all the texture objects for … … 349 349 // RO July 2001. 350 350 } 351 352 351 352 353 353 // remove any previously assigned images as these are nolonger valid. 354 354 _image = NULL; … … 356 356 // switch off mip-mapping. 357 357 // 358 358 359 359 bool needHardwareMipMap = (_min_filter != LINEAR && _min_filter != NEAREST); 360 360 bool hardwareMipMapOn = false; … … 362 362 { 363 363 hardwareMipMapOn = isHardwareMipmapGenerationEnabled(state); 364 364 365 365 if (!hardwareMipMapOn) 366 366 { … … 383 383 384 384 textureObject->bind(); 385 385 386 386 applyTexParameters(GL_TEXTURE_2D,state); 387 387 388 388 389 389 GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, hardwareMipMapOn); 390 390 … … 407 407 // get the texture object for the current contextID. 408 408 TextureObject* textureObject = getTextureObject(contextID); 409 409 410 410 if (textureObject) 411 411 { 412 412 // we have a valid image 413 413 textureObject->bind(); 414 414 415 415 applyTexParameters(GL_TEXTURE_2D,state); 416 416 … … 453 453 // get the texture object for the current contextID. 454 454 TextureObject* textureObject = getTextureObject(contextID); 455 455 456 456 if (textureObject && _textureWidth != 0 && _textureHeight != 0) 457 457 { … … 467 467 width >>= 1; 468 468 height >>= 1; 469 469 470 470 for( GLsizei k = 1; k < numMipmapLevels && (width || height); k++) 471 471 { … … 483 483 height >>= 1; 484 484 } 485 485 486 486 // inform state that this texture is the current one bound. 487 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 488 } 489 } 490 487 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 488 } 489 } 490
