I am trying to print text using glBitmapCharacter on a textured background.
//init code
void myinit(char* filename)
{
LoadGLTextures(filename);
glEnable(GL_TEXTURE_2D);
glClearColor(1.0, 1.0, 1.0, 0.0);
glViewport(0,0,430,360);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, WINDOW_WIDTH, 0, WINDOW_HEIGHT);
}
//display function
display(){
glClear(GL_COLOR_BUFFER_BIT );
glEnable(GL_TEXTURE_2D);
drawGround();
glDisable(GL_TEXTURE_2D);
glColor3f(0.0f, 1.0f, 0.0f);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'C');
glFlush();
glutSwapBuffers();
}
void drawGround()
{
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_POLYGON);
glTexCoord2f(0.0f, 0.2969f); glVertex2f(0, 0);
glTexCoord2f(0.0f, 1.0f); glVertex2f( 0, WINDOW_HEIGHT);
glTexCoord2f(0.8398f, 1.0f); glVertex2f( WINDOW_WIDTH, WINDOW_HEIGHT);
glTexCoord2f(0.8398f, 0.2969f); glVertex2f( WINDOW_WIDTH, 0);
glEnd();
}
This causes my texture to be shades of green.
so i modified the display code draw the text to save the old color and reset it after drawing the text.
GLfloat currentcolor[3];
glPushMatrix();
glGetFloatv( GL_CURRENT_COLOR, currentcolor);
glRasterPos2f(100, 100);
glColor3f(0.0f, 1.0f, 0.0f);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'C');
glColor3fv(currentcolor);
glPopMatrix();
This resulted in the text showing up… but always as a shade of white./yellowish depending on the color i set the text to be.
What am I doing wrong?