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.3 by root, Sat Aug 11 13:46:40 2007 UTC vs.
Revision 1.4 by root, Sun Aug 12 08:44:22 2007 UTC

74 74
75 SvCUR_set (arr, len); 75 SvCUR_set (arr, len);
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)
80{
81 U8 *c;
82 STRLEN len = SvCUR (arr);
83
84 SvGROW (arr, len + 2 * 2 + 1 * 4);
85
86 c = (U8 *)SvEND (arr);
87 *c++ = u;
88 *c++ = v;
89 *c++ = w;
90 *c++ = h;
91
92 // use ber-encoding for up to 14 bits (16k)
93 *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;
95
96 SvCUR_set (arr, c - (U8 *)SvPVX (arr));
97}
98
99static void
79rc_draw (rc_t *rc) 100rc_draw (rc_t *rc)
80{ 101{
81 HE *he; 102 HE *he;
82 103
83 hv_iterinit (rc->hv); 104 hv_iterinit (rc->hv);
97 else 118 else
98 glDisable (GL_TEXTURE_2D); 119 glDisable (GL_TEXTURE_2D);
99 120
100 glColor4ub (key->r, key->g, key->b, key->a); 121 glColor4ub (key->r, key->g, key->b, key->a);
101 122
123 if (key->format)
124 {
102 stride = key->format == GL_T2F_V3F ? sizeof (float) * 5 125 stride = key->format == GL_T2F_V3F ? sizeof (float) * 5
103 : key->format == GL_V2F ? sizeof (float) * 2 126 : key->format == GL_V2F ? sizeof (float) * 2
104 : 65536; 127 : 65536;
105 128
106 glInterleavedArrays (key->format, 0, (void *)arr_pv); 129 glInterleavedArrays (key->format, 0, (void *)arr_pv);
130 //glLockArraysEXT (0, len / stride);
107 glDrawArrays (key->mode, 0, len / stride); 131 glDrawArrays (key->mode, 0, len / stride);
132 //glUnlockArraysEXT ();
133 }
134 else
135 {
136 // optimised character quad storage. slower but nice on memory.
137 // reduces storage requirements from 80 bytes/char to 6-8
138 U8 *c = (U8 *)arr_pv;
139 U8 *e = c + len;
140
141 glBegin (key->mode); // practically must be quads
142
143 while (c < e)
144 {
145 int u, v, x, y, w, h;
146
147 u = *c++;
148 v = *c++;
149 w = *c++;
150 h = *c++;
151
152 x = *c++; if (x > 0x7f) x = ((x & 0x7f) << 7) | *c++;
153 y = *c++; if (y > 0x7f) y = ((y & 0x7f) << 7) | *c++;
154
155 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 );
157 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);
159 }
160
161 glEnd ();
162 }
108 } 163 }
109 164
110 glDisable (GL_TEXTURE_2D); 165 glDisable (GL_TEXTURE_2D);
111} 166}
112 167

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines