Original Post
I was reading a post about using glPrint in order to have text messages popup at mouse coords on middle mouse click. Below is the mouse function and glPrint method I have included in my source code. All it does for some reason is change the color of an object in my background to the specified color in glColorf. Any ideas?
void mouse(int button, int state, int x, int y)
{
if (button == GLUT_MIDDLE_BUTTON)
{
if (state == GLUT_DOWN)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f,0.0f,-1.0f); // Move One Unit Into The Screen
glColor3f(1.0f,0.0f,0.5f); // Colour text - bright green
glRasterPos2f(x, y); // Position The Text On The Screen
glPrint("woooo"); // Print GL Text To The Screen
}
}
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
}