Browse Source

fix char size initialisation in text renderer was not done in release mode

Kolja Strohm 1 year ago
parent
commit
cde44107c8
6 changed files with 97 additions and 86 deletions
  1. 22 22
      DX12PixelShader.h
  2. 17 17
      DX12VertexShader.h
  3. 15 4
      Schrift.cpp
  4. 5 5
      Schrift.h
  5. 23 23
      UIPixelShader.h
  6. 15 15
      UIVertexShader.h

+ 22 - 22
DX12PixelShader.h

@@ -92,10 +92,10 @@ ret
 
 const BYTE DX12PixelShaderBytes[] =
 {
-     68,  88,  66,  67, 106, 100, 
-     24,  67, 240, 139,  75, 223, 
-     36,  35,  96, 228, 153, 147, 
-    175,  74,   1,   0,   0,   0, 
+     68,  88,  66,  67, 130, 118, 
+     55, 198, 119, 198,  66,  41, 
+    214, 197,  90,  55,  12,  26, 
+     41, 189,   1,   0,   0,   0, 
     184,  91,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      36,   2,   0,   0, 188,   2, 
@@ -763,11 +763,11 @@ const BYTE DX12PixelShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0, 148,  46, 
-     49,   1, 169, 100, 225,  99, 
-      1,   0,   0,   0, 149,  24, 
-    172, 238, 136,  32, 242,  68, 
-    179,  34, 183, 214,  99, 158, 
-    126,  89,   0,   0,   0,   0, 
+     49,   1, 117, 255, 241,  99, 
+      1,   0,   0,   0,  86,  57, 
+    173, 209,  65,  69, 253,  66, 
+    164, 223,  93,  14, 137, 186, 
+     22,  14,   0,   0,   0,   0, 
       0,   0,   0,   0,   1,   0, 
       0,   0,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -938,10 +938,10 @@ const BYTE DX12PixelShaderBytes[] =
       3,   0, 242,  56,   1,   0, 
      43, 236,   3,   0,  28,  19, 
       2,   0,  65,  36,   1,   0, 
-    236, 179,   1,   0,  78,  83, 
-      3,   0, 125,  10,   2,   0, 
-    125, 181,   2,   0,  28, 222, 
-      2,   0, 193,  33,   3,   0, 
+    236, 179,   1,   0, 183, 203, 
+      0,   0, 125,  10,   2,   0, 
+    125, 181,   2,   0, 245,  69, 
+      1,   0, 193,  33,   3,   0, 
      65, 185,   2,   0, 140, 239, 
       1,   0, 246,  49,   0,   0, 
     213, 255,   0,   0,  46, 248, 
@@ -1788,7 +1788,7 @@ const BYTE DX12PixelShaderBytes[] =
     117, 114, 101,  50,  68,  32, 
     115, 104,  97, 100,  27, 226, 
      48,   1, 128,   0,   0,   0, 
-     44, 231, 187, 155, 106,  58, 
+    239, 173, 245,  71,  80,  68, 
     217,   1,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2348,14 +2348,14 @@ const BYTE DX12PixelShaderBytes[] =
       0,   0,  23,   0,   1,   0, 
       5,  16,   0,   0,  14,   0, 
      23,  21,   0,  16,   0,   0, 
-      3,   2, 128, 225,   0,   0, 
+      3,   2, 112,  32,   0,   0, 
     242, 241,  10,   0,  24,  21, 
       8,  16,   0,   0,   1,   0, 
       1,   0,  10,   0,  24,  21, 
       9,  16,   0,   0,   1,   0, 
       0,   2,  14,   0,  23,  21, 
       0,   0,   0,   0,  10,   2, 
-    128, 225,   0,   0, 242, 241, 
+    112,  32,   0,   0, 242, 241, 
      10,   0,  24,  21,  11,  16, 
       0,   0,   1,   0,   1,   0, 
      10,   0,  24,  21,  12,  16, 
@@ -3408,11 +3408,11 @@ const BYTE DX12PixelShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-    148,  46,  49,   1, 169, 100, 
-    225,  99,   1,   0,   0,   0, 
-    149,  24, 172, 238, 136,  32, 
-    242,  68, 179,  34, 183, 214, 
-     99, 158, 126,  89, 128,   0, 
+    148,  46,  49,   1, 117, 255, 
+    241,  99,   1,   0,   0,   0, 
+     86,  57, 173, 209,  65,  69, 
+    253,  66, 164, 223,  93,  14, 
+    137, 186,  22,  14, 128,   0, 
       0,   0,  47,  76, 105, 110, 
     107,  73, 110, 102, 111,   0, 
      47, 110,  97, 109, 101, 115, 
@@ -3512,7 +3512,7 @@ const BYTE DX12PixelShaderBytes[] =
       0,   0,   2,   0,   9,   0, 
     220,   4,   0,   0,   0,   0, 
       0,   0, 156,   1,   0,   0, 
-      1,   0, 214,   7,   0,   0, 
+      1,   0,  97, 180,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0, 109,  97, 
     105, 110,   0, 110, 111, 110, 

+ 17 - 17
DX12VertexShader.h

@@ -131,10 +131,10 @@ ret
 
 const BYTE DX12VertexShaderBytes[] =
 {
-     68,  88,  66,  67,  73, 144, 
-     61, 105,  52, 138, 238,  75, 
-    165, 215, 161, 104, 110, 167, 
-    124, 255,   1,   0,   0,   0, 
+     68,  88,  66,  67, 163,  95, 
+     37, 125, 222,   0,  51, 204, 
+     22, 173, 114, 162,  38,   6, 
+     78, 102,   1,   0,   0,   0, 
     144,  78,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     124,   2,   0,   0,  52,   3, 
@@ -923,11 +923,11 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-    148,  46,  49,   1, 169, 100, 
-    225,  99,   1,   0,   0,   0, 
-    170, 227, 236, 205, 133,  33, 
-    115,  68, 168,  90,  71, 147, 
-     11,   9, 216,  10,   0,   0, 
+    148,  46,  49,   1, 118, 255, 
+    241,  99,   1,   0,   0,   0, 
+     24,   9, 205,  58,  88,  67, 
+    175,  68, 179, 245, 225, 110, 
+    187, 251, 255, 130,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   1,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1103,7 +1103,7 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0, 103, 159,   1,   0, 
     179, 120,   1,   0, 238,  97, 
       2,   0,  90,  28,   0,   0, 
-    197,  72,   1,   0,  53, 174, 
+     19, 100,   0,   0,  53, 174, 
       3,   0, 206,  21,   0,   0, 
     193, 205,   3,   0, 207, 193, 
       1,   0,  62,   3,   3,   0, 
@@ -1607,7 +1607,7 @@ const BYTE DX12VertexShaderBytes[] =
      97, 109, 101, 114,  97,  13, 
      10, 115, 116, 114,  27, 226, 
      48,   1, 128,   0,   0,   0, 
-    169,  66, 212, 155, 106,  58, 
+    241, 190,  10,  72,  80,  68, 
     217,   1,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2125,7 +2125,7 @@ const BYTE DX12VertexShaderBytes[] =
      24,  21,  12,  16,   0,   0, 
       1,   0,   1,   0,  14,   0, 
      23,  21,  13,  16,   0,   0, 
-     36,   2,  80, 252,   0,   0, 
+     36,   2,   0,  80,   0,   0, 
     242, 241,  10,   0,  24,  21, 
      14,  16,   0,   0,   1,   0, 
       0,   2,  18,   0,  22,  21, 
@@ -3057,10 +3057,10 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 148,  46,  49,   1, 
-    169, 100, 225,  99,   1,   0, 
-      0,   0, 170, 227, 236, 205, 
-    133,  33, 115,  68, 168,  90, 
-     71, 147,  11,   9, 216,  10, 
+    118, 255, 241,  99,   1,   0, 
+      0,   0,  24,   9, 205,  58, 
+     88,  67, 175,  68, 179, 245, 
+    225, 110, 187, 251, 255, 130, 
     129,   0,   0,   0,  47,  76, 
     105, 110, 107,  73, 110, 102, 
     111,   0,  47, 110,  97, 109, 
@@ -3160,7 +3160,7 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0,   0,   0,   2,   0, 
       9,   0, 156,   5,   0,   0, 
       0,   0,   0,   0, 236,   2, 
-      0,   0,   1,   0,  28, 252, 
+      0,   0,   1,   0, 207,  79, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
     109,  97, 105, 110,   0, 110, 

+ 15 - 4
Schrift.cpp

@@ -292,6 +292,7 @@ TextRenderer::TextRenderer(Schrift* schrift)
     s = schrift;
     zeilenAbstand = 5;
     zeichenAbstand = 0;
+    schriftSize = 0;
     setSchriftSize(12);
 }
 
@@ -325,6 +326,11 @@ void TextRenderer::setSchriftZ(Schrift* schrift)
                                     * schriftSize
                                 + 0.5);
                 }
