Note that there are some explanatory texts on larger screens.

plurals
  1. POCompile with MinGW and install FTGL lib to render text in OpenGL
    primarykey
    data
    text
    <h1>Context</h1> <p>I'm making a game engine using SDL and OpenGL. I'm trying to find the best way to output text to the screen with fancy true type font and I came across FTGL. (If you have better/easier solution, feel free to share it.)</p> <h1>Compiling FTGL</h1> <p>It requires FreeType2 in order to work so I got it, compiled it (using Code::Block) and then I compiled the FTGL lib using Code::Block too.</p> <p>I'm using Eclipse Indigo with the CDT plugin. I'm not sure which lib to take, since there are a <code>.lib</code> and a <code>.dll</code> file. I tried both, but this doesn't seem to change my problem at all, which curently is on this line:</p> <pre><code>FTfont* m_Font = new FTTextureFont(filename.c_str()); </code></pre> <p>The error is:</p> <pre class="lang-none prettyprint-override"><code>The type 'FTTextureFont' must implement the inherited pure virtual method 'FTFont::MakeGlyph' </code></pre> <p>It doesn't change if I use another FTfont subclass, e.g. FTPixmapFont constructor.</p> <p>Here are the linker flags which I tried:</p> <pre class="lang-none prettyprint-override"><code>-lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_net -lSDL_ttf -lftgl -lfreetype234_D -lopengl32 -lglu32 -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_net -lSDL_ttf -lftgl -llibfreetype -lopengl32 -lglu32 </code></pre> <p>I'm using eclipse with MinGW. </p> <p>I have copied and pasted </p> <ul> <li>the <code>src/FTGL</code> folder and</li> <li>the content of the <code>Include</code> folder of the freetype library</li> </ul> <p>to the <code>include</code> folder of the MinGW directory.</p> <p>Both freetype2 (there a are <code>freetype.lib</code>, <code>freetype248_D.lib</code> and <code>freetype-bcc.lib</code>, not sure wich to link in the project properties) and ftgl (<code>ftgl.dll</code>, <code>ftgl_D.lib</code>, <code>ftgl_static_D.lib</code>) lib files into the corresponding lib folder of the MinGW directory.</p> <p>If I click on the line that has the error and uses the Open Declaration option, eclipse takes me to the <code>FTTextureFont</code> header file which has <code>FTTextureFont(char const*)</code> defined and the <code>MakeGlyph</code> function defined too.</p> <p>You can find the full code on the <a href="https://github.com/emileber/getrandomgame" rel="nofollow noreferrer">GetRandomGame project page</a> if you want to see more, or as a reference.</p> <p>Here's the Compiler version</p> <pre class="lang-none prettyprint-override"><code>Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.6.1/configure --enable-languages=c,c++,fortran,objc,ob j-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp - -disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runti me-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.6.1 (GCC) </code></pre> <hr> <p><strong>EDIT</strong></p> <p>Similar question: <a href="https://stackoverflow.com/questions/8714155/ftgl-undefined-references-everywere">FTGL undefined references everywere?</a>, but the answer of that question doesn't solve my problem, I still get these two errors.</p> <hr> <p><strong>EDIT 2</strong></p> <p><em>I was compiling using MSVC when I first tried to use FTGL and had two errors.</em></p> <p>I finally used code::block to import the MSVC project provided with both libraries. One of the two errors got solved! But, I still got this one:</p> <pre class="lang-none prettyprint-override"><code>The type 'FTTextureFont' must implement the inherited pure virtual method 'FTFont::MakeGlyph' </code></pre> <hr> <p><strong>EDIT 3</strong></p> <p>I've tried to compile FTGL 2.1.2 with freetype 2.3.4 and that hasn't solved my problem. I've tried FTGL 2.1.3 rc5 with freetype 2.3.4, same thing. Just to be sure, I've also tried freetype 2.3.5 and 2.4.8 (the first time was already 2.4.8).</p> <p>I've tried moving the <code>MakeGlyph</code> code into the header file, but that hasn't solved the problem.</p> <p>Here are some useful links i've found, but they haven't solved the problem yet.</p> <ul> <li><a href="http://devcry.heiho.net/2012/01/opengl-font-rendering-with-ftgl.html" rel="nofollow noreferrer">OpenGL font rendering with FTGL</a></li> <li><a href="http://forum.caravelgames.com/viewtopic.php?TopicID=13838" rel="nofollow noreferrer">Glut and FTGL</a></li> </ul> <hr> <p><strong>EDIT 4</strong></p> <p>When I remove the <code>ftgl</code> linker flag, the compiler complains about this:</p> <pre class="lang-none prettyprint-override"><code>undefined reference to FTPixmapFont::FTPixmapFont(char const*)' collect2: ld returned 1 exit status Build error occurred, build is stopped </code></pre> <p>And I still get the pure virtual method <code>MakeGlyph</code> error.</p> <p>With the <code>ftgl</code> linker flag, the only error I get is the <em>"must implement the inherited Pure Virtual method MakeGlyph"</em>. The compiler builds the project fine (but crashes at start up):</p> <pre class="lang-none prettyprint-override"><code>-lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_net -lSDL_ttf -lfreetype -lftgl -lopengl32 -lglu32 Build complete for project GetRandomGame </code></pre> <p>So I'm thinking that the FTGL lib isn't compiled correctly since it should have the <code>FTPixmapFont.cpp</code> defining the pure virtual method <code>MakeGlyph</code>. I'm kind of new with all those lib things in c++ and I might be doing something wrong building the lib.</p> <hr> <p><strong>EDIT 5</strong></p> <p>I have read and seen in an example that I needed to have a <code>config.h</code> file, so I added a properly configured <code>config.h</code> file that comes with FTGL.</p> <p>Then I found the following code in an example provided in the <code>ftgl</code> directory and I added that to my <code>Font</code> class.</p> <pre><code>class FTHaloFont : public FTFont { public: FTHaloFont(char const *fontFilePath) : FTFont(fontFilePath) {} protected: virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot) { return new FTHaloGlyph(slot); } }; </code></pre> <p>Even if I define <code>MakeGlyph</code> there, Eclipse complains about an unimplemented pure virtual method <code>FTFont::MakeGlyph</code>.</p> <hr> <p><strong>EDIT 6</strong></p> <p>I've tried debugging from command line with gdb and it tells me that freetype6.dll can't be found. I'm trying right now to find a solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload