* In the C++ demo, show that FTFont itself can be directly derived, not only its subclasses. * Minor changes to the C demo to reduce the differences with the C++ version.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
diff --git a/demo/c-demo.c b/demo/c-demo.c
index 7e359b7..2316054 100644
--- a/demo/c-demo.c
+++ b/demo/c-demo.c
@@ -25,7 +25,8 @@
#include "config.h"
-#include <math.h>
+#include <math.h> /* sin(), cos() */
+#include <stdlib.h> /* exit() */
#if defined HAVE_GL_GLUT_H
# include <GL/glut.h>
@@ -45,7 +46,7 @@ static FTGLfont *font;
*/
static void RenderScene(void)
{
- float n = (float)glutGet(GLUT_ELAPSED_TIME) / 10.;
+ float n = (float)glutGet(GLUT_ELAPSED_TIME) / 20.;
float t1 = sin(n / 80);
float t2 = sin(n / 50 + 1);
float t3 = sin(n / 30 + 2);
@@ -91,10 +92,12 @@ static void RenderScene(void)
*/
static void ProcessKeys(unsigned char key, int x, int y)
{
- if(key == 27)
+ switch(key)
{
+ case 27:
ftglDestroyFont(font);
- exit(0);
+ exit(EXIT_SUCCESS);
+ break;
}
}
@@ -120,8 +123,8 @@ int main(int argc, char **argv)
glutIdleFunc(RenderScene);
glutKeyboardFunc(ProcessKeys);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
gluPerspective(90, 640.0f / 480.0f, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
diff --git a/demo/simple.cpp b/demo/simple.cpp
index b4d8826..157b398 100644
--- a/demo/simple.cpp
+++ b/demo/simple.cpp
@@ -25,8 +25,7 @@
#include "config.h"
-#include <math.h>
-
+#include <math.h> // sin(), cos()
#include <stdlib.h> // exit()
#if defined HAVE_GL_GLUT_H
@@ -43,13 +42,14 @@ static FTFont *font[3];
static int fontindex = 0;
//
-// FTHaloGlyph is a derivation of FTOutlineGlyph that displays several
-// outlines at varying offsets and with varying outset values.
+// FTHaloGlyph is a derivation of FTPolygonGlyph that also displays a
+// halo of FTOutlineGlyph objects at varying positions and with varying
+// outset values.
//
-class FTHaloGlyph : public FTOutlineGlyph
+class FTHaloGlyph : public FTPolygonGlyph
{
public:
- FTHaloGlyph(FT_GlyphSlot glyph) : FTOutlineGlyph(glyph, 0, true)
+ FTHaloGlyph(FT_GlyphSlot glyph) : FTPolygonGlyph(glyph, 0, true)
{
for(int i = 0; i < 5; i++)
{
@@ -67,20 +67,21 @@ class FTHaloGlyph : public FTOutlineGlyph
subglyph[i]->Render(pen, renderMode);
}
glPopMatrix();
- return FTOutlineGlyph::Render(pen, renderMode);
+
+ return FTPolygonGlyph::Render(pen, renderMode);
}
- FTOutlineGlyph *subglyph[5];
+ FTGlyph *subglyph[5];
};
//
-// FTHaloFont is a simple FTOutlineFont derivation that builds FTHaloGlyph
+// FTHaloFont is a simple FTFont derivation that builds FTHaloGlyph
// objects.
//
-class FTHaloFont : public FTOutlineFont
+class FTHaloFont : public FTFont
{
public:
- FTHaloFont(char const *fontFilePath) : FTOutlineFont(fontFilePath) {}
+ FTHaloFont(char const *fontFilePath) : FTFont(fontFilePath) {}
private:
virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot)