PDA

View Full Version : glutBitmapCharacter doesn't work at all



Registrar
02-12-2011, 05:46 PM
Whenever I try to use glutBitmapCharacter it doesn't show anything on the screen. What things do you need to have enabled/disabled for this function to work?

This is my rendering code that is run inside my main loop:


glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();

glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
gluOrtho2D (0, windowinfo->width, windowinfo->width, 0);
glRasterPos2i(0,0);
glutBitmapCharacter (GLUT_BITMAP_9_BY_15, 'H');
glPopMatrix ();


This is my GL initialization code:


glShadeModel (GL_SMOOTH);

glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth (0.1f);

glEnable (GL_DEPTH_TEST);
glEnable (GL_TEXTURE_2D);
glDepthFunc (GL_LEQUAL);
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);

MaxH
02-12-2011, 11:11 PM
You're trying to display the character in the very corner of the window. Maybe it's getting clipped? Try displaying it near the middle of the window first. Then see how close you can get it to the corner. I don't see any color declared? Maybe you're drawing a black character over a black background? Also, to make sure the gl is set up properly, try to display a few points near the middle of the window. I'm not convinced it's a glutBitmap problem.

Registrar
02-13-2011, 12:35 AM
I did what you said and found out that it was being drawn bottom up from the origin, and (0,0) was one pixel outside of the screen because my glOrtho was being setup with the client rect. Is there anyway to make it so it's being drawn from the top down?

mobeen
02-13-2011, 05:50 AM
Is there anyway to make it so it's being drawn from the top down?
add the following scaling transformation

glScalef(1,-1,1);