Jump to content
  • Advertisement
Sign in to follow this  
3dnewbie

bitmap font doesnt display

This topic is 4273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);
  }
}
What am i doing wrong????

Share this post


Link to post
Share on other sites
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!