Changeset 13041 for OpenSceneGraph/trunk/src/osgText/Glyph.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgText/Glyph.cpp (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgText/Glyph.cpp
r13004 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 */ … … 40 40 } 41 41 42 GlyphTexture::~GlyphTexture() 42 GlyphTexture::~GlyphTexture() 43 43 { 44 44 } … … 57 57 int maxAxis = std::max(glyph->s(), glyph->t()); 58 58 int margin = _margin + (int)((float)maxAxis * _marginRatio); 59 59 60 60 int width = glyph->s()+2*margin; 61 61 int height = glyph->t()+2*margin; … … 69 69 // record the position in which the texture will be stored. 70 70 posX = _partUsedX+margin; 71 posY = _usedY+margin; 71 posY = _usedY+margin; 72 72 73 73 // move used markers on. … … 77 77 return true; 78 78 } 79 79 80 80 // start an new row. 81 81 if (width <= getTextureWidth() && … … 87 87 88 88 posX = _partUsedX+margin; 89 posY = _usedY+margin; 89 posY = _usedY+margin; 90 90 91 91 // move used markers on. … … 122 122 void GlyphTexture::apply(osg::State& state) const 123 123 { 124 // get the contextID (user defined ID of 0 upwards) for the 124 // get the contextID (user defined ID of 0 upwards) for the 125 125 // current OpenGL context. 126 126 const unsigned int contextID = state.getContextID(); … … 153 153 // get the texture object for the current contextID. 154 154 TextureObject* textureObject = getTextureObject(contextID); 155 155 156 156 bool newTextureObject = (textureObject == 0); 157 157 … … 184 184 return; 185 185 } 186 186 187 187 // being bound for the first time, need to allocate the texture 188 188 … … 194 194 195 195 applyTexParameters(GL_TEXTURE_2D,state); 196 196 197 197 // need to look at generate mip map extension if mip mapping required. 198 198 switch(_min_filter) … … 214 214 break; 215 215 } 216 216 217 217 unsigned int imageDataSize = getTextureHeight()*getTextureWidth(); 218 218 unsigned char* imageData = new unsigned char[imageDataSize]; … … 221 221 imageData[i] = 0; 222 222 } 223 223 224 224 225 225 // allocate the texture memory. … … 229 229 GL_UNSIGNED_BYTE, 230 230 imageData ); 231 231 232 232 delete [] imageData; 233 233 234 234 } 235 235 else … … 237 237 // reuse texture by binding. 238 238 textureObject->bind(); 239 239 240 240 if (getTextureParameterDirty(contextID)) 241 241 { … … 245 245 246 246 } 247 247 248 248 static const GLubyte* s_renderer = 0; 249 249 static bool s_subloadAllGlyphsTogether = false; … … 260 260 s_subloadAllGlyphsTogether = true; 261 261 } 262 263 if (s_renderer && 264 ((strstr((const char*)s_renderer,"Radeon")!=0) || 262 263 if (s_renderer && 264 ((strstr((const char*)s_renderer,"Radeon")!=0) || 265 265 (strstr((const char*)s_renderer,"RADEON")!=0) || 266 266 (strstr((const char*)s_renderer,"ALL-IN-WONDER")!=0))) … … 311 311 } 312 312 else // just subload the new entries. 313 { 313 { 314 314 // default way of subloading as required. 315 315 //std::cout<<"subloading"<<std::endl; … … 321 321 } 322 322 } 323 323 324 324 // clear the list since we have now subloaded them. 325 325 glyphsWereSubloading.clear(); 326 326 327 327 } 328 328 else … … 353 353 { 354 354 int sindex = (t*(*itr)->s()+s); 355 int dindex = 355 int dindex = 356 356 ((((*itr)->getTexturePositionY()+t) * getTextureWidth()) + 357 357 ((*itr)->getTexturePositionX()+s)); … … 369 369 370 370 // Subload the image once 371 glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 371 glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 372 372 getTextureWidth(), 373 373 getTextureHeight(), … … 408 408 unsigned int initialSize = _glyphsToSubload.size(); 409 409 _glyphsToSubload.resize(maxSize); 410 410 411 411 for(unsigned i=initialSize; i<_glyphsToSubload.size(); ++i) 412 412 { … … 503 503 504 504 glPixelStorei(GL_UNPACK_ALIGNMENT,getPacking()); 505 505 506 506 #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) 507 507 glPixelStorei(GL_UNPACK_ROW_LENGTH,getRowLength()); … … 514 514 (GLenum)getDataType(), 515 515 data()); 516 516 517 517 errorNo = glGetError(); 518 518 if (errorNo!=GL_NO_ERROR) … … 530 530 "\t 0x"<<(GLenum)getDataType()<<std::endl<< 531 531 "\t 0x"<<(unsigned long)data()<<");"<<dec<<std::endl; 532 } 532 } 533 533 } 534 534
