Font Position Question
Is there some way I can make the text at a fixed place all the time(like the upper left corner of the screen), because glRaterPos2f only position the text according to the center so the text move from the edge when resizing or changing resolution .
Thanks
[Edited by - L0rdDiabl0 on June 20, 2004 3:53:07 PM]
I have found this code to output TGA font on screen
i have not checked it with other res but on 640x480 it works
i have not checked it with other res but on 640x480 it works
GLvoid glPrint(GLint x, GLint y, int set, const char *fmt, ...) // Where the printing happens{ GLfloat mat_ambient[] = { 1.0, 1.0, 0.0, 1.0 }; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); char text[1024]; // 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 if (set > 1) { set = 1; } glBindTexture(GL_TEXTURE_2D, textures[0].texID ); // Select our font texture glDisable(GL_DEPTH_TEST); // Disables depth testing // glEnable(GL_BLEND); // Enable blending // glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Type of blending to use glMatrixMode(GL_PROJECTION); // Select the projection matrix glPushMatrix(); // Store the projection matrix glLoadIdentity(); // Reset the projection matrix // Set up an ortho screen glOrtho(0,640,0,480,-1,1); // Set up an ortho screen glMatrixMode(GL_MODELVIEW); // Select the modelview matrix glPushMatrix(); // Store the modelview matrix glLoadIdentity(); // Reset the modelview matrix glTranslated(x,470 - y,0); // Position the text (0,0 - Bottom left) glListBase(base-32+(128*set)); // Choose the font set (0 or 1) glCallLists(strlen(text), GL_BYTE, text); // Write the text to the screen glMatrixMode(GL_PROJECTION); // Select the projection matrix glPopMatrix(); // Restore the old projection matrix glMatrixMode(GL_MODELVIEW); // Select the modelview matrix glPopMatrix(); // Restore the old projection matrix // glDisable(GL_TEXTURE_2D); // glDisable(GL_BLEND); // Enable nlending glEnable(GL_DEPTH_TEST); // Enables depth testing}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement