PDA

View Full Version : how to print a dynamic string on the screen



debs
03-23-2007, 08:24 AM
actually i'm doing a radar display system.. i have to prprint strings on the screen.. but i dont know how to do this.. can u plz guide me how to do so.

debs
03-23-2007, 01:56 PM
hey ppl i need to print an array of strings using opengl. can u tell me the command to so..

i know only 1 command -> glBitmapCharacter() to print a single character at a time.. but my prob is to print a dynamic array of strings like

char **string={"hi","hello","fine");

can u plz tell me the command to do so.. it will be a tedious job to do so using the above command.. cos my string is also generated at runtime only..

thinks
03-23-2007, 06:58 PM
The GLUT libraries have string printing functions. Have a look there and re-post if you need more help.

debs
03-24-2007, 10:52 AM
i'm not able to find any such libraries.. can u plz tell me any such library so that i can search them on net.

i got something from net as shown below which can be helpful to me.. but its not recognized by my system.. i have fedora core 3.. may be it has a old version of opengl.. can u tell me where to download its new version.
the below mentioned header file is also not recognized..

#include <gl\glaux.h>

GLvoid glPrint(const char *fmt, ...) // Custom GL "Print" routine
{
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

glPushAttrib(GL_LIST_BIT); // Pushes the display list bits
glListBase(base - 32); // Sets the base character to 32
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws the display list text
glPopAttrib(); // Pops the display list bits
}et..

OneSadCookie
03-25-2007, 05:48 AM
svn co http://onesadcookie.com/svn/repos/SimpleText
svn co http://onesadcookie.com/svn/repos/SimpleTextCDemo

It's a little buggy with centered/right-aligned text, and not massively efficient, but it's easy enough to use.