+                else
+                {
+                    charWidths[i] = 0;
+                    charHeights[i] = 0;
+                }
             }
         }
     }
@@ -372,6 +378,11 @@ void TextRenderer::setSchriftSize(int sg)
                                     * schriftSize
                                 + 0.5);
                 }
+                else
+                {
+                    charWidths[i] = 0;
+                    charHeights[i] = 0;
+                }
             }
         }
     }
@@ -1049,10 +1060,10 @@ void KursivTextRenderer::renderChar(int& x,
                                                               colorAlpha,
                                                               b,
                                                               color](
-                                                              int x, int y) {
-                    x -= (int)((float)(charHeight - y) / 4.f + 0.5f);
-                    if (x < 0 || x >= bufferBreite) return 0x00FFFFFF;
-                    int a = b->getBuff()[y * bufferBreite + x] - colorAlpha;
+                                                              int xx, int yy) {
+                    xx -= (int)((float)(charHeight - yy) / 4.f + 0.5f);
+                    if (xx < 0 || xx >= bufferBreite) return 0x00FFFFFF;
+                    int a = b->getBuff()[yy * bufferBreite + xx] - colorAlpha;
                     return color | (a << 24);
                 };
                 if (zRObj.hasAlpha3D())

+ 5 - 5
Schrift.h

