Changeset 412

Show
Ignore:
Timestamp:
04/14/11 16:18:35 (2 years ago)
Author:
sirlemonhead
Message:

- tidied up font.cpp and changed to directly using some BFD desc struct values. font.cpp and font.h still need major rewrite.
- added credits.txt for the additional image files in SVN

Location:
branches/workbranch/trunk
Files:
3 added
2 modified

Legend:

Unmodified
Added
Removed
  • branches/workbranch/trunk/3dc/font.cpp

    r400 r412  
    5252{ 
    5353        enum FONT_TYPE  type; 
    54         uint32_t        textureWidth; 
    55         uint32_t        textureHeight; 
     54//      uint32_t        textureWidth; 
     55//      uint32_t        textureHeight; 
    5656        texID_t     textureID; 
    57         uint32_t        fontWidths[256]; 
    58         uint32_t        blockWidth; 
    59         uint32_t        blockHeight; 
     57//      uint32_t        fontWidths[256]; 
     58//      uint32_t        blockWidth; 
     59//      uint32_t        blockHeight; 
    6060        BFD                     desc; 
    6161}; 
     
    7373void Font_Init() 
    7474{ 
    75         Fonts[FONT_SMALL].textureID = Tex_CreateFromFile("test_font.tga"); 
     75        Fonts[FONT_SMALL].textureID = Tex_CreateFromFile("aa_font_grid_512.png"); 
    7676 
    7777        // zero out all values in the description struct 
    7878        memset(&Fonts[FONT_SMALL].desc, 0, sizeof(BFD)); 
     79/* 
     80        // write data file 
     81        std::ofstream outfile; 
     82        outfile.open("c:/tv/test1.dat", std::ofstream::out | std::ofstream::binary); 
    7983 
     84        if (outfile.good()) 
     85        { 
     86                unsigned val = 1024/2; 
     87                outfile.write(reinterpret_cast<char*>(&val), sizeof(unsigned)); 
     88                outfile.write(reinterpret_cast<char*>(&val), sizeof(unsigned)); 
     89 
     90                val = 64/2; 
     91 
     92                outfile.write(reinterpret_cast<char*>(&val), sizeof(unsigned)); 
     93                outfile.write(reinterpret_cast<char*>(&val), sizeof(unsigned)); 
     94 
     95                char start = ' '; 
     96                outfile.write(reinterpret_cast<char*>(&val), sizeof(char)); 
     97 
     98                char widths[256]; 
     99                for (int i = 0; i < 255; i++) 
     100                { 
     101                        widths[i] = 22; 
     102                } 
     103                 
     104                outfile.write(reinterpret_cast<char*>(&widths), 256); 
     105                outfile.close(); 
     106        } 
     107*/ 
    80108        // see if there's a font description file 
    81109        std::ifstream infile; 
    82         infile.open("test_font.dat", std::ifstream::in | std::ifstream::binary); 
     110        infile.open("aa_font_grid_512.dat", std::ifstream::in | std::ifstream::binary); 
    83111 
    84112        if (infile.good()) 
     
    97125 
    98126        // get the font texture width and height 
    99         Tex_GetDimensions(Fonts[FONT_SMALL].textureID, Fonts[FONT_SMALL].textureWidth, Fonts[FONT_SMALL].textureHeight); 
    100  
    101         // work out how big each character cell/block is 
    102         Fonts[FONT_SMALL].blockWidth = Fonts[FONT_SMALL].textureWidth / 16; 
    103         Fonts[FONT_SMALL].blockHeight = Fonts[FONT_SMALL].textureHeight / 16; 
     127        Tex_GetDimensions(Fonts[FONT_SMALL].textureID, Fonts[FONT_SMALL].desc.mapWidth, Fonts[FONT_SMALL].desc.mapHeight); 
    104128} 
    105129 
    106 uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE fontType) 
     130uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE_2 fontType) 
    107131{ 
    108         float RecipW = (1.0f / Fonts[FONT_SMALL].textureWidth); 
    109         float RecipH = (1.0f / Fonts[FONT_SMALL].textureHeight); 
     132        float RecipW = (1.0f / Fonts[FONT_SMALL].desc.mapWidth); 
     133        float RecipH = (1.0f / Fonts[FONT_SMALL].desc.mapHeight); 
    110134 
    111135        uint32_t charIndex = 0; 
    112         uint32_t charHeight = 16; 
     136        uint32_t charHeight = Fonts[FONT_SMALL].desc.mapHeight / 16; 
    113137 
    114138        while (charIndex < text.size()) 
     
    122146                uint32_t column = c % 16;                       // get column from remainder value 
    123147 
    124                 uint32_t tex_x = column * Fonts[FONT_SMALL].blockWidth; 
    125                 uint32_t tex_y = row * Fonts[FONT_SMALL].blockHeight; 
     148                uint32_t tex_x = column * Fonts[FONT_SMALL].desc.cellWidth; 
     149                uint32_t tex_y = row * Fonts[FONT_SMALL].desc.cellHeight; 
    126150 
    127151                // generate the texture UVs for this character 
     
    152176                else 
    153177                { 
    154                         x += Fonts[FONT_SMALL].blockWidth; 
     178                        x += Fonts[FONT_SMALL].desc.cellWidth; 
    155179                } 
    156180 
  • branches/workbranch/trunk/3dc/font2.h

    r278 r412  
    2929#include <stdint.h> 
    3030 
    31 enum FONT_TYPE 
     31enum FONT_TYPE_2 // fixme 
    3232{ 
    3333        FONT_SMALL, 
     
    3737 
    3838void Font_Init(); 
    39 uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE fontType); 
     39uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE_2 fontType); 
    4040void Font_Release(); 
    4141