I'm trying to implement texture-mapped-font drawer in OpenGL.
It currently works like so:
1. Load a .fnt file (containing character description, position etc).
2. Load a texture.
3. Splice the texture into smaller sub-textures according to the fnt file.
4. Assign each sub-texture to its character.
Is it really necessary though? Can I not somehow only draw the parts I need from the bigger texture map? Or do I actually have to generate the sub-textures.
Vertex texture coordinates will allow you to 'address' different sections of the image.
Texture coordinates will always satisfy 0.0 > value > 1.0 and in your case will be:
u = texel_coord_x / texture_width;
v = texel_coord_y / texture_height;
Isnt it 0.0<=value<=1.0?
Originally Posted by Bubba
Or have i been away from programming for so long?
Um..yes it is. My inequality is incorrect.
Thanks, this is just what I was looking for. Will try it right after work
Great! I used this technique to calculate u,v values for every character and reused them in my drawing function.
result. Thanks : )