commit 195240962683e56b337feb05f702b495c564b94c parent 98aa59a34632e101e55c0132ecd8611aaa1718e7 Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Oct 12 21:23:25 +0300 Const fix in stb_truetype Diffstat:
hm.cc | | | 2 | +- |
stb_truetype.h | | | 6 | +++--- |
diff --git a/hm.cc b/hm.cc @@ -227,7 +227,7 @@ static void draw_string( const GameState * game, while( *str != '\0' ) { stbtt_aligned_quad q; - stbtt_GetBakedQuad( ( stbtt_bakedchar * ) game->test_chars, 512, 256, *str - ' ', &x, &y, &q, true ); + stbtt_GetBakedQuad( game->test_chars, 512, 256, *str - ' ', &x, &y, &q, 1 ); const ImmediateVertex v1A = { glm::vec3( q.x0 * scale, -q.y0 * scale, 0 ), white, glm::vec2( q.s0, q.t0 ) }; const ImmediateVertex v2A = { glm::vec3( q.x1 * scale, -q.y0 * scale, 0 ), white, glm::vec2( q.s1, q.t0 ) }; diff --git a/stb_truetype.h b/stb_truetype.h @@ -487,7 +487,7 @@ typedef struct float x1,y1,s1,t1; // bottom-right } stbtt_aligned_quad; -STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw @@ -2578,11 +2578,11 @@ STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // fo return bottom_y; } -STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) { float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; - stbtt_bakedchar *b = chardata + char_index; + const stbtt_bakedchar *b = chardata + char_index; int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f);