Commit d70b194df81a82c0071e3e18e7ec93034b356a99

patrick 2003-04-06T20:51:38

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.

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;
 	}