… | |
… | |
15 | |
15 | |
16 | #include "EXTERN.h" |
16 | #include "EXTERN.h" |
17 | #include "perl.h" |
17 | #include "perl.h" |
18 | #include "XSUB.h" |
18 | #include "XSUB.h" |
19 | |
19 | |
|
|
20 | #include "flat_hash_map.hpp" |
|
|
21 | |
20 | #ifdef _WIN32 |
22 | #ifdef _WIN32 |
21 | # undef pipe |
23 | # undef pipe |
22 | // microsoft vs. C |
24 | // microsoft vs. C |
23 | # define sqrtf(x) sqrt(x) |
25 | # define sqrtf(x) sqrt(x) |
24 | # define atan2f(x,y) atan2(x,y) |
26 | # define atan2f(x,y) atan2(x,y) |
25 | # define M_PI 3.14159265f |
27 | # define M_PI 3.14159265f |
26 | #endif |
28 | #endif |
27 | |
29 | |
28 | #include <assert.h> |
30 | #include <cassert> |
29 | #include <math.h> |
31 | #include <cmath> |
30 | #include <string.h> |
32 | #include <cstring> |
31 | #include <stdio.h> |
33 | #include <cstdio> |
32 | #include <stdlib.h> |
34 | #include <cstdlib> |
|
|
35 | |
|
|
36 | #include <utility> |
|
|
37 | #include <bitset> |
33 | |
38 | |
34 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
39 | #define USE_RWOPS 1 // for SDL_mixer:LoadMUS_RW |
35 | |
40 | |
36 | #include <SDL.h> |
41 | #include <SDL.h> |
37 | #include <SDL_thread.h> |
42 | #include <SDL_thread.h> |
… | |
… | |
48 | #endif |
53 | #endif |
49 | |
54 | |
50 | #define PANGO_ENABLE_BACKEND |
55 | #define PANGO_ENABLE_BACKEND |
51 | #define G_DISABLE_CAST_CHECKS |
56 | #define G_DISABLE_CAST_CHECKS |
52 | |
57 | |
53 | #include <glib/gmacros.h> |
58 | #include <glib.h> |
54 | |
59 | |
55 | #include <pango/pango.h> |
60 | #include <pango/pango.h> |
56 | |
61 | |
57 | #ifndef PANGO_VERSION_CHECK |
62 | #ifndef PANGO_VERSION_CHECK |
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
63 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
… | |
… | |
71 | # include <netinet/in.h> |
76 | # include <netinet/in.h> |
72 | # include <netinet/tcp.h> |
77 | # include <netinet/tcp.h> |
73 | # include <inttypes.h> |
78 | # include <inttypes.h> |
74 | #endif |
79 | #endif |
75 | |
80 | |
76 | #if __GNUC__ >= 4 |
81 | #include "ecb.h" |
77 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
82 | #include "salloc.h" |
78 | #else |
|
|
79 | # define expect(expr,value) (expr) |
|
|
80 | #endif |
|
|
81 | |
|
|
82 | #define expect_false(expr) expect ((expr) != 0, 0) |
|
|
83 | #define expect_true(expr) expect ((expr) != 0, 1) |
|
|
84 | |
83 | |
85 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
84 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
86 | |
85 | |
87 | /* this is used as fow flag as well, so has to have a different value */ |
86 | /* this is used as fow flag as well, so has to have a different value */ |
88 | /* then anything that is computed by incoming darkness */ |
87 | /* then anything that is computed by incoming darkness */ |
… | |
… | |
106 | fast_sv_grow (SV *sv, STRLEN need) |
105 | fast_sv_grow (SV *sv, STRLEN need) |
107 | { |
106 | { |
108 | STRLEN len = SvLEN (sv); |
107 | STRLEN len = SvLEN (sv); |
109 | STRLEN want = SvCUR (sv) + need; |
108 | STRLEN want = SvCUR (sv) + need; |
110 | |
109 | |
111 | if (expect_false (len < want)) |
110 | if (ecb_expect_false (len < want)) |
112 | { |
111 | { |
113 | do |
112 | do |
114 | len *= 2; |
113 | len *= 2; |
115 | while (len < want); |
114 | while (len < want); |
116 | |
115 | |
… | |
… | |
184 | { |
183 | { |
185 | GSList *attrs = run->item->analysis.extra_attrs; |
184 | GSList *attrs = run->item->analysis.extra_attrs; |
186 | |
185 | |
187 | while (attrs) |
186 | while (attrs) |
188 | { |
187 | { |
189 | PangoAttribute *attr = attrs->data; |
188 | PangoAttribute *attr = (PangoAttribute *)attrs->data; |
190 | |
189 | |
191 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
190 | if (attr->klass->type == PANGO_ATTR_SHAPE) |
192 | return 1; |
191 | return 1; |
193 | |
192 | |
194 | attrs = attrs->next; |
193 | attrs = attrs->next; |
195 | } |
194 | } |
196 | |
195 | |
197 | return 0; |
196 | return 0; |
198 | } |
197 | } |
199 | |
198 | |
200 | typedef struct cf_layout { |
199 | struct cf_layout { |
201 | PangoLayout *pl; |
200 | PangoLayout *pl; |
202 | float r, g, b, a; // default color for rgba mode |
201 | float r, g, b, a; // default color for rgba mode |
203 | int base_height; |
202 | int base_height; |
204 | DC__Font font; |
203 | DC__Font font; |
205 | rc_t *rc; |
204 | rc_t rc; |
206 | } *DC__Layout; |
205 | }; |
|
|
206 | |
|
|
207 | typedef cf_layout *DC__Layout; |
207 | |
208 | |
208 | static DC__Font default_font; |
209 | static DC__Font default_font; |
209 | static PangoContext *opengl_context; |
210 | static PangoContext *opengl_context; |
210 | static PangoFontMap *opengl_fontmap; |
211 | static PangoFontMap *opengl_fontmap; |
211 | |
212 | |
212 | static void |
213 | static void |
213 | substitute_func (FcPattern *pattern, gpointer data) |
214 | substitute_func (FcPattern *pattern, gpointer data) |
214 | { |
215 | { |
215 | FcPatternAddBool (pattern, FC_HINTING, 1); |
216 | FcPatternAddBool (pattern, FC_HINTING, 1); |
216 | #ifdef FC_HINT_STYLE |
217 | #ifdef FC_HINT_STYLE |
217 | FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
218 | FcPatternAddInteger (pattern, FC_HINT_STYLE, FC_HINT_FULL); |
218 | #endif |
219 | #endif |
219 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
220 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
220 | } |
221 | } |
221 | |
222 | |
222 | static void |
223 | static void |
… | |
… | |
249 | |
250 | |
250 | *w = rect.width; |
251 | *w = rect.width; |
251 | *h = rect.height; |
252 | *h = rect.height; |
252 | } |
253 | } |
253 | |
254 | |
|
|
255 | ///////////////////////////////////////////////////////////////////////////// |
|
|
256 | |
254 | typedef uint16_t tileid; |
257 | typedef uint16_t tileid; |
255 | typedef uint16_t faceid; |
258 | typedef uint16_t faceid; |
256 | |
259 | |
257 | typedef struct { |
260 | struct maptex |
|
|
261 | { |
258 | GLuint name; |
262 | GLuint name; |
259 | int w, h; |
263 | int w, h; |
260 | float s, t; |
264 | float s, t; |
261 | uint8_t r, g, b, a; |
265 | uint8_t r, g, b, a; |
262 | tileid smoothtile; |
266 | tileid smoothtile; |
263 | uint8_t smoothlevel; |
267 | uint8_t smoothlevel; |
264 | uint8_t unused; /* set to zero on use */ |
268 | uint8_t unused; /* set to zero on use */ |
265 | } maptex; |
269 | }; |
266 | |
270 | |
267 | typedef struct { |
271 | struct mapcell |
|
|
272 | { |
268 | uint32_t player; |
273 | uint32_t player; |
269 | tileid tile[3]; |
274 | tileid tile[3]; |
270 | uint16_t darkness; |
275 | uint16_t darkness; |
271 | uint8_t stat_width, stat_hp, flags, smoothmax; |
276 | uint8_t stat_width, stat_hp, flags, smoothmax; |
272 | } mapcell; |
277 | }; |
273 | |
278 | |
274 | typedef struct { |
279 | struct maprow |
|
|
280 | { |
275 | int32_t c0, c1; |
281 | int32_t c0, c1; |
276 | mapcell *col; |
282 | mapcell *col; |
277 | } maprow; |
283 | }; |
278 | |
284 | |
279 | typedef struct map { |
285 | struct mapgrid { |
280 | int x, y, w, h; |
286 | int x, y, w, h; |
281 | int ox, oy; /* offset to virtual global coordinate system */ |
287 | int ox, oy; /* offset to virtual global coordinate system */ |
282 | int faces; tileid *face2tile; // [faceid] |
288 | int faces; tileid *face2tile; // [faceid] |
283 | int texs; maptex *tex; // [tileid] |
289 | int texs; maptex *tex; // [tileid] |
284 | |
290 | |
285 | int32_t rows; |
291 | int32_t rows; |
286 | maprow *row; |
292 | maprow *row; |
287 | } *DC__Map; |
293 | }; |
288 | |
294 | |
289 | static char * |
295 | typedef mapgrid *DC__Map; |
|
|
296 | |
|
|
297 | template<typename T> |
|
|
298 | static void |
290 | prepend (char *ptr, int sze, int inc) |
299 | prepend (T *&ptr, int sze, int inc) |
291 | { |
300 | { |
292 | char *p; |
301 | T *p; |
293 | |
302 | |
294 | New (0, p, sze + inc, char); |
303 | Newx (p, inc + sze, T); |
295 | Zero (p, inc, char); |
304 | Zero (p, inc, T); |
296 | Move (ptr, p + inc, sze, char); |
305 | Move (ptr, p + inc, sze, T); |
297 | Safefree (ptr); |
306 | Safefree (ptr); |
298 | |
307 | |
299 | return p; |
308 | ptr = p; |
300 | } |
309 | } |
301 | |
310 | |
302 | static char * |
311 | template<typename T> |
303 | append (char *ptr, int sze, int inc) |
|
|
304 | { |
|
|
305 | Renew (ptr, sze + inc, char); |
|
|
306 | Zero (ptr + sze, inc, char); |
|
|
307 | |
|
|
308 | return ptr; |
|
|
309 | } |
|
|
310 | |
|
|
311 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
|
|
312 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
|
|
313 | |
|
|
314 | static void |
312 | static void |
|
|
313 | append (T *&ptr, int sze, int inc) |
|
|
314 | { |
|
|
315 | Renew (ptr, sze + inc, T); |
|
|
316 | Zero (ptr + sze, inc, T); |
|
|
317 | } |
|
|
318 | |
|
|
319 | static void |
315 | need_facenum (struct map *self, faceid face) |
320 | need_facenum (struct mapgrid *self, faceid face) |
316 | { |
321 | { |
317 | while (self->faces <= face) |
322 | while (self->faces <= face) |
318 | { |
323 | { |
319 | Append (tileid, self->face2tile, self->faces, self->faces); |
324 | append (self->face2tile, self->faces, self->faces); |
320 | self->faces *= 2; |
325 | self->faces *= 2; |
321 | } |
326 | } |
322 | } |
327 | } |
323 | |
328 | |
324 | static void |
329 | static void |
325 | need_texid (struct map *self, int texid) |
330 | need_texid (struct mapgrid *self, int texid) |
326 | { |
331 | { |
327 | while (self->texs <= texid) |
332 | while (self->texs <= texid) |
328 | { |
333 | { |
329 | Append (maptex, self->tex, self->texs, self->texs); |
334 | append (self->tex, self->texs, self->texs); |
330 | self->texs *= 2; |
335 | self->texs *= 2; |
331 | } |
336 | } |
332 | } |
337 | } |
333 | |
338 | |
334 | static maprow * |
339 | static maprow * |
335 | map_get_row (DC__Map self, int y) |
340 | map_get_row (mapgrid *self, int y) |
336 | { |
341 | { |
337 | if (0 > y) |
342 | if (0 > y) |
338 | { |
343 | { |
339 | int extend = - y + MAP_EXTEND_Y; |
344 | int extend = - y + MAP_EXTEND_Y; |
340 | Prepend (maprow, self->row, self->rows, extend); |
345 | prepend (self->row, self->rows, extend); |
341 | |
346 | |
342 | self->rows += extend; |
347 | self->rows += extend; |
343 | self->y += extend; |
348 | self->y += extend; |
344 | y += extend; |
349 | y += extend; |
345 | } |
350 | } |
346 | else if (y >= self->rows) |
351 | else if (y >= self->rows) |
347 | { |
352 | { |
348 | int extend = y - self->rows + MAP_EXTEND_Y; |
353 | int extend = y - self->rows + MAP_EXTEND_Y; |
349 | Append (maprow, self->row, self->rows, extend); |
354 | append (self->row, self->rows, extend); |
350 | self->rows += extend; |
355 | self->rows += extend; |
351 | } |
356 | } |
352 | |
357 | |
353 | return self->row + y; |
358 | return self->row + y; |
354 | } |
359 | } |
… | |
… | |
364 | } |
369 | } |
365 | |
370 | |
366 | if (row->c0 > x) |
371 | if (row->c0 > x) |
367 | { |
372 | { |
368 | int extend = row->c0 - x + MAP_EXTEND_X; |
373 | int extend = row->c0 - x + MAP_EXTEND_X; |
369 | Prepend (mapcell, row->col, row->c1 - row->c0, extend); |
374 | prepend (row->col, row->c1 - row->c0, extend); |
370 | row->c0 -= extend; |
375 | row->c0 -= extend; |
371 | } |
376 | } |
372 | else if (x >= row->c1) |
377 | else if (x >= row->c1) |
373 | { |
378 | { |
374 | int extend = x - row->c1 + MAP_EXTEND_X; |
379 | int extend = x - row->c1 + MAP_EXTEND_X; |
375 | Append (mapcell, row->col, row->c1 - row->c0, extend); |
380 | append (row->col, row->c1 - row->c0, extend); |
376 | row->c1 += extend; |
381 | row->c1 += extend; |
377 | } |
382 | } |
378 | |
383 | |
379 | return row->col + (x - row->c0); |
384 | return row->col + (x - row->c0); |
380 | } |
385 | } |
381 | |
386 | |
382 | static mapcell * |
387 | static mapcell * |
383 | map_get_cell (DC__Map self, int x, int y) |
388 | map_get_cell (mapgrid *self, int x, int y) |
384 | { |
389 | { |
385 | return row_get_cell (map_get_row (self, y), x); |
390 | return row_get_cell (map_get_row (self, y), x); |
386 | } |
391 | } |
387 | |
392 | |
388 | static void |
393 | static void |
389 | map_clear (DC__Map self) |
394 | map_clear (mapgrid *self) |
390 | { |
395 | { |
391 | int r; |
396 | int r; |
392 | |
397 | |
393 | for (r = 0; r < self->rows; r++) |
398 | for (r = 0; r < self->rows; r++) |
394 | Safefree (self->row[r].col); |
399 | Safefree (self->row[r].col); |
… | |
… | |
412 | (cell)->flags = 0; \ |
417 | (cell)->flags = 0; \ |
413 | (cell)->player = 0; \ |
418 | (cell)->player = 0; \ |
414 | } while (0) |
419 | } while (0) |
415 | |
420 | |
416 | static void |
421 | static void |
417 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
422 | map_blank (mapgrid *self, int x0, int y0, int w, int h) |
418 | { |
423 | { |
419 | int x, y; |
424 | int x, y; |
420 | maprow *row; |
425 | maprow *row; |
421 | mapcell *cell; |
426 | mapcell *cell; |
422 | |
427 | |
… | |
… | |
439 | CELL_CLEAR (cell); |
444 | CELL_CLEAR (cell); |
440 | } |
445 | } |
441 | } |
446 | } |
442 | } |
447 | } |
443 | |
448 | |
444 | typedef struct { |
449 | struct smooth_key |
|
|
450 | { |
445 | tileid tile; |
451 | tileid tile; |
446 | uint8_t x, y, level; |
452 | uint8_t x, y, level; |
447 | } smooth_key; |
453 | |
|
|
454 | bool operator == (const smooth_key &o) const |
|
|
455 | { |
|
|
456 | return tile == o.tile && x == o.x && y == o.y && level == o.level; |
|
|
457 | } |
|
|
458 | }; |
|
|
459 | |
|
|
460 | typedef ska::flat_hash_map<smooth_key, IV> smooth_hash; |
|
|
461 | |
|
|
462 | namespace std { |
|
|
463 | template <> |
|
|
464 | struct hash<smooth_key> |
|
|
465 | { |
|
|
466 | size_t operator () (const smooth_key &v) const |
|
|
467 | { |
|
|
468 | return v.tile + (v.x << 8) + (v.y << 16) + (v.level << 24); |
|
|
469 | } |
|
|
470 | }; |
|
|
471 | } |
448 | |
472 | |
449 | static void |
473 | static void |
450 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
474 | smooth_or_bits (smooth_hash &h, smooth_key &key, IV bits) |
451 | { |
475 | { |
452 | SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); |
476 | auto &&it = h.find (key); |
453 | |
477 | |
454 | if (SvIOK (*sv)) |
478 | if (it == h.end ()) |
455 | SvIV_set (*sv, SvIVX (*sv) | bits); |
479 | h.insert (std::make_pair (key, bits)); |
456 | else |
480 | else |
457 | sv_setiv (*sv, bits); |
481 | it->second |= bits; |
458 | } |
482 | } |
459 | |
483 | |
460 | static void |
484 | static void |
461 | music_finished (void) |
485 | music_finished (void) |
462 | { |
486 | { |
… | |
… | |
481 | ev.data2 = 0; |
505 | ev.data2 = 0; |
482 | |
506 | |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
507 | SDL_PushEvent ((SDL_Event *)&ev); |
484 | } |
508 | } |
485 | |
509 | |
|
|
510 | // approximately divide by 255 |
486 | static unsigned int |
511 | static unsigned int |
487 | div255 (unsigned int n) |
512 | div255 (unsigned int n) |
488 | { |
513 | { |
489 | return (n + (n >> 8)) >> 8; |
514 | return (n + (n >> 8)) >> 8; |
490 | } |
515 | } |
… | |
… | |
504 | n |= n >> 16; |
529 | n |= n >> 16; |
505 | |
530 | |
506 | return n + 1; |
531 | return n + 1; |
507 | } |
532 | } |
508 | |
533 | |
509 | static unsigned int |
|
|
510 | popcount (unsigned int n) |
|
|
511 | { |
|
|
512 | n -= (n >> 1) & 0x55555555U; |
|
|
513 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
514 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
515 | n *= 0x01010101U; |
|
|
516 | |
|
|
517 | return n >> 24; |
|
|
518 | } |
|
|
519 | |
|
|
520 | /* SDL should provide this, really. */ |
534 | /* SDL should provide this, really. */ |
521 | #define SDLK_MODIFIER_MIN 300 |
535 | #define SDLK_MODIFIER_MIN 300 |
522 | #define SDLK_MODIFIER_MAX 314 |
536 | #define SDLK_MODIFIER_MAX 314 |
523 | |
537 | |
524 | /******************************************************************************/ |
538 | /******************************************************************************/ |
… | |
… | |
577 | |
591 | |
578 | return mod; |
592 | return mod; |
579 | } |
593 | } |
580 | |
594 | |
581 | static void |
595 | static void |
582 | deliantra_main () |
596 | deliantra_main (SV *real_main) |
583 | { |
597 | { |
584 | char *argv[] = { 0 }; |
598 | dSP; |
585 | call_argv ("DC::Main::main", G_DISCARD | G_VOID, argv); |
599 | |
|
|
600 | PUSHMARK (SP); |
|
|
601 | call_sv (real_main, G_DISCARD | G_VOID); |
586 | } |
602 | } |
587 | |
603 | |
588 | #ifdef __MACOSX__ |
604 | #ifdef __MACOSX__ |
|
|
605 | static SV *real_main; |
|
|
606 | |
589 | /* to due surprising braindamage on the side of SDL design, we |
607 | /* to due surprising braindamage on the side of SDL design, we |
590 | * do some mind-boggling hack here: SDL requires a custom main() |
608 | * do some mind-boggling hack here: SDL requires a custom main() |
591 | * on OS X, so... we provide one and call the original main(), which, |
609 | * on OS X, so... we provide one and call the original main(), which, |
592 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
610 | * due to shared library magic, calls -lSDLmain's main, not perl's main, |
593 | * and which calls our main (== SDL_main) back. |
611 | * and which calls our main (== SDL_main) back. |
594 | */ |
612 | */ |
595 | extern C_LINKAGE int |
613 | extern C_LINKAGE int |
596 | main (int argc, char *argv[]) |
614 | main (int argc, char *argv[]) |
597 | { |
615 | { |
598 | deliantra_main (); |
616 | deliantra_main (real_main); |
599 | } |
617 | } |
600 | |
618 | |
601 | #undef main |
619 | #undef main |
602 | |
620 | |
603 | extern C_LINKAGE int main (int argc, char *argv[]); |
621 | extern C_LINKAGE int main (int argc, char *argv[]); |
604 | |
622 | |
605 | static void |
623 | static void |
606 | SDL_braino (void) |
624 | SDL_main_hack (SV *real_main_) |
607 | { |
625 | { |
|
|
626 | real_main = real_main_; |
|
|
627 | |
608 | char *argv[] = { "deliantra client", 0 }; |
628 | char *argv[] = { "deliantra client", 0 }; |
609 | (main) (1, argv); |
629 | (main) (1, argv); |
610 | } |
630 | } |
611 | #else |
631 | #else |
612 | static void |
632 | static void |
613 | SDL_braino (void) |
633 | SDL_main_hack (SV *real_main) |
614 | { |
634 | { |
615 | deliantra_main (); |
635 | deliantra_main (real_main); |
616 | } |
636 | } |
617 | #endif |
637 | #endif |
618 | |
638 | |
619 | MODULE = Deliantra::Client PACKAGE = DC |
639 | MODULE = Deliantra::Client PACKAGE = DC |
620 | |
640 | |
… | |
… | |
847 | |
867 | |
848 | NV ceil (NV x) |
868 | NV ceil (NV x) |
849 | |
869 | |
850 | IV minpot (UV n) |
870 | IV minpot (UV n) |
851 | |
871 | |
|
|
872 | UV ld32 (UV n) |
|
|
873 | CODE: |
|
|
874 | RETVAL = ecb_ld32 (n); |
|
|
875 | OUTPUT: |
|
|
876 | RETVAL |
|
|
877 | |
852 | IV popcount (UV n) |
878 | IV popcount (UV n) |
|
|
879 | CODE: |
|
|
880 | RETVAL = ecb_popcount32 (n); |
|
|
881 | OUTPUT: |
|
|
882 | RETVAL |
853 | |
883 | |
854 | NV distance (NV dx, NV dy) |
884 | NV distance (NV dx, NV dy) |
855 | CODE: |
885 | CODE: |
856 | RETVAL = pow (dx * dx + dy * dy, 0.5); |
886 | RETVAL = pow (dx * dx + dy * dy, 0.5); |
857 | OUTPUT: |
887 | OUTPUT: |
… | |
… | |
871 | #endif |
901 | #endif |
872 | } |
902 | } |
873 | |
903 | |
874 | char *SDL_GetError () |
904 | char *SDL_GetError () |
875 | |
905 | |
876 | void SDL_braino () |
906 | void SDL_main_hack (SV *real_main) |
|
|
907 | PROTOTYPE: & |
877 | |
908 | |
878 | int SDL_Init (U32 flags) |
909 | int SDL_Init (U32 flags) |
879 | |
910 | |
880 | int SDL_InitSubSystem (U32 flags) |
911 | int SDL_InitSubSystem (U32 flags) |
881 | |
912 | |
882 | void SDL_QuitSubSystem (U32 flags) |
913 | void SDL_QuitSubSystem (U32 flags) |
883 | |
914 | |
884 | void SDL_Quit () |
915 | void SDL_Quit () |
885 | |
916 | |
886 | int SDL_GL_SetAttribute (int attr, int value) |
917 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
918 | C_ARGS: (SDL_GLattr)attr, value |
887 | |
919 | |
888 | int SDL_GL_GetAttribute (int attr) |
920 | int SDL_GL_GetAttribute (int attr) |
889 | CODE: |
921 | CODE: |
890 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
922 | if (SDL_GL_GetAttribute ((SDL_GLattr)attr, &RETVAL)) |
891 | XSRETURN_UNDEF; |
923 | XSRETURN_UNDEF; |
892 | OUTPUT: |
924 | OUTPUT: |
893 | RETVAL |
925 | RETVAL |
894 | |
926 | |
895 | void |
927 | void |
… | |
… | |
968 | void |
1000 | void |
969 | SDL_GL_SwapBuffers () |
1001 | SDL_GL_SwapBuffers () |
970 | |
1002 | |
971 | char * |
1003 | char * |
972 | SDL_GetKeyName (int sym) |
1004 | SDL_GetKeyName (int sym) |
|
|
1005 | C_ARGS: (SDLKey)sym |
973 | |
1006 | |
974 | int |
1007 | int |
975 | SDL_GetAppState () |
1008 | SDL_GetAppState () |
976 | |
1009 | |
977 | int |
1010 | int |
… | |
… | |
1074 | OUTPUT: |
1107 | OUTPUT: |
1075 | RETVAL |
1108 | RETVAL |
1076 | |
1109 | |
1077 | int |
1110 | int |
1078 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1111 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
1079 | POSTCALL: |
1112 | POSTCALL: |
1080 | Mix_HookMusicFinished (music_finished); |
1113 | Mix_HookMusicFinished (music_finished); |
1081 | Mix_ChannelFinished (channel_finished); |
1114 | Mix_ChannelFinished (channel_finished); |
1082 | |
1115 | |
1083 | void |
1116 | void |
1084 | Mix_QuerySpec () |
1117 | Mix_QuerySpec () |
… | |
… | |
1205 | |
1238 | |
1206 | SDL_LockSurface (surface2); |
1239 | SDL_LockSurface (surface2); |
1207 | EXTEND (SP, 6); |
1240 | EXTEND (SP, 6); |
1208 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1241 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
1209 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1242 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
1210 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
1243 | PUSHs (sv_2mortal (newSVpvn ((const char *)surface2->pixels, surface2->h * surface2->pitch))); |
1211 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1244 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
1212 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1245 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
1213 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1246 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
1214 | SDL_UnlockSurface (surface2); |
1247 | SDL_UnlockSurface (surface2); |
1215 | |
1248 | |
… | |
… | |
1287 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1320 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1288 | |
1321 | |
1289 | PROTOTYPES: DISABLE |
1322 | PROTOTYPES: DISABLE |
1290 | |
1323 | |
1291 | DC::Font |
1324 | DC::Font |
1292 | new_from_file (SV *class, char *path, int id = 0) |
1325 | new_from_file (SV *klass, char *path, int id = 0) |
1293 | CODE: |
1326 | CODE: |
1294 | { |
1327 | { |
1295 | int count; |
1328 | int count; |
1296 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1329 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1297 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
1330 | RETVAL = pango_fc_font_description_from_pattern (pattern, 0); |
… | |
… | |
1326 | PROTOTYPE: |
1359 | PROTOTYPE: |
1327 | CODE: |
1360 | CODE: |
1328 | tc_restore (); |
1361 | tc_restore (); |
1329 | |
1362 | |
1330 | DC::Layout |
1363 | DC::Layout |
1331 | new (SV *class) |
1364 | new (SV *klass) |
1332 | CODE: |
1365 | CODE: |
1333 | New (0, RETVAL, 1, struct cf_layout); |
1366 | RETVAL = new cf_layout; |
1334 | |
1367 | |
1335 | RETVAL->pl = pango_layout_new (opengl_context); |
1368 | RETVAL->pl = pango_layout_new (opengl_context); |
1336 | RETVAL->r = 1.; |
1369 | RETVAL->r = 1.; |
1337 | RETVAL->g = 1.; |
1370 | RETVAL->g = 1.; |
1338 | RETVAL->b = 1.; |
1371 | RETVAL->b = 1.; |
1339 | RETVAL->a = 1.; |
1372 | RETVAL->a = 1.; |
1340 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1373 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1341 | RETVAL->font = 0; |
1374 | RETVAL->font = 0; |
1342 | RETVAL->rc = rc_alloc (); |
|
|
1343 | |
1375 | |
1344 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1376 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1345 | layout_update_font (RETVAL); |
1377 | layout_update_font (RETVAL); |
1346 | OUTPUT: |
1378 | OUTPUT: |
1347 | RETVAL |
1379 | RETVAL |
1348 | |
1380 | |
1349 | void |
1381 | void |
1350 | DESTROY (DC::Layout self) |
1382 | DESTROY (DC::Layout self) |
1351 | CODE: |
1383 | CODE: |
1352 | g_object_unref (self->pl); |
1384 | g_object_unref (self->pl); |
1353 | rc_free (self->rc); |
|
|
1354 | Safefree (self); |
1385 | delete self; |
1355 | |
1386 | |
1356 | void |
1387 | void |
1357 | set_text (DC::Layout self, SV *text_) |
1388 | set_text (DC::Layout self, SV *text_) |
1358 | CODE: |
1389 | CODE: |
1359 | { |
1390 | { |
… | |
… | |
1485 | |
1516 | |
1486 | void |
1517 | void |
1487 | set_height (DC::Layout self, int base_height) |
1518 | set_height (DC::Layout self, int base_height) |
1488 | CODE: |
1519 | CODE: |
1489 | if (self->base_height != base_height) |
1520 | if (self->base_height != base_height) |
1490 | { |
1521 | { |
1491 | self->base_height = base_height; |
1522 | self->base_height = base_height; |
1492 | layout_update_font (self); |
1523 | layout_update_font (self); |
1493 | } |
1524 | } |
1494 | |
1525 | |
1495 | void |
1526 | void |
… | |
… | |
1613 | } |
1644 | } |
1614 | |
1645 | |
1615 | void |
1646 | void |
1616 | render (DC::Layout self, float x, float y, int flags = 0) |
1647 | render (DC::Layout self, float x, float y, int flags = 0) |
1617 | CODE: |
1648 | CODE: |
1618 | rc_clear (self->rc); |
1649 | self->rc.clear (); |
1619 | pango_opengl_render_layout_subpixel ( |
1650 | pango_opengl_render_layout_subpixel ( |
1620 | self->pl, |
1651 | self->pl, |
1621 | self->rc, |
1652 | &self->rc, |
1622 | x * PANGO_SCALE, y * PANGO_SCALE, |
1653 | x * PANGO_SCALE, y * PANGO_SCALE, |
1623 | self->r, self->g, self->b, self->a, |
1654 | self->r, self->g, self->b, self->a, |
1624 | flags |
1655 | flags |
1625 | ); |
1656 | ); |
1626 | // we assume that context_change actually clears/frees stuff |
1657 | // we assume that context_change actually clears/frees stuff |
… | |
… | |
1637 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
1668 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
1638 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
1669 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
1639 | glEnable (GL_ALPHA_TEST); |
1670 | glEnable (GL_ALPHA_TEST); |
1640 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
1671 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
1641 | |
1672 | |
1642 | rc_draw (self->rc); |
1673 | self->rc.draw (); |
1643 | |
1674 | |
1644 | glDisable (GL_ALPHA_TEST); |
1675 | glDisable (GL_ALPHA_TEST); |
1645 | glDisable (GL_BLEND); |
1676 | glDisable (GL_BLEND); |
1646 | glDisable (GL_TEXTURE_2D); |
1677 | glDisable (GL_TEXTURE_2D); |
1647 | } |
1678 | } |
… | |
… | |
1859 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1890 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1860 | |
1891 | |
1861 | PROTOTYPES: DISABLE |
1892 | PROTOTYPES: DISABLE |
1862 | |
1893 | |
1863 | DC::Map |
1894 | DC::Map |
1864 | new (SV *class) |
1895 | new (SV *klass) |
1865 | CODE: |
1896 | CODE: |
1866 | New (0, RETVAL, 1, struct map); |
1897 | New (0, RETVAL, 1, mapgrid); |
1867 | RETVAL->x = 0; |
1898 | RETVAL->x = 0; |
1868 | RETVAL->y = 0; |
1899 | RETVAL->y = 0; |
1869 | RETVAL->w = 0; |
1900 | RETVAL->w = 0; |
1870 | RETVAL->h = 0; |
1901 | RETVAL->h = 0; |
1871 | RETVAL->ox = 0; |
1902 | RETVAL->ox = 0; |
… | |
… | |
1908 | |
1939 | |
1909 | void |
1940 | void |
1910 | set_smooth (DC::Map self, int face, int smooth, int level) |
1941 | set_smooth (DC::Map self, int face, int smooth, int level) |
1911 | CODE: |
1942 | CODE: |
1912 | { |
1943 | { |
1913 | tileid texid; |
1944 | tileid texid; |
1914 | maptex *tex; |
1945 | maptex *tex; |
1915 | |
1946 | |
1916 | if (face < 0 || face >= self->faces) |
1947 | if (face < 0 || face >= self->faces) |
1917 | return; |
1948 | return; |
1918 | |
1949 | |
1919 | if (smooth < 0 || smooth >= self->faces) |
1950 | if (smooth < 0 || smooth >= self->faces) |
1920 | return; |
1951 | return; |
1921 | |
1952 | |
1922 | texid = self->face2tile [face]; |
1953 | texid = self->face2tile [face]; |
1923 | |
1954 | |
1924 | if (!texid) |
1955 | if (!texid) |
1925 | return; |
1956 | return; |
1926 | |
1957 | |
1927 | tex = self->tex + texid; |
1958 | tex = self->tex + texid; |
… | |
… | |
1960 | } |
1991 | } |
1961 | |
1992 | |
1962 | void |
1993 | void |
1963 | expire_textures (DC::Map self, int texid, int count) |
1994 | expire_textures (DC::Map self, int texid, int count) |
1964 | PPCODE: |
1995 | PPCODE: |
1965 | for (; texid < self->texs && count; ++texid, --count) |
1996 | for (; texid < self->texs && count; ++texid, --count) |
1966 | { |
1997 | { |
1967 | maptex *tex = self->tex + texid; |
1998 | maptex *tex = self->tex + texid; |
1968 | |
1999 | |
1969 | if (tex->name) |
2000 | if (tex->name) |
1970 | { |
2001 | { |
… | |
… | |
2017 | self->ox += dx; self->x += dx; |
2048 | self->ox += dx; self->x += dx; |
2018 | self->oy += dy; self->y += dy; |
2049 | self->oy += dy; self->y += dy; |
2019 | |
2050 | |
2020 | while (self->y < 0) |
2051 | while (self->y < 0) |
2021 | { |
2052 | { |
2022 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
2053 | prepend (self->row, self->rows, MAP_EXTEND_Y); |
2023 | |
2054 | |
2024 | self->rows += MAP_EXTEND_Y; |
2055 | self->rows += MAP_EXTEND_Y; |
2025 | self->y += MAP_EXTEND_Y; |
2056 | self->y += MAP_EXTEND_Y; |
2026 | } |
2057 | } |
2027 | } |
2058 | } |
2028 | |
2059 | |
2029 | SV * |
2060 | SV * |
2030 | map1a_update (DC::Map self, SV *data_, int extmap) |
2061 | map1a_update (DC::Map self, SV *data_) |
2031 | CODE: |
2062 | CODE: |
2032 | { |
2063 | { |
2033 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2064 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2034 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2065 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2035 | mapcell *cell; |
2066 | mapcell *cell; |
… | |
… | |
2056 | |
2087 | |
2057 | //TODO: don't trust server data to be in-range(!) |
2088 | //TODO: don't trust server data to be in-range(!) |
2058 | |
2089 | |
2059 | if (flags & 8) |
2090 | if (flags & 8) |
2060 | { |
2091 | { |
|
|
2092 | uint8_t ext, cmd; |
|
|
2093 | |
2061 | if (extmap) |
2094 | do |
2062 | { |
2095 | { |
2063 | uint8_t ext, cmd; |
2096 | ext = *data++; |
|
|
2097 | cmd = ext & 0x7f; |
2064 | |
2098 | |
2065 | do |
2099 | if (cmd < 4) |
|
|
2100 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2101 | else if (cmd == 5) // health |
2066 | { |
2102 | { |
2067 | ext = *data++; |
|
|
2068 | cmd = ext & 0x7f; |
|
|
2069 | |
|
|
2070 | if (cmd < 4) |
|
|
2071 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
|
|
2072 | else if (cmd == 5) // health |
|
|
2073 | { |
|
|
2074 | cell->stat_width = 1; |
2103 | cell->stat_width = 1; |
2075 | cell->stat_hp = *data++; |
2104 | cell->stat_hp = *data++; |
2076 | } |
|
|
2077 | else if (cmd == 6) // monster width |
|
|
2078 | cell->stat_width = *data++ + 1; |
|
|
2079 | else if (cmd == 0x47) |
|
|
2080 | { |
|
|
2081 | if (*data == 1) cell->player = data [1]; |
|
|
2082 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2083 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2084 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2085 | |
|
|
2086 | data += *data + 1; |
|
|
2087 | } |
|
|
2088 | else if (cmd == 8) // cell flags |
|
|
2089 | cell->flags = *data++; |
|
|
2090 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2091 | data += *data + 1; |
|
|
2092 | else |
|
|
2093 | data++; |
|
|
2094 | } |
2105 | } |
2095 | while (ext & 0x80); |
2106 | else if (cmd == 6) // monster width |
|
|
2107 | cell->stat_width = *data++ + 1; |
|
|
2108 | else if (cmd == 0x47) |
|
|
2109 | { |
|
|
2110 | if (*data == 1) cell->player = data [1]; |
|
|
2111 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2112 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2113 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
|
|
2114 | |
|
|
2115 | data += *data + 1; |
|
|
2116 | } |
|
|
2117 | else if (cmd == 8) // cell flags |
|
|
2118 | cell->flags = *data++; |
|
|
2119 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
2120 | data += *data + 1; |
|
|
2121 | else |
|
|
2122 | data++; |
2096 | } |
2123 | } |
2097 | else |
2124 | while (ext & 0x80); |
2098 | cell->darkness = *data++ + 1; |
|
|
2099 | } |
2125 | } |
2100 | |
2126 | |
2101 | for (z = 0; z <= 2; ++z) |
2127 | for (z = 0; z <= 2; ++z) |
2102 | if (flags & (4 >> z)) |
2128 | if (flags & (4 >> z)) |
2103 | { |
2129 | { |
… | |
… | |
2177 | | (b << 16) |
2203 | | (b << 16) |
2178 | | (a << 24); |
2204 | | (a << 24); |
2179 | } |
2205 | } |
2180 | } |
2206 | } |
2181 | |
2207 | |
2182 | RETVAL = map_sv; |
2208 | RETVAL = map_sv; |
2183 | } |
2209 | } |
2184 | OUTPUT: |
2210 | OUTPUT: |
2185 | RETVAL |
2211 | RETVAL |
2186 | |
2212 | |
2187 | void |
2213 | void |
2188 | draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2214 | draw (DC::Map self, int mx, int my, int sw, int sh, int Tw, int Th, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
2189 | CODE: |
2215 | CODE: |
2190 | { |
2216 | { |
2191 | int x, y, z; |
2217 | int x, y, z; |
2192 | |
2218 | |
2193 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
|
|
2194 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
|
|
2195 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2219 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! |
2196 | smooth_key skey; |
|
|
2197 | int pl_x, pl_y; |
2220 | int pl_x, pl_y; |
2198 | maptex pl_tex; |
2221 | maptex pl_tex; |
2199 | rc_t *rc = rc_alloc (); |
2222 | rc_t rc; |
2200 | rc_t *rc_ov = rc_alloc (); |
2223 | rc_t rc_ov; |
2201 | rc_key_t key; |
2224 | rc_key_t key; |
2202 | rc_array_t *arr; |
2225 | rc_t::array_t *arr; |
2203 | |
2226 | |
2204 | pl_tex.name = 0; |
2227 | pl_tex.name = 0; |
2205 | |
2228 | |
2206 | // that's current max. sorry. |
2229 | // that's current max. sorry. |
2207 | if (sw > 255) sw = 255; |
2230 | if (sw > 255) sw = 255; |
2208 | if (sh > 255) sh = 255; |
2231 | if (sh > 255) sh = 255; |
2209 | |
|
|
2210 | // clear key, in case of extra padding |
|
|
2211 | memset (&skey, 0, sizeof (skey)); |
|
|
2212 | |
2232 | |
2213 | memset (&key, 0, sizeof (key)); |
2233 | memset (&key, 0, sizeof (key)); |
2214 | key.r = 255; |
2234 | key.r = 255; |
2215 | key.g = 255; |
2235 | key.g = 255; |
2216 | key.b = 255; |
2236 | key.b = 255; |
… | |
… | |
2222 | my += self->y; |
2242 | my += self->y; |
2223 | |
2243 | |
2224 | // first pass: determine smooth_max |
2244 | // first pass: determine smooth_max |
2225 | // rather ugly, if you ask me |
2245 | // rather ugly, if you ask me |
2226 | // could also be stored inside mapcell and updated on change |
2246 | // could also be stored inside mapcell and updated on change |
2227 | memset (smooth_max, 0, sizeof (smooth_max)); |
2247 | memset (smooth_max, 0, sizeof (smooth_max[0]) * (sh + 1)); |
2228 | |
2248 | |
2229 | for (y = 0; y < sh; y++) |
2249 | for (y = 0; y < sh; y++) |
2230 | if (0 <= y + my && y + my < self->rows) |
2250 | if (0 <= y + my && y + my < self->rows) |
2231 | { |
2251 | { |
2232 | maprow *row = self->row + (y + my); |
2252 | maprow *row = self->row + (y + my); |
… | |
… | |
2247 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2267 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2248 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2268 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2249 | |
2269 | |
2250 | for (z = 0; z <= 2; z++) |
2270 | for (z = 0; z <= 2; z++) |
2251 | { |
2271 | { |
2252 | memset (smooth_level, 0, sizeof (smooth_level)); |
2272 | std::bitset<256> smooth_level; // one bit for every possible smooth level |
|
|
2273 | smooth_key skey; |
|
|
2274 | smooth_hash smooth; |
2253 | key.texname = -1; |
2275 | key.texname = -1; |
2254 | |
2276 | |
2255 | for (y = 0; y < sh; y++) |
2277 | for (y = 0; y < sh; y++) |
2256 | if (0 <= y + my && y + my < self->rows) |
2278 | if (0 <= y + my && y + my < self->rows) |
2257 | { |
2279 | { |
… | |
… | |
2274 | |
2296 | |
2275 | if (!tex.name) |
2297 | if (!tex.name) |
2276 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
2298 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
2277 | |
2299 | |
2278 | key.texname = tex.name; |
2300 | key.texname = tex.name; |
2279 | arr = rc_array (rc, &key); |
2301 | arr = &rc.array (key); |
2280 | } |
2302 | } |
2281 | |
2303 | |
2282 | px = (x + 1) * Th - tex.w; |
2304 | px = (x + 1) * Th - tex.w; |
2283 | py = (y + 1) * Tw - tex.h; |
2305 | py = (y + 1) * Tw - tex.h; |
2284 | |
2306 | |
2285 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
2307 | if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2)) |
2286 | { |
2308 | { |
2287 | pl_x = px; |
2309 | pl_x = px; |
2288 | pl_y = py; |
2310 | pl_y = py; |
2289 | pl_tex = tex; |
2311 | pl_tex = tex; |
2290 | continue; |
2312 | continue; |
2291 | } |
2313 | } |
2292 | |
2314 | |
2293 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2315 | arr->t2f_v3f (0 , 0 , px , py , 0); |
2294 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2316 | arr->t2f_v3f (0 , tex.t, px , py + tex.h, 0); |
2295 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2317 | arr->t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2296 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2318 | arr->t2f_v3f (tex.s, 0 , px + tex.w, py , 0); |
2297 | |
2319 | |
2298 | // update smooth hash |
2320 | // update smooth hash |
2299 | if (tex.smoothtile) |
2321 | if (tex.smoothtile) |
2300 | { |
2322 | { |
2301 | skey.tile = tex.smoothtile; |
2323 | skey.tile = tex.smoothtile; |
2302 | skey.level = tex.smoothlevel; |
2324 | skey.level = tex.smoothlevel; |
2303 | |
2325 | |
2304 | smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); |
2326 | smooth_level[tex.smoothlevel] = 1; |
2305 | |
2327 | |
2306 | // add bits to current tile and all neighbours. skey.x|y is |
2328 | // add bits to current tile and all neighbours. skey.x|y is |
2307 | // shifted +1|+1 so we always stay positive. |
2329 | // shifted +1|+1 so we always stay positive. |
2308 | |
2330 | |
2309 | // bits is ___n cccc CCCC bbbb |
2331 | // bits is ___n cccc CCCC bbbb |
… | |
… | |
2317 | |
2339 | |
2318 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2340 | // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· |
2319 | // ·· ·· ·┏ ┓· |
2341 | // ·· ·· ·┏ ┓· |
2320 | |
2342 | |
2321 | // full tile |
2343 | // full tile |
2322 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); |
2344 | skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x1000); |
2323 | |
2345 | |
2324 | // borders |
2346 | // borders |
2325 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); |
2347 | skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0091); |
2326 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); |
2348 | skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0032); |
2327 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); |
2349 | skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, skey, 0x0064); |
2328 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); |
2350 | skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, skey, 0x00c8); |
2329 | |
2351 | |
2330 | // corners |
2352 | // corners |
2331 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2353 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0100); |
2332 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2354 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, skey, 0x0200); |
2333 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2355 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); |
2334 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2356 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); |
2335 | } |
2357 | } |
2336 | } |
2358 | } |
2337 | |
2359 | |
2338 | if (expect_false (z == 2) && expect_false (cell->flags)) |
2360 | if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags)) |
2339 | { |
2361 | { |
2340 | // overlays such as the speech bubble, probably more to come |
2362 | // overlays such as the speech bubble, probably more to come |
2341 | if (cell->flags & 1) |
2363 | if (cell->flags & 1) |
2342 | { |
2364 | { |
2343 | rc_key_t key_ov = key; |
2365 | rc_key_t key_ov = key; |
2344 | maptex tex = self->tex [TEXID_SPEECH]; |
2366 | maptex tex = self->tex[TEXID_SPEECH]; |
2345 | rc_array_t *arr; |
|
|
2346 | int px = x * Tw + Tw * 2 / 32; |
2367 | int px = x * Tw + Tw * 2 / 32; |
2347 | int py = y * Th - Th * 6 / 32; |
2368 | int py = y * Th - Th * 6 / 32; |
2348 | |
2369 | |
2349 | key_ov.texname = tex.name; |
2370 | key_ov.texname = tex.name; |
2350 | arr = rc_array (rc_ov, &key_ov); |
2371 | rc_t::array_t &arr = rc_ov.array (key_ov); |
2351 | |
2372 | |
2352 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2373 | arr.t2f_v3f (0 , 0 , px , py , 0); |
2353 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
2374 | arr.t2f_v3f (0 , tex.t, px , py + Th, 0); |
2354 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
2375 | arr.t2f_v3f (tex.s, tex.t, px + Tw, py + Th, 0); |
2355 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
2376 | arr.t2f_v3f (tex.s, 0 , px + Tw, py , 0); |
2356 | } |
2377 | } |
2357 | } |
2378 | } |
2358 | } |
2379 | } |
2359 | } |
2380 | } |
2360 | |
2381 | |
2361 | rc_draw (rc); |
2382 | rc.draw (); |
2362 | rc_clear (rc); |
2383 | rc.clear (); |
2363 | |
2384 | |
2364 | // go through all smoothlevels, lowest to highest, then draw. |
2385 | // go through all smoothlevels, lowest to highest, then draw. |
2365 | // this is basically counting sort |
2386 | // this is basically counting sort |
2366 | { |
2387 | { |
2367 | int w, b; |
2388 | int w, b; |
2368 | |
2389 | |
2369 | glEnable (GL_TEXTURE_2D); |
2390 | glEnable (GL_TEXTURE_2D); |
2370 | glBegin (GL_QUADS); |
2391 | glBegin (GL_QUADS); |
2371 | for (w = 0; w < 256 / 32; ++w) |
2392 | for (int level = 0; level < smooth_level.size (); ++level) |
|
|
2393 | if (smooth_level[level]) |
|
|
2394 | for (auto &&it = smooth.begin (); it != smooth.end (); ++it) |
2372 | { |
2395 | { |
2373 | uint32_t smask = smooth_level [w]; |
2396 | smooth_key &skey = it->first; |
2374 | if (smask) |
2397 | IV bits = it->second; |
2375 | for (b = 0; b < 32; ++b) |
2398 | |
2376 | if (smask & (((uint32_t)1) << b)) |
2399 | if (!(bits & 0x1000) |
|
|
2400 | && skey.level == level |
|
|
2401 | && level > smooth_max [skey.x][skey.y]) |
2377 | { |
2402 | { |
2378 | int level = (w << 5) | b; |
2403 | maptex tex = self->tex [skey.tile]; |
|
|
2404 | int px = (((int)skey.x) - 1) * Tw; |
|
|
2405 | int py = (((int)skey.y) - 1) * Th; |
|
|
2406 | int border = bits & 15; |
|
|
2407 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
|
|
2408 | float dx = tex.s * .0625f; // 16 images/row |
|
|
2409 | float dy = tex.t * .5f ; // 2 images/column |
|
|
2410 | |
2379 | HE *he; |
2411 | if (tex.name) |
2380 | |
|
|
2381 | hv_iterinit (smooth); |
|
|
2382 | while ((he = hv_iternext (smooth))) |
|
|
2383 | { |
2412 | { |
2384 | smooth_key *skey = (smooth_key *)HeKEY (he); |
2413 | // this time avoiding texture state changes |
2385 | IV bits = SvIVX (HeVAL (he)); |
2414 | // save gobs of state changes. |
2386 | |
2415 | if (key.texname != tex.name) |
2387 | if (!(bits & 0x1000) |
|
|
2388 | && skey->level == level |
|
|
2389 | && level > smooth_max [skey->x][skey->y]) |
|
|
2390 | { |
2416 | { |
2391 | maptex tex = self->tex [skey->tile]; |
|
|
2392 | int px = (((int)skey->x) - 1) * Tw; |
|
|
2393 | int py = (((int)skey->y) - 1) * Th; |
|
|
2394 | int border = bits & 15; |
|
|
2395 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
|
|
2396 | float dx = tex.s * .0625f; // 16 images/row |
|
|
2397 | float dy = tex.t * .5f ; // 2 images/column |
|
|
2398 | |
|
|
2399 | if (tex.name) |
|
|
2400 | { |
|
|
2401 | // this time avoiding texture state changes |
|
|
2402 | // save gobs of state changes. |
|
|
2403 | if (key.texname != tex.name) |
|
|
2404 | { |
|
|
2405 | self->tex [skey->tile].unused = 0; |
2417 | self->tex [skey.tile].unused = 0; |
2406 | |
2418 | |
2407 | glEnd (); |
2419 | glEnd (); |
2408 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2420 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2409 | glBegin (GL_QUADS); |
2421 | glBegin (GL_QUADS); |
2410 | } |
2422 | } |
2411 | |
2423 | |
2412 | if (border) |
2424 | if (border) |
2413 | { |
2425 | { |
2414 | float ox = border * dx; |
2426 | float ox = border * dx; |
2415 | |
2427 | |
2416 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2428 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2417 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2429 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
2418 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2430 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
2419 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2431 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
2420 | } |
2432 | } |
2421 | |
2433 | |
2422 | if (corner) |
2434 | if (corner) |
2423 | { |
2435 | { |
2424 | float ox = corner * dx; |
2436 | float ox = corner * dx; |
2425 | |
2437 | |
2426 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2438 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2427 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2439 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
2428 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2440 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
2429 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2441 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
2430 | } |
|
|
2431 | } |
|
|
2432 | } |
2442 | } |
2433 | } |
2443 | } |
2434 | } |
2444 | } |
2435 | } |
2445 | } |
2436 | |
2446 | |
2437 | glEnd (); |
2447 | glEnd (); |
2438 | glDisable (GL_TEXTURE_2D); |
2448 | glDisable (GL_TEXTURE_2D); |
2439 | key.texname = -1; |
2449 | key.texname = -1; |
2440 | } |
2450 | } |
2441 | |
|
|
2442 | hv_clear (smooth); |
|
|
2443 | } |
2451 | } |
2444 | |
2452 | |
2445 | if (pl_tex.name) |
2453 | if (pl_tex.name) |
2446 | { |
2454 | { |
2447 | maptex tex = pl_tex; |
2455 | maptex tex = pl_tex; |
2448 | int px = pl_x + sdx; |
2456 | int px = pl_x + sdx; |
2449 | int py = pl_y + sdy; |
2457 | int py = pl_y + sdy; |
2450 | |
2458 | |
2451 | key.texname = tex.name; |
2459 | key.texname = tex.name; |
2452 | arr = rc_array (rc, &key); |
2460 | rc_t::array_t &arr = rc.array (key); |
2453 | |
2461 | |
2454 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2462 | arr.t2f_v3f (0 , 0 , px , py , 0); |
2455 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2463 | arr.t2f_v3f (0 , tex.t, px , py + tex.h, 0); |
2456 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2464 | arr.t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2457 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2465 | arr.t2f_v3f (tex.s, 0 , px + tex.w, py , 0); |
2458 | |
2466 | |
2459 | rc_draw (rc); |
2467 | rc.draw (); |
2460 | } |
2468 | } |
2461 | |
2469 | |
2462 | rc_draw (rc_ov); |
2470 | rc_ov.draw (); |
2463 | rc_clear (rc_ov); |
2471 | rc_ov.clear (); |
2464 | |
2472 | |
2465 | glDisable (GL_BLEND); |
2473 | glDisable (GL_BLEND); |
2466 | rc_free (rc); |
|
|
2467 | rc_free (rc_ov); |
|
|
2468 | |
2474 | |
2469 | // top layer: overlays such as the health bar |
2475 | // top layer: overlays such as the health bar |
2470 | for (y = 0; y < sh; y++) |
2476 | for (y = 0; y < sh; y++) |
2471 | if (0 <= y + my && y + my < self->rows) |
2477 | if (0 <= y + my && y + my < self->rows) |
2472 | { |
2478 | { |
… | |
… | |
2478 | mapcell *cell = row->col + (x + mx - row->c0); |
2484 | mapcell *cell = row->col + (x + mx - row->c0); |
2479 | |
2485 | |
2480 | int px = x * Tw; |
2486 | int px = x * Tw; |
2481 | int py = y * Th; |
2487 | int py = y * Th; |
2482 | |
2488 | |
2483 | if (expect_false (cell->player == player)) |
2489 | if (ecb_expect_false (cell->player == player)) |
2484 | { |
2490 | { |
2485 | px += sdx; |
2491 | px += sdx; |
2486 | py += sdy; |
2492 | py += sdy; |
2487 | } |
2493 | } |
2488 | |
2494 | |
… | |
… | |
2716 | else |
2722 | else |
2717 | *data++ = 0; |
2723 | *data++ = 0; |
2718 | } |
2724 | } |
2719 | } |
2725 | } |
2720 | |
2726 | |
2721 | /* if size is w*h + 5 then no data has been found */ |
2727 | /* if size is w*h + 5 then no data has been found */ |
2722 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2728 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
2723 | { |
2729 | { |
2724 | SvPOK_only (data_sv); |
2730 | SvPOK_only (data_sv); |
2725 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2731 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2726 | } |
2732 | } |
2727 | |
2733 | |
2728 | RETVAL = data_sv; |
2734 | RETVAL = data_sv; |
2729 | } |
2735 | } |
2730 | OUTPUT: |
2736 | OUTPUT: |
2731 | RETVAL |
2737 | RETVAL |
2732 | |
2738 | |
2733 | void |
2739 | void |
… | |
… | |
2740 | STRLEN len; |
2746 | STRLEN len; |
2741 | uint8_t *data, *end; |
2747 | uint8_t *data, *end; |
2742 | |
2748 | |
2743 | len = SvLEN (data_sv); |
2749 | len = SvLEN (data_sv); |
2744 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2750 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
2745 | data = SvPVbyte_nolen (data_sv); |
2751 | data = (uint8_t *)SvPVbyte_nolen (data_sv); |
2746 | end = data + len + 8; |
2752 | end = data + len + 8; |
2747 | |
2753 | |
2748 | if (len < 5) |
2754 | if (len < 5) |
2749 | XSRETURN_EMPTY; |
2755 | XSRETURN_EMPTY; |
2750 | |
2756 | |
… | |
… | |
2811 | } |
2817 | } |
2812 | |
2818 | |
2813 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2819 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2814 | |
2820 | |
2815 | DC::RW |
2821 | DC::RW |
2816 | new (SV *class, SV *data_sv) |
2822 | new (SV *klass, SV *data_sv) |
2817 | CODE: |
2823 | CODE: |
2818 | { |
2824 | { |
2819 | STRLEN datalen; |
2825 | STRLEN datalen; |
2820 | char *data = SvPVbyte (data_sv, datalen); |
2826 | char *data = SvPVbyte (data_sv, datalen); |
2821 | |
2827 | |
… | |
… | |
2823 | } |
2829 | } |
2824 | OUTPUT: |
2830 | OUTPUT: |
2825 | RETVAL |
2831 | RETVAL |
2826 | |
2832 | |
2827 | DC::RW |
2833 | DC::RW |
2828 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2834 | new_from_file (SV *klass, const char *path, const char *mode = "rb") |
2829 | CODE: |
2835 | CODE: |
2830 | RETVAL = SDL_RWFromFile (path, mode); |
2836 | RETVAL = SDL_RWFromFile (path, mode); |
2831 | OUTPUT: |
2837 | OUTPUT: |
2832 | RETVAL |
2838 | RETVAL |
2833 | |
2839 | |
… | |
… | |
2942 | #else |
2948 | #else |
2943 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2949 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
2944 | #endif |
2950 | #endif |
2945 | |
2951 | |
2946 | DC::MixChunk |
2952 | DC::MixChunk |
2947 | new (SV *class, DC::RW rwops) |
2953 | new (SV *klass, DC::RW rwops) |
2948 | CODE: |
2954 | CODE: |
2949 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2955 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2950 | OUTPUT: |
2956 | OUTPUT: |
2951 | RETVAL |
2957 | RETVAL |
2952 | |
2958 | |
… | |
… | |
3022 | RETVAL = Mix_PlayingMusic (); |
3028 | RETVAL = Mix_PlayingMusic (); |
3023 | OUTPUT: |
3029 | OUTPUT: |
3024 | RETVAL |
3030 | RETVAL |
3025 | |
3031 | |
3026 | DC::MixMusic |
3032 | DC::MixMusic |
3027 | new (SV *class, DC::RW rwops) |
3033 | new (SV *klass, DC::RW rwops) |
3028 | CODE: |
3034 | CODE: |
3029 | RETVAL = Mix_LoadMUS_RW (rwops); |
3035 | RETVAL = Mix_LoadMUS_RW (rwops); |
3030 | OUTPUT: |
3036 | OUTPUT: |
3031 | RETVAL |
3037 | RETVAL |
3032 | |
3038 | |
… | |
… | |
3185 | gl.BlendFuncSeparateEXT = 0; |
3191 | gl.BlendFuncSeparateEXT = 0; |
3186 | |
3192 | |
3187 | void |
3193 | void |
3188 | apple_nvidia_bug (int enable) |
3194 | apple_nvidia_bug (int enable) |
3189 | |
3195 | |
3190 | char * |
3196 | const char * |
3191 | gl_vendor () |
3197 | gl_vendor () |
3192 | CODE: |
3198 | CODE: |
3193 | RETVAL = (char *)glGetString (GL_VENDOR); |
3199 | RETVAL = (const char *)glGetString (GL_VENDOR); |
3194 | OUTPUT: |
3200 | OUTPUT: |
3195 | RETVAL |
3201 | RETVAL |
3196 | |
3202 | |
3197 | char * |
3203 | const char * |
3198 | gl_version () |
3204 | gl_version () |
3199 | CODE: |
3205 | CODE: |
3200 | RETVAL = (char *)glGetString (GL_VERSION); |
3206 | RETVAL = (const char *)glGetString (GL_VERSION); |
3201 | OUTPUT: |
3207 | OUTPUT: |
3202 | RETVAL |
3208 | RETVAL |
3203 | |
3209 | |
3204 | char * |
3210 | const char * |
3205 | gl_extensions () |
3211 | gl_extensions () |
3206 | CODE: |
3212 | CODE: |
3207 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
3213 | RETVAL = (const char *)glGetString (GL_EXTENSIONS); |
3208 | OUTPUT: |
3214 | OUTPUT: |
3209 | RETVAL |
3215 | RETVAL |
3210 | |
3216 | |
3211 | const char *glGetString (GLenum pname) |
3217 | const char *glGetString (GLenum pname) |
|
|
3218 | CODE: |
|
|
3219 | RETVAL = (const char *)glGetString (pname); |
|
|
3220 | OUTPUT: |
|
|
3221 | RETVAL |
3212 | |
3222 | |
3213 | GLint glGetInteger (GLenum pname) |
3223 | GLint glGetInteger (GLenum pname) |
3214 | CODE: |
3224 | CODE: |
3215 | glGetIntegerv (pname, &RETVAL); |
3225 | glGetIntegerv (pname, &RETVAL); |
3216 | OUTPUT: |
3226 | OUTPUT: |
… | |
… | |
3419 | |
3429 | |
3420 | void |
3430 | void |
3421 | find_widget (SV *self, NV x, NV y) |
3431 | find_widget (SV *self, NV x, NV y) |
3422 | PPCODE: |
3432 | PPCODE: |
3423 | { |
3433 | { |
3424 | if (within_widget (self, x, y)) |
3434 | if (within_widget (self, x, y)) |
3425 | XPUSHs (self); |
3435 | XPUSHs (self); |
3426 | } |
3436 | } |
3427 | |
3437 | |
3428 | BOOT: |
3438 | BOOT: |
3429 | { |
3439 | { |
… | |
… | |
3437 | |
3447 | |
3438 | void |
3448 | void |
3439 | draw (SV *self) |
3449 | draw (SV *self) |
3440 | CODE: |
3450 | CODE: |
3441 | { |
3451 | { |
3442 | HV *hv; |
3452 | HV *hv; |
3443 | SV **svp; |
3453 | SV **svp; |
3444 | NV x, y, w, h; |
3454 | NV x, y, w, h; |
3445 | SV *draw_x_sv = GvSV (draw_x_gv); |
3455 | SV *draw_x_sv = GvSV (draw_x_gv); |
3446 | SV *draw_y_sv = GvSV (draw_y_gv); |
3456 | SV *draw_y_sv = GvSV (draw_y_gv); |
3447 | SV *draw_w_sv = GvSV (draw_w_gv); |
3457 | SV *draw_w_sv = GvSV (draw_w_gv); |
3448 | SV *draw_h_sv = GvSV (draw_h_gv); |
3458 | SV *draw_h_sv = GvSV (draw_h_gv); |