Commit 150528ab39d60c01f96d36203b9f1bd00c09b443

sammy 2008-05-12T14:11:45

* The examples now use FONT_FILE if it was found by the configure step.

diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index 221a545..fc490cf 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -43,18 +43,13 @@
 
 #include "tb.h"
 
-// YOU'LL PROBABLY WANT TO CHANGE THESE
-#ifdef __linux__
-#   define FONT_FILE "/usr/share/fonts/truetype/arial.ttf"
-#endif
-#ifdef __APPLE_CC__
-#   define FONT_FILE "/usr/X11R6/lib/X11/fonts/TTF/Vera.ttf"
-#endif
-#ifdef WIN32
-#   define FONT_FILE "C:\\WINNT\\Fonts\\arial.ttf"
-#endif
-#ifndef FONT_FILE
-#   define FONT_FILE 0
+#if !defined FONT_FILE
+#   ifdef WIN32
+#       define FONT_FILE "C:\\WINNT\\Fonts\\arial.ttf"
+#   else
+        // Put your font file here if configure did not find it.
+#       define FONT_FILE 0
+#   endif
 #endif
 
 #define EDITING 1
diff --git a/demo/FTGLMFontDemo.cpp b/demo/FTGLMFontDemo.cpp
index 7142db9..efde368 100644
--- a/demo/FTGLMFontDemo.cpp
+++ b/demo/FTGLMFontDemo.cpp
@@ -42,22 +42,20 @@
 #include "tb.h"
 
 // YOU'LL PROBABLY WANT TO CHANGE THESE
-#ifdef __linux__
-    char const *defaultFonts[] = { "/usr/share/fonts/truetype/arial.ttf" };
+#if defined FONT_FILE
+    char const *defaultFonts[] = { FONT_FILE };
     const int NumDefaultFonts = 1;
-#endif
-#ifdef __APPLE_CC__
-    //#define FONT_FILE "/Users/henry/Development/PROJECTS/FTGL/ftglcvs/FTGL/test/arial.ttf"
+#elif defined __APPLE_CC__
     char const *defaultFonts[] = { "/System/Library/Fonts/Helvetica.dfont",
                                    "/System/Library/Fonts/Geneva.dfont" };
     const int NumDefaultFonts = 2;
-#endif
-#ifdef WIN32
+#elif defined WIN32
     char const *defaultFonts[] = { "C:\\WINNT\\Fonts\\arial.ttf" };
     const int NumDefaultFonts = 1;
-#endif
-#ifndef FONT_FILE
-#   define FONT_FILE 0
+#else
+    // Put your font files here if configure did not find any.
+    char const *defaultFonts[] = { };
+    const int NumDefaultFonts = 0;
 #endif
 
 /* Set this to 1 to build a Mac os app (ignore the command line args). */
diff --git a/demo/c-demo.c b/demo/c-demo.c
index 2a0ae8b..7ab809a 100644
--- a/demo/c-demo.c
+++ b/demo/c-demo.c
@@ -169,11 +169,22 @@ static void ProcessKeys(unsigned char key, int x, int y)
  */
 int main(int argc, char **argv)
 {
+    char const *file = NULL;
+
+#ifdef FONT_FILE
+    file = FONT_FILE;
+#else
     if(argc < 2)
     {
         fprintf(stderr, "Usage: %s <font_name.ttf>\n", argv[0]);
         return EXIT_FAILURE;
     }
+#endif
+
+    if(argc > 1)
+    {
+        file = argv[1];
+    }
 
     /* Initialise GLUT stuff */
     glutInit(&argc, argv);
@@ -194,13 +205,12 @@ int main(int argc, char **argv)
     gluLookAt(0.0, 0.0, 640.0f / 2.0f, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
 
     /* Initialise FTGL stuff */
-    //font = ftglCreateExtrudeFont(argv[1]);
-    font[0] = ftglCreateExtrudeFont(argv[1]);
-    font[1] = ftglCreatePolygonFont(argv[1]);
-    font[2] = ftglCreateCustomFont(argv[1], NULL, MakeHaloGlyph);
+    font[0] = ftglCreateExtrudeFont(file);
+    font[1] = ftglCreatePolygonFont(file);
+    font[2] = ftglCreateCustomFont(file, NULL, MakeHaloGlyph);
     if(!font[0] || !font[1] || !font[2])
     {
-        fprintf(stderr, "%s: could not load font `%s'\n", argv[0], argv[1]);
+        fprintf(stderr, "%s: could not load font `%s'\n", argv[0], file);
         return EXIT_FAILURE;
     }
 
diff --git a/demo/simple.cpp b/demo/simple.cpp
index 68e79f7..299d4b0 100644
--- a/demo/simple.cpp
+++ b/demo/simple.cpp
@@ -161,11 +161,22 @@ static void ProcessKeys(unsigned char key, int x, int y)
 //
 int main(int argc, char **argv)
 {
+    char const *file = NULL;
+
+#ifdef FONT_FILE
+    file = FONT_FILE;
+#else
     if(argc < 2)
     {
         fprintf(stderr, "Usage: %s <font_name.ttf>\n", argv[0]);
         return EXIT_FAILURE;
     }
+#endif
+
+    if(argc > 1)
+    {
+        file = argv[1];
+    }
 
     // Initialise GLUT stuff
     glutInit(&argc, argv);
@@ -186,13 +197,13 @@ int main(int argc, char **argv)
     gluLookAt(0.0, 0.0, 640.0f / 2.0f, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
 
     // Initialise FTGL stuff
-    font[0] = new FTExtrudeFont(argv[1]);
-    font[1] = new FTPolygonFont(argv[1]);
-    font[2] = new FTHaloFont(argv[1]);
+    font[0] = new FTExtrudeFont(file);
+    font[1] = new FTPolygonFont(file);
+    font[2] = new FTHaloFont(file);
 
     if(font[0]->Error() || font[1]->Error() || font[2]->Error())
     {
-        fprintf(stderr, "%s: could not load font `%s'\n", argv[0], argv[1]);
+        fprintf(stderr, "%s: could not load font `%s'\n", argv[0], file);
         return EXIT_FAILURE;
     }