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