Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Custom Bitmap Fonts

This topic is 5743 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 have been doing tutorial 17 - Texture Fonts and have become stuck. I am trying to adopt the code to fit a 100x100 pixel bitmap with each character being 10x10 pixels. I have modified the build font function and is here in full:
void BuildFont()
	// x, y positions of character inside the font
	float charX, charY;

	// generate display lists
	base = glGenLists(100);

	// select the font texture
	glBindTexture(GL_TEXTURE_2D, fontTexture);

	for(int loop = 0; loop < 100; loop++)
		// find the coordinate of the character we wish to build a quad for
		charX = float(loop % 10) / 10;
		charY = float(loop / 10) / 10;

		// start building a lisplay list for the character selected
		glNewList(base + loop, GL_COMPILE);

			// begin building the quad
				// texture coord for bottom left
				glTexCoord2f(charX, 1 - charY - 0.1f);

				// quad coord bottom left
				glVertex2i(0, 0);

				// ----------------------------------

				// texture coord bottom right
				glTexCoord2f(charX + 0.1f, 1 - charY - 0.1f);

				// quad coord bottom right
				glVertex2i(10, 0);

				// ----------------------------------

				// texture coord top right
				glTexCoord2f(charX + 0.1f, 1 - charY);

				// quad coord top right
				glVertex2i(10, 10);

				// ----------------------------------

				// texture coord top left
				glTexCoord2f(charX, 1 - charY);

				// quad coord top left
				glVertex2i(0, 10);

			// finished building the character quad

			// move to the right for the next character
			glTranslated(10, 0, 0);
		// finished building display list
Is my problem related to the fact that OpenGL or my graphics drivers can only load textures with dimentions of powers of 2? or is my code wrong? I haven't had problems with non ^2 textures before with my current card, can anyone suggest anything? Thanks, sckoobs [edited by - sckoobs on October 3, 2002 12:11:27 PM]

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
all textures in opengl must be powers of two, so 100x100 won''t work,
but 128x128 works. characters can be 10x10, just add black pixels to
your image so it is 128x128.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!