OpenGl -> Schrift
-
Hi, gibt es die Möglich bei OpenGl ins Fenster zu schreiben ? zwar gibt es sowas auch bei der winapi (gdi) aber vlt gibt es das ja auch für OpenGl....
Gruß Chris
-
Ja, z.B. bietet dir die Kleberschnittstelle zwischen OS und OpenGL die Möglichkeit, Displaylisten automatisch von dem Betriebssystemfonts zu generieren.
Bei Windows wäre das die WGl, die diese Funktionen bereitstellt.
EDIT: Meist fährt man aber besser, wenn man das selbst macht, indem man eine Textur mit dem Alphabet lädt und dann kleine Rechtecke für jeden Buchstaben damit rendert.
-
Stimmt, das hört sich jut an
danke^^
-
Erst vor ein paar Tagen entdeckt:
http://quesoglc.sourceforge.net/
Basiert auf FreeType 2.
-
Meinst du sowas:
GLYPHMETRICSFLOAT gmf[256]; // für Textausgabe GLuint base; GLvoid BuildFont() // Build Our Bitmap Font { HFONT font; // Windows Font ID base = glGenLists(256); // Storage For 256 Characters font = CreateFont( -12, // Height Of Font 0, // Width Of Font 0, // Angle Of Escapement 0, // Orientation Angle FW_BOLD, // Font Weight FALSE, // Italic FALSE, // Underline FALSE, // Strikeout ANSI_CHARSET, // Character Set Identifier OUT_TT_PRECIS, // Output Precision CLIP_DEFAULT_PRECIS, // Clipping Precision NONANTIALIASED_QUALITY, // Output Quality FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch L"Comic Sans MS"); // Font Name SelectObject(g_window->hDC, font); // Selects The Font We Created wglUseFontOutlines( g_window->hDC, // Select The Current DC 0, // Starting Character 256, // Number Of Display Lists To Build base, // Starting Display Lists 0.0f, // Deviation From The True Outlines 0.001f, // Font Thickness In The Z Direction WGL_FONT_LINES , // Use Polygons, Not Lines WGL_FONT_POLYGONS, gmf); // Address Of Buffer To Recieve Data } GLvoid glPrint(const char *fmt, ...) // Custom GL "Print" Routine { float length=0; // Used To Find The Length Of The Text char text[256]; // Holds Our String va_list ap; // Pointer To List Of Arguments if (fmt == NULL) // If There's No Text return; // Do Nothing va_start(ap, fmt); // Parses The String For Variables vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers va_end(ap); // Results Are Stored In Text for (unsigned int loop=0;loop<(strlen(text));loop++) // Loop To Find Text Length { length+=gmf[text[loop]].gmfCellIncX; // Increase Length By Each Characters Width } glTranslatef(-length/2,0.0f,0.0f); // Center Our Text On The Screen glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits glListBase(base); // Sets The Base Character to 0 glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glPopAttrib(); // Pops The Display List Bits }
Steht auf
http://nehe.gamedev.net/lesson.asp?index=03
lesson 14
-
Ich würde lieber eine Font-Textur nehmen und den Text im Ortho-Modus mit normalen Tri/Quad wasauchimmer Strips als Poly rendern. Dieses Font-Rendering wie NeHe das macht ist ziemlich langsam und fehleranfällig.