Changeset 13041 for OpenSceneGraph/trunk/include/osgText/Text
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgText/Text (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgText/Text
r12068 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 */ … … 74 74 enum BackdropImplementation 75 75 { 76 /* POLYGON_OFFSET: 77 * This uses glPolygonOffset to draw the text multiple times to 78 * create the drop-shadow and outline effects. glPolygonOffset 76 /* POLYGON_OFFSET: 77 * This uses glPolygonOffset to draw the text multiple times to 78 * create the drop-shadow and outline effects. glPolygonOffset 79 79 * is used to prevent z-fighting of the overlapping text. 80 80 * This probably should have been the best option, but all the ATI … … 83 83 * which move around depending on the viewing angle. For moving text, 84 84 * the moving holes give an extremely unpleasant flickering effect. 85 * Pumping up the "units" parameter in glPolygonOffset can minimize 85 * Pumping up the "units" parameter in glPolygonOffset can minimize 86 86 * this problem, but two other bad side-effects occur if you do this. 87 87 * First, high values will cause problems with clipping, particularly 88 88 * when there are objects behind the text. The drop-shadows or outline 89 * may be culled because their computed offset is behind the object or 89 * may be culled because their computed offset is behind the object or 90 90 * z-far plane. Second, there is an additional problem associated with 91 91 * the Z-slope. High values can make large chunks of the backdrop … … 96 96 * for the large-section clipping. 97 97 * Experimentally, we have found units values from 150-512 to be tolerable 98 * to acceptable with respect to the 'holes'. A factor of .1 seems to 98 * to acceptable with respect to the 'holes'. A factor of .1 seems to 99 99 * bring down the large clipping problem without creating a new z-fighting 100 100 * problem. 101 * (You can experiment with these numbers by playing with the 101 * (You can experiment with these numbers by playing with the 102 102 * osg:PolygonOffset multipliers which this backend tries to respect.) 103 103 * 104 * If ATI ever fixes their cards/drivers, then this might become the 104 * If ATI ever fixes their cards/drivers, then this might become the 105 105 * best option.*/ 106 106 POLYGON_OFFSET = 0, 107 107 108 108 /* NO_DEPTH_BUFFER 109 109 * Instead of using glPolygonOffset to prevent z-fighting, this mode 110 110 * just disables the depth buffer when rendering the text. This allows 111 * the text to be rendered without any z-fighting. The downside to this 112 * mode is that render order begins to matter and the text will not 113 * necessarily correctly appear above or behind other objects in the 111 * the text to be rendered without any z-fighting. The downside to this 112 * mode is that render order begins to matter and the text will not 113 * necessarily correctly appear above or behind other objects in the 114 114 * scene based on depth values. 115 * This mode is best for text that only needs to be ontop and 115 * This mode is best for text that only needs to be ontop and 116 116 * not obscured by any objects.*/ 117 117 NO_DEPTH_BUFFER, … … 121 121 * This uses glDepthRange as a substitute for glPolygonOffset. 122 122 * Strangely, experiments on ATI cards seem to produce cleaner results 123 * than when using glPolygonOffset. The trade-off for this is that the 123 * than when using glPolygonOffset. The trade-off for this is that the 124 124 * backdrop still may be placed too far back and might be culled by objects 125 125 * directly behind the object or by the far z-plane. If ATI ever fixes 126 * the glPolygonOffset problem, polygon offset is probably a slightly 127 * better solution because you can use smaller offsets. But with the 126 * the glPolygonOffset problem, polygon offset is probably a slightly 127 * better solution because you can use smaller offsets. But with the 128 128 * current ATI problem, this option may be preferable.*/ 129 129 DEPTH_RANGE, … … 131 131 * (Assuming the backend is written correctly,) the Stencil Buffer is 132 132 * the most "correct" and reliable way of producing backdrop text. 133 * The stencil buffer is a multipass system that allows writing to the 133 * The stencil buffer is a multipass system that allows writing to the 134 134 * same z-values without needing to resort to offsets. This implementation 135 135 * should not have any of the problems associated with the 3 previous 136 * implementations. But the trade-off for this mode is that without 137 * hardware acceleration for the stencil buffer, rendering will be 138 * extremely slow. (There is also potentially more overhead for this 139 * algorithm so it could be slower than the other implementations. 136 * implementations. But the trade-off for this mode is that without 137 * hardware acceleration for the stencil buffer, rendering will be 138 * extremely slow. (There is also potentially more overhead for this 139 * algorithm so it could be slower than the other implementations. 140 140 * Benchmarking would be required to determine if the speed differences 141 * are significant on your particular hardware.) This mode is best for 142 * when quality is important and stencil buffer hardware acceleration 141 * are significant on your particular hardware.) This mode is best for 142 * when quality is important and stencil buffer hardware acceleration 143 143 * is available.*/ 144 144 STENCIL_BUFFER, … … 156 156 157 157 /** 158 * BackdropType gives you a background shadow text behind your regular 159 * text. This helps give text extra contrast which can be useful when 160 * placing text against noisy backgrounds. 158 * BackdropType gives you a background shadow text behind your regular 159 * text. This helps give text extra contrast which can be useful when 160 * placing text against noisy backgrounds. 161 161 * The color of the background shadow text is specified by setBackdropColor(). 162 * DROP_SHADOW_BOTTOM_RIGHT will draw backdrop text to the right and down of 162 * DROP_SHADOW_BOTTOM_RIGHT will draw backdrop text to the right and down of 163 163 * the normal text. Other DROW_SHADOW_* modes do the same for their repective directions. 164 164 * OUTLINE will draw backdrop text so that it appears the text has an outline 165 165 * or border around the normal text. This mode is particularly useful against 166 * really noisy backgrounds that may put text on top of things that have 167 * all types of colors which you don't have control over. 168 * Some real world examples of this general technique in use that I know of 166 * really noisy backgrounds that may put text on top of things that have 167 * all types of colors which you don't have control over. 168 * Some real world examples of this general technique in use that I know of 169 169 * are Google Earth, Sid Meier's Pirates (2004 Remake), and Star Control 2 (PC 1993). 170 170 * The default is NONE. … … 174 174 BackdropType getBackdropType() const { return _backdropType; } 175 175 176 /** 177 * Sets the amount text is offset to create the backdrop/shadow effect. 176 /** 177 * Sets the amount text is offset to create the backdrop/shadow effect. 178 178 * Set the value too high and for example, in OUTLINE mode you will get a "Brady Bunch" 179 179 * effect where you see duplicates of the text in a 3x3 grid. … … 186 186 * Note that the text bounding boxes are updated to include backdrop offsets. 187 187 * However, other metric information such as getCharacterHeight() are unaffected 188 * by this. This means that individual glyph spacing (kerning?) are unchanged 188 * by this. This means that individual glyph spacing (kerning?) are unchanged 189 189 * even when this mode is used. 190 190 * The default is 0.07 (7% offset). … … 214 214 * so this function is provided to let you 'pick your poison'. Each 215 215 * implementation has trade-offs. See BackdropImplementation enum 216 * docs for details.*/ 216 * docs for details.*/ 217 217 void setBackdropImplementation(BackdropImplementation implementation); 218 218 … … 230 230 /** 231 231 * This sets different types of text coloring modes. 232 * When the coloring mode is not set to SOLID, the 232 * When the coloring mode is not set to SOLID, the 233 233 * colors specified in setColorGradientCorners() determine 234 234 * the colors for the text. … … 237 237 * were a single polygon and you had applied colors to each of the four 238 238 * corners with GL_SMOOTH enabled. In this mode, OpenGL interpolates 239 * the colors across the polygon, and this is what OVERALL tries to 240 * emulate. This can be used to give nice embellishments on things 239 * the colors across the polygon, and this is what OVERALL tries to 240 * emulate. This can be used to give nice embellishments on things 241 241 * like logos and names. 242 * PER_CHARACTER is similar to OVERALL except that it applies the 242 * PER_CHARACTER is similar to OVERALL except that it applies the 243 243 * color interpolation to the four corners of each character instead 244 244 * of across the overall text box. … … 251 251 /** 252 252 * Used only for gradient mode, let's you specify the colors of the 4 corners. 253 * If ColorGradients are off, these values are ignored (and the value from setColor() 253 * If ColorGradients are off, these values are ignored (and the value from setColor() 254 254 * is the only one that is relevant. 255 255 */ … … 262 262 263 263 264 264 265 265 /** Draw the text.*/ 266 266 virtual void drawImplementation(osg::RenderInfo& renderInfo) const; … … 341 341 } 342 342 343 const TextureGlyphQuadMap& getTextureGlyphQuadMap() const 343 const TextureGlyphQuadMap& getTextureGlyphQuadMap() const 344 344 { 345 345 return _textureGlyphQuadMap; … … 355 355 356 356 String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last); 357 357 358 358 // members which have public access. 359 359 360 360 // iternal map used for rendering. Set up by the computeGlyphRepresentation() method. 361 361 mutable TextureGlyphQuadMap _textureGlyphQuadMap; 362 362 363 363 void computeGlyphRepresentation(); 364 364 365 365 // internal caches of the positioning of the text. 366 366 367 367 bool computeAverageGlyphWidthAndHeight(float& avg_width, float& avg_height) const; 368 368 369 369 virtual void computePositions(unsigned int contextID) const; 370 370 371 371 void computeBackdropPositions(unsigned int contextID) const; 372 372 void computeBackdropBoundingBox() const; … … 386 386 void renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const; 387 387 void renderWithDelayedDepthWrites(osg::State& state, const osg::Vec4& colorMultiplier) const; 388 388 389 389 bool _enableDepthWrites; 390 390
