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

Why doesnt this work??? bitmap fonts

This topic is 4272 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 desperately trying to but a xy coordinate with a bitmapped font in the very sector i draw, but i get nothing at all.. i tested it out before outside of the loop, and it works, although i'm not sure what coordinate system i should use.
GLfloat angle,a,s,d;

GLvoid display(void)
{
	GLfloat x,y;
		
	/* Clear color and depth buffer [specified in init()] */
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	
	/* Reset MODELVIEW and PROJECTION matrices */
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	/* Initialization mode. Here we 	maintain our grid. */
	glTranslatef(0.0,0.0,-6.0);
	/* This will rotate local coordinate system!*/
	//for(a=0.0;a<95.0;a+=1.1) 
	glRotatef(a,1.0f,0.0f,0.0f);
	glRotatef(s,0.0f,1.0f,0.0f);
	glRotatef(d,0.0f,0.0f,1.0f);
	
	glMatrixMode(GL_PROJECTION);
	//glLoadIdentity();
	
	/* Setup our main grid. We use QUADS and POINTS to 
	define the sectors. The QUADS are using blending. */
	
	glBegin(GL_QUADS);
	
	for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {
	glColor4f(1.0,1.0,1.0,0.0);
	renderbitmapfont(x,y,0,GLUT_BITMAP_TIMES_ROMAN_10,"TEST");
	glColor4f(0.0,0.0,0.1,1.0);
		for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {
		glVertex3f(x-SECTOR_SIZE,y,0); 
		glVertex3f(x,y,0); 
		glVertex3f(x-SECTOR_SIZE,y-SECTOR_SIZE,0); 
		glVertex3f(x,y-SECTOR_SIZE,0); 
		glVertex3f(x-SECTOR_SIZE,y,0);
		glVertex3f(x-SECTOR_SIZE,y-SECTOR_SIZE,0);
		glVertex3f(x,y,0);
		glVertex3f(x,y-SECTOR_SIZE,0);
		}
		glColor4f(1.0,1.0,1.0,0.0);
		renderbitmapfont(x,y,0,GLUT_BITMAP_TIMES_ROMAN_10,"TEST");
	}
	glEnd();
	
	glColor4f(0.5,0.0,0.0,1.0);
	glBegin(GL_LINES);
	
	for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {
		for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {
		glVertex3f(x-SECTOR_SIZE,y,0); 
		glVertex3f(x,y,0); 
		glVertex3f(x-SECTOR_SIZE,y-SECTOR_SIZE,0); 
		glVertex3f(x,y-SECTOR_SIZE,0); 
		glVertex3f(x-SECTOR_SIZE,y,0);
		glVertex3f(x-SECTOR_SIZE,y-SECTOR_SIZE,0);
		glVertex3f(x,y,0);
		glVertex3f(x,y-SECTOR_SIZE,0);
		}
	}
	glEnd();
	
		
	glFlush();
	glutSwapBuffers();
	}
the bitmap function is :
void renderbitmapfont(GLint x,GLint y,GLint z,void *font,char *string)
{
	char *c;
	
	/* Set position of text */
	glRasterPos3f(x,y,z);
	
	for (c=string;*c!='\0';c++) {
    glutBitmapCharacter(font, *c);
  }
  
}
Please help because i'm going completely crazy.

Share this post


Link to post
Share on other sites
Advertisement

for(x=-10.0;x<GRID_SIZE;x+=SECTOR_SIZE) {
glColor4f(1.0,1.0,1.0,0.0);
renderbitmapfont(x,y,0,GLUT_BITMAP_TIMES_ROMAN_10,"TEST");
glColor4f(0.0,0.0,0.1,1.0);
for(y=-10.0;y<GRID_SIZE;y+=SECTOR_SIZE) {


You are using y outside of the the loop in which it is set. I'm not sure what you really intended, so I can't tell you exactly how to fix it, but you definitely don't want to be referencing y outside of the for-loop that sets it.

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!