PDA

View Full Version : glutBitmapCharacter delayed display



newbie1002
10-02-2011, 01:56 PM
Hi everyone,

I'm a newbie to opengl so I appreciate any help with the program below. (Sorry if this post appears twice. IE shut down when I first try to post this message.)

I have a problem getting the following program to display the string "abc" immediately. When I first run the program, the window is blank (white). Only after I toggle the opengl window another, then the string "abc" appears.

Thanks.
-newbie


#include <GL/glut.h>

void init()
{
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0f, 400.0f, 0.0f, 400.0f);
glViewport(0, 0, 100, 100);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glRasterPos2i(50, 200);
glColor3f(0.0f, 0.0f, 1.0f);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'a');
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'b');
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'c');
glFlush();
}

int main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("");
glutDisplayFunc(display);
init();
glutMainLoop();
return 0;
}