Changeset 13041 for OpenSceneGraph/trunk/src/osg/Texture3D.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/Texture3D.cpp (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/Texture3D.cpp
r12993 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 */ … … 73 73 else 74 74 { 75 return 1; // valid lhs._image is greater than null. 75 return 1; // valid lhs._image is greater than null. 76 76 } 77 77 } 78 else if (rhs._image.valid()) 79 { 80 return -1; // valid rhs._image is greater than null. 78 else if (rhs._image.valid()) 79 { 80 return -1; // valid rhs._image is greater than null. 81 81 } 82 82 } … … 154 154 if (height>extensions->maxTexture3DSize()) height = extensions->maxTexture3DSize(); 155 155 if (depth>extensions->maxTexture3DSize()) depth = extensions->maxTexture3DSize(); 156 156 157 157 inwidth = width; 158 158 inheight = height; 159 159 indepth = depth; 160 160 161 161 bool useHardwareMipMapGeneration = !image.isMipmap() && _useHardwareMipMapGeneration && texExtensions->isGenerateMipMapSupported(); 162 162 … … 185 185 height >>= 1; 186 186 depth >>= 1; 187 } 187 } 188 188 } 189 189 } … … 192 192 { 193 193 194 // get the contextID (user defined ID of 0 upwards) for the 194 // get the contextID (user defined ID of 0 upwards) for the 195 195 // current OpenGL context. 196 196 const unsigned int contextID = state.getContextID(); … … 201 201 202 202 const Extensions* extensions = getExtensions(contextID,true); 203 203 204 204 if (!extensions->isTexture3DSupported()) 205 205 { … … 311 311 _textureObjectBuffer[contextID] = textureObject = generateTextureObject( 312 312 this, contextID,GL_TEXTURE_3D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0); 313 313 314 314 textureObject->bind(); 315 315 … … 322 322 _sourceFormat ? _sourceFormat : _internalFormat, 323 323 _sourceType ? _sourceType : GL_UNSIGNED_BYTE, 324 0); 325 324 0); 325 326 326 if (_readPBuffer.valid()) 327 327 { 328 328 _readPBuffer->bindPBufferToTexture(GL_FRONT); 329 329 } 330 330 331 331 } 332 332 else … … 334 334 glBindTexture( GL_TEXTURE_3D, 0 ); 335 335 } 336 336 337 337 // if texture object is now valid and we have to allocate mipmap levels, then 338 338 if (textureObject != 0 && _texMipmapGenerationDirtyList[contextID]) … … 344 344 void Texture3D::computeInternalFormat() const 345 345 { 346 if (_image.valid()) computeInternalFormatWithImage(*_image); 346 if (_image.valid()) computeInternalFormatWithImage(*_image); 347 347 else computeInternalFormatType(); 348 348 } … … 354 354 return; 355 355 356 // get the contextID (user defined ID of 0 upwards) for the 356 // get the contextID (user defined ID of 0 upwards) for the 357 357 // current OpenGL context. 358 358 const unsigned int contextID = state.getContextID(); 359 const Extensions* extensions = getExtensions(contextID,true); 359 const Extensions* extensions = getExtensions(contextID,true); 360 360 const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true); 361 361 … … 371 371 //OSG_WARN<<"Warning::cannot currently use compressed format with 3D textures."<<std::endl; 372 372 //return; 373 } 374 373 } 374 375 375 //Rescale if resize hint is set or NPOT not supported or dimensions exceed max size 376 376 if( _resizeNonPowerOfTwoHint || !texExtensions->isNonPowerOfTwoTextureSupported(_min_filter) … … 390 390 { 391 391 bool hardwareMipMapOn = false; 392 if (_min_filter != LINEAR && _min_filter != NEAREST) 392 if (_min_filter != LINEAR && _min_filter != NEAREST) 393 393 { 394 394 if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE); … … 415 415 getCompressedSize(_internalFormat, inwidth, inheight, indepth, blockSize,size); 416 416 417 extensions->glCompressedTexImage3D(target, 0, _internalFormat, 418 inwidth, inheight, indepth, 417 extensions->glCompressedTexImage3D(target, 0, _internalFormat, 418 inwidth, inheight, indepth, 419 419 _borderWidth, 420 size, 420 size, 421 421 image->data()); 422 422 } … … 473 473 inheight = image->t(); 474 474 indepth = image->r(); 475 475 476 476 } 477 477 … … 510 510 // get the texture object for the current contextID. 511 511 TextureObject* textureObject = getTextureObject(contextID); 512 512 513 513 if (textureObject && _textureWidth != 0 && _textureHeight != 0 && _textureDepth != 0) 514 514 { 515 515 const Extensions* extensions = getExtensions(contextID,true); 516 516 517 517 // bind texture 518 518 textureObject->bind(); … … 528 528 height >>= 1; 529 529 depth >>= 1; 530 530 531 531 for( GLsizei k = 1; k < numMipmapLevels && (width || height || depth); k++) 532 532 { … … 547 547 depth >>= 1; 548 548 } 549 549 550 550 // inform state that this texture is the current one bound. 551 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 551 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 552 552 } 553 553 } … … 609 609 if (_isTexture3DFast) _isTexture3DSupported = true; 610 610 else _isTexture3DSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; 611 611 612 612 _maxTexture3DSize = 0; 613 613 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &_maxTexture3DSize);
