Creating sub-textures

This is a discussion on Creating sub-textures within the Game Programming forums, part of the General Programming Boards category; Hi I'm trying to implement texture-mapped-font drawer in OpenGL. It currently works like so: 1. Load a .fnt file (containing ...

  1. #1
    glo
    glo is offline
    Registered User
    Join Date
    May 2006
    Posts
    169

    Creating sub-textures

    Hi

    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.
    Something like:
    Code:
    glTexCoordxxxx(StartX,StartY,PixelWidth,PixelHeight)
    Thanks!

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,597
    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;
    Last edited by VirtualAce; 12-27-2008 at 02:58 PM.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    1,209
    Quote Originally Posted by Bubba View Post
    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?

    Or have i been away from programming for so long?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,597
    Um..yes it is. My inequality is incorrect.

  5. #5
    glo
    glo is offline
    Registered User
    Join Date
    May 2006
    Posts
    169
    Thanks, this is just what I was looking for. Will try it right after work

  6. #6
    glo
    glo is offline
    Registered User
    Join Date
    May 2006
    Posts
    169
    Great! I used this technique to calculate u,v values for every character and reused them in my drawing function.
    result. Thanks : )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Textures
    By fighter92 in forum Game Programming
    Replies: 1
    Last Post: 03-21-2009, 11:57 AM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 10:38 AM
  3. Textures not setting properly.
    By psychopath in forum Game Programming
    Replies: 5
    Last Post: 07-24-2006, 11:54 PM
  4. loading textures from resources (dx8/9)
    By X PaYnE X in forum Game Programming
    Replies: 1
    Last Post: 12-25-2005, 04:44 PM
  5. the effects of textures on my frame rate
    By DavidP in forum Game Programming
    Replies: 37
    Last Post: 10-03-2003, 12:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21