--- deliantra/Deliantra-Client/rendercache.c 2007/08/12 08:49:51 1.5 +++ deliantra/Deliantra-Client/rendercache.c 2008/01/13 08:31:45 1.9 @@ -1,7 +1,7 @@ typedef struct { GLenum mode; GLenum format; // 0, GL_T2F_V3F, GL_V2F - GLint texname; + GLuint texname; unsigned char r, g, b, a; } rc_key_t; @@ -12,7 +12,7 @@ typedef SV rc_array_t; static rc_t * -rc_alloc () +rc_alloc (void) { rc_t *rc = g_slice_new0 (rc_t); rc->hv = newHV (); @@ -78,21 +78,27 @@ static void rc_glyph (rc_array_t *arr, int u, int v, int w, int h, int x, int y) { - U8 *c; - STRLEN len = SvCUR (arr); - SvGROW (arr, len + 2 * 2 + 1 * 4); - c = (U8 *)SvEND (arr); - - *c++ = u; - *c++ = v; - *c++ = w; - *c++ = h; - - // use ber-encoding for up to 14 bits (16k) - *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f; - *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f; + if (w && h) + { + U8 *c; + STRLEN len = SvCUR (arr); + SvGROW (arr, len + 2 * 2 + 1 * 4); + c = (U8 *)SvEND (arr); + + x += w; + y += h; + + *c++ = u; + *c++ = v; + *c++ = w; + *c++ = h; + + // use ber-encoding for up to 14 bits (16k) + *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f; + *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f; - SvCUR_set (arr, c - (U8 *)SvPVX (arr)); + SvCUR_set (arr, c - (U8 *)SvPVX (arr)); + } } static void @@ -151,6 +157,9 @@ x = *c++; if (x > 0x7f) x = ((x & 0x7f) << 7) | *c++; y = *c++; if (y > 0x7f) y = ((y & 0x7f) << 7) | *c++; + x -= w; + y -= h; + glTexCoord2f ( u * (1.f / TC_WIDTH), v * (1.f / TC_HEIGHT)); glVertex2i (x , y ); glTexCoord2f ((u + w) * (1.f / TC_WIDTH), v * (1.f / TC_HEIGHT)); glVertex2i (x + w, y ); glTexCoord2f ((u + w) * (1.f / TC_WIDTH), (v + h) * (1.f / TC_HEIGHT)); glVertex2i (x + w, y + h);