<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: csplugincommon/opengl/glfontcache.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>csplugincommon/opengl/glfontcache.h</h1><a href="glfontcache_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (C) 2003 by Jorrit Tyberghein</span> <a name="l00003"></a>00003 <span class="comment"> (C) 2003 by Frank Richter</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00006"></a>00006 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00007"></a>00007 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00008"></a>00008 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00009"></a>00009 <span class="comment"></span> <a name="l00010"></a>00010 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00011"></a>00011 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00012"></a>00012 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00013"></a>00013 <span class="comment"> Library General Public License for more details.</span> <a name="l00014"></a>00014 <span class="comment"></span> <a name="l00015"></a>00015 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00016"></a>00016 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00017"></a>00017 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00018"></a>00018 <span class="comment">*/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef __CS_CANVAS_OPENGLCOMMON_GLFONTCACHE_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __CS_CANVAS_OPENGLCOMMON_GLFONTCACHE_H__</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00027"></a>00027 <span class="preprocessor">#include "csextern_gl.h"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="subrec_8h.html" title="Stuff small rectangles into a bigger one.">csgeom/subrec.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="vector2_8h.html" title="2D vector.">csgeom/vector2.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="dirtyaccessarray_8h.html" title="Templated array class, allowing direct access to the internally stored array.">csutil/dirtyaccessarray.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="refarr_8h.html" title="Smart Pointer array.">csutil/refarr.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="fontcache_8h.html" title="Font glyph cache base.">csplugincommon/canvas/fontcache.h</a>"</span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="keyword">class </span><a class="code" href="classcsGLStateCache.html" title="OpenGL state cache.">csGLStateCache</a>; <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="keyword">class </span><a class="code" href="classcsGraphics2DGLCommon.html" title="Basic OpenGL version of the 2D driver class.">csGraphics2DGLCommon</a>; <a name="l00037"></a>00037 <a name="l00044"></a><a class="code" href="classcsGLFontCache.html">00044</a> <span class="keyword">class </span>CS_CSPLUGINCOMMON_GL_EXPORT <a class="code" href="classcsGLFontCache.html" title="OpenGL font cache.">csGLFontCache</a> : <span class="keyword">public</span> <a class="code" href="classcsFontCache.html" title="A cache for font glyphs.">csFontCache</a> <a name="l00045"></a>00045 { <a name="l00046"></a>00046 <span class="keyword">struct </span>GLGlyphCacheData : <span class="keyword">public</span> <a class="code" href="classcsFontCache.html" title="A cache for font glyphs.">csFontCache</a>::GlyphCacheData <a name="l00047"></a>00047 { <a name="l00048"></a>00048 <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">CS::SubRectangles::SubRect</a>* subrect; <a name="l00049"></a>00049 <span class="keywordtype">float</span> tx1, ty1, tx2, ty2; <a name="l00050"></a>00050 <span class="keywordtype">size_t</span> texNum; <a name="l00051"></a>00051 <a class="code" href="structcsBitmapMetrics.html" title="Metrics for a glyph that are dependent from whether a simple or antialiased image...">csBitmapMetrics</a> bmetrics; <a name="l00052"></a>00052 }; <a name="l00053"></a>00053 <a name="l00054"></a>00054 <a class="code" href="classcsGraphics2DGLCommon.html" title="Basic OpenGL version of the 2D driver class.">csGraphics2DGLCommon</a>* G2D; <a name="l00055"></a>00055 <a class="code" href="classcsGLStateCache.html" title="OpenGL state cache.">csGLStateCache</a>* statecache; <a name="l00056"></a>00056 <a name="l00057"></a>00057 <span class="keywordtype">int</span> texSize; <a name="l00058"></a>00058 <span class="keywordtype">size_t</span> maxTxts; <a name="l00059"></a>00059 <span class="keywordtype">size_t</span> usedTexs; <a name="l00060"></a>00060 <span class="keywordtype">int</span> glyphAlign; <a name="l00061"></a>00061 <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> texWhite; <a name="l00062"></a>00062 <span class="comment">/* There are currently 3 ways to draw text:</span> <a name="l00063"></a>00063 <span class="comment"> 1) Using a special multitexture setup that blends the FG and BG color.</span> <a name="l00064"></a>00064 <span class="comment"> Preferred, as we save the texture environment switch.</span> <a name="l00065"></a>00065 <span class="comment"> Obviously requires MT.</span> <a name="l00066"></a>00066 <span class="comment"> 2) Using ARB_fragment_program.</span> <a name="l00067"></a>00067 <span class="comment"> This is a workaround for a bug in some ATI drivers that seem to garble</span> <a name="l00068"></a>00068 <span class="comment"> text drawing under certain circumstances, which is avoided by using an</span> <a name="l00069"></a>00069 <span class="comment"> AFP instead of a multitexturing setup.</span> <a name="l00070"></a>00070 <span class="comment"> 3) Using "Blend" environment which has the same effect as (1).</span> <a name="l00071"></a>00071 <span class="comment"> Not all HW properly supports this.</span> <a name="l00072"></a>00072 <span class="comment"> 4) Most ugly: separate passes for FG and BG - needs two textures (one </span> <a name="l00073"></a>00073 <span class="comment"> with background, one with foreground transparency), and doesn't always </span> <a name="l00074"></a>00074 <span class="comment"> look right with AA! (We ignore that until someone complains.)</span> <a name="l00075"></a>00075 <span class="comment"> */</span> <a name="l00076"></a>00076 <span class="comment">// Whether to use method 1.</span> <a name="l00077"></a>00077 <span class="keywordtype">bool</span> multiTexText; <a name="l00078"></a>00078 <span class="comment">// Whether to use method 2.</span> <a name="l00079"></a>00079 <span class="keywordtype">bool</span> afpText; <a name="l00080"></a>00080 <span class="comment">// Whether to use method 3.</span> <a name="l00081"></a>00081 <span class="keywordtype">bool</span> intensityBlendText; <a name="l00082"></a>00082 <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> textProgram; <a name="l00083"></a>00083 <a name="l00084"></a>00084 <span class="keyword">struct </span>CacheTexture <a name="l00085"></a>00085 { <a name="l00086"></a>00086 <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> handle; <a name="l00087"></a>00087 <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> mirrorHandle; <a name="l00088"></a>00088 <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">CS::SubRectangles</a>* glyphRects; <a name="l00089"></a>00089 <a name="l00090"></a>00090 CacheTexture () <a name="l00091"></a>00091 { <a name="l00092"></a>00092 glyphRects = 0; <a name="l00093"></a>00093 } <a name="l00094"></a>00094 ~CacheTexture () <a name="l00095"></a>00095 { <a name="l00096"></a>00096 <span class="keyword">delete</span> glyphRects; <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <span class="keywordtype">void</span> InitRects (<span class="keywordtype">int</span> size) <a name="l00099"></a>00099 { <a name="l00100"></a>00100 glyphRects = <span class="keyword">new</span> <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">CS::SubRectangles</a> (<a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> (0, 0, size, size)); <a name="l00101"></a>00101 } <a name="l00102"></a>00102 }; <a name="l00103"></a>00103 <a class="code" href="classcsArray.html" title="A templated array class.">csArray<CacheTexture></a> textures; <a name="l00104"></a>00104 <a class="code" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">csBlockAllocator<GLGlyphCacheData></a> cacheDataAlloc; <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="keyword">struct </span>TextJob <a name="l00107"></a>00107 { <a name="l00108"></a>00108 <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> texture; <a name="l00109"></a>00109 <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> mirrorTexture; <a name="l00110"></a>00110 <span class="keywordtype">int</span> fg, bg; <a name="l00111"></a>00111 <span class="keywordtype">size_t</span> vertOffset, vertCount, bgVertOffset, bgVertCount; <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="keywordtype">void</span> ClearRanges() <a name="l00114"></a>00114 { <a name="l00115"></a>00115 vertOffset = vertCount = bgVertOffset = bgVertCount = 0; <a name="l00116"></a>00116 } <a name="l00117"></a>00117 }; <a name="l00118"></a>00118 <a class="code" href="classcsArray.html" title="A templated array class.">csArray<TextJob></a> jobs; <a name="l00119"></a>00119 <span class="keywordtype">size_t</span> jobCount; <a name="l00120"></a>00120 <span class="keywordtype">bool</span> textWriting; <a name="l00121"></a>00121 <span class="keywordtype">bool</span> needStates; <a name="l00122"></a>00122 <span class="keywordtype">int</span> envColor; <a name="l00123"></a>00123 <span class="keywordtype">size_t</span> numFloats; <a name="l00124"></a>00124 <span class="keywordtype">size_t</span> maxFloats; <a name="l00125"></a>00125 <span class="keywordtype">bool</span> tcaEnabled, vaEnabled, caEnabled; <a name="l00126"></a>00126 <a class="code" href="classcsDirtyAccessArray.html" title="A templated array class.">csDirtyAccessArray<float></a> verts2d; <a name="l00127"></a>00127 <a class="code" href="classcsDirtyAccessArray.html" title="A templated array class.">csDirtyAccessArray<float></a> texcoords; <a name="l00128"></a>00128 <a name="l00129"></a>00129 TextJob& GetJob (<span class="keywordtype">int</span> fg, <span class="keywordtype">int</span> bg, <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> texture, <a class="code" href="glextmanager_8h.html#782e952cf00e0d28f426254d7b09d8c8">GLuint</a> mirrorTexture, <a name="l00130"></a>00130 <span class="keywordtype">size_t</span> bgOffset); <a name="l00131"></a>00131 <a name="l00132"></a>00132 <span class="keyword">inline</span> <span class="keywordtype">void</span> FlushArrays (); <a name="l00133"></a>00133 <span class="keywordtype">void</span> BeginText (); <a name="l00134"></a>00134 <span class="keyword">protected</span>: <a name="l00135"></a>00135 <span class="keywordtype">void</span> Report (<span class="keywordtype">int</span> severity, <span class="keyword">const</span> <span class="keywordtype">char</span>* msg, ...); <a name="l00136"></a>00136 <a name="l00137"></a>00137 <span class="keyword">virtual</span> GlyphCacheData* <a class="code" href="classcsFontCache.html#a75e7bb25e36e13bdef089d397c54e02" title="Cache canvas-dependent information for a specific font/glyph pair.">InternalCacheGlyph</a> (KnownFont* font, <a name="l00138"></a>00138 <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> glyph, <a class="code" href="group__util.html#g91ad9478d81a7aaf2593e8d9c3d06a14" title="Shortcut for default unsigned int.">uint</a> flags); <a name="l00139"></a>00139 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcsFontCache.html#cbe7b5c1ac104b682bad13734fbad1ab" title="Uncache canvas-dependent information.">InternalUncacheGlyph</a> (GlyphCacheData* cacheData); <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="keywordtype">void</span> CopyGlyphData (<a class="code" href="structiFont.html" title="A font object.">iFont</a>* font, <a class="code" href="group__util.html#g47e911f87ff568b2779f26cf226f5070" title="A single char in a UTF32 encoded string.">utf32_char</a> glyph, <span class="keywordtype">size_t</span> tex, <a name="l00142"></a>00142 <span class="keyword">const</span> <a class="code" href="structcsBitmapMetrics.html" title="Metrics for a glyph that are dependent from whether a simple or antialiased image...">csBitmapMetrics</a>& bmetrics, <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& texRect, <a name="l00143"></a>00143 <a class="code" href="structiDataBuffer.html" title="The iDataBuffer interface can be used to exchange buffers with abstract data between...">iDataBuffer</a>* bitmapDataBuf, <a class="code" href="structiDataBuffer.html" title="The iDataBuffer interface can be used to exchange buffers with abstract data between...">iDataBuffer</a>* alphaDataBuf); <a name="l00144"></a>00144 <span class="keyword">public</span>: <a name="l00145"></a>00145 <a class="code" href="classcsGLFontCache.html" title="OpenGL font cache.">csGLFontCache</a> (<a class="code" href="classcsGraphics2DGLCommon.html" title="Basic OpenGL version of the 2D driver class.">csGraphics2DGLCommon</a>* G2D); <a name="l00146"></a>00146 <span class="keyword">virtual</span> ~<a class="code" href="classcsGLFontCache.html" title="OpenGL font cache.">csGLFontCache</a> (); <a name="l00147"></a>00147 <a name="l00149"></a>00149 <span class="keywordtype">void</span> Setup(); <a name="l00150"></a>00150 <a name="l00154"></a>00154 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcsFontCache.html#4f8e363dca268664dab4c7e9df4a851f" title="Draw a string.">WriteString</a> (<a class="code" href="structiFont.html" title="A font object.">iFont</a> *font, <span class="keywordtype">int</span> pen_x, <span class="keywordtype">int</span> pen_y, <a name="l00155"></a>00155 <span class="keywordtype">int</span> fg, <span class="keywordtype">int</span> bg, <span class="keyword">const</span> <span class="keywordtype">void</span>* text, <span class="keywordtype">bool</span> isWide, <a class="code" href="group__util.html#g91ad9478d81a7aaf2593e8d9c3d06a14" title="Shortcut for default unsigned int.">uint</a> flags); <a name="l00156"></a>00156 <a name="l00163"></a>00163 <span class="keywordtype">void</span> FlushText (); <a name="l00164"></a>00164 <a name="l00168"></a>00168 <span class="keywordtype">void</span> DumpFontCache (<a class="code" href="classcsRefArray.html" title="An array of smart pointers.">csRefArray<iImage></a>& pages); <a name="l00169"></a>00169 }; <a name="l00170"></a>00170 <a name="l00173"></a>00173 <span class="preprocessor">#endif // __CS_CANVAS_OPENGLCOMMON_GLFONTCACHE_H__</span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>