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