@@ -332,15 +332,15 @@ namespace Framework
             int color,
             bool underlined = 0,
             bool selected = 0,
-            int selectedBackgroundColor = 0);
+            int selectedBackgroundColor = 0) override;
         //! Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten
         //! Buchstaben vollständig darzustellen \param c Der Buchstabe, von dem
         //! die Breite in Pixeln ermitelt werden soll
-        DLLEXPORT virtual int getCharWidth(const char c) const;
+        DLLEXPORT virtual int getCharWidth(const char c) const override;
         //! Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text
         //! vollständig darzustellen \param c Der Buchstabe, von dem die Höhe in
         //! Pixeln ermitelt werden soll
-        DLLEXPORT virtual int getCharHeight(const char c) const;
+        DLLEXPORT virtual int getCharHeight(const char c) const override;
     };
 
     class KursivTextRenderer : public TextRenderer
@@ -367,11 +367,11 @@ namespace Framework
             int color,
             bool underlined = 0,
             bool selected = 0,
-            int selectedBackgroundColor = 0);
+            int selectedBackgroundColor = 0) override;
         //! Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten
         //! Buchstaben vollständig darzustellen \param c Der Buchstabe, von dem
         //! die Breite in Pixeln ermitelt werden soll
-        DLLEXPORT virtual int getCharWidth(const char c) const;
+        DLLEXPORT virtual int getCharWidth(const char c) const override;
     };
 } // namespace Framework
 

+ 23 - 23
UIPixelShader.h

