Sign in to follow this  
3dnewbie

bitmap font doesnt display

Recommended Posts

3dnewbie    100
i'm going nuts here. after another poster pointed out that i used an y coordinate which i shouldnt be using, i now think this should work. but i don't see anything..:-( this just creates a matrix of quads
	glBegin(GL_LINES);
	
	for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {
	for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {
	
		/* Set color for QUADS */
		glColor4f(0.0,0.2,0.0,1.0);
		
		/* Draw QUADS */
		glVertex3f(x,y,0); /* left */
		glVertex3f(x,y+SECTOR_SIZE,0); /* left */ 
		glVertex3f(x,y,0); /* right up*/ 
		glVertex3f(x+SECTOR_SIZE,y,0); /* right down */
		glVertex3f(x+SECTOR_SIZE,y+SECTOR_SIZE,0); /* leftbottom */
		glVertex3f(x,y+SECTOR_SIZE,0); /* rightbottom */ 
		glVertex3f(x+SECTOR_SIZE,y,0); /* leftupper*/ 
		glVertex3f(x+SECTOR_SIZE,y+SECTOR_SIZE,0);
		
		}
	}	
	glEnd();
and this is the font function:
void renderbitmapfont(GLfloat x, GLfloat y, GLfloat z,char *string)
{
  int len, i;

  glRasterPos3f(x, y,z);
  len = (int) strlen(string);
  for (i = 0; i < len; i++) {
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, string[i]);
  }
}
What am i doing wrong????

Share this post


Link to post
Share on other sites
Captain P    1092
Have you checked the following things already?

- Quad direction. Perhaps you're rendering the quads backwards while you're culling back sides? Can be tested by disabling culling.
- Order. Perhaps something else gets displayed in front? Can be tested by only rendering the font.
- Out of view. Maybe - unlikely perhaps - you're rendering somewhere outside the screen?

Oh, bytheway, I'd use std::string rather than char* if I were you. Less error-prone, and it's the standard C++ string anyway. You're not working in C, aren't you? :)

Share this post


Link to post
Share on other sites
3dnewbie    100
Hi CaptainP,
I tried rendering them without anything else, nothing.
I disabled pretty much everything (texturing,depth test, culling) no go.

I had it (sort of) working yesterday. sometimes when something is printed out of screen it's hard to find :-P
But i can actually notice when it is being drawn, as that string printed for every coordinate will slow things down to a halt :-)

I don't know what std::string is. Ofcourse i use C, real men use that :-)

but i will fiddle on.


PS when i use the renderstrokefont function, i just get blank screen with a noticabely slowed down app with a strange glow on it :-(. I'm almost beginning to think that GLUT on a mac doesn't have these fonts compiled in or something, where it not for the fact that yesterday i actually had something printed on the screen, far far in the depths of it.


glBegin(GL_QUADS);

for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {
for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {

/* Set color for QUADS */
glColor4f(0.0f,0.0f,0.1f,0.5f);

/* Draw QUADS */
glVertex3f(x,y,0); /* left */
glVertex3f(x,y+SECTOR_SIZE,0); /* left */
glVertex3f(x,y,0); /* right up*/
glVertex3f(x+SECTOR_SIZE,y,0); /* right down */
glVertex3f(x+SECTOR_SIZE,y+SECTOR_SIZE,0); /* leftbottom */
glVertex3f(x,y+SECTOR_SIZE,0); /* rightbottom */
glVertex3f(x+SECTOR_SIZE,y,0); /* leftupper*/
glVertex3f(x+SECTOR_SIZE,y+SECTOR_SIZE,0);

glColor4f(1.0f,1.0f,1.0f,1.0f);
renderstrokefont(x,y,0,"%f %f",x,y);
}
}
glEnd();


renderstrokefunction:

void renderstrokefont(GLfloat x, GLfloat y, GLfloat z,char *format,...)
{
va_list args;
char buffer[200], *p;

va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);

glPushMatrix();
glTranslatef(x, y, z);
glScalef(0.005, 0.005, 0.005);
for (p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
}


[Edited by - 3dnewbie on November 8, 2006 11:16:49 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this