blob: 566ed0b6f6c490528bc722017bfaeb04475537ed [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>FTGL: FTTextureGlyph.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>FTTextureGlyph.cpp</h1><a href="FTTextureGlyph_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#include "<a class="code" href="FTTextureGlyph_8h.html">FTTextureGlyph.h</a>"</span>
00002
00003 GLint FTTextureGlyph::activeTextureID = 0;
00004
<a name="l00005"></a><a class="code" href="classFTTextureGlyph.html#a0">00005</a> <a class="code" href="classFTTextureGlyph.html#a0">FTTextureGlyph::FTTextureGlyph</a>( FT_GlyphSlot glyph, <span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> xOffset, <span class="keywordtype">int</span> yOffset, GLsizei width, GLsizei height)
00006 : <a class="code" href="classFTGlyph.html">FTGlyph</a>( glyph),
00007 destWidth(0),
00008 destHeight(0),
00009 glTextureID(id)
00010 {
00011 err = FT_Render_Glyph( glyph, <a class="code" href="FTGL_8h.html#a2">FT_RENDER_MODE_NORMAL</a>);
00012 <span class="keywordflow">if</span>( err || glyph-&gt;format != ft_glyph_format_bitmap)
00013 {
00014 <span class="keywordflow">return</span>;
00015 }
00016
00017 FT_Bitmap bitmap = glyph-&gt;bitmap;
00018
00019 destWidth = bitmap.width;
00020 destHeight = bitmap.rows;
00021
00022 <span class="keywordflow">if</span>( destWidth &amp;&amp; destHeight)
00023 {
00024 glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
00025 glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
00026 glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
00027 glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
00028
00029 glBindTexture( GL_TEXTURE_2D, glTextureID);
00030 glTexSubImage2D( GL_TEXTURE_2D, 0, xOffset, yOffset, destWidth, destHeight, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap.buffer);
00031
00032 glPopClientAttrib();
00033 }
00034
00035
00036 <span class="comment">// 0 </span>
00037 <span class="comment">// +----+</span>
00038 <span class="comment">// | |</span>
00039 <span class="comment">// | |</span>
00040 <span class="comment">// | |</span>
00041 <span class="comment">// +----+</span>
00042 <span class="comment">// 1</span>
00043
00044 uv[0].<a class="code" href="classFTPoint.html#a7">X</a>( static_cast&lt;float&gt;(xOffset) / static_cast&lt;float&gt;(width));
00045 uv[0].<a class="code" href="classFTPoint.html#a8">Y</a>( static_cast&lt;float&gt;(yOffset) / static_cast&lt;float&gt;(height));
00046 uv[1].<a class="code" href="classFTPoint.html#a7">X</a>( static_cast&lt;float&gt;( xOffset + destWidth) / static_cast&lt;float&gt;(width));
00047 uv[1].<a class="code" href="classFTPoint.html#a8">Y</a>( static_cast&lt;float&gt;( yOffset + destHeight) / static_cast&lt;float&gt;(height));
00048
00049 pos.<a class="code" href="classFTPoint.html#a7">X</a>( glyph-&gt;bitmap_left);
00050 pos.<a class="code" href="classFTPoint.html#a8">Y</a>( glyph-&gt;bitmap_top);
00051 }
00052
00053
<a name="l00054"></a><a class="code" href="classFTTextureGlyph.html#a1">00054</a> <a class="code" href="classFTTextureGlyph.html#a1">FTTextureGlyph::~FTTextureGlyph</a>()
00055 {}
00056
00057
<a name="l00058"></a><a class="code" href="classFTTextureGlyph.html#a2">00058</a> <span class="keyword">const</span> <a class="code" href="classFTPoint.html">FTPoint</a>&amp; <a class="code" href="classFTTextureGlyph.html#a2">FTTextureGlyph::Render</a>( <span class="keyword">const</span> <a class="code" href="classFTPoint.html">FTPoint</a>&amp; pen)
00059 {
00060 <span class="keywordflow">if</span>( activeTextureID != glTextureID)
00061 {
00062 glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
00063 activeTextureID = glTextureID;
00064 }
00065
00066 glTranslatef( pen.<a class="code" href="classFTPoint.html#a7">X</a>(), pen.<a class="code" href="classFTPoint.html#a8">Y</a>(), 0.0f);
00067
00068 glBegin( GL_QUADS);
00069 glTexCoord2f( uv[0].X(), uv[0].Y());
00070 glVertex2f( pos.<a class="code" href="classFTPoint.html#a7">X</a>(), pos.<a class="code" href="classFTPoint.html#a8">Y</a>());
00071
00072 glTexCoord2f( uv[0].X(), uv[1].Y());
00073 glVertex2f( pos.<a class="code" href="classFTPoint.html#a7">X</a>(), pos.<a class="code" href="classFTPoint.html#a8">Y</a>() - destHeight);
00074
00075 glTexCoord2f( uv[1].X(), uv[1].Y());
00076 glVertex2f( destWidth + pos.<a class="code" href="classFTPoint.html#a7">X</a>(), pos.<a class="code" href="classFTPoint.html#a8">Y</a>() - destHeight);
00077
00078 glTexCoord2f( uv[1].X(), uv[0].Y());
00079 glVertex2f( destWidth + pos.<a class="code" href="classFTPoint.html#a7">X</a>(), pos.<a class="code" href="classFTPoint.html#a8">Y</a>());
00080 glEnd();
00081
00082 <span class="keywordflow">return</span> advance;
00083 }
00084
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Dec 5 22:24:06 2004 for FTGL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.6 </small></address>
</body>
</html>