@@ -352,10 +352,10 @@ ret
 
 const BYTE UIPixelShader[] =
 {
-     68,  88,  66,  67, 216, 160, 
-     93, 199,   4, 194,  19,  14, 
-    255, 190, 198, 127,  38,  58, 
-    244, 248,   1,   0,   0,   0, 
+     68,  88,  66,  67, 220, 134, 
+     55, 178,  53,  80, 233, 131, 
+    255, 210, 210,  14,  97,  27, 
+    236, 255,   1,   0,   0,   0, 
      12, 134,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     140,   6,   0,   0,  28,   7, 
@@ -1805,11 +1805,11 @@ const BYTE UIPixelShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0, 148,  46, 
-     49,   1, 170, 100, 225,  99, 
-      1,   0,   0,   0, 186, 119, 
-     25,  68, 155, 175, 160,  75, 
-    172, 255,  68, 138, 150, 236, 
-    117, 124,   0,   0,   0,   0, 
+     49,   1, 118, 255, 241,  99, 
+      1,   0,   0,   0,  83,   4, 
+    177,  16, 146, 233, 135,  71, 
+    169,  45,  76,   7,  84, 158, 
+     28, 204,   0,   0,   0,   0, 
       0,   0,   0,   0,   1,   0, 
       0,   0,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1980,10 +1980,10 @@ const BYTE UIPixelShader[] =
       3,   0, 242,  56,   1,   0, 
      43, 236,   3,   0,  28,  19, 
       2,   0,  65,  36,   1,   0, 
-    236, 179,   1,   0,  78,  83, 
-      3,   0, 125,  10,   2,   0, 
-    125, 181,   2,   0,  28, 222, 
-      2,   0, 193,  33,   3,   0, 
+    236, 179,   1,   0, 183, 203, 
+      0,   0, 125,  10,   2,   0, 
+    125, 181,   2,   0, 245,  69, 
+      1,   0, 193,  33,   3,   0, 
      65, 185,   2,   0,   9, 241, 
       2,   0, 146, 230,   3,   0, 
     125, 218,   1,   0, 118,  19, 
@@ -3000,8 +3000,8 @@ const BYTE UIPixelShader[] =
      84, 101, 120, 116, 117, 114, 
     101,  50,  68,  32, 115, 104, 
      97, 100,  27, 226,  48,   1, 
-    128,   0,   0,   0,  14, 222, 
-    229, 155, 106,  58, 217,   1, 
+    128,   0,   0,   0, 153, 100, 
+     27,  72,  80,  68, 217,   1, 
       1,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -4243,14 +4243,14 @@ const BYTE UIPixelShader[] =
       6,  16,   0,   0,  23,   0, 
       1,   0,   5,  16,   0,   0, 
      14,   0,  23,  21,   0,  16, 
-      0,   0,   3,   2, 128, 225, 
+      0,   0,   3,   2, 112,  32, 
       0,   0, 242, 241,  10,   0, 
      24,  21,   8,  16,   0,   0, 
       1,   0,   1,   0,  10,   0, 
      24,  21,   9,  16,   0,   0, 
       1,   0,   0,   2,  14,   0, 
      23,  21,   0,   0,   0,   0, 
-     10,   2, 128, 225,   0,   0, 
+     10,   2, 112,  32,   0,   0, 
     242, 241,  10,   0,  24,  21, 
      11,  16,   0,   0,   1,   0, 
       1,   0,  10,   0,  24,  21, 
@@ -5474,11 +5474,11 @@ const BYTE UIPixelShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-    148,  46,  49,   1, 170, 100, 
-    225,  99,   1,   0,   0,   0, 
-    186, 119,  25,  68, 155, 175, 
-    160,  75, 172, 255,  68, 138, 
-    150, 236, 117, 124, 128,   0, 
+    148,  46,  49,   1, 118, 255, 
+    241,  99,   1,   0,   0,   0, 
+     83,   4, 177,  16, 146, 233, 
+    135,  71, 169,  45,  76,   7, 
+     84, 158,  28, 204, 128,   0, 
       0,   0,  47,  76, 105, 110, 
     107,  73, 110, 102, 111,   0, 
      47, 110,  97, 109, 101, 115, 
@@ -5578,7 +5578,7 @@ const BYTE UIPixelShader[] =
       0,   0,   2,   0,   9,   0, 
     204,   8,   0,   0,   0,   0, 
       0,   0, 164,  14,   0,   0, 
-      1,   0, 116, 185,   0,   0, 
+      1,   0,  67, 188,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  84, 101, 
     120, 116, 117, 114, 101,  80, 

+ 15 - 15
UIVertexShader.h

@@ -121,10 +121,10 @@ ret
 
 const BYTE UIVertexShader[] =
 {
-     68,  88,  66,  67,  68, 207, 
-    209,   1, 217,  87,  48, 122, 
-     43,  43, 154, 235,  15, 220, 
-    198,  42,   1,   0,   0,   0, 
+     68,  88,  66,  67,  56,  85, 
+    129, 129,  11, 106, 183, 228, 
+     90,  58,  77,  58, 147, 252, 
+    145, 183,   1,   0,   0,   0, 
     204,  77,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      20,   2,   0,   0, 204,   2, 
@@ -881,10 +881,10 @@ const BYTE UIVertexShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 148,  46,  49,   1, 
-    170, 100, 225,  99,   1,   0, 
-      0,   0, 127, 142,  89, 168, 
-    138,  47, 212,  73, 146, 255, 
-     66, 124, 201, 153, 139, 176, 
+    118, 255, 241,  99,   1,   0, 
+      0,   0, 167, 125, 163,  74, 
+    170, 132, 110,  66, 174,  43, 
+    125,  97, 210,   9, 194, 206, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
@@ -1564,8 +1564,8 @@ const BYTE UIVertexShader[] =
      13,  10,  47,  47,  32,  84, 
      89,  80,  69,  68,  69,  70, 
      27, 226,  48,   1, 128,   0, 
-      0,   0, 139,  47,   1, 156, 
-    106,  58, 217,   1,   1,   0, 
+      0,   0, 184, 225,  52,  72, 
+     80,  68, 217,   1,   1,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2929,10 +2929,10 @@ const BYTE UIVertexShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 148,  46,  49,   1, 
-    170, 100, 225,  99,   1,   0, 
-      0,   0, 127, 142,  89, 168, 
-    138,  47, 212,  73, 146, 255, 
-     66, 124, 201, 153, 139, 176, 
+    118, 255, 241,  99,   1,   0, 
+      0,   0, 167, 125, 163,  74, 
+    170, 132, 110,  66, 174,  43, 
+    125,  97, 210,   9, 194, 206, 
     129,   0,   0,   0,  47,  76, 
     105, 110, 107,  73, 110, 102, 
     111,   0,  47, 110,  97, 109, 
@@ -3032,7 +3032,7 @@ const BYTE UIVertexShader[] =
       0,   0,   0,   0,   2,   0, 
       9,   0, 104,   5,   0,   0, 
       0,   0,   0,   0, 236,   2, 
-      0,   0,   1,   0, 205,  49, 
+      0,   0,   1,   0,  21, 115, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
      84, 101, 120, 116, 117, 114,