… | |
… | |
19 | |
19 | |
20 | #ifdef _WIN32 |
20 | #ifdef _WIN32 |
21 | # undef pipe |
21 | # undef pipe |
22 | // microsoft vs. C |
22 | // microsoft vs. C |
23 | # define sqrtf(x) sqrt(x) |
23 | # define sqrtf(x) sqrt(x) |
24 | # define roundf(x) (int)(x) |
|
|
25 | # define atan2f(x,y) atan2(x,y) |
24 | # define atan2f(x,y) atan2(x,y) |
26 | # define M_PI 3.14159265f |
25 | # define M_PI 3.14159265f |
27 | #endif |
26 | #endif |
28 | |
27 | |
29 | #include <assert.h> |
28 | #include <assert.h> |
… | |
… | |
39 | #include <SDL_endian.h> |
38 | #include <SDL_endian.h> |
40 | #include <SDL_image.h> |
39 | #include <SDL_image.h> |
41 | #include <SDL_mixer.h> |
40 | #include <SDL_mixer.h> |
42 | #include <SDL_opengl.h> |
41 | #include <SDL_opengl.h> |
43 | |
42 | |
|
|
43 | /* work around os x broken headers */ |
|
|
44 | #ifdef __MACOSX__ |
|
|
45 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); |
|
|
46 | typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); |
|
|
47 | typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); |
|
|
48 | #endif |
|
|
49 | |
44 | #define PANGO_ENABLE_BACKEND |
50 | #define PANGO_ENABLE_BACKEND |
45 | #define G_DISABLE_CAST_CHECKS |
51 | #define G_DISABLE_CAST_CHECKS |
46 | |
52 | |
47 | #include <glib/gmacros.h> |
53 | #include <glib/gmacros.h> |
48 | |
54 | |
49 | #include <pango/pango.h> |
55 | #include <pango/pango.h> |
|
|
56 | |
|
|
57 | #ifndef PANGO_VERSION_CHECK |
|
|
58 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
|
|
59 | #endif |
|
|
60 | |
|
|
61 | #if !PANGO_VERSION_CHECK (1, 15, 2) |
|
|
62 | # define pango_layout_get_line_readonly pango_layout_get_line |
|
|
63 | # define pango_layout_get_lines_readonly pango_layout_get_lines |
|
|
64 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line |
|
|
65 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run |
|
|
66 | #endif |
50 | |
67 | |
51 | #ifndef _WIN32 |
68 | #ifndef _WIN32 |
52 | # include <sys/types.h> |
69 | # include <sys/types.h> |
53 | # include <sys/socket.h> |
70 | # include <sys/socket.h> |
54 | # include <netinet/in.h> |
71 | # include <netinet/in.h> |
55 | # include <netinet/tcp.h> |
72 | # include <netinet/tcp.h> |
56 | # include <inttypes.h> |
73 | # include <inttypes.h> |
57 | #endif |
74 | #endif |
58 | |
75 | |
|
|
76 | #if __GNUC__ >= 4 |
|
|
77 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
|
|
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 | |
59 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
85 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
60 | |
86 | |
|
|
87 | /* this is used as fow flag as well, so has to have a different value */ |
|
|
88 | /* then anything that is computed by incoming darkness */ |
61 | #define FOW_DARKNESS 32 |
89 | #define FOW_DARKNESS 50 |
|
|
90 | #define DARKNESS_ADJUST(n) (n) |
62 | |
91 | |
63 | #define MAP_EXTEND_X 32 |
92 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
93 | #define MAP_EXTEND_Y 512 |
65 | |
94 | |
66 | #define MIN_FONT_HEIGHT 10 |
95 | #define MIN_FONT_HEIGHT 10 |
67 | |
96 | |
68 | #if 0 |
97 | /* mask out modifiers we are not interested in */ |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
98 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
70 | #else |
99 | |
71 | # define PARACHUTE 0 |
100 | #define KMOD_LRAM 0x10000 // our extension |
72 | #endif |
101 | |
|
|
102 | #define TEXID_SPEECH 1 |
|
|
103 | #define TEXID_NOFACE 2 |
|
|
104 | |
|
|
105 | static char * |
|
|
106 | fast_sv_grow (SV *sv, STRLEN need) |
|
|
107 | { |
|
|
108 | STRLEN len = SvLEN (sv); |
|
|
109 | STRLEN want = SvCUR (sv) + need; |
|
|
110 | |
|
|
111 | if (expect_false (len < want)) |
|
|
112 | { |
|
|
113 | do |
|
|
114 | len *= 2; |
|
|
115 | while (len < want); |
|
|
116 | |
|
|
117 | sv_grow (sv, len); |
|
|
118 | } |
|
|
119 | |
|
|
120 | SvCUR_set (sv, want); |
|
|
121 | return SvEND (sv) - need; |
|
|
122 | } |
73 | |
123 | |
74 | static AV *texture_av; |
124 | static AV *texture_av; |
75 | |
125 | |
76 | static struct |
126 | static struct |
77 | { |
127 | { |
… | |
… | |
120 | |
170 | |
121 | #include "pango-font.c" |
171 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
172 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
173 | #include "pango-render.c" |
124 | |
174 | |
125 | typedef IV CFPlus__Channel; |
175 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
176 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
177 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
178 | typedef Mix_Music *DC__MixMusic; |
129 | |
179 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
180 | typedef PangoFontDescription *DC__Font; |
131 | |
181 | |
132 | static int |
182 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
183 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
184 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
185 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
199 | |
150 | typedef struct cf_layout { |
200 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
201 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
202 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
203 | int base_height; |
154 | CFPlus__Font font; |
204 | DC__Font font; |
155 | rc_t *rc; |
205 | rc_t *rc; |
156 | } *CFPlus__Layout; |
206 | } *DC__Layout; |
157 | |
207 | |
158 | static CFPlus__Font default_font; |
208 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
209 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
210 | static PangoFontMap *opengl_fontmap; |
161 | |
211 | |
162 | static void |
212 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
213 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
218 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
219 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
220 | } |
171 | |
221 | |
172 | static void |
222 | static void |
173 | layout_update_font (CFPlus__Layout self) |
223 | layout_update_font (DC__Layout self) |
174 | { |
224 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
225 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
226 | * reasonably well with dejavu/bistream fonts |
177 | */ |
227 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
228 | PangoFontDescription *font = self->font ? self->font : default_font; |
179 | |
229 | |
180 | pango_font_description_set_absolute_size (font, |
230 | pango_font_description_set_absolute_size (font, |
181 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
231 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
182 | |
232 | |
183 | pango_layout_set_font_description (self->pl, font); |
233 | pango_layout_set_font_description (self->pl, font); |
184 | } |
234 | } |
185 | |
235 | |
186 | static void |
236 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
237 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
238 | { |
189 | PangoRectangle rect; |
239 | PangoRectangle rect; |
190 | |
240 | |
191 | // get_pixel_* wrongly rounds down |
241 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
242 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
203 | |
253 | |
204 | typedef uint16_t tileid; |
254 | typedef uint16_t tileid; |
205 | typedef uint16_t faceid; |
255 | typedef uint16_t faceid; |
206 | |
256 | |
207 | typedef struct { |
257 | typedef struct { |
208 | int name; |
258 | GLuint name; |
209 | int w, h; |
259 | int w, h; |
210 | float s, t; |
260 | float s, t; |
211 | uint8_t r, g, b, a; |
261 | uint8_t r, g, b, a; |
212 | tileid smoothtile; |
262 | tileid smoothtile; |
213 | uint8_t smoothlevel; |
263 | uint8_t smoothlevel; |
|
|
264 | uint8_t unused; /* set to zero on use */ |
214 | } maptex; |
265 | } maptex; |
215 | |
266 | |
216 | typedef struct { |
267 | typedef struct { |
217 | uint32_t player; |
268 | uint32_t player; |
218 | tileid tile[3]; |
269 | tileid tile[3]; |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
282 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
283 | int texs; maptex *tex; // [tileid] |
233 | |
284 | |
234 | int32_t rows; |
285 | int32_t rows; |
235 | maprow *row; |
286 | maprow *row; |
236 | } *CFPlus__Map; |
287 | } *DC__Map; |
237 | |
288 | |
238 | static char * |
289 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
290 | prepend (char *ptr, int sze, int inc) |
240 | { |
291 | { |
241 | char *p; |
292 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
330 | self->texs *= 2; |
280 | } |
331 | } |
281 | } |
332 | } |
282 | |
333 | |
283 | static maprow * |
334 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
335 | map_get_row (DC__Map self, int y) |
285 | { |
336 | { |
286 | if (0 > y) |
337 | if (0 > y) |
287 | { |
338 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
339 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
340 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
378 | |
328 | return row->col + (x - row->c0); |
379 | return row->col + (x - row->c0); |
329 | } |
380 | } |
330 | |
381 | |
331 | static mapcell * |
382 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
383 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
384 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
385 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
386 | } |
336 | |
387 | |
337 | static void |
388 | static void |
338 | map_clear (CFPlus__Map self) |
389 | map_clear (DC__Map self) |
339 | { |
390 | { |
340 | int r; |
391 | int r; |
341 | |
392 | |
342 | for (r = 0; r < self->rows; r++) |
393 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
394 | Safefree (self->row[r].col); |
… | |
… | |
350 | self->oy = 0; |
401 | self->oy = 0; |
351 | self->row = 0; |
402 | self->row = 0; |
352 | self->rows = 0; |
403 | self->rows = 0; |
353 | } |
404 | } |
354 | |
405 | |
|
|
406 | #define CELL_CLEAR(cell) \ |
|
|
407 | do { \ |
|
|
408 | if ((cell)->player) \ |
|
|
409 | (cell)->tile [2] = 0; \ |
|
|
410 | (cell)->darkness = 0; \ |
|
|
411 | (cell)->stat_hp = 0; \ |
|
|
412 | (cell)->flags = 0; \ |
|
|
413 | (cell)->player = 0; \ |
|
|
414 | } while (0) |
|
|
415 | |
355 | static void |
416 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
417 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
418 | { |
358 | int x, y; |
419 | int x, y; |
359 | maprow *row; |
420 | maprow *row; |
360 | mapcell *cell; |
421 | mapcell *cell; |
361 | |
422 | |
… | |
… | |
373 | if (x >= row->c1) |
434 | if (x >= row->c1) |
374 | break; |
435 | break; |
375 | |
436 | |
376 | cell = row->col + x - row->c0; |
437 | cell = row->col + x - row->c0; |
377 | |
438 | |
378 | cell->darkness = 0; |
439 | CELL_CLEAR (cell); |
379 | cell->stat_hp = 0; |
|
|
380 | cell->flags = 0; |
|
|
381 | cell->player = 0; |
|
|
382 | } |
440 | } |
383 | } |
441 | } |
384 | } |
442 | } |
385 | |
443 | |
386 | typedef struct { |
444 | typedef struct { |
… | |
… | |
421 | ev.code = 1; |
479 | ev.code = 1; |
422 | ev.data1 = (void *)(long)channel; |
480 | ev.data1 = (void *)(long)channel; |
423 | ev.data2 = 0; |
481 | ev.data2 = 0; |
424 | |
482 | |
425 | SDL_PushEvent ((SDL_Event *)&ev); |
483 | SDL_PushEvent ((SDL_Event *)&ev); |
|
|
484 | } |
|
|
485 | |
|
|
486 | static unsigned int |
|
|
487 | div255 (unsigned int n) |
|
|
488 | { |
|
|
489 | return (n + (n >> 8)) >> 8; |
426 | } |
490 | } |
427 | |
491 | |
428 | static unsigned int |
492 | static unsigned int |
429 | minpot (unsigned int n) |
493 | minpot (unsigned int n) |
430 | { |
494 | { |
… | |
… | |
440 | n |= n >> 16; |
504 | n |= n >> 16; |
441 | |
505 | |
442 | return n + 1; |
506 | return n + 1; |
443 | } |
507 | } |
444 | |
508 | |
|
|
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 | |
445 | /* SDL should provide this, really. */ |
520 | /* SDL should provide this, really. */ |
446 | #define SDLK_MODIFIER_MIN 300 |
521 | #define SDLK_MODIFIER_MIN 300 |
447 | #define SDLK_MODIFIER_MAX 314 |
522 | #define SDLK_MODIFIER_MAX 314 |
448 | |
523 | |
449 | /******************************************************************************/ |
524 | /******************************************************************************/ |
… | |
… | |
487 | return 0; |
562 | return 0; |
488 | |
563 | |
489 | return 1; |
564 | return 1; |
490 | } |
565 | } |
491 | |
566 | |
492 | MODULE = CFPlus PACKAGE = CFPlus |
567 | /******************************************************************************/ |
|
|
568 | |
|
|
569 | /* process keyboard modifiers */ |
|
|
570 | static int |
|
|
571 | mod_munge (int mod) |
|
|
572 | { |
|
|
573 | mod &= MOD_MASK; |
|
|
574 | |
|
|
575 | if (mod & (KMOD_META | KMOD_ALT)) |
|
|
576 | mod |= KMOD_LRAM; |
|
|
577 | |
|
|
578 | return mod; |
|
|
579 | } |
|
|
580 | |
|
|
581 | static void |
|
|
582 | deliantra_main () |
|
|
583 | { |
|
|
584 | char *argv[] = { 0 }; |
|
|
585 | call_argv ("::main", G_DISCARD | G_VOID, argv); |
|
|
586 | } |
|
|
587 | |
|
|
588 | #ifdef __MACOSX__ |
|
|
589 | /* to due surprising braindamage on the side of SDL design, we |
|
|
590 | * 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, |
|
|
592 | * due to share dlibrary magic, calls -lSDLmain's main, not perl's main, |
|
|
593 | * and which calls our main (== SDL_main) back. |
|
|
594 | */ |
|
|
595 | extern C_LINKAGE int |
|
|
596 | main (int argc, char *argv[]) |
|
|
597 | { |
|
|
598 | deliantra_main (); |
|
|
599 | } |
|
|
600 | |
|
|
601 | #undef main |
|
|
602 | |
|
|
603 | extern C_LINKAGE int main (int argc, char *argv[]); |
|
|
604 | |
|
|
605 | static void |
|
|
606 | SDL_braino (void) |
|
|
607 | { |
|
|
608 | char *argv[] = { "deliantra client", 0 }; |
|
|
609 | (main) (1, argv); |
|
|
610 | } |
|
|
611 | #else |
|
|
612 | static void |
|
|
613 | SDL_braino (void) |
|
|
614 | { |
|
|
615 | deliantra_main (); |
|
|
616 | } |
|
|
617 | #endif |
|
|
618 | |
|
|
619 | MODULE = Deliantra::Client PACKAGE = DC |
493 | |
620 | |
494 | PROTOTYPES: ENABLE |
621 | PROTOTYPES: ENABLE |
495 | |
622 | |
496 | BOOT: |
623 | BOOT: |
497 | { |
624 | { |
498 | HV *stash = gv_stashpv ("CFPlus", 1); |
625 | HV *stash = gv_stashpv ("DC", 1); |
499 | static const struct { |
626 | static const struct { |
500 | const char *name; |
627 | const char *name; |
501 | IV iv; |
628 | IV iv; |
502 | } *civ, const_iv[] = { |
629 | } *civ, const_iv[] = { |
503 | # define const_iv(name) { # name, (IV)name } |
630 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
525 | |
652 | |
526 | const_iv (SDL_APPINPUTFOCUS), |
653 | const_iv (SDL_APPINPUTFOCUS), |
527 | const_iv (SDL_APPMOUSEFOCUS), |
654 | const_iv (SDL_APPMOUSEFOCUS), |
528 | const_iv (SDL_APPACTIVE), |
655 | const_iv (SDL_APPACTIVE), |
529 | |
656 | |
|
|
657 | |
|
|
658 | const_iv (SDLK_UNKNOWN), |
|
|
659 | const_iv (SDLK_FIRST), |
|
|
660 | const_iv (SDLK_BACKSPACE), |
|
|
661 | const_iv (SDLK_TAB), |
|
|
662 | const_iv (SDLK_CLEAR), |
|
|
663 | const_iv (SDLK_RETURN), |
|
|
664 | const_iv (SDLK_PAUSE), |
|
|
665 | const_iv (SDLK_ESCAPE), |
|
|
666 | const_iv (SDLK_SPACE), |
|
|
667 | const_iv (SDLK_EXCLAIM), |
|
|
668 | const_iv (SDLK_QUOTEDBL), |
|
|
669 | const_iv (SDLK_HASH), |
|
|
670 | const_iv (SDLK_DOLLAR), |
|
|
671 | const_iv (SDLK_AMPERSAND), |
|
|
672 | const_iv (SDLK_QUOTE), |
|
|
673 | const_iv (SDLK_LEFTPAREN), |
|
|
674 | const_iv (SDLK_RIGHTPAREN), |
|
|
675 | const_iv (SDLK_ASTERISK), |
|
|
676 | const_iv (SDLK_PLUS), |
|
|
677 | const_iv (SDLK_COMMA), |
|
|
678 | const_iv (SDLK_MINUS), |
|
|
679 | const_iv (SDLK_PERIOD), |
|
|
680 | const_iv (SDLK_SLASH), |
|
|
681 | const_iv (SDLK_0), |
|
|
682 | const_iv (SDLK_1), |
|
|
683 | const_iv (SDLK_2), |
|
|
684 | const_iv (SDLK_3), |
|
|
685 | const_iv (SDLK_4), |
|
|
686 | const_iv (SDLK_5), |
|
|
687 | const_iv (SDLK_6), |
|
|
688 | const_iv (SDLK_7), |
|
|
689 | const_iv (SDLK_8), |
|
|
690 | const_iv (SDLK_9), |
|
|
691 | const_iv (SDLK_COLON), |
|
|
692 | const_iv (SDLK_SEMICOLON), |
|
|
693 | const_iv (SDLK_LESS), |
|
|
694 | const_iv (SDLK_EQUALS), |
|
|
695 | const_iv (SDLK_GREATER), |
|
|
696 | const_iv (SDLK_QUESTION), |
|
|
697 | const_iv (SDLK_AT), |
|
|
698 | |
|
|
699 | const_iv (SDLK_LEFTBRACKET), |
|
|
700 | const_iv (SDLK_BACKSLASH), |
|
|
701 | const_iv (SDLK_RIGHTBRACKET), |
|
|
702 | const_iv (SDLK_CARET), |
|
|
703 | const_iv (SDLK_UNDERSCORE), |
|
|
704 | const_iv (SDLK_BACKQUOTE), |
|
|
705 | const_iv (SDLK_DELETE), |
|
|
706 | |
|
|
707 | const_iv (SDLK_FIRST), |
|
|
708 | const_iv (SDLK_LAST), |
530 | const_iv (SDLK_KP0), |
709 | const_iv (SDLK_KP0), |
531 | const_iv (SDLK_KP1), |
710 | const_iv (SDLK_KP1), |
532 | const_iv (SDLK_KP2), |
711 | const_iv (SDLK_KP2), |
533 | const_iv (SDLK_KP3), |
712 | const_iv (SDLK_KP3), |
534 | const_iv (SDLK_KP4), |
713 | const_iv (SDLK_KP4), |
… | |
… | |
606 | const_iv (KMOD_LMETA), |
785 | const_iv (KMOD_LMETA), |
607 | const_iv (KMOD_RMETA), |
786 | const_iv (KMOD_RMETA), |
608 | const_iv (KMOD_NUM), |
787 | const_iv (KMOD_NUM), |
609 | const_iv (KMOD_CAPS), |
788 | const_iv (KMOD_CAPS), |
610 | const_iv (KMOD_MODE), |
789 | const_iv (KMOD_MODE), |
|
|
790 | |
|
|
791 | const_iv (KMOD_LRAM), |
|
|
792 | |
|
|
793 | const_iv (MIX_DEFAULT_FORMAT), |
|
|
794 | |
|
|
795 | const_iv (SDL_INIT_TIMER), |
|
|
796 | const_iv (SDL_INIT_AUDIO), |
|
|
797 | const_iv (SDL_INIT_VIDEO), |
|
|
798 | const_iv (SDL_INIT_CDROM), |
|
|
799 | const_iv (SDL_INIT_JOYSTICK), |
|
|
800 | const_iv (SDL_INIT_EVERYTHING), |
|
|
801 | const_iv (SDL_INIT_NOPARACHUTE), |
|
|
802 | const_iv (SDL_INIT_EVENTTHREAD), |
|
|
803 | |
|
|
804 | const_iv (SDL_GL_RED_SIZE), |
|
|
805 | const_iv (SDL_GL_GREEN_SIZE), |
|
|
806 | const_iv (SDL_GL_BLUE_SIZE), |
|
|
807 | const_iv (SDL_GL_ALPHA_SIZE), |
|
|
808 | const_iv (SDL_GL_DOUBLEBUFFER), |
|
|
809 | const_iv (SDL_GL_BUFFER_SIZE), |
|
|
810 | const_iv (SDL_GL_DEPTH_SIZE), |
|
|
811 | const_iv (SDL_GL_STENCIL_SIZE), |
|
|
812 | const_iv (SDL_GL_ACCUM_RED_SIZE), |
|
|
813 | const_iv (SDL_GL_ACCUM_GREEN_SIZE), |
|
|
814 | const_iv (SDL_GL_ACCUM_BLUE_SIZE), |
|
|
815 | const_iv (SDL_GL_ACCUM_ALPHA_SIZE), |
|
|
816 | const_iv (SDL_GL_STEREO), |
|
|
817 | const_iv (SDL_GL_MULTISAMPLEBUFFERS), |
|
|
818 | const_iv (SDL_GL_MULTISAMPLESAMPLES), |
|
|
819 | const_iv (SDL_GL_ACCELERATED_VISUAL), |
|
|
820 | const_iv (SDL_GL_SWAP_CONTROL), |
|
|
821 | |
|
|
822 | const_iv (FOW_DARKNESS) |
611 | # undef const_iv |
823 | # undef const_iv |
612 | }; |
824 | }; |
613 | |
825 | |
614 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
826 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
615 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
827 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
633 | |
845 | |
634 | NV floor (NV x) |
846 | NV floor (NV x) |
635 | |
847 | |
636 | NV ceil (NV x) |
848 | NV ceil (NV x) |
637 | |
849 | |
|
|
850 | IV minpot (UV n) |
|
|
851 | |
|
|
852 | IV popcount (UV n) |
|
|
853 | |
|
|
854 | NV distance (NV dx, NV dy) |
|
|
855 | CODE: |
|
|
856 | RETVAL = pow (dx * dx + dy * dy, 0.5); |
|
|
857 | OUTPUT: |
|
|
858 | RETVAL |
|
|
859 | |
638 | void |
860 | void |
639 | pango_init () |
861 | pango_init () |
640 | CODE: |
862 | CODE: |
641 | { |
863 | { |
642 | opengl_fontmap = pango_opengl_font_map_new (); |
864 | opengl_fontmap = pango_opengl_font_map_new (); |
643 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
865 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
644 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
866 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
867 | /*pango_context_set_font_description (opengl_context, default_font);*/ |
|
|
868 | #if PANGO_VERSION_CHECK (1, 15, 2) |
|
|
869 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
870 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
871 | #endif |
645 | } |
872 | } |
646 | |
873 | |
647 | char * |
|
|
648 | SDL_GetError () |
874 | char *SDL_GetError () |
649 | |
875 | |
650 | int |
876 | void SDL_braino () |
651 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
|
|
652 | |
877 | |
653 | void |
878 | int SDL_Init (U32 flags) |
|
|
879 | |
|
|
880 | int SDL_InitSubSystem (U32 flags) |
|
|
881 | |
|
|
882 | void SDL_QuitSubSystem (U32 flags) |
|
|
883 | |
654 | SDL_Quit () |
884 | void SDL_Quit () |
|
|
885 | |
|
|
886 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
887 | |
|
|
888 | int SDL_GL_GetAttribute (int attr) |
|
|
889 | CODE: |
|
|
890 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
891 | XSRETURN_UNDEF; |
|
|
892 | OUTPUT: |
|
|
893 | RETVAL |
655 | |
894 | |
656 | void |
895 | void |
657 | SDL_ListModes (int rgb, int alpha) |
896 | SDL_ListModes (int rgb, int alpha) |
658 | PPCODE: |
897 | PPCODE: |
659 | { |
898 | { |
… | |
… | |
671 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
910 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
672 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
911 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
673 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
912 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
674 | |
913 | |
675 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
914 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
676 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
677 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
678 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
915 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
679 | #endif |
|
|
680 | |
916 | |
681 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
917 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
682 | |
918 | |
683 | if (m && m != (SDL_Rect **)-1) |
919 | if (m && m != (SDL_Rect **)-1) |
684 | while (*m) |
920 | while (*m) |
685 | { |
921 | { |
686 | if ((*m)->w >= 640 && (*m)->h >= 480) |
922 | if ((*m)->w >= 400 && (*m)->h >= 300) |
687 | { |
923 | { |
688 | AV *av = newAV (); |
924 | AV *av = newAV (); |
689 | av_push (av, newSViv ((*m)->w)); |
925 | av_push (av, newSViv ((*m)->w)); |
690 | av_push (av, newSViv ((*m)->h)); |
926 | av_push (av, newSViv ((*m)->h)); |
691 | av_push (av, newSViv (rgb)); |
927 | av_push (av, newSViv (rgb)); |
… | |
… | |
715 | |
951 | |
716 | if (RETVAL) |
952 | if (RETVAL) |
717 | { |
953 | { |
718 | av_clear (texture_av); |
954 | av_clear (texture_av); |
719 | |
955 | |
720 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
956 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
721 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
957 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
722 | #include "glfunc.h" |
958 | #include "glfunc.h" |
723 | #undef GL_FUNC |
959 | #undef GL_FUNC |
|
|
960 | |
|
|
961 | if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; |
|
|
962 | if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; |
724 | } |
963 | } |
725 | } |
964 | } |
726 | OUTPUT: |
965 | OUTPUT: |
727 | RETVAL |
966 | RETVAL |
728 | |
967 | |
… | |
… | |
732 | char * |
971 | char * |
733 | SDL_GetKeyName (int sym) |
972 | SDL_GetKeyName (int sym) |
734 | |
973 | |
735 | int |
974 | int |
736 | SDL_GetAppState () |
975 | SDL_GetAppState () |
|
|
976 | |
|
|
977 | int |
|
|
978 | SDL_GetModState () |
737 | |
979 | |
738 | void |
980 | void |
739 | poll_events () |
981 | poll_events () |
740 | PPCODE: |
982 | PPCODE: |
741 | { |
983 | { |
… | |
… | |
751 | { |
993 | { |
752 | case SDL_KEYDOWN: |
994 | case SDL_KEYDOWN: |
753 | case SDL_KEYUP: |
995 | case SDL_KEYUP: |
754 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
996 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
755 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
997 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
756 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
998 | hv_store (hv, "mod", 3, newSViv (mod_munge (ev.key.keysym.mod)), 0); |
757 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ |
999 | hv_store (hv, "cmod", 4, newSViv (mod_munge (SDL_GetModState ())), 0); /* current mode */ |
758 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
1000 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
759 | break; |
1001 | break; |
760 | |
1002 | |
761 | case SDL_ACTIVEEVENT: |
1003 | case SDL_ACTIVEEVENT: |
762 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
1004 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
780 | x = ev.motion.x; |
1022 | x = ev.motion.x; |
781 | y = ev.motion.y; |
1023 | y = ev.motion.y; |
782 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
1024 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
783 | } |
1025 | } |
784 | |
1026 | |
785 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
1027 | hv_store (hv, "mod", 3, newSViv (mod_munge (SDL_GetModState ())), 0); |
786 | hv_store (hv, "state", 5, newSViv (state), 0); |
1028 | hv_store (hv, "state", 5, newSViv (state), 0); |
787 | hv_store (hv, "x", 1, newSViv (x), 0); |
1029 | hv_store (hv, "x", 1, newSViv (x), 0); |
788 | hv_store (hv, "y", 1, newSViv (y), 0); |
1030 | hv_store (hv, "y", 1, newSViv (y), 0); |
789 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
1031 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
790 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
1032 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
791 | } |
1033 | } |
792 | break; |
1034 | break; |
793 | |
1035 | |
794 | case SDL_MOUSEBUTTONDOWN: |
1036 | case SDL_MOUSEBUTTONDOWN: |
795 | case SDL_MOUSEBUTTONUP: |
1037 | case SDL_MOUSEBUTTONUP: |
796 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
1038 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
797 | |
1039 | |
798 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
1040 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
799 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
1041 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
800 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
1042 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
801 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
1043 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
806 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
1048 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
807 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
1049 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
808 | break; |
1050 | break; |
809 | } |
1051 | } |
810 | |
1052 | |
811 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
1053 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
812 | } |
1054 | } |
813 | } |
1055 | } |
814 | |
1056 | |
|
|
1057 | char * |
|
|
1058 | SDL_AudioDriverName () |
|
|
1059 | CODE: |
|
|
1060 | { |
|
|
1061 | char buf [256]; |
|
|
1062 | if (!SDL_AudioDriverName (buf, sizeof (buf))) |
|
|
1063 | XSRETURN_UNDEF; |
|
|
1064 | |
|
|
1065 | RETVAL = buf; |
|
|
1066 | } |
|
|
1067 | OUTPUT: |
|
|
1068 | RETVAL |
|
|
1069 | |
815 | int |
1070 | int |
816 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
1071 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
817 | POSTCALL: |
1072 | POSTCALL: |
818 | Mix_HookMusicFinished (music_finished); |
1073 | Mix_HookMusicFinished (music_finished); |
819 | Mix_ChannelFinished (channel_finished); |
1074 | Mix_ChannelFinished (channel_finished); |
|
|
1075 | |
|
|
1076 | void |
|
|
1077 | Mix_QuerySpec () |
|
|
1078 | PPCODE: |
|
|
1079 | { |
|
|
1080 | int freq, channels; |
|
|
1081 | Uint16 format; |
|
|
1082 | |
|
|
1083 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
1084 | { |
|
|
1085 | EXTEND (SP, 3); |
|
|
1086 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
1087 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
1088 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
1089 | } |
|
|
1090 | } |
820 | |
1091 | |
821 | void |
1092 | void |
822 | Mix_CloseAudio () |
1093 | Mix_CloseAudio () |
823 | |
1094 | |
824 | int |
1095 | int |
… | |
… | |
859 | } |
1130 | } |
860 | } |
1131 | } |
861 | #endif |
1132 | #endif |
862 | } |
1133 | } |
863 | |
1134 | |
864 | void |
1135 | int |
865 | add_font (char *file) |
1136 | add_font (char *file) |
866 | CODE: |
1137 | CODE: |
867 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
1138 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
|
|
1139 | OUTPUT: |
|
|
1140 | RETVAL |
|
|
1141 | |
|
|
1142 | void |
|
|
1143 | IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) |
868 | |
1144 | |
869 | void |
1145 | void |
870 | load_image_inline (SV *image_) |
1146 | load_image_inline (SV *image_) |
871 | ALIAS: |
1147 | ALIAS: |
872 | load_image_file = 1 |
1148 | load_image_file = 1 |
… | |
… | |
958 | void |
1234 | void |
959 | error (char *message) |
1235 | error (char *message) |
960 | CODE: |
1236 | CODE: |
961 | fprintf (stderr, "ERROR: %s\n", message); |
1237 | fprintf (stderr, "ERROR: %s\n", message); |
962 | #ifdef _WIN32 |
1238 | #ifdef _WIN32 |
963 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1239 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
964 | #endif |
1240 | #endif |
965 | |
1241 | |
966 | void |
1242 | void |
967 | fatal (char *message) |
1243 | fatal (char *message) |
968 | CODE: |
1244 | CODE: |
969 | fprintf (stderr, "FATAL: %s\n", message); |
1245 | fprintf (stderr, "FATAL: %s\n", message); |
970 | #ifdef _WIN32 |
1246 | #ifdef _WIN32 |
971 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1247 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
972 | #endif |
1248 | #endif |
973 | _exit (1); |
1249 | _exit (1); |
974 | |
1250 | |
975 | void |
1251 | void |
976 | _exit (int retval = 0) |
1252 | _exit (int retval = 0) |
… | |
… | |
988 | #if DEBUG |
1264 | #if DEBUG |
989 | VALGRIND_DO_LEAK_CHECK; |
1265 | VALGRIND_DO_LEAK_CHECK; |
990 | #endif |
1266 | #endif |
991 | } |
1267 | } |
992 | |
1268 | |
993 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1269 | int |
|
|
1270 | SvREFCNT (SV *sv) |
|
|
1271 | CODE: |
|
|
1272 | RETVAL = SvREFCNT (sv); |
|
|
1273 | OUTPUT: |
|
|
1274 | RETVAL |
|
|
1275 | |
|
|
1276 | MODULE = Deliantra::Client PACKAGE = DC::Font |
994 | |
1277 | |
995 | PROTOTYPES: DISABLE |
1278 | PROTOTYPES: DISABLE |
996 | |
1279 | |
997 | CFPlus::Font |
1280 | DC::Font |
998 | new_from_file (SV *class, char *path, int id = 0) |
1281 | new_from_file (SV *class, char *path, int id = 0) |
999 | CODE: |
1282 | CODE: |
1000 | { |
1283 | { |
1001 | int count; |
1284 | int count; |
1002 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1285 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1005 | } |
1288 | } |
1006 | OUTPUT: |
1289 | OUTPUT: |
1007 | RETVAL |
1290 | RETVAL |
1008 | |
1291 | |
1009 | void |
1292 | void |
1010 | DESTROY (CFPlus::Font self) |
1293 | DESTROY (DC::Font self) |
1011 | CODE: |
1294 | CODE: |
1012 | pango_font_description_free (self); |
1295 | pango_font_description_free (self); |
1013 | |
1296 | |
1014 | void |
1297 | void |
1015 | make_default (CFPlus::Font self) |
1298 | make_default (DC::Font self) |
1016 | PROTOTYPE: $ |
1299 | PROTOTYPE: $ |
1017 | CODE: |
1300 | CODE: |
1018 | default_font = self; |
1301 | default_font = self; |
1019 | |
1302 | |
1020 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1303 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1021 | |
1304 | |
1022 | PROTOTYPES: DISABLE |
1305 | PROTOTYPES: DISABLE |
1023 | |
1306 | |
1024 | void |
1307 | void |
1025 | reset_glyph_cache () |
1308 | glyph_cache_backup () |
1026 | PROTOTYPE: |
1309 | PROTOTYPE: |
1027 | CODE: |
1310 | CODE: |
|
|
1311 | tc_backup (); |
|
|
1312 | |
|
|
1313 | void |
|
|
1314 | glyph_cache_restore () |
|
|
1315 | PROTOTYPE: |
|
|
1316 | CODE: |
1028 | tc_clear (); |
1317 | tc_restore (); |
1029 | |
1318 | |
1030 | CFPlus::Layout |
1319 | DC::Layout |
1031 | new (SV *class) |
1320 | new (SV *class) |
1032 | CODE: |
1321 | CODE: |
1033 | New (0, RETVAL, 1, struct cf_layout); |
1322 | New (0, RETVAL, 1, struct cf_layout); |
1034 | |
1323 | |
1035 | RETVAL->pl = pango_layout_new (opengl_context); |
1324 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1045 | layout_update_font (RETVAL); |
1334 | layout_update_font (RETVAL); |
1046 | OUTPUT: |
1335 | OUTPUT: |
1047 | RETVAL |
1336 | RETVAL |
1048 | |
1337 | |
1049 | void |
1338 | void |
1050 | DESTROY (CFPlus::Layout self) |
1339 | DESTROY (DC::Layout self) |
1051 | CODE: |
1340 | CODE: |
1052 | g_object_unref (self->pl); |
1341 | g_object_unref (self->pl); |
1053 | rc_free (self->rc); |
1342 | rc_free (self->rc); |
1054 | Safefree (self); |
1343 | Safefree (self); |
1055 | |
1344 | |
1056 | void |
1345 | void |
1057 | set_text (CFPlus::Layout self, SV *text_) |
1346 | set_text (DC::Layout self, SV *text_) |
1058 | CODE: |
1347 | CODE: |
1059 | { |
1348 | { |
1060 | STRLEN textlen; |
1349 | STRLEN textlen; |
1061 | char *text = SvPVutf8 (text_, textlen); |
1350 | char *text = SvPVutf8 (text_, textlen); |
1062 | |
1351 | |
1063 | pango_layout_set_text (self->pl, text, textlen); |
1352 | pango_layout_set_text (self->pl, text, textlen); |
1064 | } |
1353 | } |
1065 | |
1354 | |
1066 | void |
1355 | void |
1067 | set_markup (CFPlus::Layout self, SV *text_) |
1356 | set_markup (DC::Layout self, SV *text_) |
1068 | CODE: |
1357 | CODE: |
1069 | { |
1358 | { |
1070 | STRLEN textlen; |
1359 | STRLEN textlen; |
1071 | char *text = SvPVutf8 (text_, textlen); |
1360 | char *text = SvPVutf8 (text_, textlen); |
1072 | |
1361 | |
1073 | pango_layout_set_markup (self->pl, text, textlen); |
1362 | pango_layout_set_markup (self->pl, text, textlen); |
1074 | } |
1363 | } |
1075 | |
1364 | |
1076 | void |
1365 | void |
1077 | set_shapes (CFPlus::Layout self, ...) |
1366 | set_shapes (DC::Layout self, ...) |
1078 | CODE: |
1367 | CODE: |
1079 | { |
1368 | { |
1080 | PangoAttrList *attrs = 0; |
1369 | PangoAttrList *attrs = 0; |
1081 | const char *text = pango_layout_get_text (self->pl); |
1370 | const char *text = pango_layout_get_text (self->pl); |
1082 | const char *pos = text; |
1371 | const char *pos = text; |
… | |
… | |
1117 | if (attrs) |
1406 | if (attrs) |
1118 | pango_layout_set_attributes (self->pl, attrs); |
1407 | pango_layout_set_attributes (self->pl, attrs); |
1119 | } |
1408 | } |
1120 | |
1409 | |
1121 | void |
1410 | void |
1122 | get_shapes (CFPlus::Layout self) |
1411 | get_shapes (DC::Layout self) |
1123 | PPCODE: |
1412 | PPCODE: |
1124 | { |
1413 | { |
1125 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1414 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1126 | |
1415 | |
1127 | do |
1416 | do |
1128 | { |
1417 | { |
1129 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1418 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1130 | |
1419 | |
1131 | if (run && shape_attr_p (run)) |
1420 | if (run && shape_attr_p (run)) |
1132 | { |
1421 | { |
1133 | PangoRectangle extents; |
1422 | PangoRectangle extents; |
1134 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1423 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1142 | |
1431 | |
1143 | pango_layout_iter_free (iter); |
1432 | pango_layout_iter_free (iter); |
1144 | } |
1433 | } |
1145 | |
1434 | |
1146 | int |
1435 | int |
1147 | has_wrapped (CFPlus::Layout self) |
1436 | has_wrapped (DC::Layout self) |
1148 | CODE: |
1437 | CODE: |
1149 | { |
1438 | { |
1150 | int lines = 1; |
1439 | int lines = 1; |
1151 | const char *text = pango_layout_get_text (self->pl); |
1440 | const char *text = pango_layout_get_text (self->pl); |
1152 | |
1441 | |
… | |
… | |
1157 | } |
1446 | } |
1158 | OUTPUT: |
1447 | OUTPUT: |
1159 | RETVAL |
1448 | RETVAL |
1160 | |
1449 | |
1161 | SV * |
1450 | SV * |
1162 | get_text (CFPlus::Layout self) |
1451 | get_text (DC::Layout self) |
1163 | CODE: |
1452 | CODE: |
1164 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1453 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1165 | sv_utf8_decode (RETVAL); |
1454 | sv_utf8_decode (RETVAL); |
1166 | OUTPUT: |
1455 | OUTPUT: |
1167 | RETVAL |
1456 | RETVAL |
1168 | |
1457 | |
1169 | void |
1458 | void |
1170 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1459 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1171 | CODE: |
1460 | CODE: |
1172 | self->r = r; |
1461 | self->r = r; |
1173 | self->g = g; |
1462 | self->g = g; |
1174 | self->b = b; |
1463 | self->b = b; |
1175 | self->a = a; |
1464 | self->a = a; |
1176 | |
1465 | |
1177 | void |
1466 | void |
1178 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1467 | set_font (DC::Layout self, DC::Font font = 0) |
1179 | CODE: |
1468 | CODE: |
1180 | if (self->font != font) |
1469 | if (self->font != font) |
1181 | { |
1470 | { |
1182 | self->font = font; |
1471 | self->font = font; |
1183 | layout_update_font (self); |
1472 | layout_update_font (self); |
1184 | } |
1473 | } |
1185 | |
1474 | |
1186 | void |
1475 | void |
1187 | set_height (CFPlus::Layout self, int base_height) |
1476 | set_height (DC::Layout self, int base_height) |
1188 | CODE: |
1477 | CODE: |
1189 | if (self->base_height != base_height) |
1478 | if (self->base_height != base_height) |
1190 | { |
1479 | { |
1191 | self->base_height = base_height; |
1480 | self->base_height = base_height; |
1192 | layout_update_font (self); |
1481 | layout_update_font (self); |
1193 | } |
1482 | } |
1194 | |
1483 | |
1195 | void |
1484 | void |
1196 | set_width (CFPlus::Layout self, int max_width = -1) |
1485 | set_width (DC::Layout self, int max_width = -1) |
1197 | CODE: |
1486 | CODE: |
1198 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1487 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1199 | |
1488 | |
1200 | void |
1489 | void |
1201 | set_indent (CFPlus::Layout self, int indent) |
1490 | set_indent (DC::Layout self, int indent) |
1202 | CODE: |
1491 | CODE: |
1203 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1492 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1204 | |
1493 | |
1205 | void |
1494 | void |
1206 | set_spacing (CFPlus::Layout self, int spacing) |
1495 | set_spacing (DC::Layout self, int spacing) |
1207 | CODE: |
1496 | CODE: |
1208 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1497 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1209 | |
1498 | |
1210 | void |
1499 | void |
1211 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1500 | set_ellipsise (DC::Layout self, int ellipsise) |
1212 | CODE: |
1501 | CODE: |
1213 | pango_layout_set_ellipsize (self->pl, |
1502 | pango_layout_set_ellipsize (self->pl, |
1214 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1503 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1215 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1504 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1216 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1505 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1217 | : PANGO_ELLIPSIZE_NONE |
1506 | : PANGO_ELLIPSIZE_NONE |
1218 | ); |
1507 | ); |
1219 | |
1508 | |
1220 | void |
1509 | void |
1221 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1510 | set_single_paragraph_mode (DC::Layout self, int spm) |
1222 | CODE: |
1511 | CODE: |
1223 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1512 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1224 | |
1513 | |
1225 | void |
1514 | void |
1226 | size (CFPlus::Layout self) |
1515 | size (DC::Layout self) |
1227 | PPCODE: |
1516 | PPCODE: |
1228 | { |
1517 | { |
1229 | int w, h; |
1518 | int w, h; |
1230 | |
1519 | |
1231 | layout_get_pixel_size (self, &w, &h); |
1520 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1234 | PUSHs (sv_2mortal (newSViv (w))); |
1523 | PUSHs (sv_2mortal (newSViv (w))); |
1235 | PUSHs (sv_2mortal (newSViv (h))); |
1524 | PUSHs (sv_2mortal (newSViv (h))); |
1236 | } |
1525 | } |
1237 | |
1526 | |
1238 | int |
1527 | int |
1239 | descent (CFPlus::Layout self) |
1528 | descent (DC::Layout self) |
1240 | CODE: |
1529 | CODE: |
1241 | { |
1530 | { |
1242 | PangoRectangle rect; |
1531 | PangoRectangle rect; |
1243 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1532 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1244 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1533 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1245 | RETVAL = PANGO_DESCENT (rect); |
1534 | RETVAL = PANGO_DESCENT (rect); |
1246 | } |
1535 | } |
1247 | OUTPUT: |
1536 | OUTPUT: |
1248 | RETVAL |
1537 | RETVAL |
1249 | |
1538 | |
1250 | int |
1539 | int |
1251 | xy_to_index (CFPlus::Layout self, int x, int y) |
1540 | xy_to_index (DC::Layout self, int x, int y) |
1252 | CODE: |
1541 | CODE: |
1253 | { |
1542 | { |
1254 | int index, trailing; |
1543 | int index, trailing; |
1255 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1544 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1256 | RETVAL = index + trailing; |
1545 | RETVAL = index + trailing; |
1257 | } |
1546 | } |
1258 | OUTPUT: |
1547 | OUTPUT: |
1259 | RETVAL |
1548 | RETVAL |
1260 | |
1549 | |
1261 | void |
1550 | void |
1262 | cursor_pos (CFPlus::Layout self, int index) |
1551 | cursor_pos (DC::Layout self, int index) |
1263 | PPCODE: |
1552 | PPCODE: |
1264 | { |
1553 | { |
1265 | PangoRectangle strong_pos; |
1554 | PangoRectangle pos; |
1266 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1555 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1267 | |
1556 | |
1268 | EXTEND (SP, 3); |
1557 | EXTEND (SP, 3); |
1269 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1558 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1270 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1559 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1271 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1560 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1272 | } |
1561 | } |
1273 | |
1562 | |
1274 | void |
1563 | void |
1275 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1564 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1276 | PPCODE: |
1565 | PPCODE: |
1277 | { |
1566 | { |
1278 | int line, x; |
1567 | int line, x; |
1279 | |
1568 | |
1280 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1569 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1570 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1281 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1571 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1282 | |
1572 | --line; |
|
|
1573 | #endif |
1283 | EXTEND (SP, 2); |
1574 | EXTEND (SP, 2); |
1284 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1575 | PUSHs (sv_2mortal (newSViv (line))); |
1285 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1576 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1286 | } |
1577 | } |
1287 | |
1578 | |
1288 | void |
1579 | void |
1289 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1580 | line_x_to_index (DC::Layout self, int line, int x) |
1290 | PPCODE: |
1581 | PPCODE: |
1291 | { |
1582 | { |
1292 | PangoLayoutLine *lp; |
1583 | PangoLayoutLine *lp; |
1293 | int index, trailing; |
1584 | int index, trailing; |
1294 | |
1585 | |
1295 | if (line < 0) |
1586 | if (line < 0) |
1296 | XSRETURN_EMPTY; |
1587 | XSRETURN_EMPTY; |
1297 | |
1588 | |
1298 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1589 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1299 | XSRETURN_EMPTY; /* do better */ |
1590 | XSRETURN_EMPTY; /* do better */ |
1300 | |
1591 | |
1301 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1592 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1302 | |
1593 | |
1303 | EXTEND (SP, 2); |
1594 | EXTEND (SP, 2); |
… | |
… | |
1309 | PUSHs (sv_2mortal (newSViv (trailing))); |
1600 | PUSHs (sv_2mortal (newSViv (trailing))); |
1310 | } |
1601 | } |
1311 | } |
1602 | } |
1312 | |
1603 | |
1313 | void |
1604 | void |
1314 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1605 | render (DC::Layout self, float x, float y, int flags = 0) |
1315 | CODE: |
1606 | CODE: |
1316 | rc_clear (self->rc); |
1607 | rc_clear (self->rc); |
1317 | pango_opengl_render_layout_subpixel ( |
1608 | pango_opengl_render_layout_subpixel ( |
1318 | self->pl, |
1609 | self->pl, |
1319 | self->rc, |
1610 | self->rc, |
… | |
… | |
1324 | // we assume that context_change actually clears/frees stuff |
1615 | // we assume that context_change actually clears/frees stuff |
1325 | // and does not do any recomputation... |
1616 | // and does not do any recomputation... |
1326 | pango_layout_context_changed (self->pl); |
1617 | pango_layout_context_changed (self->pl); |
1327 | |
1618 | |
1328 | void |
1619 | void |
1329 | draw (CFPlus::Layout self) |
1620 | draw (DC::Layout self) |
1330 | CODE: |
1621 | CODE: |
1331 | { |
1622 | { |
1332 | glEnable (GL_TEXTURE_2D); |
1623 | glEnable (GL_TEXTURE_2D); |
1333 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1624 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1334 | glEnable (GL_BLEND); |
1625 | glEnable (GL_BLEND); |
… | |
… | |
1342 | glDisable (GL_ALPHA_TEST); |
1633 | glDisable (GL_ALPHA_TEST); |
1343 | glDisable (GL_BLEND); |
1634 | glDisable (GL_BLEND); |
1344 | glDisable (GL_TEXTURE_2D); |
1635 | glDisable (GL_TEXTURE_2D); |
1345 | } |
1636 | } |
1346 | |
1637 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1638 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1348 | |
1639 | |
1349 | PROTOTYPES: ENABLE |
1640 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1641 | |
1353 | void |
1642 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1643 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1644 | CODE: |
1356 | { |
1645 | { |
… | |
… | |
1422 | glDisable (GL_ALPHA_TEST); |
1711 | glDisable (GL_ALPHA_TEST); |
1423 | glDisable (GL_BLEND); |
1712 | glDisable (GL_BLEND); |
1424 | } |
1713 | } |
1425 | } |
1714 | } |
1426 | |
1715 | |
|
|
1716 | void |
|
|
1717 | draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) |
|
|
1718 | PROTOTYPE: @ |
|
|
1719 | CODE: |
|
|
1720 | { |
|
|
1721 | glEnable (GL_BLEND); |
|
|
1722 | glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1723 | glEnable (GL_TEXTURE_2D); |
|
|
1724 | glBindTexture (GL_TEXTURE_2D, name1); |
|
|
1725 | |
|
|
1726 | glColor3f (intensity, intensity, intensity); |
|
|
1727 | glPushMatrix (); |
|
|
1728 | glScalef (1./3, 1./3, 1.); |
|
|
1729 | |
|
|
1730 | if (blend > 0.f) |
|
|
1731 | { |
|
|
1732 | float dx3 = dx * -3.f / w; |
|
|
1733 | float dy3 = dy * -3.f / h; |
|
|
1734 | GLfloat env_color[4] = { 0., 0., 0., blend }; |
|
|
1735 | |
|
|
1736 | /* interpolate the two shadow textures */ |
|
|
1737 | /* stage 0 == rgb(glcolor) + alpha(t0) */ |
|
|
1738 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
|
1739 | |
|
|
1740 | /* stage 1 == rgb(glcolor) + alpha(interpolate t0, t1, texenv) */ |
|
|
1741 | gl.ActiveTexture (GL_TEXTURE1); |
|
|
1742 | glEnable (GL_TEXTURE_2D); |
|
|
1743 | glBindTexture (GL_TEXTURE_2D, name2); |
|
|
1744 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); |
|
|
1745 | |
|
|
1746 | /* rgb == rgb(glcolor) */ |
|
|
1747 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); |
|
|
1748 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); |
|
|
1749 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); |
|
|
1750 | |
|
|
1751 | /* alpha = interpolate t0, t1 by env_alpha */ |
|
|
1752 | glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); |
|
|
1753 | |
|
|
1754 | glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE); |
|
|
1755 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); |
|
|
1756 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); |
|
|
1757 | |
|
|
1758 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS); |
|
|
1759 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); |
|
|
1760 | |
|
|
1761 | glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT); |
|
|
1762 | glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA); |
|
|
1763 | |
|
|
1764 | glBegin (GL_QUADS); |
|
|
1765 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 , dy3 ); glVertex2i (0, 0); |
|
|
1766 | gl.MultiTexCoord2f (GL_TEXTURE0, 0, t); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 , dy3 + t); glVertex2i (0, h); |
|
|
1767 | gl.MultiTexCoord2f (GL_TEXTURE0, s, t); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 + s, dy3 + t); glVertex2i (w, h); |
|
|
1768 | gl.MultiTexCoord2f (GL_TEXTURE0, s, 0); gl.MultiTexCoord2f (GL_TEXTURE1, dx3 + s, dy3 ); glVertex2i (w, 0); |
|
|
1769 | glEnd (); |
|
|
1770 | |
|
|
1771 | glDisable (GL_TEXTURE_2D); |
|
|
1772 | gl.ActiveTexture (GL_TEXTURE0); |
|
|
1773 | } |
|
|
1774 | else |
|
|
1775 | { |
|
|
1776 | /* simple blending of one texture, also opengl <1.3 path */ |
|
|
1777 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
|
|
1778 | |
|
|
1779 | glBegin (GL_QUADS); |
|
|
1780 | glTexCoord2f (0, 0); glVertex2f (0, 0); |
|
|
1781 | glTexCoord2f (0, t); glVertex2f (0, h); |
|
|
1782 | glTexCoord2f (s, t); glVertex2f (w, h); |
|
|
1783 | glTexCoord2f (s, 0); glVertex2f (w, 0); |
|
|
1784 | glEnd (); |
|
|
1785 | } |
|
|
1786 | |
|
|
1787 | /* draw ?-marks or equivalent, this is very clumsy code :/ */ |
|
|
1788 | { |
|
|
1789 | int x, y; |
|
|
1790 | int dx3 = dx * 3; |
|
|
1791 | int dy3 = dy * 3; |
|
|
1792 | |
|
|
1793 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1794 | glBindTexture (GL_TEXTURE_2D, hidden_tex); |
|
|
1795 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1796 | glTranslatef (-1., -1., 0); |
|
|
1797 | glBegin (GL_QUADS); |
|
|
1798 | |
|
|
1799 | for (y = 1; y < h; y += 3) |
|
|
1800 | { |
|
|
1801 | int y1 = y - dy3; |
|
|
1802 | int y1valid = y1 >= 0 && y1 < h; |
|
|
1803 | |
|
|
1804 | for (x = 1; x < w; x += 3) |
|
|
1805 | { |
|
|
1806 | int x1 = x - dx3; |
|
|
1807 | uint8_t h1 = data1 [x + y * w] == DARKNESS_ADJUST (255 - FOW_DARKNESS); |
|
|
1808 | uint8_t h2; |
|
|
1809 | |
|
|
1810 | if (y1valid && x1 >= 0 && x1 < w) |
|
|
1811 | h2 = data2 [x1 + y1 * w] == DARKNESS_ADJUST (255 - FOW_DARKNESS); |
|
|
1812 | else |
|
|
1813 | h2 = 1; /* out of range == invisible */ |
|
|
1814 | |
|
|
1815 | if (h1 || h2) |
|
|
1816 | { |
|
|
1817 | float alpha = h1 == h2 ? 1.f : h1 ? 1.f - blend : blend; |
|
|
1818 | glColor4f (1., 1., 1., alpha); |
|
|
1819 | |
|
|
1820 | glTexCoord2f (0, 0.); glVertex2i (x , y ); |
|
|
1821 | glTexCoord2f (0, 1.); glVertex2i (x , y + 3); |
|
|
1822 | glTexCoord2f (1, 1.); glVertex2i (x + 3, y + 3); |
|
|
1823 | glTexCoord2f (1, 0.); glVertex2i (x + 3, y ); |
|
|
1824 | } |
|
|
1825 | } |
|
|
1826 | } |
|
|
1827 | } |
|
|
1828 | |
|
|
1829 | glEnd (); |
|
|
1830 | |
|
|
1831 | glPopMatrix (); |
|
|
1832 | |
|
|
1833 | glDisable (GL_TEXTURE_2D); |
|
|
1834 | glDisable (GL_BLEND); |
|
|
1835 | } |
|
|
1836 | |
1427 | IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type) |
1837 | IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type) |
1428 | CODE: |
1838 | CODE: |
1429 | { |
1839 | { |
1430 | GLint width; |
1840 | GLint width; |
1431 | glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0); |
1841 | glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0); |
… | |
… | |
1433 | RETVAL = width > 0; |
1843 | RETVAL = width > 0; |
1434 | } |
1844 | } |
1435 | OUTPUT: |
1845 | OUTPUT: |
1436 | RETVAL |
1846 | RETVAL |
1437 | |
1847 | |
1438 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1848 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1439 | |
1849 | |
1440 | PROTOTYPES: DISABLE |
1850 | PROTOTYPES: DISABLE |
1441 | |
1851 | |
1442 | CFPlus::Map |
1852 | DC::Map |
1443 | new (SV *class) |
1853 | new (SV *class) |
1444 | CODE: |
1854 | CODE: |
1445 | New (0, RETVAL, 1, struct map); |
1855 | New (0, RETVAL, 1, struct map); |
1446 | RETVAL->x = 0; |
1856 | RETVAL->x = 0; |
1447 | RETVAL->y = 0; |
1857 | RETVAL->y = 0; |
… | |
… | |
1455 | RETVAL->row = 0; |
1865 | RETVAL->row = 0; |
1456 | OUTPUT: |
1866 | OUTPUT: |
1457 | RETVAL |
1867 | RETVAL |
1458 | |
1868 | |
1459 | void |
1869 | void |
1460 | DESTROY (CFPlus::Map self) |
1870 | DESTROY (DC::Map self) |
1461 | CODE: |
1871 | CODE: |
1462 | { |
1872 | { |
1463 | map_clear (self); |
1873 | map_clear (self); |
1464 | Safefree (self->face2tile); |
1874 | Safefree (self->face2tile); |
1465 | Safefree (self->tex); |
1875 | Safefree (self->tex); |
1466 | Safefree (self); |
1876 | Safefree (self); |
1467 | } |
1877 | } |
1468 | |
1878 | |
1469 | void |
1879 | void |
1470 | resize (CFPlus::Map self, int map_width, int map_height) |
1880 | resize (DC::Map self, int map_width, int map_height) |
1471 | CODE: |
1881 | CODE: |
1472 | self->w = map_width; |
1882 | self->w = map_width; |
1473 | self->h = map_height; |
1883 | self->h = map_height; |
1474 | |
1884 | |
1475 | void |
1885 | void |
1476 | clear (CFPlus::Map self) |
1886 | clear (DC::Map self) |
1477 | CODE: |
1887 | CODE: |
1478 | map_clear (self); |
1888 | map_clear (self); |
1479 | |
1889 | |
1480 | void |
1890 | void |
1481 | set_tileid (CFPlus::Map self, int face, int tile) |
1891 | set_tileid (DC::Map self, int face, int tile) |
1482 | CODE: |
1892 | CODE: |
1483 | { |
1893 | { |
1484 | need_facenum (self, face); self->face2tile [face] = tile; |
1894 | need_facenum (self, face); self->face2tile [face] = tile; |
1485 | need_texid (self, tile); |
1895 | need_texid (self, tile); |
1486 | } |
1896 | } |
1487 | |
1897 | |
1488 | void |
1898 | void |
1489 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1899 | set_smooth (DC::Map self, int face, int smooth, int level) |
1490 | CODE: |
1900 | CODE: |
1491 | { |
1901 | { |
1492 | tileid texid; |
1902 | tileid texid; |
1493 | maptex *tex; |
1903 | maptex *tex; |
1494 | |
1904 | |
… | |
… | |
1507 | tex->smoothtile = self->face2tile [smooth]; |
1917 | tex->smoothtile = self->face2tile [smooth]; |
1508 | tex->smoothlevel = level; |
1918 | tex->smoothlevel = level; |
1509 | } |
1919 | } |
1510 | |
1920 | |
1511 | void |
1921 | void |
1512 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1922 | set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1513 | CODE: |
1923 | CODE: |
1514 | { |
1924 | { |
1515 | need_texid (self, texid); |
1925 | need_texid (self, texid); |
1516 | |
1926 | |
1517 | { |
1927 | { |
… | |
… | |
1536 | // use uglier nearest interpolation because linear suffers |
1946 | // use uglier nearest interpolation because linear suffers |
1537 | // from transparent color bleeding and ugly wrapping effects. |
1947 | // from transparent color bleeding and ugly wrapping effects. |
1538 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1948 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1539 | } |
1949 | } |
1540 | |
1950 | |
|
|
1951 | void |
|
|
1952 | expire_textures (DC::Map self, int texid, int count) |
|
|
1953 | PPCODE: |
|
|
1954 | for (; texid < self->texs && count; ++texid, --count) |
|
|
1955 | { |
|
|
1956 | maptex *tex = self->tex + texid; |
|
|
1957 | |
|
|
1958 | if (tex->name) |
|
|
1959 | { |
|
|
1960 | if (tex->unused) |
|
|
1961 | { |
|
|
1962 | tex->name = 0; |
|
|
1963 | tex->unused = 0; |
|
|
1964 | XPUSHs (sv_2mortal (newSViv (texid))); |
|
|
1965 | } |
|
|
1966 | else |
|
|
1967 | tex->unused = 1; |
|
|
1968 | } |
|
|
1969 | } |
|
|
1970 | |
1541 | int |
1971 | int |
1542 | ox (CFPlus::Map self) |
1972 | ox (DC::Map self) |
1543 | ALIAS: |
1973 | ALIAS: |
1544 | oy = 1 |
1974 | oy = 1 |
1545 | x = 2 |
1975 | x = 2 |
1546 | y = 3 |
1976 | y = 3 |
1547 | w = 4 |
1977 | w = 4 |
… | |
… | |
1558 | } |
1988 | } |
1559 | OUTPUT: |
1989 | OUTPUT: |
1560 | RETVAL |
1990 | RETVAL |
1561 | |
1991 | |
1562 | void |
1992 | void |
1563 | scroll (CFPlus::Map self, int dx, int dy) |
1993 | scroll (DC::Map self, int dx, int dy) |
1564 | CODE: |
1994 | CODE: |
1565 | { |
1995 | { |
1566 | if (dx > 0) |
1996 | if (dx > 0) |
1567 | map_blank (self, self->x, self->y, dx, self->h); |
1997 | map_blank (self, self->x, self->y, dx, self->h); |
1568 | else if (dx < 0) |
1998 | else if (dx < 0) |
… | |
… | |
1584 | self->y += MAP_EXTEND_Y; |
2014 | self->y += MAP_EXTEND_Y; |
1585 | } |
2015 | } |
1586 | } |
2016 | } |
1587 | |
2017 | |
1588 | SV * |
2018 | SV * |
1589 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
2019 | map1a_update (DC::Map self, SV *data_, int extmap) |
1590 | CODE: |
2020 | CODE: |
1591 | { |
2021 | { |
1592 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
2022 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1593 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
2023 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1594 | mapcell *cell; |
2024 | mapcell *cell; |
… | |
… | |
1622 | uint8_t ext, cmd; |
2052 | uint8_t ext, cmd; |
1623 | |
2053 | |
1624 | do |
2054 | do |
1625 | { |
2055 | { |
1626 | ext = *data++; |
2056 | ext = *data++; |
1627 | cmd = ext & 0x3f; |
2057 | cmd = ext & 0x7f; |
1628 | |
2058 | |
1629 | if (cmd < 4) |
2059 | if (cmd < 4) |
1630 | cell->darkness = 255 - ext * 64 + 1; |
2060 | cell->darkness = 255 - ext * 64 + 1; /* make sure this doesn't collide with FOW_DARKNESS */ |
1631 | else if (cmd == 5) // health |
2061 | else if (cmd == 5) // health |
1632 | { |
2062 | { |
1633 | cell->stat_width = 1; |
2063 | cell->stat_width = 1; |
1634 | cell->stat_hp = *data++; |
2064 | cell->stat_hp = *data++; |
1635 | } |
2065 | } |
1636 | else if (cmd == 6) // monster width |
2066 | else if (cmd == 6) // monster width |
1637 | cell->stat_width = *data++ + 1; |
2067 | cell->stat_width = *data++ + 1; |
1638 | else if (cmd == 0x47) |
2068 | else if (cmd == 0x47) |
1639 | { |
2069 | { |
1640 | if (*data == 4) |
2070 | if (*data == 1) cell->player = data [1]; |
1641 | ; // decode player count |
2071 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
2072 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
2073 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
1642 | |
2074 | |
1643 | data += *data + 1; |
2075 | data += *data + 1; |
1644 | } |
2076 | } |
1645 | else if (cmd == 8) // cell flags |
2077 | else if (cmd == 8) // cell flags |
1646 | cell->flags = *data++; |
2078 | cell->flags = *data++; |
… | |
… | |
1663 | cell->tile [z] = self->face2tile [face]; |
2095 | cell->tile [z] = self->face2tile [face]; |
1664 | |
2096 | |
1665 | if (cell->tile [z]) |
2097 | if (cell->tile [z]) |
1666 | { |
2098 | { |
1667 | maptex *tex = self->tex + cell->tile [z]; |
2099 | maptex *tex = self->tex + cell->tile [z]; |
|
|
2100 | tex->unused = 0; |
1668 | if (!tex->name) |
2101 | if (!tex->name) |
1669 | av_push (missing, newSViv (cell->tile [z])); |
2102 | av_push (missing, newSViv (cell->tile [z])); |
1670 | |
2103 | |
1671 | if (tex->smoothtile) |
2104 | if (tex->smoothtile) |
1672 | { |
2105 | { |
1673 | maptex *smooth = self->tex + tex->smoothtile; |
2106 | maptex *smooth = self->tex + tex->smoothtile; |
|
|
2107 | smooth->unused = 0; |
1674 | if (!smooth->name) |
2108 | if (!smooth->name) |
1675 | av_push (missing, newSViv (tex->smoothtile)); |
2109 | av_push (missing, newSViv (tex->smoothtile)); |
1676 | } |
2110 | } |
1677 | } |
2111 | } |
1678 | } |
2112 | } |
1679 | } |
2113 | } |
1680 | else |
2114 | else |
1681 | cell->darkness = 0; |
2115 | CELL_CLEAR (cell); |
1682 | } |
2116 | } |
1683 | } |
2117 | } |
1684 | OUTPUT: |
2118 | OUTPUT: |
1685 | RETVAL |
2119 | RETVAL |
1686 | |
2120 | |
1687 | SV * |
2121 | SV * |
1688 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
2122 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1689 | CODE: |
2123 | CODE: |
1690 | { |
2124 | { |
1691 | int x1, x; |
2125 | int x1, x; |
1692 | int y1, y; |
2126 | int y1, y; |
1693 | int z; |
2127 | int z; |
… | |
… | |
1706 | ? self->row + y |
2140 | ? self->row + y |
1707 | : 0; |
2141 | : 0; |
1708 | |
2142 | |
1709 | for (x = x0; x < x1; x++) |
2143 | for (x = x0; x < x1; x++) |
1710 | { |
2144 | { |
1711 | int r = 32, g = 32, b = 32, a = 192; |
2145 | unsigned int r = 32, g = 32, b = 32, a = 192; |
1712 | |
2146 | |
1713 | if (row && row->c0 <= x && x < row->c1) |
2147 | if (row && row->c0 <= x && x < row->c1) |
1714 | { |
2148 | { |
1715 | mapcell *cell = row->col + (x - row->c0); |
2149 | mapcell *cell = row->col + (x - row->c0); |
1716 | |
2150 | |
… | |
… | |
1718 | { |
2152 | { |
1719 | maptex tex = self->tex [cell->tile [z]]; |
2153 | maptex tex = self->tex [cell->tile [z]]; |
1720 | int a0 = 255 - tex.a; |
2154 | int a0 = 255 - tex.a; |
1721 | int a1 = tex.a; |
2155 | int a1 = tex.a; |
1722 | |
2156 | |
1723 | r = (r * a0 + tex.r * a1) / 255; |
2157 | r = div255 (r * a0 + tex.r * a1); |
1724 | g = (g * a0 + tex.g * a1) / 255; |
2158 | g = div255 (g * a0 + tex.g * a1); |
1725 | b = (b * a0 + tex.b * a1) / 255; |
2159 | b = div255 (b * a0 + tex.b * a1); |
1726 | a = (a * a0 + tex.a * a1) / 255; |
2160 | a = div255 (a * a0 + tex.a * a1); |
1727 | } |
2161 | } |
1728 | } |
2162 | } |
1729 | |
2163 | |
1730 | *map++ = (r ) |
2164 | *map++ = (r ) |
1731 | | (g << 8) |
2165 | | (g << 8) |
… | |
… | |
1738 | } |
2172 | } |
1739 | OUTPUT: |
2173 | OUTPUT: |
1740 | RETVAL |
2174 | RETVAL |
1741 | |
2175 | |
1742 | void |
2176 | void |
1743 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
2177 | 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) |
1744 | CODE: |
2178 | CODE: |
1745 | { |
2179 | { |
1746 | int x, y, z; |
2180 | int x, y, z; |
1747 | |
2181 | |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
2182 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1749 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
2183 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1750 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
2184 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1751 | smooth_key skey; |
2185 | smooth_key skey; |
1752 | |
2186 | int pl_x, pl_y; |
|
|
2187 | maptex pl_tex; |
1753 | rc_t *rc = rc_alloc (); |
2188 | rc_t *rc = rc_alloc (); |
|
|
2189 | rc_t *rc_ov = rc_alloc (); |
1754 | rc_key_t key; |
2190 | rc_key_t key; |
1755 | rc_array_t *arr; |
2191 | rc_array_t *arr; |
1756 | |
2192 | |
|
|
2193 | pl_tex.name = 0; |
|
|
2194 | |
1757 | // thats current max. sorry. |
2195 | // that's current max. sorry. |
1758 | if (sw > 255) sw = 255; |
2196 | if (sw > 255) sw = 255; |
1759 | if (sh > 255) sh = 255; |
2197 | if (sh > 255) sh = 255; |
1760 | |
2198 | |
1761 | // clear key, in case of extra padding |
2199 | // clear key, in case of extra padding |
1762 | memset (&skey, 0, sizeof (skey)); |
2200 | memset (&skey, 0, sizeof (skey)); |
… | |
… | |
1766 | key.g = 255; |
2204 | key.g = 255; |
1767 | key.b = 255; |
2205 | key.b = 255; |
1768 | key.a = 255; |
2206 | key.a = 255; |
1769 | key.mode = GL_QUADS; |
2207 | key.mode = GL_QUADS; |
1770 | key.format = GL_T2F_V3F; |
2208 | key.format = GL_T2F_V3F; |
1771 | key.texname = -1; |
|
|
1772 | |
2209 | |
1773 | mx += self->x; |
2210 | mx += self->x; |
1774 | my += self->y; |
2211 | my += self->y; |
1775 | |
2212 | |
1776 | // first pass: determine smooth_max |
2213 | // first pass: determine smooth_max |
… | |
… | |
1800 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2237 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1801 | |
2238 | |
1802 | for (z = 0; z <= 2; z++) |
2239 | for (z = 0; z <= 2; z++) |
1803 | { |
2240 | { |
1804 | memset (smooth_level, 0, sizeof (smooth_level)); |
2241 | memset (smooth_level, 0, sizeof (smooth_level)); |
|
|
2242 | key.texname = -1; |
1805 | |
2243 | |
1806 | for (y = 0; y < sh; y++) |
2244 | for (y = 0; y < sh; y++) |
1807 | if (0 <= y + my && y + my < self->rows) |
2245 | if (0 <= y + my && y + my < self->rows) |
1808 | { |
2246 | { |
1809 | maprow *row = self->row + (y + my); |
2247 | maprow *row = self->row + (y + my); |
… | |
… | |
1819 | maptex tex = self->tex [tile]; |
2257 | maptex tex = self->tex [tile]; |
1820 | int px, py; |
2258 | int px, py; |
1821 | |
2259 | |
1822 | if (key.texname != tex.name) |
2260 | if (key.texname != tex.name) |
1823 | { |
2261 | { |
|
|
2262 | self->tex [tile].unused = 0; |
|
|
2263 | |
1824 | if (!tex.name) |
2264 | if (!tex.name) |
1825 | tex = self->tex [2]; /* missing, replace by noface */ |
2265 | tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ |
1826 | |
2266 | |
1827 | key.texname = tex.name; |
2267 | key.texname = tex.name; |
1828 | arr = rc_array (rc, &key); |
2268 | arr = rc_array (rc, &key); |
1829 | } |
2269 | } |
1830 | |
2270 | |
1831 | px = (x + 1) * T - tex.w; |
2271 | px = (x + 1) * Th - tex.w; |
1832 | py = (y + 1) * T - tex.h; |
2272 | py = (y + 1) * Tw - tex.h; |
|
|
2273 | |
|
|
2274 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
|
|
2275 | { |
|
|
2276 | pl_x = px; |
|
|
2277 | pl_y = py; |
|
|
2278 | pl_tex = tex; |
|
|
2279 | continue; |
|
|
2280 | } |
1833 | |
2281 | |
1834 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
2282 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1835 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
2283 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1836 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
2284 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1837 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
2285 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1838 | |
|
|
1839 | if (cell->flags && z == 2) |
|
|
1840 | { |
|
|
1841 | // overlays such as the speech bubble, probably more to come |
|
|
1842 | if (cell->flags & 1) |
|
|
1843 | { |
|
|
1844 | maptex tex = self->tex [1]; |
|
|
1845 | int px = x * T + T * 2 / 32; |
|
|
1846 | int py = y * T - T * 6 / 32; |
|
|
1847 | |
|
|
1848 | if (tex.name) |
|
|
1849 | { |
|
|
1850 | if (key.texname != tex.name) |
|
|
1851 | { |
|
|
1852 | key.texname = tex.name; |
|
|
1853 | arr = rc_array (rc, &key); |
|
|
1854 | } |
|
|
1855 | |
|
|
1856 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
1857 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
1858 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
1859 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
|
|
1860 | } |
|
|
1861 | } |
|
|
1862 | } |
|
|
1863 | |
2286 | |
1864 | // update smooth hash |
2287 | // update smooth hash |
1865 | if (tex.smoothtile) |
2288 | if (tex.smoothtile) |
1866 | { |
2289 | { |
1867 | skey.tile = tex.smoothtile; |
2290 | skey.tile = tex.smoothtile; |
… | |
… | |
1896 | // corners |
2319 | // corners |
1897 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
2320 | skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); |
1898 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
2321 | skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200); |
1899 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
2322 | skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400); |
1900 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
2323 | skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800); |
|
|
2324 | } |
|
|
2325 | } |
|
|
2326 | |
|
|
2327 | if (expect_false (z == 2) && expect_false (cell->flags)) |
|
|
2328 | { |
|
|
2329 | // overlays such as the speech bubble, probably more to come |
|
|
2330 | if (cell->flags & 1) |
|
|
2331 | { |
|
|
2332 | rc_key_t key_ov = key; |
|
|
2333 | maptex tex = self->tex [TEXID_SPEECH]; |
|
|
2334 | rc_array_t *arr; |
|
|
2335 | int px = x * Tw + Tw * 2 / 32; |
|
|
2336 | int py = y * Th - Th * 6 / 32; |
|
|
2337 | |
|
|
2338 | key_ov.texname = tex.name; |
|
|
2339 | arr = rc_array (rc_ov, &key_ov); |
|
|
2340 | |
|
|
2341 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2342 | rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); |
|
|
2343 | rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); |
|
|
2344 | rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); |
1901 | } |
2345 | } |
1902 | } |
2346 | } |
1903 | } |
2347 | } |
1904 | } |
2348 | } |
1905 | |
2349 | |
… | |
… | |
1932 | if (!(bits & 0x1000) |
2376 | if (!(bits & 0x1000) |
1933 | && skey->level == level |
2377 | && skey->level == level |
1934 | && level > smooth_max [skey->x][skey->y]) |
2378 | && level > smooth_max [skey->x][skey->y]) |
1935 | { |
2379 | { |
1936 | maptex tex = self->tex [skey->tile]; |
2380 | maptex tex = self->tex [skey->tile]; |
1937 | int px = (((int)skey->x) - 1) * T; |
2381 | int px = (((int)skey->x) - 1) * Tw; |
1938 | int py = (((int)skey->y) - 1) * T; |
2382 | int py = (((int)skey->y) - 1) * Th; |
1939 | int border = bits & 15; |
2383 | int border = bits & 15; |
1940 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
2384 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1941 | float dx = tex.s * .0625f; // 16 images/row |
2385 | float dx = tex.s * .0625f; // 16 images/row |
1942 | float dy = tex.t * .5f ; // 2 images/column |
2386 | float dy = tex.t * .5f ; // 2 images/column |
1943 | |
2387 | |
… | |
… | |
1945 | { |
2389 | { |
1946 | // this time avoiding texture state changes |
2390 | // this time avoiding texture state changes |
1947 | // save gobs of state changes. |
2391 | // save gobs of state changes. |
1948 | if (key.texname != tex.name) |
2392 | if (key.texname != tex.name) |
1949 | { |
2393 | { |
|
|
2394 | self->tex [skey->tile].unused = 0; |
|
|
2395 | |
1950 | glEnd (); |
2396 | glEnd (); |
1951 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2397 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1952 | glBegin (GL_QUADS); |
2398 | glBegin (GL_QUADS); |
1953 | } |
2399 | } |
1954 | |
2400 | |
1955 | if (border) |
2401 | if (border) |
1956 | { |
2402 | { |
1957 | float ox = border * dx; |
2403 | float ox = border * dx; |
1958 | |
2404 | |
1959 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
2405 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1960 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
2406 | glTexCoord2f (ox , dy ); glVertex2i (px , py + Th); |
1961 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
2407 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py + Th); |
1962 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
2408 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + Tw, py ); |
1963 | } |
2409 | } |
1964 | |
2410 | |
1965 | if (corner) |
2411 | if (corner) |
1966 | { |
2412 | { |
1967 | float ox = corner * dx; |
2413 | float ox = corner * dx; |
1968 | |
2414 | |
1969 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
2415 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1970 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
2416 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + Th); |
1971 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
2417 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + Tw, py + Th); |
1972 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
2418 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + Tw, py ); |
1973 | } |
2419 | } |
1974 | } |
2420 | } |
1975 | } |
2421 | } |
1976 | } |
2422 | } |
1977 | } |
2423 | } |
… | |
… | |
1983 | } |
2429 | } |
1984 | |
2430 | |
1985 | hv_clear (smooth); |
2431 | hv_clear (smooth); |
1986 | } |
2432 | } |
1987 | |
2433 | |
|
|
2434 | if (pl_tex.name) |
|
|
2435 | { |
|
|
2436 | maptex tex = pl_tex; |
|
|
2437 | int px = pl_x + sdx; |
|
|
2438 | int py = pl_y + sdy; |
|
|
2439 | |
|
|
2440 | key.texname = tex.name; |
|
|
2441 | arr = rc_array (rc, &key); |
|
|
2442 | |
|
|
2443 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2444 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
|
|
2445 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
|
|
2446 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
|
|
2447 | |
|
|
2448 | rc_draw (rc); |
|
|
2449 | } |
|
|
2450 | |
|
|
2451 | rc_draw (rc_ov); |
|
|
2452 | rc_clear (rc_ov); |
|
|
2453 | |
1988 | glDisable (GL_BLEND); |
2454 | glDisable (GL_BLEND); |
1989 | rc_free (rc); |
2455 | rc_free (rc); |
|
|
2456 | rc_free (rc_ov); |
1990 | |
2457 | |
1991 | // top layer: overlays such as the health bar |
2458 | // top layer: overlays such as the health bar |
1992 | for (y = 0; y < sh; y++) |
2459 | for (y = 0; y < sh; y++) |
1993 | if (0 <= y + my && y + my < self->rows) |
2460 | if (0 <= y + my && y + my < self->rows) |
1994 | { |
2461 | { |
… | |
… | |
1997 | for (x = 0; x < sw; x++) |
2464 | for (x = 0; x < sw; x++) |
1998 | if (row->c0 <= x + mx && x + mx < row->c1) |
2465 | if (row->c0 <= x + mx && x + mx < row->c1) |
1999 | { |
2466 | { |
2000 | mapcell *cell = row->col + (x + mx - row->c0); |
2467 | mapcell *cell = row->col + (x + mx - row->c0); |
2001 | |
2468 | |
2002 | int px = x * T; |
2469 | int px = x * Tw; |
2003 | int py = y * T; |
2470 | int py = y * Th; |
|
|
2471 | |
|
|
2472 | if (expect_false (cell->player == player)) |
|
|
2473 | { |
|
|
2474 | px += sdx; |
|
|
2475 | py += sdy; |
|
|
2476 | } |
2004 | |
2477 | |
2005 | if (cell->stat_hp) |
2478 | if (cell->stat_hp) |
2006 | { |
2479 | { |
2007 | int width = cell->stat_width * T; |
2480 | int width = cell->stat_width * Tw; |
2008 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2481 | int thick = (sh * Th / 32 + 27) / 28 + 1 + cell->stat_width; |
2009 | |
2482 | |
2010 | glColor3ub (0, 0, 0); |
2483 | glColor3ub (0, 0, 0); |
2011 | glRectf (px + 1, py - thick - 2, |
2484 | glRectf (px + 1, py - thick - 2, |
2012 | px + width - 1, py); |
2485 | px + width - 1, py); |
2013 | |
2486 | |
… | |
… | |
2019 | } |
2492 | } |
2020 | } |
2493 | } |
2021 | } |
2494 | } |
2022 | |
2495 | |
2023 | void |
2496 | void |
2024 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2497 | draw_magicmap (DC::Map self, int w, int h, unsigned char *data) |
2025 | CODE: |
2498 | CODE: |
2026 | { |
2499 | { |
2027 | static float color[16][3] = { |
2500 | static float color[16][3] = { |
2028 | { 0.00F, 0.00F, 0.00F }, |
2501 | { 0.00f, 0.00f, 0.00f }, |
2029 | { 1.00F, 1.00F, 1.00F }, |
2502 | { 1.00f, 1.00f, 1.00f }, |
2030 | { 0.00F, 0.00F, 0.55F }, |
2503 | { 0.00f, 0.00f, 0.55f }, |
2031 | { 1.00F, 0.00F, 0.00F }, |
2504 | { 1.00f, 0.00f, 0.00f }, |
2032 | |
2505 | |
2033 | { 1.00F, 0.54F, 0.00F }, |
2506 | { 1.00f, 0.54f, 0.00f }, |
2034 | { 0.11F, 0.56F, 1.00F }, |
2507 | { 0.11f, 0.56f, 1.00f }, |
2035 | { 0.93F, 0.46F, 0.00F }, |
2508 | { 0.93f, 0.46f, 0.00f }, |
2036 | { 0.18F, 0.54F, 0.34F }, |
2509 | { 0.18f, 0.54f, 0.34f }, |
2037 | |
2510 | |
2038 | { 0.56F, 0.73F, 0.56F }, |
2511 | { 0.56f, 0.73f, 0.56f }, |
2039 | { 0.80F, 0.80F, 0.80F }, |
2512 | { 0.80f, 0.80f, 0.80f }, |
2040 | { 0.55F, 0.41F, 0.13F }, |
2513 | { 0.55f, 0.41f, 0.13f }, |
2041 | { 0.99F, 0.77F, 0.26F }, |
2514 | { 0.99f, 0.77f, 0.26f }, |
2042 | |
2515 | |
2043 | { 0.74F, 0.65F, 0.41F }, |
2516 | { 0.74f, 0.65f, 0.41f }, |
2044 | |
2517 | |
2045 | { 0.00F, 1.00F, 1.00F }, |
2518 | { 0.00f, 1.00f, 1.00f }, |
2046 | { 1.00F, 0.00F, 1.00F }, |
2519 | { 1.00f, 0.00f, 1.00f }, |
2047 | { 1.00F, 1.00F, 0.00F }, |
2520 | { 1.00f, 1.00f, 0.00f }, |
2048 | }; |
2521 | }; |
2049 | |
2522 | |
2050 | int x, y; |
2523 | int x, y; |
2051 | |
2524 | |
2052 | glEnable (GL_TEXTURE_2D); |
2525 | glEnable (GL_TEXTURE_2D); |
|
|
2526 | /* GL_REPLACE would be correct, as we don't need to modulate alpha, |
|
|
2527 | * but the nvidia driver (185.18.14) mishandles alpha textures |
|
|
2528 | * and takes the colour from god knows where instead of using |
|
|
2529 | * Cp. MODULATE results in the same colour, but slightly different |
|
|
2530 | * alpha, but atcually gives us the correct colour with nvidia. |
|
|
2531 | */ |
2053 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2532 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
2054 | glEnable (GL_BLEND); |
2533 | glEnable (GL_BLEND); |
2055 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2534 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
2056 | glBegin (GL_QUADS); |
2535 | glBegin (GL_QUADS); |
2057 | |
2536 | |
2058 | for (y = 0; y < h; y++) |
2537 | for (y = 0; y < h; y++) |
… | |
… | |
2062 | |
2541 | |
2063 | if (m) |
2542 | if (m) |
2064 | { |
2543 | { |
2065 | float *c = color [m & 15]; |
2544 | float *c = color [m & 15]; |
2066 | |
2545 | |
2067 | float tx1 = m & 0x40 ? 0.5 : 0.; |
2546 | float tx1 = m & 0x40 ? 0.5f : 0.f; |
2068 | float tx2 = tx1 + 0.5; |
2547 | float tx2 = tx1 + 0.5f; |
2069 | |
2548 | |
2070 | glColor4f (c[0], c[1], c[2], 0.75); |
2549 | glColor4f (c[0], c[1], c[2], 1); |
2071 | glTexCoord2f (tx1, 0.); glVertex2i (x , y ); |
2550 | glTexCoord2f (tx1, 0.); glVertex2i (x , y ); |
2072 | glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); |
2551 | glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); |
2073 | glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); |
2552 | glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); |
2074 | glTexCoord2f (tx2, 0.); glVertex2i (x + 1, y ); |
2553 | glTexCoord2f (tx2, 0.); glVertex2i (x + 1, y ); |
2075 | } |
2554 | } |
… | |
… | |
2079 | glDisable (GL_BLEND); |
2558 | glDisable (GL_BLEND); |
2080 | glDisable (GL_TEXTURE_2D); |
2559 | glDisable (GL_TEXTURE_2D); |
2081 | } |
2560 | } |
2082 | |
2561 | |
2083 | void |
2562 | void |
2084 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2563 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2085 | PPCODE: |
2564 | PPCODE: |
2086 | { |
2565 | { |
2087 | int x, y; |
2566 | int x, y; |
2088 | int sw1 = sw + 2; |
2567 | int sw1 = sw + 2; |
2089 | int sh1 = sh + 2; |
2568 | int sh1 = sh + 2; |
2090 | int sh3 = sh * 3; |
2569 | int sh3 = sh * 3; |
2091 | int sw34 = (sw * 3 + 3) & ~3; |
2570 | int sw3 = sw * 3; |
2092 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
2571 | uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); |
2093 | SV *darkness3_sv = sv_2mortal (newSV (sw34 * sh3)); |
2572 | SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); |
2094 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2573 | uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); |
2095 | |
2574 | |
2096 | SvPOK_only (darkness3_sv); |
2575 | SvPOK_only (darkness3_sv); |
2097 | SvCUR_set (darkness3_sv, sw34 * sh3); |
2576 | SvCUR_set (darkness3_sv, sw3 * sh3); |
2098 | |
2577 | |
2099 | mx += self->x - 1; |
2578 | mx += self->x - 1; |
2100 | my += self->y - 1; |
2579 | my += self->y - 1; |
2101 | |
|
|
2102 | memset (darkness1, 255, sw1 * sh1); |
|
|
2103 | |
2580 | |
2104 | for (y = 0; y < sh1; y++) |
2581 | for (y = 0; y < sh1; y++) |
2105 | if (0 <= y + my && y + my < self->rows) |
2582 | if (0 <= y + my && y + my < self->rows) |
2106 | { |
2583 | { |
2107 | maprow *row = self->row + (y + my); |
2584 | maprow *row = self->row + (y + my); |
… | |
… | |
2110 | if (row->c0 <= x + mx && x + mx < row->c1) |
2587 | if (row->c0 <= x + mx && x + mx < row->c1) |
2111 | { |
2588 | { |
2112 | mapcell *cell = row->col + (x + mx - row->c0); |
2589 | mapcell *cell = row->col + (x + mx - row->c0); |
2113 | |
2590 | |
2114 | darkness1 [y * sw1 + x] = cell->darkness |
2591 | darkness1 [y * sw1 + x] = cell->darkness |
2115 | ? 255 - (cell->darkness - 1) |
2592 | ? DARKNESS_ADJUST (255 - (cell->darkness - 1)) |
2116 | : 255 - FOW_DARKNESS; |
2593 | : DARKNESS_ADJUST (255 - FOW_DARKNESS); |
2117 | } |
2594 | } |
2118 | } |
2595 | } |
2119 | |
2596 | |
2120 | for (y = 0; y < sh; ++y) |
2597 | for (y = 0; y < sh; ++y) |
2121 | for (x = 0; x < sw; ++x) |
2598 | for (x = 0; x < sw; ++x) |
… | |
… | |
2140 | |
2617 | |
2141 | uint8_t r13 = (d13 + d23 + d12) / 3; |
2618 | uint8_t r13 = (d13 + d23 + d12) / 3; |
2142 | uint8_t r23 = d23; |
2619 | uint8_t r23 = d23; |
2143 | uint8_t r33 = (d23 + d33 + d32) / 3; |
2620 | uint8_t r33 = (d23 + d33 + d32) / 3; |
2144 | |
2621 | |
2145 | darkness3 [(y * 3 ) * sw34 + (x * 3 )] = MAX (d22, r11); |
2622 | darkness3 [(y * 3 ) * sw3 + (x * 3 )] = MAX (d22, r11); |
2146 | darkness3 [(y * 3 ) * sw34 + (x * 3 + 1)] = MAX (d22, r21); |
2623 | darkness3 [(y * 3 ) * sw3 + (x * 3 + 1)] = MAX (d22, r21); |
2147 | darkness3 [(y * 3 ) * sw34 + (x * 3 + 2)] = MAX (d22, r31); |
2624 | darkness3 [(y * 3 ) * sw3 + (x * 3 + 2)] = MAX (d22, r31); |
2148 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 )] = MAX (d22, r12); |
2625 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 )] = MAX (d22, r12); |
2149 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 + 1)] = MAX (d22, r22); |
2626 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 + 1)] = MAX (d22, r22); /* this MUST be == d22 */ |
2150 | darkness3 [(y * 3 + 1) * sw34 + (x * 3 + 2)] = MAX (d22, r32); |
2627 | darkness3 [(y * 3 + 1) * sw3 + (x * 3 + 2)] = MAX (d22, r32); |
2151 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 )] = MAX (d22, r13); |
2628 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 )] = MAX (d22, r13); |
2152 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 + 1)] = MAX (d22, r23); |
2629 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 + 1)] = MAX (d22, r23); |
2153 | darkness3 [(y * 3 + 2) * sw34 + (x * 3 + 2)] = MAX (d22, r33); |
2630 | darkness3 [(y * 3 + 2) * sw3 + (x * 3 + 2)] = MAX (d22, r33); |
2154 | } |
2631 | } |
2155 | |
2632 | |
2156 | free (darkness1); |
2633 | free (darkness1); |
2157 | |
2634 | |
2158 | EXTEND (SP, 3); |
2635 | EXTEND (SP, 3); |
2159 | PUSHs (sv_2mortal (newSViv (sw34))); |
2636 | PUSHs (sv_2mortal (newSViv (sw3))); |
2160 | PUSHs (sv_2mortal (newSViv (sh3))); |
2637 | PUSHs (sv_2mortal (newSViv (sh3))); |
2161 | PUSHs (darkness3_sv); |
2638 | PUSHs (darkness3_sv); |
2162 | } |
2639 | } |
2163 | |
2640 | |
2164 | SV * |
2641 | SV * |
2165 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2642 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2166 | CODE: |
2643 | CODE: |
2167 | { |
2644 | { |
2168 | int x, y, x1, y1; |
2645 | int x, y, x1, y1; |
2169 | SV *data_sv = newSV (w * h * 7 + 5); |
2646 | SV *data_sv = newSV (w * h * 7 + 5); |
2170 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2647 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2227 | else |
2704 | else |
2228 | *data++ = 0; |
2705 | *data++ = 0; |
2229 | } |
2706 | } |
2230 | } |
2707 | } |
2231 | |
2708 | |
|
|
2709 | /* if size is w*h + 5 then no data has been found */ |
|
|
2710 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
|
|
2711 | { |
2232 | SvPOK_only (data_sv); |
2712 | SvPOK_only (data_sv); |
2233 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2713 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2714 | } |
|
|
2715 | |
2234 | RETVAL = data_sv; |
2716 | RETVAL = data_sv; |
2235 | } |
2717 | } |
2236 | OUTPUT: |
2718 | OUTPUT: |
2237 | RETVAL |
2719 | RETVAL |
2238 | |
2720 | |
2239 | void |
2721 | void |
2240 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2722 | set_rect (DC::Map self, int x0, int y0, SV *data_sv) |
2241 | PPCODE: |
2723 | PPCODE: |
2242 | { |
2724 | { |
2243 | int x, y, z; |
2725 | int x, y, z; |
2244 | int w, h; |
2726 | int w, h; |
2245 | int x1, y1; |
2727 | int x1, y1; |
|
|
2728 | STRLEN len; |
|
|
2729 | uint8_t *data, *end; |
|
|
2730 | |
|
|
2731 | len = SvLEN (data_sv); |
|
|
2732 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
|
|
2733 | data = SvPVbyte_nolen (data_sv); |
|
|
2734 | end = data + len + 8; |
|
|
2735 | |
|
|
2736 | if (len < 5) |
|
|
2737 | XSRETURN_EMPTY; |
2246 | |
2738 | |
2247 | if (*data++ != 0) |
2739 | if (*data++ != 0) |
2248 | return; /* version mismatch */ |
2740 | XSRETURN_EMPTY; /* version mismatch */ |
2249 | |
2741 | |
2250 | w = *data++ << 8; w |= *data++; |
2742 | w = *data++ << 8; w |= *data++; |
2251 | h = *data++ << 8; h |= *data++; |
2743 | h = *data++ << 8; h |= *data++; |
2252 | |
2744 | |
2253 | // we need to do this 'cause we don't keep an absolute coord system for rows |
2745 | // we need to do this 'cause we don't keep an absolute coord system for rows |
… | |
… | |
2265 | { |
2757 | { |
2266 | maprow *row = map_get_row (self, y); |
2758 | maprow *row = map_get_row (self, y); |
2267 | |
2759 | |
2268 | for (x = x0; x < x1; x++) |
2760 | for (x = x0; x < x1; x++) |
2269 | { |
2761 | { |
|
|
2762 | uint8_t flags; |
|
|
2763 | |
|
|
2764 | if (data + 7 >= end) |
|
|
2765 | XSRETURN_EMPTY; |
|
|
2766 | |
2270 | uint8_t flags = *data++; |
2767 | flags = *data++; |
2271 | |
2768 | |
2272 | if (flags) |
2769 | if (flags) |
2273 | { |
2770 | { |
2274 | mapcell *cell = row_get_cell (row, x); |
2771 | mapcell *cell = row_get_cell (row, x); |
2275 | tileid tile[3] = { 0, 0, 0 }; |
2772 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2278 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2775 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2279 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2776 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2280 | |
2777 | |
2281 | if (cell->darkness == 0) |
2778 | if (cell->darkness == 0) |
2282 | { |
2779 | { |
2283 | cell->darkness = 0; |
2780 | /*cell->darkness = 0;*/ |
|
|
2781 | EXTEND (SP, 3); |
2284 | |
2782 | |
2285 | for (z = 0; z <= 2; z++) |
2783 | for (z = 0; z <= 2; z++) |
2286 | { |
2784 | { |
2287 | tileid t = tile [z]; |
2785 | tileid t = tile [z]; |
2288 | |
2786 | |
2289 | if (t >= self->texs || (t && !self->tex [t].name)) |
2787 | if (t >= self->texs || (t && !self->tex [t].name)) |
2290 | { |
2788 | { |
2291 | XPUSHs (sv_2mortal (newSViv (t))); |
2789 | PUSHs (sv_2mortal (newSViv (t))); |
2292 | need_texid (self, t); |
2790 | need_texid (self, t); |
2293 | } |
2791 | } |
2294 | |
2792 | |
2295 | cell->tile [z] = t; |
2793 | cell->tile [z] = t; |
2296 | } |
2794 | } |
… | |
… | |
2298 | } |
2796 | } |
2299 | } |
2797 | } |
2300 | } |
2798 | } |
2301 | } |
2799 | } |
2302 | |
2800 | |
2303 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2801 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2304 | |
2802 | |
2305 | CFPlus::RW |
2803 | DC::RW |
2306 | new (SV *class, SV *data_sv) |
2804 | new (SV *class, SV *data_sv) |
2307 | CODE: |
2805 | CODE: |
2308 | { |
2806 | { |
2309 | STRLEN datalen; |
2807 | STRLEN datalen; |
2310 | char *data = SvPVbyte (data_sv, datalen); |
2808 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2312 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2810 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2313 | } |
2811 | } |
2314 | OUTPUT: |
2812 | OUTPUT: |
2315 | RETVAL |
2813 | RETVAL |
2316 | |
2814 | |
2317 | CFPlus::RW |
2815 | DC::RW |
2318 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2816 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2319 | CODE: |
2817 | CODE: |
2320 | RETVAL = SDL_RWFromFile (path, mode); |
2818 | RETVAL = SDL_RWFromFile (path, mode); |
2321 | OUTPUT: |
2819 | OUTPUT: |
2322 | RETVAL |
2820 | RETVAL |
2323 | |
2821 | |
2324 | # fails on win32: |
2822 | # fails on win32: |
2325 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2823 | # dc.xs(2268) : error C2059: syntax error : '(' |
2326 | #void |
2824 | #void |
2327 | #close (CFPlus::RW self) |
2825 | #close (DC::RW self) |
2328 | # CODE: |
2826 | # CODE: |
2329 | # (self->(close)) (self); |
2827 | # (self->(close)) (self); |
2330 | |
2828 | |
2331 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2829 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2332 | |
2830 | |
2333 | PROTOTYPES: DISABLE |
2831 | PROTOTYPES: DISABLE |
2334 | |
2832 | |
2335 | CFPlus::Channel |
2833 | DC::Channel |
2336 | find () |
2834 | find () |
2337 | CODE: |
2835 | CODE: |
2338 | { |
2836 | { |
2339 | RETVAL = Mix_GroupAvailable (-1); |
2837 | RETVAL = Mix_GroupAvailable (-1); |
2340 | |
2838 | |
2341 | if (RETVAL < 0) |
2839 | if (RETVAL < 0) |
2342 | { |
2840 | { |
2343 | RETVAL = Mix_GroupOldest (-1); |
2841 | RETVAL = Mix_GroupOldest (-1); |
2344 | |
2842 | |
2345 | if (RETVAL < 0) |
2843 | if (RETVAL < 0) |
|
|
2844 | { |
|
|
2845 | // happens sometimes, maybe it just stopped playing(?) |
|
|
2846 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2847 | |
|
|
2848 | if (RETVAL < 0) |
2346 | XSRETURN_UNDEF; |
2849 | XSRETURN_UNDEF; |
2347 | |
2850 | } |
|
|
2851 | else |
2348 | Mix_HaltChannel (RETVAL); |
2852 | Mix_HaltChannel (RETVAL); |
2349 | } |
2853 | } |
2350 | |
2854 | |
2351 | Mix_UnregisterAllEffects (RETVAL); |
2855 | Mix_UnregisterAllEffects (RETVAL); |
2352 | Mix_Volume (RETVAL, 128); |
2856 | Mix_Volume (RETVAL, 128); |
2353 | } |
2857 | } |
2354 | OUTPUT: |
2858 | OUTPUT: |
2355 | RETVAL |
2859 | RETVAL |
2356 | |
2860 | |
2357 | void |
2861 | void |
2358 | halt (CFPlus::Channel self) |
2862 | halt (DC::Channel self) |
2359 | CODE: |
2863 | CODE: |
2360 | Mix_HaltChannel (self); |
2864 | Mix_HaltChannel (self); |
2361 | |
2865 | |
2362 | void |
2866 | void |
2363 | expire (CFPlus::Channel self, int ticks = -1) |
2867 | expire (DC::Channel self, int ticks = -1) |
2364 | CODE: |
2868 | CODE: |
2365 | Mix_ExpireChannel (self, ticks); |
2869 | Mix_ExpireChannel (self, ticks); |
2366 | |
2870 | |
2367 | void |
2871 | void |
2368 | fade_out (CFPlus::Channel self, int ticks = -1) |
2872 | fade_out (DC::Channel self, int ticks = -1) |
2369 | CODE: |
2873 | CODE: |
2370 | Mix_FadeOutChannel (self, ticks); |
2874 | Mix_FadeOutChannel (self, ticks); |
2371 | |
2875 | |
2372 | int |
2876 | int |
2373 | volume (CFPlus::Channel self, int volume) |
2877 | volume (DC::Channel self, int volume) |
2374 | CODE: |
2878 | CODE: |
2375 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2879 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2376 | OUTPUT: |
2880 | OUTPUT: |
2377 | RETVAL |
2881 | RETVAL |
2378 | |
2882 | |
2379 | void |
2883 | void |
2380 | unregister_all_effects (CFPlus::Channel self) |
2884 | unregister_all_effects (DC::Channel self) |
2381 | CODE: |
2885 | CODE: |
2382 | Mix_UnregisterAllEffects (self); |
2886 | Mix_UnregisterAllEffects (self); |
2383 | |
2887 | |
2384 | void |
2888 | void |
2385 | set_panning (CFPlus::Channel self, int left, int right) |
2889 | set_panning (DC::Channel self, int left, int right) |
2386 | CODE: |
2890 | CODE: |
2387 | left = CLAMP (left , 0, 255); |
2891 | left = CLAMP (left , 0, 255); |
2388 | right = CLAMP (right, 0, 255); |
2892 | right = CLAMP (right, 0, 255); |
2389 | Mix_SetPanning (self, left, right); |
2893 | Mix_SetPanning (self, left, right); |
2390 | |
2894 | |
2391 | void |
2895 | void |
2392 | set_distance (CFPlus::Channel self, int distance) |
2896 | set_distance (DC::Channel self, int distance) |
2393 | CODE: |
2897 | CODE: |
2394 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2898 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2395 | |
2899 | |
2396 | void |
2900 | void |
2397 | set_position (CFPlus::Channel self, int angle, int distance) |
2901 | set_position (DC::Channel self, int angle, int distance) |
2398 | CODE: |
2902 | CODE: |
2399 | |
2903 | |
2400 | void |
2904 | void |
2401 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2905 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2402 | CODE: |
2906 | CODE: |
2403 | { |
2907 | { |
2404 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2908 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2405 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2909 | int angle = atan2f (dx, -dy) * 180.f / (float)M_PI + 360.f; |
2406 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2910 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2407 | } |
2911 | } |
2408 | |
2912 | |
2409 | void |
2913 | void |
2410 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2914 | set_reverse_stereo (DC::Channel self, int flip) |
2411 | CODE: |
2915 | CODE: |
2412 | Mix_SetReverseStereo (self, flip); |
2916 | Mix_SetReverseStereo (self, flip); |
2413 | |
2917 | |
2414 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2918 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2415 | |
2919 | |
2416 | PROTOTYPES: DISABLE |
2920 | PROTOTYPES: DISABLE |
2417 | |
2921 | |
|
|
2922 | void |
|
|
2923 | decoders () |
|
|
2924 | PPCODE: |
|
|
2925 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2926 | int i, num = Mix_GetNumChunkDecoders (); |
|
|
2927 | EXTEND (SP, num); |
|
|
2928 | for (i = 0; i < num; ++i) |
|
|
2929 | PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0))); |
|
|
2930 | #else |
|
|
2931 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2932 | #endif |
|
|
2933 | |
2418 | CFPlus::MixChunk |
2934 | DC::MixChunk |
2419 | new (SV *class, CFPlus::RW rwops) |
2935 | new (SV *class, DC::RW rwops) |
2420 | CODE: |
2936 | CODE: |
2421 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2937 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2422 | OUTPUT: |
2938 | OUTPUT: |
2423 | RETVAL |
2939 | RETVAL |
2424 | |
2940 | |
2425 | void |
2941 | void |
2426 | DESTROY (CFPlus::MixChunk self) |
2942 | DESTROY (DC::MixChunk self) |
2427 | CODE: |
2943 | CODE: |
2428 | Mix_FreeChunk (self); |
2944 | Mix_FreeChunk (self); |
2429 | |
2945 | |
2430 | int |
2946 | int |
2431 | volume (CFPlus::MixChunk self, int volume = -1) |
2947 | volume (DC::MixChunk self, int volume = -1) |
2432 | CODE: |
2948 | CODE: |
2433 | if (items > 1) |
2949 | if (items > 1) |
2434 | volume = CLAMP (volume, 0, 128); |
2950 | volume = CLAMP (volume, 0, 128); |
2435 | RETVAL = Mix_VolumeChunk (self, volume); |
2951 | RETVAL = Mix_VolumeChunk (self, volume); |
2436 | OUTPUT: |
2952 | OUTPUT: |
2437 | RETVAL |
2953 | RETVAL |
2438 | |
2954 | |
2439 | CFPlus::Channel |
2955 | DC::Channel |
2440 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2956 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2441 | CODE: |
2957 | CODE: |
2442 | { |
2958 | { |
2443 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2959 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2444 | |
2960 | |
2445 | if (RETVAL < 0) |
2961 | if (RETVAL < 0) |
… | |
… | |
2452 | } |
2968 | } |
2453 | } |
2969 | } |
2454 | OUTPUT: |
2970 | OUTPUT: |
2455 | RETVAL |
2971 | RETVAL |
2456 | |
2972 | |
2457 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2973 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
|
|
2974 | |
|
|
2975 | void |
|
|
2976 | decoders () |
|
|
2977 | PPCODE: |
|
|
2978 | #if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10 |
|
|
2979 | int i, num = Mix_GetNumMusicDecoders (); |
|
|
2980 | EXTEND (SP, num); |
|
|
2981 | for (i = 0; i < num; ++i) |
|
|
2982 | PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0))); |
|
|
2983 | #else |
|
|
2984 | XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0))); |
|
|
2985 | #endif |
2458 | |
2986 | |
2459 | int |
2987 | int |
2460 | volume (int volume = -1) |
2988 | volume (int volume = -1) |
2461 | PROTOTYPE: ;$ |
2989 | PROTOTYPE: ;$ |
2462 | CODE: |
2990 | CODE: |
… | |
… | |
2474 | void |
3002 | void |
2475 | halt () |
3003 | halt () |
2476 | CODE: |
3004 | CODE: |
2477 | Mix_HaltMusic (); |
3005 | Mix_HaltMusic (); |
2478 | |
3006 | |
|
|
3007 | int |
|
|
3008 | playing () |
|
|
3009 | CODE: |
|
|
3010 | RETVAL = Mix_PlayingMusic (); |
|
|
3011 | OUTPUT: |
|
|
3012 | RETVAL |
|
|
3013 | |
2479 | CFPlus::MixMusic |
3014 | DC::MixMusic |
2480 | new (SV *class, CFPlus::RW rwops) |
3015 | new (SV *class, DC::RW rwops) |
2481 | CODE: |
3016 | CODE: |
2482 | RETVAL = Mix_LoadMUS_RW (rwops); |
3017 | RETVAL = Mix_LoadMUS_RW (rwops); |
2483 | OUTPUT: |
3018 | OUTPUT: |
2484 | RETVAL |
3019 | RETVAL |
2485 | |
3020 | |
2486 | void |
3021 | void |
2487 | DESTROY (CFPlus::MixMusic self) |
3022 | DESTROY (DC::MixMusic self) |
2488 | CODE: |
3023 | CODE: |
2489 | Mix_FreeMusic (self); |
3024 | Mix_FreeMusic (self); |
2490 | |
3025 | |
2491 | int |
3026 | int |
2492 | play (CFPlus::MixMusic self, int loops = -1) |
3027 | play (DC::MixMusic self, int loops = -1) |
2493 | CODE: |
3028 | CODE: |
2494 | RETVAL = Mix_PlayMusic (self, loops); |
3029 | RETVAL = Mix_PlayMusic (self, loops); |
2495 | OUTPUT: |
3030 | OUTPUT: |
2496 | RETVAL |
3031 | RETVAL |
2497 | |
3032 | |
2498 | void |
3033 | void |
2499 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
3034 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2500 | CODE: |
3035 | CODE: |
2501 | Mix_FadeInMusicPos (self, loops, ms, position); |
3036 | Mix_FadeInMusicPos (self, loops, ms, position); |
2502 | |
3037 | |
2503 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
3038 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2504 | |
3039 | |
2505 | PROTOTYPES: ENABLE |
3040 | PROTOTYPES: ENABLE |
2506 | |
3041 | |
2507 | BOOT: |
3042 | BOOT: |
2508 | { |
3043 | { |
2509 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
3044 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2510 | static const struct { |
3045 | static const struct { |
2511 | const char *name; |
3046 | const char *name; |
2512 | IV iv; |
3047 | IV iv; |
2513 | } *civ, const_iv[] = { |
3048 | } *civ, const_iv[] = { |
2514 | # define const_iv(name) { # name, (IV)name } |
3049 | # define const_iv(name) { # name, (IV)name } |
2515 | const_iv (GL_VENDOR), |
3050 | const_iv (GL_VENDOR), |
2516 | const_iv (GL_VERSION), |
3051 | const_iv (GL_VERSION), |
2517 | const_iv (GL_EXTENSIONS), |
3052 | const_iv (GL_EXTENSIONS), |
|
|
3053 | const_iv (GL_MAX_TEXTURE_UNITS), |
2518 | const_iv (GL_COLOR_MATERIAL), |
3054 | const_iv (GL_COLOR_MATERIAL), |
2519 | const_iv (GL_SMOOTH), |
3055 | const_iv (GL_SMOOTH), |
2520 | const_iv (GL_FLAT), |
3056 | const_iv (GL_FLAT), |
2521 | const_iv (GL_DITHER), |
3057 | const_iv (GL_DITHER), |
2522 | const_iv (GL_BLEND), |
3058 | const_iv (GL_BLEND), |
… | |
… | |
2534 | const_iv (GL_ZERO), |
3070 | const_iv (GL_ZERO), |
2535 | const_iv (GL_SRC_ALPHA), |
3071 | const_iv (GL_SRC_ALPHA), |
2536 | const_iv (GL_DST_ALPHA), |
3072 | const_iv (GL_DST_ALPHA), |
2537 | const_iv (GL_ONE_MINUS_SRC_ALPHA), |
3073 | const_iv (GL_ONE_MINUS_SRC_ALPHA), |
2538 | const_iv (GL_ONE_MINUS_DST_ALPHA), |
3074 | const_iv (GL_ONE_MINUS_DST_ALPHA), |
|
|
3075 | const_iv (GL_SRC_COLOR), |
|
|
3076 | const_iv (GL_DST_COLOR), |
|
|
3077 | const_iv (GL_ONE_MINUS_SRC_COLOR), |
|
|
3078 | const_iv (GL_ONE_MINUS_DST_COLOR), |
2539 | const_iv (GL_SRC_ALPHA_SATURATE), |
3079 | const_iv (GL_SRC_ALPHA_SATURATE), |
2540 | const_iv (GL_RGB), |
3080 | const_iv (GL_RGB), |
2541 | const_iv (GL_RGBA), |
3081 | const_iv (GL_RGBA), |
2542 | const_iv (GL_RGBA4), |
3082 | const_iv (GL_RGBA4), |
2543 | const_iv (GL_RGBA8), |
3083 | const_iv (GL_RGBA8), |
… | |
… | |
2549 | const_iv (GL_INTENSITY), |
3089 | const_iv (GL_INTENSITY), |
2550 | const_iv (GL_LUMINANCE), |
3090 | const_iv (GL_LUMINANCE), |
2551 | const_iv (GL_LUMINANCE_ALPHA), |
3091 | const_iv (GL_LUMINANCE_ALPHA), |
2552 | const_iv (GL_FLOAT), |
3092 | const_iv (GL_FLOAT), |
2553 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
3093 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
3094 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
3095 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
3096 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
3097 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
3098 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
3099 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2554 | const_iv (GL_COMPILE), |
3100 | const_iv (GL_COMPILE), |
2555 | const_iv (GL_PROXY_TEXTURE_1D), |
3101 | const_iv (GL_PROXY_TEXTURE_1D), |
2556 | const_iv (GL_PROXY_TEXTURE_2D), |
3102 | const_iv (GL_PROXY_TEXTURE_2D), |
2557 | const_iv (GL_TEXTURE_1D), |
3103 | const_iv (GL_TEXTURE_1D), |
2558 | const_iv (GL_TEXTURE_2D), |
3104 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2597 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
3143 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2598 | const_iv (GL_POINT_SMOOTH_HINT), |
3144 | const_iv (GL_POINT_SMOOTH_HINT), |
2599 | const_iv (GL_LINE_SMOOTH_HINT), |
3145 | const_iv (GL_LINE_SMOOTH_HINT), |
2600 | const_iv (GL_POLYGON_SMOOTH_HINT), |
3146 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2601 | const_iv (GL_GENERATE_MIPMAP_HINT), |
3147 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
3148 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2602 | const_iv (GL_FASTEST), |
3149 | const_iv (GL_FASTEST), |
2603 | const_iv (GL_DONT_CARE), |
3150 | const_iv (GL_DONT_CARE), |
2604 | const_iv (GL_NICEST), |
3151 | const_iv (GL_NICEST), |
2605 | const_iv (GL_V2F), |
3152 | const_iv (GL_V2F), |
2606 | const_iv (GL_V3F), |
3153 | const_iv (GL_V3F), |
2607 | const_iv (GL_T2F_V3F), |
3154 | const_iv (GL_T2F_V3F), |
2608 | const_iv (GL_T2F_N3F_V3F), |
3155 | const_iv (GL_T2F_N3F_V3F), |
|
|
3156 | const_iv (GL_FUNC_ADD), |
|
|
3157 | const_iv (GL_FUNC_SUBTRACT), |
|
|
3158 | const_iv (GL_FUNC_REVERSE_SUBTRACT), |
2609 | # undef const_iv |
3159 | # undef const_iv |
2610 | }; |
3160 | }; |
2611 | |
3161 | |
2612 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
3162 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
2613 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
3163 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
2614 | |
3164 | |
2615 | texture_av = newAV (); |
3165 | texture_av = newAV (); |
2616 | AvREAL_off (texture_av); |
3166 | AvREAL_off (texture_av); |
2617 | } |
3167 | } |
2618 | |
3168 | |
|
|
3169 | void |
|
|
3170 | disable_GL_EXT_blend_func_separate () |
|
|
3171 | CODE: |
|
|
3172 | gl.BlendFuncSeparate = 0; |
|
|
3173 | gl.BlendFuncSeparateEXT = 0; |
|
|
3174 | |
|
|
3175 | void |
|
|
3176 | apple_nvidia_bug (int enable) |
|
|
3177 | |
2619 | char * |
3178 | char * |
2620 | gl_vendor () |
3179 | gl_vendor () |
2621 | CODE: |
3180 | CODE: |
2622 | RETVAL = (char *)glGetString (GL_VENDOR); |
3181 | RETVAL = (char *)glGetString (GL_VENDOR); |
2623 | OUTPUT: |
3182 | OUTPUT: |
… | |
… | |
2653 | |
3212 | |
2654 | int glGetError () |
3213 | int glGetError () |
2655 | |
3214 | |
2656 | void glFinish () |
3215 | void glFinish () |
2657 | |
3216 | |
|
|
3217 | void glFlush () |
|
|
3218 | |
2658 | void glClear (int mask) |
3219 | void glClear (int mask) |
2659 | |
3220 | |
2660 | void glClearColor (float r, float g, float b, float a = 1.0) |
3221 | void glClearColor (float r, float g, float b, float a = 1.0) |
2661 | PROTOTYPE: @ |
3222 | PROTOTYPE: @ |
2662 | |
3223 | |
… | |
… | |
2671 | void glBlendFunc (int sfactor, int dfactor) |
3232 | void glBlendFunc (int sfactor, int dfactor) |
2672 | |
3233 | |
2673 | void glBlendFuncSeparate (int sa, int da, int saa, int daa) |
3234 | void glBlendFuncSeparate (int sa, int da, int saa, int daa) |
2674 | CODE: |
3235 | CODE: |
2675 | gl_BlendFuncSeparate (sa, da, saa, daa); |
3236 | gl_BlendFuncSeparate (sa, da, saa, daa); |
|
|
3237 | |
|
|
3238 | # void glBlendEquation (int se) |
2676 | |
3239 | |
2677 | void glDepthMask (int flag) |
3240 | void glDepthMask (int flag) |
2678 | |
3241 | |
2679 | void glLogicOp (int opcode) |
3242 | void glLogicOp (int opcode) |
2680 | |
3243 | |
… | |
… | |
2715 | void glRotate (float angle, float x, float y, float z) |
3278 | void glRotate (float angle, float x, float y, float z) |
2716 | CODE: |
3279 | CODE: |
2717 | glRotatef (angle, x, y, z); |
3280 | glRotatef (angle, x, y, z); |
2718 | |
3281 | |
2719 | void glColor (float r, float g, float b, float a = 1.0) |
3282 | void glColor (float r, float g, float b, float a = 1.0) |
|
|
3283 | PROTOTYPE: @ |
2720 | ALIAS: |
3284 | ALIAS: |
2721 | glColor_premultiply = 1 |
3285 | glColor_premultiply = 1 |
2722 | CODE: |
3286 | CODE: |
2723 | if (ix) |
3287 | if (ix) |
2724 | { |
3288 | { |
… | |
… | |
2744 | |
3308 | |
2745 | void glRect (float x1, float y1, float x2, float y2) |
3309 | void glRect (float x1, float y1, float x2, float y2) |
2746 | CODE: |
3310 | CODE: |
2747 | glRectf (x1, y1, x2, y2); |
3311 | glRectf (x1, y1, x2, y2); |
2748 | |
3312 | |
|
|
3313 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
3314 | CODE: |
|
|
3315 | glBegin (GL_LINE_LOOP); |
|
|
3316 | glVertex2f (x1, y1); |
|
|
3317 | glVertex2f (x2, y1); |
|
|
3318 | glVertex2f (x2, y2); |
|
|
3319 | glVertex2f (x1, y2); |
|
|
3320 | glEnd (); |
|
|
3321 | |
2749 | PROTOTYPES: ENABLE |
3322 | PROTOTYPES: ENABLE |
2750 | |
3323 | |
2751 | void glBegin (int mode) |
3324 | void glBegin (int mode) |
2752 | |
3325 | |
2753 | void glEnd () |
3326 | void glEnd () |
… | |
… | |
2785 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
3358 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2786 | CODE: |
3359 | CODE: |
2787 | if (gl.SeparableFilter2D) |
3360 | if (gl.SeparableFilter2D) |
2788 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
3361 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2789 | |
3362 | |
2790 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
3363 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2791 | |
3364 | |
2792 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
3365 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2793 | |
3366 | |
2794 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
3367 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2795 | |
3368 | |
… | |
… | |
2821 | |
3394 | |
2822 | void glEndList () |
3395 | void glEndList () |
2823 | |
3396 | |
2824 | void glCallList (int list) |
3397 | void glCallList (int list) |
2825 | |
3398 | |
2826 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
3399 | void c_init () |
|
|
3400 | CODE: |
|
|
3401 | glPixelStorei (GL_PACK_ALIGNMENT , 1); |
|
|
3402 | glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
|
|
3403 | |
|
|
3404 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2827 | |
3405 | |
2828 | PROTOTYPES: DISABLE |
3406 | PROTOTYPES: DISABLE |
2829 | |
3407 | |
2830 | void |
3408 | void |
2831 | find_widget (SV *self, NV x, NV y) |
3409 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2835 | XPUSHs (self); |
3413 | XPUSHs (self); |
2836 | } |
3414 | } |
2837 | |
3415 | |
2838 | BOOT: |
3416 | BOOT: |
2839 | { |
3417 | { |
2840 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
3418 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2841 | |
3419 | |
2842 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
3420 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2843 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
3421 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2844 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
3422 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2845 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
3423 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2846 | } |
3424 | } |
2847 | |
3425 | |
2848 | void |
3426 | void |
2849 | draw (SV *self) |
3427 | draw (SV *self) |
2850 | CODE: |
3428 | CODE: |
… | |
… | |
2854 | NV x, y, w, h; |
3432 | NV x, y, w, h; |
2855 | SV *draw_x_sv = GvSV (draw_x_gv); |
3433 | SV *draw_x_sv = GvSV (draw_x_gv); |
2856 | SV *draw_y_sv = GvSV (draw_y_gv); |
3434 | SV *draw_y_sv = GvSV (draw_y_gv); |
2857 | SV *draw_w_sv = GvSV (draw_w_gv); |
3435 | SV *draw_w_sv = GvSV (draw_w_gv); |
2858 | SV *draw_h_sv = GvSV (draw_h_gv); |
3436 | SV *draw_h_sv = GvSV (draw_h_gv); |
2859 | SV *hover; |
|
|
2860 | double draw_x, draw_y, draw_w, draw_h; |
3437 | double draw_x, draw_y; |
2861 | |
3438 | |
2862 | if (!SvROK (self)) |
3439 | if (!SvROK (self)) |
2863 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
3440 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2864 | |
3441 | |
2865 | hv = (HV *)SvRV (self); |
3442 | hv = (HV *)SvRV (self); |
2866 | |
3443 | |
2867 | if (SvTYPE (hv) != SVt_PVHV) |
3444 | if (SvTYPE (hv) != SVt_PVHV) |
2868 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
3445 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2869 | |
3446 | |
2870 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
3447 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2871 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
3448 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2872 | |
3449 | |
2873 | if (!h || !w) |
3450 | if (!h || !w) |
… | |
… | |
2893 | { |
3470 | { |
2894 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
3471 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2895 | |
3472 | |
2896 | if (svp && SvTRUE (*svp)) |
3473 | if (svp && SvTRUE (*svp)) |
2897 | { |
3474 | { |
2898 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
3475 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2899 | glEnable (GL_BLEND); |
3476 | glEnable (GL_BLEND); |
2900 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
3477 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2901 | glBegin (GL_QUADS); |
3478 | glBegin (GL_QUADS); |
2902 | glVertex2f (0, 0); |
3479 | glVertex2f (0, 0); |
2903 | glVertex2f (w, 0); |
3480 | glVertex2f (w, 0); |
… | |
… | |
2906 | glEnd (); |
3483 | glEnd (); |
2907 | glDisable (GL_BLEND); |
3484 | glDisable (GL_BLEND); |
2908 | } |
3485 | } |
2909 | } |
3486 | } |
2910 | #if 0 |
3487 | #if 0 |
2911 | if ($ENV{CFPLUS_DEBUG} & 1) { |
3488 | // draw borders, for debugging |
2912 | glPushMatrix; |
3489 | glPushMatrix (); |
2913 | glColor 1, 1, 0, 1; |
3490 | glColor4f (1., 1., 0., 1.); |
2914 | glTranslate 0.375, 0.375; |
3491 | glTranslatef (.5, .5, 0.); |
2915 | glBegin GL_LINE_LOOP; |
3492 | glBegin (GL_LINE_LOOP); |
2916 | glVertex 0 , 0; |
3493 | glVertex2f (0 , 0); |
2917 | glVertex $self->{w} - 1, 0; |
3494 | glVertex2f (w - 1, 0); |
2918 | glVertex $self->{w} - 1, $self->{h} - 1; |
3495 | glVertex2f (w - 1, h - 1); |
2919 | glVertex 0 , $self->{h} - 1; |
3496 | glVertex2f (0 , h - 1); |
2920 | glEnd; |
3497 | glEnd (); |
2921 | glPopMatrix; |
3498 | glPopMatrix (); |
2922 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2923 | } |
|
|
2924 | #endif |
3499 | #endif |
2925 | PUSHMARK (SP); |
3500 | PUSHMARK (SP); |
2926 | XPUSHs (self); |
3501 | XPUSHs (self); |
2927 | PUTBACK; |
3502 | PUTBACK; |
2928 | call_method ("_draw", G_VOID | G_DISCARD); |
3503 | call_method ("_draw", G_VOID | G_DISCARD); |