瀏覽代碼

Fixed Font character placement.

glPrintf now also activates the string.
Thomas Buck 11 年之前
父節點
當前提交
ec2d858b4e
共有 3 個檔案被更改,包括 16 行新增11 行删除
  1. 4
    0
      src/GLString.cpp
  2. 5
    10
      src/Render.cpp
  3. 7
    1
      src/Texture.cpp

+ 4
- 0
src/GLString.cpp 查看文件

118
     if (_num_string > _num_string_max)
118
     if (_num_string > _num_string_max)
119
         return -2;
119
         return -2;
120
 
120
 
121
+    // xythobuz 2014.02.23, Activate, so we don't have to call SetString
122
+    // directly after glPrintf, with the same text...
123
+    _string[_num_string].active = true;
124
+
121
     // Mongoose 2002.01.01, Assume no longer than 'sz' wide lines
125
     // Mongoose 2002.01.01, Assume no longer than 'sz' wide lines
122
     //   on first try
126
     //   on first try
123
     _string[_num_string].text = new char[sz];
127
     _string[_num_string].text = new char[sz];

+ 5
- 10
src/Render.cpp 查看文件

259
     mString.Init(5);
259
     mString.Init(5);
260
 
260
 
261
     // String 0: OpenRaider version in lower right corner
261
     // String 0: OpenRaider version in lower right corner
262
-    mString.Scale(1.00);
262
+    mString.Scale(0.75f);
263
     err = mString.glPrintf(mWidth - 15 * strlen(VERSION),
263
     err = mString.glPrintf(mWidth - 15 * strlen(VERSION),
264
             mHeight-35, "%s", VERSION);
264
             mHeight-35, "%s", VERSION);
265
-    mString.SetString(0, "%s", VERSION);
266
 
265
 
267
     if (err)
266
     if (err)
268
     {
267
     {
270
     }
269
     }
271
 
270
 
272
     // String 1: Used for FPS in game text output
271
     // String 1: Used for FPS in game text output
273
-    mString.Scale(0.75);
272
+    mString.Scale(0.60f);
274
     err = mString.glPrintf(8, mHeight - 25, "%s", "                ");
273
     err = mString.glPrintf(8, mHeight - 25, "%s", "                ");
275
-    mString.SetString(1, "%s", "                ");
276
 
274
 
277
     if (err)
275
     if (err)
278
     {
276
     {
280
     }
278
     }
281
 
279
 
282
     // String 2: Used for game console
280
     // String 2: Used for game console
283
-    mString.Scale(1.0);
281
+    mString.Scale(0.75f);
284
     err = mString.glPrintf(8, 25, "%s", console);
282
     err = mString.glPrintf(8, 25, "%s", console);
285
-    mString.SetString(2, "%s", console);
286
 
283
 
287
     if (err)
284
     if (err)
288
     {
285
     {
290
     }
287
     }
291
 
288
 
292
     // String 3: Used for one line map select menu
289
     // String 3: Used for one line map select menu
293
-    mString.Scale(1.75);
290
+    mString.Scale(1.25f);
294
     err = mString.glPrintf(mWidth/2-235, mHeight/2-24, "%s", menu);
291
     err = mString.glPrintf(mWidth/2-235, mHeight/2-24, "%s", menu);
295
-    mString.SetString(3, "%s", menu);
296
 
292
 
297
     if (err)
293
     if (err)
298
     {
294
     {
300
     }
296
     }
301
 
297
 
302
     // String 4: Used for one line in game text output
298
     // String 4: Used for one line in game text output
303
-    mString.Scale(1.0);
299
+    mString.Scale(0.75f);
304
     err = mString.glPrintf(8, 55, "%s", "                    ");
300
     err = mString.glPrintf(8, 55, "%s", "                    ");
305
-    mString.SetString(4, "%s", "                    ");
306
 
301
 
307
     if (err)
302
     if (err)
308
     {
303
     {

+ 7
- 1
src/Texture.cpp 查看文件

320
             h = 0;
320
             h = 0;
321
         }
321
         }
322
 
322
 
323
-        h += -texture->fontHeight/2-(texture->fontDescent + texture->glyphs[i].miny);
323
+        // After migrating to SDL2_TTF, some characters where rendered slightly
324
+        // vertically offset. However, dumping the font texture as TGA did not show
325
+        // this offset. It turns out, this fixes the issue...? O.o --xythobuz
326
+        // h += -texture->fontHeight/2-(texture->fontDescent + texture->glyphs[i].miny);
327
+        h -= texture->fontHeight/2 + texture->fontDescent;
324
 
328
 
325
         /* Make a list for this TTF glyph, one nonuniform Quad per glyph */
329
         /* Make a list for this TTF glyph, one nonuniform Quad per glyph */
326
         glNewList(font->drawListBase + i, GL_COMPILE);
330
         glNewList(font->drawListBase + i, GL_COMPILE);
405
     int renderStyle = TTF_STYLE_NORMAL;
409
     int renderStyle = TTF_STYLE_NORMAL;
406
     TTF_SetFontStyle(font, renderStyle);
410
     TTF_SetFontStyle(font, renderStyle);
407
 
411
 
412
+    TTF_SetFontHinting(font, TTF_HINTING_LIGHT);
413
+
408
     /* Allocate a new TTF font texture */
414
     /* Allocate a new TTF font texture */
409
     printf("Creating font texture from '%s'...\n", filename);
415
     printf("Creating font texture from '%s'...\n", filename);
410
     texture = new ttf_texture_t;
416
     texture = new ttf_texture_t;

Loading…
取消
儲存