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.4 by root, Sun Aug 12 08:44:22 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);
85 SvGROW (arr, len + 2 * 2 + 1 * 4);
86 c = (U8 *)SvEND (arr);
83 87
84 SvGROW (arr, len + 2 * 2 + 1 * 4); 88 x += w;
89 y += h;
85 90
86 c = (U8 *)SvEND (arr);
87 *c++ = u; 91 *c++ = u;
88 *c++ = v; 92 *c++ = v;
89 *c++ = w; 93 *c++ = w;
90 *c++ = h; 94 *c++ = h;
91 95
92 // use ber-encoding for up to 14 bits (16k) 96 // use ber-encoding for up to 14 bits (16k)
93 *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f; 97 *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f;
94 *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f; 98 *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f;
95 99
96 SvCUR_set (arr, c - (U8 *)SvPVX (arr)); 100 SvCUR_set (arr, c - (U8 *)SvPVX (arr));
101 }
97} 102}
98 103
99static void 104static void
100rc_draw (rc_t *rc) 105rc_draw (rc_t *rc)
101{ 106{
150 h = *c++; 155 h = *c++;
151 156
152 x = *c++; if (x > 0x7f) x = ((x & 0x7f) << 7) | *c++; 157 x = *c++; if (x > 0x7f) x = ((x & 0x7f) << 7) | *c++;
153 y = *c++; if (y > 0x7f) y = ((y & 0x7f) << 7) | *c++; 158 y = *c++; if (y > 0x7f) y = ((y & 0x7f) << 7) | *c++;
154 159
160 x -= w;
161 y -= h;
162
155 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 );
156 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 );
157 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);
158 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);
159 } 167 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines