void myinit(int numFontFiles) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.13, 0.17, 0.32, 0.0); glColor3f(1.0, 1.0, 1.0); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glEnable(GL_DEPTH_TEST); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(1.0, 1.0); // ???? SetCamera(); tbInit(GLUT_LEFT_BUTTON); tbAnimate(GL_FALSE); setUpFonts(numFontFiles); // Configure the SimpleLayout simpleLayout.SetLineLength(InitialLineLength); simpleLayout.SetFont(fonts[current_font]); }
Gwen::Point Chowdren::MeasureText( Gwen::Font* pFont, const Gwen::UnicodeString & text ) { FTSimpleLayout layout; layout.SetLineLength(10000); layout.SetFont(get_font(pFont->size)); FTBBox bbox = layout.BBox(text.c_str()); FTPoint size = bbox.Upper() - bbox.Lower(); return Gwen::Point((int)ceil(size.X()), (int)ceil(size.Y())); }
void Chowdren::RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString & text ) { if (!init_font()) return; FTTextureFont* font = get_font(pFont->size); if (font) { Translate(pos.x, pos.y); FTTextureFont::color = m_Color; FTSimpleLayout layout; layout.SetLineLength(10000); layout.SetFont(font); layout.Render(text.c_str(), -1, FTPoint(pos.x, pos.y + font->Ascender())); } }
void myinit(const char* file) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.5, 0.5, 0.7, 0.0); glColor3f(1.0, 1.0, 1.0); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glShadeModel(GL_SMOOTH); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(1.0, 1.0); // ???? SetCamera(); tbInit(GLUT_LEFT_BUTTON); tbAnimate(GL_FALSE); setUpFonts(file); // Configure the SimpleLayout simpleLayout.SetLineLength(InitialLineLength); simpleLayout.SetFont(fonts[current_font]); glGenTextures(2, textureID); for(int i = 0; i < 2; i++) { glBindTexture(GL_TEXTURE_2D, textureID[i]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_FLOAT, textures[i]); } }
void parsekey(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; case 13: if(mode == EDITING) { mode = INTERACTIVE; } else { mode = EDITING; carat = 0; } break; case '\t': // If current layout is a SimpleLayout, change its alignment properties if(layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) { FTSimpleLayout *l = (FTSimpleLayout *)layouts[currentLayout]; // Decrement the layout switch (l->GetAlignment()) { case FTGL::ALIGN_LEFT: l->SetAlignment(FTGL::ALIGN_RIGHT); break; case FTGL::ALIGN_RIGHT: l->SetAlignment(FTGL::ALIGN_CENTER); break; case FTGL::ALIGN_CENTER: l->SetAlignment(FTGL::ALIGN_JUSTIFY); break; case FTGL::ALIGN_JUSTIFY: l->SetAlignment(FTGL::ALIGN_LEFT); break; } } break; default: if(mode == INTERACTIVE) { myString[0] = key; myString[1] = 0; } else { myString[carat] = key; myString[carat + 1] = 0; carat = carat > 2000 ? 2000 : carat + 1; } break; } glutPostRedisplay(); }
void loadingscreen(string s) { extern FTGLPixmapFont* font; int size=36; font->FaceSize(size); FTSimpleLayout status; status.SetFont(font); status.SetAlignment(FTGL::ALIGN_CENTER); status.SetLineLength(WINDOW_X); FTBBox box=status.BBox(s.c_str()); float boxx=box.Upper().Xf()-box.Lower().Xf(), boxy=box.Upper().Yf()-box.Lower().Yf(); glDisable(GL_LIGHTING); glViewport(0,0,WINDOW_X,WINDOW_Y); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,1,0,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glBindTexture(GL_TEXTURE_2D, textures[LOADTX]); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBegin(GL_QUADS); glTexCoord2i(0,0); glVertex2i(0,0); glTexCoord2i(1,0); glVertex2i(1,0); glTexCoord2i(1,1); glVertex2i(1,1); glTexCoord2i(0,1); glVertex2i(0,1); glEnd(); glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,WINDOW_X,0,WINDOW_Y); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRasterPos2i(0,WINDOW_Y/2+boxy/2-size-status.GetLineSpacing()); status.Render(s.c_str()); glRasterPos2i(0,0); glfwSwapBuffers(); }
void parseSpecialKey(int key, int x, int y) { FTSimpleLayout *l = NULL; // If the currentLayout is a SimpleLayout store a pointer in l if(layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) { l = (FTSimpleLayout *)layouts[currentLayout]; } switch (key) { case GLUT_KEY_UP: current_font = (GetFace()*NumStyles + (current_font + 1)%NumStyles)%totalFonts; break; case GLUT_KEY_DOWN: current_font = (GetFace()*NumStyles + (current_font + NumStyles - 1)%NumStyles)%totalFonts; 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; case GLUT_KEY_PAGE_UP: current_font = (current_font + NumStyles)%totalFonts; break; case GLUT_KEY_PAGE_DOWN: current_font = (current_font + totalFonts - NumStyles)%totalFonts; break; case GLUT_KEY_HOME: currentLayout = (currentLayout + 1)%NumLayouts; break; case GLUT_KEY_END: currentLayout = (currentLayout + NumLayouts - 1)%NumLayouts; break; case GLUT_KEY_F1: case GLUT_KEY_F10: // If the current layout is simple decrement its line length if (l) l->SetLineLength(l->GetLineLength() - 10.0f); break; case GLUT_KEY_F2: case GLUT_KEY_F11: // If the current layout is simple increment its line length if (l) l->SetLineLength(l->GetLineLength() + 10.0f); break; } // If the current layout is a SimpleLayout, update its font. if(l) { l->SetFont(fonts[current_font]); } glutPostRedisplay(); }