views:

33

answers:

1

I'm implementing a simple font renderer in OpenGL and have a few questions regarding that

It basically loads an image with characters on them into an OpenGL texture

  • Is it better to have one big texture with all characters on it, or can I have one texture per character as well?

  • Using the big texture, I can't seem to figure out how to correctly draw a quad with one character from the texture on it.

Let's say the whole texture is 256 * 256, and each character is 16 * 16

I want to draw a quad which is 16 * 16 and map one character from the texture on it

I have tried glTexCoord2f() but that only works with ranges from 0-1

+2  A: 

1.- It's better for performance to have one big texture with all the characters. This is called a Texture Atlas.

2.- To get the texture coordinates, convert from pixel coords to texture coords dividing by the width and height. For example, pixel (16, 16) has texture coords (16 / 256.0, 16 / 256.0).

Matias Valdenegro