Minor reformatting and enabled texture fonts to be selected
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index 19af4a1..46f8ea8 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -23,8 +23,7 @@
#define FONT_FILE "/usr/share/fonts/truetype/arial.ttf"
#endif
#ifdef __APPLE_CC__
- //#define FONT_FILE "/Users/henry/Development/PROJECTS/FTGL/ftglcvs/FTGL/test/arial.ttf"
- #define FONT_FILE "/Users/progers/Desktop/arial.ttf"
+ #define FONT_FILE "/Users/henry/Development/PROJECTS/FTGL/test/font_pack/arial.ttf"
#endif
#ifdef WIN32
#define FONT_FILE "C:\\WINNT\\Fonts\\arial.ttf"
@@ -322,12 +321,15 @@ void do_display (void)
glColor3f( 1.0, 1.0, 1.0);
// If you do want to switch the color of bitmaps rendered with glBitmap,
-// you will need to explicitly call glRasterPos3f (or its ilk) to lock
+// you will need to explicitly call glRasterPos (or its ilk) to lock
// in a changed current color.
- if (layouts[currentLayout]) {
+ if (layouts[currentLayout])
+ {
layouts[currentLayout]->Render(myString);
- } else {
+ }
+ else
+ {
fonts[current_font]->Render( myString);
} /* If there is an active layout use it to render the font (if/else layouts[currentLayout]) */
@@ -443,70 +445,70 @@ void parsekey(unsigned char key, int x, int y)
void parseSpecialKey(int key, int x, int y)
{
- FTSimpleLayout *simpleLayout = NULL;
- if (layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) {
- simpleLayout = (FTSimpleLayout *)layouts[currentLayout];
- } /* If the currentLayout is a simple layout store a pointer in simpleLayout (if layouts[currentLayout]) */
-
- switch (key)
- {
- case GLUT_KEY_UP:
- current_font = (current_font + 1)%5;
- break;
- case GLUT_KEY_DOWN:
- current_font = (current_font + 4)%5;
- break;
- case GLUT_KEY_PAGE_UP:
- currentLayout = (currentLayout + 1)%NumLayouts;
- break;
- case GLUT_KEY_PAGE_DOWN:
- currentLayout = (currentLayout + NumLayouts - 1)%NumLayouts;
- break;
- case GLUT_KEY_HOME:
- /* If the current layout is simple decrement its line length */
- if (simpleLayout) simpleLayout->SetLineLength(simpleLayout->GetLineLength() - 10.0f);
- break;
- case GLUT_KEY_END:
- /* If the current layout is simple increment its line length */
- if (simpleLayout) simpleLayout->SetLineLength(simpleLayout->GetLineLength() + 10.0f);
- break;
- case GLUT_KEY_LEFT:
- fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() - 1);
- break;
- case GLUT_KEY_RIGHT:
- fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() + 1);
- break;
- }
-
- if (simpleLayout) {
- simpleLayout->SetFont(fonts[current_font]);
- } /* If the current layout is a simple layout update it's font (if simpleLayout) */
-
- glutPostRedisplay();
+ FTSimpleLayout *simpleLayout = NULL;
+ if (layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) {
+ simpleLayout = (FTSimpleLayout *)layouts[currentLayout];
+ } /* If the currentLayout is a simple layout store a pointer in simpleLayout (if layouts[currentLayout]) */
+
+ switch (key)
+ {
+ case GLUT_KEY_UP:
+ current_font = ( current_font == FTGL_TEXTURE) ? FTGL_BITMAP: ++current_font;
+ break;
+ case GLUT_KEY_DOWN:
+ current_font = ( current_font == FTGL_BITMAP) ? FTGL_TEXTURE : --current_font;
+ break;
+ case GLUT_KEY_PAGE_UP:
+ currentLayout = (currentLayout + 1)%NumLayouts;
+ break;
+ case GLUT_KEY_PAGE_DOWN:
+ currentLayout = (currentLayout + NumLayouts - 1)%NumLayouts;
+ break;
+ case GLUT_KEY_HOME:
+ /* If the current layout is simple decrement its line length */
+ if (simpleLayout) simpleLayout->SetLineLength(simpleLayout->GetLineLength() - 10.0f);
+ break;
+ case GLUT_KEY_END:
+ /* If the current layout is simple increment its line length */
+ if (simpleLayout) simpleLayout->SetLineLength(simpleLayout->GetLineLength() + 10.0f);
+ break;
+ case GLUT_KEY_LEFT:
+ fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() - 1);
+ break;
+ case GLUT_KEY_RIGHT:
+ fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() + 1);
+ break;
+ }
+
+ if (simpleLayout) {
+ simpleLayout->SetFont(fonts[current_font]);
+ } /* If the current layout is a simple layout update it's font (if simpleLayout) */
+
+ glutPostRedisplay();
}
void motion(int x, int y)
{
- tbMotion( x, y);
+ tbMotion( x, y);
}
void mouse(int button, int state, int x, int y)
{
- tbMouse( button, state, x, y);
+ tbMouse( button, state, x, y);
}
void myReshape(int w, int h)
{
- glMatrixMode (GL_MODELVIEW);
- glViewport (0, 0, w, h);
- glLoadIdentity();
-
- w_win = w;
- h_win = h;
- SetCamera();
-
- tbReshape(w_win, h_win);
+ glMatrixMode (GL_MODELVIEW);
+ glViewport (0, 0, w, h);
+ glLoadIdentity();
+
+ w_win = w;
+ h_win = h;
+ SetCamera();
+
+ tbReshape(w_win, h_win);
}
void SetCamera(void)