Changeset 412
- Timestamp:
- 04/14/11 16:18:35 (2 years ago)
- Location:
- branches/workbranch/trunk
- Files:
-
- 3 added
- 2 modified
-
3dc/font.cpp (modified) (5 diffs)
-
3dc/font2.h (modified) (2 diffs)
-
images/aa_font_512.dat (added)
-
images/aa_font_512.png (added)
-
images/credits.txt (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/workbranch/trunk/3dc/font.cpp
r400 r412 52 52 { 53 53 enum FONT_TYPE type; 54 uint32_t textureWidth;55 uint32_t textureHeight;54 // uint32_t textureWidth; 55 // uint32_t textureHeight; 56 56 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; 60 60 BFD desc; 61 61 }; … … 73 73 void Font_Init() 74 74 { 75 Fonts[FONT_SMALL].textureID = Tex_CreateFromFile(" test_font.tga");75 Fonts[FONT_SMALL].textureID = Tex_CreateFromFile("aa_font_grid_512.png"); 76 76 77 77 // zero out all values in the description struct 78 78 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); 79 83 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 */ 80 108 // see if there's a font description file 81 109 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); 83 111 84 112 if (infile.good()) … … 97 125 98 126 // 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); 104 128 } 105 129 106 uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE fontType)130 uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE_2 fontType) 107 131 { 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); 110 134 111 135 uint32_t charIndex = 0; 112 uint32_t charHeight = 16;136 uint32_t charHeight = Fonts[FONT_SMALL].desc.mapHeight / 16; 113 137 114 138 while (charIndex < text.size()) … … 122 146 uint32_t column = c % 16; // get column from remainder value 123 147 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; 126 150 127 151 // generate the texture UVs for this character … … 152 176 else 153 177 { 154 x += Fonts[FONT_SMALL]. blockWidth;178 x += Fonts[FONT_SMALL].desc.cellWidth; 155 179 } 156 180 -
branches/workbranch/trunk/3dc/font2.h
r278 r412 29 29 #include <stdint.h> 30 30 31 enum FONT_TYPE 31 enum FONT_TYPE_2 // fixme 32 32 { 33 33 FONT_SMALL, … … 37 37 38 38 void Font_Init(); 39 uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE fontType);39 uint32_t Font_DrawText(const std::string &text, uint32_t x, uint32_t y, uint32_t colour, enum FONT_TYPE_2 fontType); 40 40 void Font_Release(); 41 41