ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/rendercache.c
(Generate patch)

Comparing deliantra/Deliantra-Client/rendercache.c (file contents):
Revision 1.5 by root, Sun Aug 12 08:49:51 2007 UTC vs.
Revision 1.9 by root, Sun Jan 13 08:31:45 2008 UTC

1typedef struct { 1typedef struct {
2 GLenum mode; 2 GLenum mode;
3 GLenum format; // 0, GL_T2F_V3F, GL_V2F 3 GLenum format; // 0, GL_T2F_V3F, GL_V2F
4 GLint texname; 4 GLuint texname;
5 unsigned char r, g, b, a; 5 unsigned char r, g, b, a;
6} rc_key_t; 6} rc_key_t;
7 7
8typedef struct { 8typedef struct {
9 HV *hv; 9 HV *hv;
10} rc_t; 10} rc_t;
11 11
12typedef SV rc_array_t; 12typedef SV rc_array_t;
13 13
14static rc_t * 14static rc_t *
15rc_alloc () 15rc_alloc (void)
16{ 16{
17 rc_t *rc = g_slice_new0 (rc_t); 17 rc_t *rc = g_slice_new0 (rc_t);
18 rc->hv = newHV (); 18 rc->hv = newHV ();
19 19
20 return rc; 20 return rc;
76} 76}
77 77
78static void 78static void
79rc_glyph (rc_array_t *arr, int u, int v, int w, int h, int x, int y) 79rc_glyph (rc_array_t *arr, int u, int v, int w, int h, int x, int y)
80{ 80{
81 if (w && h)
82 {
81 U8 *c; 83 U8 *c;
82 STRLEN len = SvCUR (arr); 84 STRLEN len = SvCUR (arr);
83 SvGROW (arr, len + 2 * 2 + 1 * 4); 85 SvGROW (arr, len + 2 * 2 + 1 * 4);
84 c = (U8 *)SvEND (arr); 86 c = (U8 *)SvEND (arr);
85 87
86 *c++ = u; 88 x += w;
87 *c++ = v; 89 y += h;
88 *c++ = w;
89 *c++ = h;
90 90
91 // use ber-encoding for up to 14 bits (16k) 91 *c++ = u;
92 *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f; 92 *c++ = v;
93 *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f; 93 *c++ = w;
94 *c++ = h;
94 95
96 // use ber-encoding for up to 14 bits (16k)
97 *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f;
98 *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f;
99
95 SvCUR_set (arr, c - (U8 *)SvPVX (arr)); 100 SvCUR_set (arr, c - (U8 *)SvPVX (arr));
101 }
96} 102}
97 103
98static void 104static void
99rc_draw (rc_t *rc) 105rc_draw (rc_t *rc)
100{ 106{
149 h = *c++; 155 h = *c++;
150 156
151 x = *c++; if (x > 0x7f) x = ((x & 0x7f) << 7) | *c++; 157 x = *c++; if (x > 0x7f) x = ((x & 0x7f) << 7) | *c++;
152 y = *c++; if (y > 0x7f) y = ((y & 0x7f) << 7) | *c++; 158 y = *c++; if (y > 0x7f) y = ((y & 0x7f) << 7) | *c++;
153 159
160 x -= w;
161 y -= h;
162
154 glTexCoord2f ( u * (1.f / TC_WIDTH), v * (1.f / TC_HEIGHT)); glVertex2i (x , y ); 163 glTexCoord2f ( u * (1.f / TC_WIDTH), v * (1.f / TC_HEIGHT)); glVertex2i (x , y );
155 glTexCoord2f ((u + w) * (1.f / TC_WIDTH), v * (1.f / TC_HEIGHT)); glVertex2i (x + w, y ); 164 glTexCoord2f ((u + w) * (1.f / TC_WIDTH), v * (1.f / TC_HEIGHT)); glVertex2i (x + w, y );
156 glTexCoord2f ((u + w) * (1.f / TC_WIDTH), (v + h) * (1.f / TC_HEIGHT)); glVertex2i (x + w, y + h); 165 glTexCoord2f ((u + w) * (1.f / TC_WIDTH), (v + h) * (1.f / TC_HEIGHT)); glVertex2i (x + w, y + h);
157 glTexCoord2f ( u * (1.f / TC_WIDTH), (v + h) * (1.f / TC_HEIGHT)); glVertex2i (x , y + h); 166 glTexCoord2f ( u * (1.f / TC_WIDTH), (v + h) * (1.f / TC_HEIGHT)); glVertex2i (x , y + h);
158 } 167 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines