Changeset 13041 for OpenSceneGraph/trunk/src/osg/Texture1D.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/Texture1D.cpp (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/Texture1D.cpp
r12912 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 else 64 64 { 65 return 1; // valid lhs._image is greater than null. 65 return 1; // valid lhs._image is greater than null. 66 66 } 67 67 } 68 else if (rhs._image.valid()) 69 { 70 return -1; // valid rhs._image is greater than null. 68 else if (rhs._image.valid()) 69 { 70 return -1; // valid rhs._image is greater than null. 71 71 } 72 72 } … … 108 108 _image = image; 109 109 _modifiedCount.setAllElementsTo(0); 110 110 111 111 if (_image.valid() && _image->requiresUpdateCall()) 112 112 { … … 120 120 { 121 121 #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) 122 // get the contextID (user defined ID of 0 upwards) for the 122 // get the contextID (user defined ID of 0 upwards) for the 123 123 // current OpenGL context. 124 124 const unsigned int contextID = state.getContextID(); … … 172 172 { 173 173 174 // we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object. 174 // we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object. 175 175 _textureObjectBuffer[contextID] = textureObject = generateTextureObject(this, contextID, GL_TEXTURE_1D); 176 176 … … 193 193 { 194 194 195 // we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object. 195 // we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object. 196 196 textureObject = generateTextureObject(this, contextID,GL_TEXTURE_1D); 197 197 … … 206 206 // update the modified count to show that it is upto date. 207 207 getModifiedCount(contextID) = _image->getModifiedCount(); 208 208 209 209 _textureObjectBuffer[contextID] = textureObject; 210 210 211 211 // unref image data? 212 212 if (isSafeToUnrefImageData(state) && _image->getDataVariance()==STATIC) … … 215 215 non_const_this->_image = NULL; 216 216 } 217 217 218 218 } 219 219 else if ( (_textureWidth!=0) && (_internalFormat!=0) ) … … 221 221 _textureObjectBuffer[contextID] = textureObject = generateTextureObject( 222 222 this,contextID,GL_TEXTURE_1D,_numMipmapLevels,_internalFormat,_textureWidth,1,1,0); 223 223 224 224 textureObject->bind(); 225 225 … … 231 231 _sourceFormat ? _sourceFormat : _internalFormat, 232 232 _sourceType ? _sourceType : GL_UNSIGNED_BYTE, 233 0); 234 233 0); 234 235 235 if (_readPBuffer.valid()) 236 236 { … … 256 256 void Texture1D::computeInternalFormat() const 257 257 { 258 if (_image.valid()) computeInternalFormatWithImage(*_image); 258 if (_image.valid()) computeInternalFormatWithImage(*_image); 259 259 else computeInternalFormatType(); 260 260 } … … 267 267 return; 268 268 269 // get the contextID (user defined ID of 0 upwards) for the 269 // get the contextID (user defined ID of 0 upwards) for the 270 270 // current OpenGL context. 271 271 const unsigned int contextID = state.getContextID(); … … 278 278 // select the internalFormat required for the texture. 279 279 bool compressed = isCompressedInternalFormat(_internalFormat); 280 280 281 281 //Rescale if resize hint is set or NPOT not supported or dimension exceeds max size 282 282 if( _resizeNonPowerOfTwoHint || !extensions->isNonPowerOfTwoTextureSupported(_min_filter) || inwidth > extensions->maxTextureSize() ) … … 289 289 glPixelStorei(GL_UNPACK_ROW_LENGTH,image->getRowLength()); 290 290 291 static MyCompressedTexImage1DArbProc glCompressedTexImage1D_ptr = 291 static MyCompressedTexImage1DArbProc glCompressedTexImage1D_ptr = 292 292 convertPointerType<MyCompressedTexImage1DArbProc, void*>(getGLExtensionFuncPtr("glCompressedTexImage1DARB")); 293 293 … … 307 307 { 308 308 numMipmapLevels = 1; 309 GLint blockSize = ( _internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? 8 : 16 ); 309 GLint blockSize = ( _internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? 8 : 16 ); 310 310 GLint size = ((image->s()+3)/4)*((image->t()+3)/4)*blockSize; 311 glCompressedTexImage1D_ptr(target, 0, _internalFormat, 312 image->s(), _borderWidth, 313 size, 314 image->data()); 311 glCompressedTexImage1D_ptr(target, 0, _internalFormat, 312 image->s(), _borderWidth, 313 size, 314 image->data()); 315 315 316 316 } … … 352 352 else if(glCompressedTexImage1D_ptr) 353 353 { 354 GLint blockSize = ( _internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? 8 : 16 ); 355 GLint size = 0; 354 GLint blockSize = ( _internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? 8 : 16 ); 355 GLint size = 0; 356 356 for( GLsizei k = 0 ; k < numMipmapLevels && width ;k++) 357 357 { 358 358 359 359 size = ((width+3)/4)*blockSize; 360 glCompressedTexImage1D_ptr(target, k, _internalFormat, 361 width, _borderWidth, size, image->getMipmapData(k)); 360 glCompressedTexImage1D_ptr(target, k, _internalFormat, 361 width, _borderWidth, size, image->getMipmapData(k)); 362 362 363 363 width >>= 1; … … 394 394 } 395 395 // the relevent texture object is not of the right size so 396 // needs to been deleted 397 // remove previously bound textures. 396 // needs to been deleted 397 // remove previously bound textures. 398 398 dirtyTextureObject(); 399 399 // note, dirtyTextureObject() dirties all the texture objects for … … 402 402 // RO July 2001. 403 403 } 404 405 404 405 406 406 // remove any previously assigned images as these are nolonger valid. 407 407 _image = NULL; … … 421 421 _textureWidth = width; 422 422 _numMipmapLevels = 1; 423 423 424 424 textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,1,1,0); 425 425 … … 470 470 // get the texture object for the current contextID. 471 471 TextureObject* textureObject = getTextureObject(contextID); 472 472 473 473 if (textureObject && _textureWidth != 0) 474 474 { … … 482 482 // we do not reallocate the level 0, since it was already allocated 483 483 width >>= 1; 484 484 485 485 for( GLsizei k = 1; k < numMipmapLevels && width; k++) 486 486 { … … 495 495 width >>= 1; 496 496 } 497 497 498 498 // inform state that this texture is the current one bound. 499 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 499 state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this); 500 500 } 501 501 #else
