Alex Rivera | Logout

How do I draw text with GLUT / OpenGL in C++?

Asked 2009-02-11T20:40:04.170
25

How do I draw a text string onto the screen using GLUT / OpenGL drawing functions?

Edit
Report

1 Answer

10
void RenderString(float x, float y, void *font, const char* string, RGB const& rgb)
{  
  char *c;

  glColor3f(rgb.r, rgb.g, rgb.b); 
  glRasterPos2f(x, y);

  glutBitmapString(font, string);
}

And you can call it like;

RenderString(0.0f, 0.0f, GLUT_BITMAP_TIMES_ROMAN_24, "Hello", RGB(1.0f, 0.0f, 0.0f));
answered 2009-02-11T20:49:16.143

Your Answer