PDA

View Full Version : Text on screen in OpenGL



Clark
11-13-2001, 03:04 AM
I've followed the glut example for displaying text on screen. It worked in a separate program but not in my larger 2D paint program code. No text appears:

void Print_Text(int tx, int ty){
cout << "x=" << tx << endl;
cout << "y=" << ty << endl;
void* font[1] {GLUT_BITMAP_9_BY_15 };
char* number[1] = { "HEJ VICTOR" };
glColor3f(R,G,B);
glRasterPos2f(tx,ty);
print_bitmap_string(font[font_index],number[font_index]);
}

void print_bitmap_string(void* font, char* s)
{
if (s && strlen(s)) {
while (*s) {
glutBitmapCharacter(font, *s);
s++;
}
}
}

I figure I need a glRasterPos(), but with what coordinates? I believe my coordinates begin with 0,0 in the left upper corner of the window (as it is what I use when drawing lines and my sub-menu),

/Clark

krishna
11-13-2001, 03:45 AM
Have you done any transformations? Check the
values of R,G ,B ?

Clark
11-13-2001, 03:56 AM
R,G,B is 0,0,0 from start (black). When I tried in the short test program I couldn't change the color from white. Don't know why. I followed an example where the author changed the color to green before glBitmapCharacter() was used. But it didn't work in my test program, or the real program. I haven't made any transformations.

/Clark