Commit 68419d9b30e28357e1f3bac10949194bcc62d6d5

sammy 2008-05-07T07:17:17

* 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.

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)