Ignore:
Timestamp:
Jan 23, 2011, 6:52:58 PM (10 years ago)
Author:
sam
Message:

Fix font rendering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/font.cpp

    r269 r272  
    4242    SDL_Surface *img;
    4343    int width, height;
     44    float tx, ty;
    4445    GLuint texture;
    4546};
     
    6566    }
    6667
     68    data->width = data->img->w / 16;
     69    data->height = data->img->h / 16;
     70    data->tx = 7.0f / PotUp(data->img->w);
     71    data->ty = 15.0f / PotUp(data->img->h);
     72
    6773    drawgroup = DRAWGROUP_BEFORE;
    6874}
     
    8692    else if (data->img)
    8793    {
    88         data->width = data->img->w / 16;
    89         data->height = data->img->h / 16;
    90 
    9194        GLuint format = data->img->format->Amask ? GL_RGBA : GL_RGB;
    9295        int planes = data->img->format->Amask ? 4 : 3;
     
    137140    {
    138141        uint32_t ch = (uint8_t)*str++;
    139         float tx = .0625f * (ch & 0xf);
    140         float ty = .0625f * ((ch >> 4) & 0xf);
     142        float tx = data->tx * (ch & 0xf);
     143        float ty = data->ty * ((ch >> 4) & 0xf);
    141144
    142145        if (ch != ' ')
    143146        {
    144             glTexCoord2f(tx, ty + .0625f);
     147            glTexCoord2f(tx, ty + data->ty);
    145148            glVertex2f(x, y);
    146             glTexCoord2f(tx + .0625f, ty + .0625f);
     149            glTexCoord2f(tx + data->tx, ty + data->ty);
    147150            glVertex2f(x + data->width, y);
    148             glTexCoord2f(tx + .0625f, ty);
     151            glTexCoord2f(tx + data->tx, ty);
    149152            glVertex2f(x + data->width, y + data->height);
    150153            glTexCoord2f(tx, ty);
Note: See TracChangeset for help on using the changeset viewer.