Updated FTGLDemo to use the new FTSimpleLayout. Changes include: - Added a font origin to specify the location to render the font. - The default text is now blatantly plagarized from the back cover of the OGL red book. - The font size is much smaller. - Font metrics are rendered differently depending on the current layout manager. - The FTSimpleLayout alignment mode is now output with other font information. - The space bar no longer cycles through the fonts. The cursor up/down keys do. - The cursor left/right keys increment/decrement the size of the current font. - The page up/page down keys cycle through the layout managers. - The home/end keys increment and decrement the line length of a simple layout - The tab key cycles through the alignment modes of a simple layout.
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
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index ac6af1f..4314d7d 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -346,8 +346,8 @@ void display(void)
{
case FTGL_BITMAP:
case FTGL_PIXMAP:
- glRasterPos2i( w_win / 2 + OX, h_win / 2 + OY);
- glTranslatef( w_win / 2 + OX, h_win / 2 + OY, 0.0);
+ glRasterPos2i((long)( w_win / 2 + OX),(long)( h_win / 2 + OY));
+ glTranslatef(w_win / 2 + OX,h_win / 2 + OY, 0.0);
break;
case FTGL_OUTLINE:
case FTGL_POLYGON:
@@ -411,6 +411,17 @@ void parsekey(unsigned char key, int x, int y)
carat = 0;
}
break;
+ case '\t':
+ if (layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) {
+ FTSimpleLayout *simpleLayout = (FTSimpleLayout *)layouts[currentLayout];
+ switch (simpleLayout->GetAlignment()) {
+ case FTSimpleLayout::ALIGN_LEFT: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_RIGHT); break;
+ case FTSimpleLayout::ALIGN_RIGHT: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_CENTER); break;
+ case FTSimpleLayout::ALIGN_CENTER: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_JUST); break;
+ case FTSimpleLayout::ALIGN_JUST: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_LEFT); break;
+ } /* Decrement the layout (switch GetAlignemnt()) */
+ } /* If the current layout is a simple layout change it's alignment properties (if simpleLayout) */
+ break;
default:
if( mode == INTERACTIVE)
{
@@ -460,24 +471,10 @@ void parseSpecialKey(int key, int x, int y)
if (simpleLayout) simpleLayout->SetLineLength(simpleLayout->GetLineLength() + 10.0f);
break;
case GLUT_KEY_LEFT:
- if (simpleLayout) {
- switch (simpleLayout->GetAlignment()) {
- case FTSimpleLayout::ALIGN_LEFT: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_JUST); break;
- case FTSimpleLayout::ALIGN_RIGHT: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_LEFT); break;
- case FTSimpleLayout::ALIGN_CENTER: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_RIGHT); break;
- case FTSimpleLayout::ALIGN_JUST: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_CENTER); break;
- } /* Increment the layout (switch GetAlignemnt()) */
- } /* If the current layout is a simple layout change it's alignment properties (if simpleLayout) */
- break;
+ fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() - 1);
+ break;
case GLUT_KEY_RIGHT:
- if (simpleLayout) {
- switch (simpleLayout->GetAlignment()) {
- case FTSimpleLayout::ALIGN_LEFT: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_RIGHT); break;
- case FTSimpleLayout::ALIGN_RIGHT: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_CENTER); break;
- case FTSimpleLayout::ALIGN_CENTER: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_JUST); break;
- case FTSimpleLayout::ALIGN_JUST: simpleLayout->SetAlignment(FTSimpleLayout::ALIGN_LEFT); break;
- } /* Decrement the layout (switch GetAlignemnt()) */
- } /* If the current layout is a simple layout change it's alignment properties (if simpleLayout) */
+ fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() + 1);
break;
}