PDA

View Full Version : displaying font charcters on windows XP



fredocom
05-09-2002, 03:29 AM
Hi,

I encounter a problem when I try to display text with Opengl/glut. I use glutBitmapCharacter. The following program works very well on Win 98 and linux but on my notebook which turns with Win XP, there are problems with text displaying. If you have a notebook, could you test my code?
I need to know if the problem comes from XP or the hardware associated with notebook (low refresh rate of the monitor, LCD screen...).

#include < GL/glut.h >
#include < stdio.h >
#include < stdlib.h >
#include < string.h >

int font=(int)GLUT_BITMAP_8_BY_13;
int bitmapHeight=13;

int frame,time,timebase=0;
char s[30];


void renderBitmapString(float x, float y, void *font,char *string)
{

char *c;
glRasterPos2f(x, y);
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(font, *c);
}
}

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
glEnable(GL_DEPTH_TEST);

}

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

frame++;
time=glutGet(GLUT_ELAPSED_TIME);
if (time - timebase > 1000) {
sprintf(s,"FPS:%4.2f",frame*1000.0/(time-timebase));
timebase = time;
frame = 0;
}
glColor3f(0.0f,1.0f,1.0f);
renderBitmapString(-9.5,7.2,(void *)font,"Displaying test");
renderBitmapString(-9.5,6.0,(void *)font,"The low part of the letters disappear");
renderBitmapString(-9.5,5.0,(void *)font,"I encounter this problem only on notebook with Win XP");
renderBitmapString(-9.5,4.0,(void *)font,"GLUT bug or problem with screen?");
renderBitmapString(-9.5,3.0,(void *)font,s);

glutSwapBuffers();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D(-10,10,-10,10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow("displaying text");
init();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
return 0;
}