… | |
… | |
46 | |
46 | |
47 | #include <glib/gmacros.h> |
47 | #include <glib/gmacros.h> |
48 | |
48 | |
49 | #include <pango/pango.h> |
49 | #include <pango/pango.h> |
50 | |
50 | |
|
|
51 | #ifndef PANGO_VERSION_CHECK |
|
|
52 | # define PANGO_VERSION_CHECK(a,b,c) 0 |
|
|
53 | #endif |
|
|
54 | |
|
|
55 | #if !PANGO_VERSION_CHECK (1, 15, 2) |
|
|
56 | # define pango_layout_get_line_readonly pango_layout_get_line |
|
|
57 | # define pango_layout_get_lines_readonly pango_layout_get_lines |
|
|
58 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line |
|
|
59 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run |
|
|
60 | #endif |
|
|
61 | |
51 | #ifndef _WIN32 |
62 | #ifndef _WIN32 |
52 | # include <sys/types.h> |
63 | # include <sys/types.h> |
53 | # include <sys/socket.h> |
64 | # include <sys/socket.h> |
54 | # include <netinet/in.h> |
65 | # include <netinet/in.h> |
55 | # include <netinet/tcp.h> |
66 | # include <netinet/tcp.h> |
56 | # include <inttypes.h> |
67 | # include <inttypes.h> |
57 | #endif |
68 | #endif |
58 | |
69 | |
|
|
70 | #if __GNUC__ >= 4 |
|
|
71 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
|
|
72 | #else |
|
|
73 | # define expect(expr,value) (expr) |
|
|
74 | #endif |
|
|
75 | |
|
|
76 | #define expect_false(expr) expect ((expr) != 0, 0) |
|
|
77 | #define expect_true(expr) expect ((expr) != 0, 1) |
|
|
78 | |
59 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
79 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
60 | |
80 | |
61 | #define FOW_DARKNESS 32 |
81 | #define FOW_DARKNESS 32 |
62 | |
82 | |
63 | #define MAP_EXTEND_X 32 |
83 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
84 | #define MAP_EXTEND_Y 512 |
65 | |
85 | |
66 | #define MIN_FONT_HEIGHT 10 |
86 | #define MIN_FONT_HEIGHT 10 |
67 | |
87 | |
68 | #if 0 |
88 | /* mask out modifiers we are not interested in */ |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
89 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
70 | #else |
|
|
71 | # define PARACHUTE 0 |
|
|
72 | #endif |
|
|
73 | |
90 | |
74 | static AV *texture_av; |
91 | static AV *texture_av; |
75 | |
92 | |
76 | static struct |
93 | static struct |
77 | { |
94 | { |
… | |
… | |
120 | |
137 | |
121 | #include "pango-font.c" |
138 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
139 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
140 | #include "pango-render.c" |
124 | |
141 | |
125 | typedef IV CFPlus__Channel; |
142 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
143 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
144 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
145 | typedef Mix_Music *DC__MixMusic; |
129 | |
146 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
147 | typedef PangoFontDescription *DC__Font; |
131 | |
148 | |
132 | static int |
149 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
150 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
151 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
152 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
166 | |
150 | typedef struct cf_layout { |
167 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
168 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
169 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
170 | int base_height; |
154 | CFPlus__Font font; |
171 | DC__Font font; |
|
|
172 | rc_t *rc; |
155 | } *CFPlus__Layout; |
173 | } *DC__Layout; |
156 | |
174 | |
157 | static CFPlus__Font default_font; |
175 | static DC__Font default_font; |
158 | static PangoContext *opengl_context; |
176 | static PangoContext *opengl_context; |
159 | static PangoFontMap *opengl_fontmap; |
177 | static PangoFontMap *opengl_fontmap; |
160 | |
178 | |
161 | static void |
179 | static void |
162 | substitute_func (FcPattern *pattern, gpointer data) |
180 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
167 | #endif |
185 | #endif |
168 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
186 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
169 | } |
187 | } |
170 | |
188 | |
171 | static void |
189 | static void |
172 | layout_update_font (CFPlus__Layout self) |
190 | layout_update_font (DC__Layout self) |
173 | { |
191 | { |
174 | /* use a random scale factor to account for unknown descenders, 0.8 works |
192 | /* use a random scale factor to account for unknown descenders, 0.8 works |
175 | * reasonably well with bitstream vera |
193 | * reasonably well with dejavu/bistream fonts |
176 | */ |
194 | */ |
177 | PangoFontDescription *font = self->font ? self->font : default_font; |
195 | PangoFontDescription *font = self->font ? self->font : default_font; |
178 | |
196 | |
179 | pango_font_description_set_absolute_size (font, |
197 | pango_font_description_set_absolute_size (font, |
180 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
198 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
181 | |
199 | |
182 | pango_layout_set_font_description (self->pl, font); |
200 | pango_layout_set_font_description (self->pl, font); |
183 | } |
201 | } |
184 | |
202 | |
185 | static void |
203 | static void |
186 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
204 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
187 | { |
205 | { |
188 | PangoRectangle rect; |
206 | PangoRectangle rect; |
189 | |
207 | |
190 | // get_pixel_* wrongly rounds down |
208 | // get_pixel_* wrongly rounds down |
191 | pango_layout_get_extents (self->pl, 0, &rect); |
209 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
202 | |
220 | |
203 | typedef uint16_t tileid; |
221 | typedef uint16_t tileid; |
204 | typedef uint16_t faceid; |
222 | typedef uint16_t faceid; |
205 | |
223 | |
206 | typedef struct { |
224 | typedef struct { |
207 | int name; |
225 | GLuint name; |
208 | int w, h; |
226 | int w, h; |
209 | float s, t; |
227 | float s, t; |
210 | uint8_t r, g, b, a; |
228 | uint8_t r, g, b, a; |
211 | tileid smoothtile; |
229 | tileid smoothtile; |
212 | uint8_t smoothlevel; |
230 | uint8_t smoothlevel; |
… | |
… | |
230 | int faces; tileid *face2tile; // [faceid] |
248 | int faces; tileid *face2tile; // [faceid] |
231 | int texs; maptex *tex; // [tileid] |
249 | int texs; maptex *tex; // [tileid] |
232 | |
250 | |
233 | int32_t rows; |
251 | int32_t rows; |
234 | maprow *row; |
252 | maprow *row; |
235 | } *CFPlus__Map; |
253 | } *DC__Map; |
236 | |
254 | |
237 | static char * |
255 | static char * |
238 | prepend (char *ptr, int sze, int inc) |
256 | prepend (char *ptr, int sze, int inc) |
239 | { |
257 | { |
240 | char *p; |
258 | char *p; |
… | |
… | |
278 | self->texs *= 2; |
296 | self->texs *= 2; |
279 | } |
297 | } |
280 | } |
298 | } |
281 | |
299 | |
282 | static maprow * |
300 | static maprow * |
283 | map_get_row (CFPlus__Map self, int y) |
301 | map_get_row (DC__Map self, int y) |
284 | { |
302 | { |
285 | if (0 > y) |
303 | if (0 > y) |
286 | { |
304 | { |
287 | int extend = - y + MAP_EXTEND_Y; |
305 | int extend = - y + MAP_EXTEND_Y; |
288 | Prepend (maprow, self->row, self->rows, extend); |
306 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
326 | |
344 | |
327 | return row->col + (x - row->c0); |
345 | return row->col + (x - row->c0); |
328 | } |
346 | } |
329 | |
347 | |
330 | static mapcell * |
348 | static mapcell * |
331 | map_get_cell (CFPlus__Map self, int x, int y) |
349 | map_get_cell (DC__Map self, int x, int y) |
332 | { |
350 | { |
333 | return row_get_cell (map_get_row (self, y), x); |
351 | return row_get_cell (map_get_row (self, y), x); |
334 | } |
352 | } |
335 | |
353 | |
336 | static void |
354 | static void |
337 | map_clear (CFPlus__Map self) |
355 | map_clear (DC__Map self) |
338 | { |
356 | { |
339 | int r; |
357 | int r; |
340 | |
358 | |
341 | for (r = 0; r < self->rows; r++) |
359 | for (r = 0; r < self->rows; r++) |
342 | Safefree (self->row[r].col); |
360 | Safefree (self->row[r].col); |
… | |
… | |
349 | self->oy = 0; |
367 | self->oy = 0; |
350 | self->row = 0; |
368 | self->row = 0; |
351 | self->rows = 0; |
369 | self->rows = 0; |
352 | } |
370 | } |
353 | |
371 | |
|
|
372 | #define CELL_CLEAR(cell) \ |
|
|
373 | do { \ |
|
|
374 | if ((cell)->player) \ |
|
|
375 | (cell)->tile [2] = 0; \ |
|
|
376 | (cell)->darkness = 0; \ |
|
|
377 | (cell)->stat_hp = 0; \ |
|
|
378 | (cell)->flags = 0; \ |
|
|
379 | (cell)->player = 0; \ |
|
|
380 | } while (0) |
|
|
381 | |
354 | static void |
382 | static void |
355 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
383 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
356 | { |
384 | { |
357 | int x, y; |
385 | int x, y; |
358 | maprow *row; |
386 | maprow *row; |
359 | mapcell *cell; |
387 | mapcell *cell; |
360 | |
388 | |
… | |
… | |
372 | if (x >= row->c1) |
400 | if (x >= row->c1) |
373 | break; |
401 | break; |
374 | |
402 | |
375 | cell = row->col + x - row->c0; |
403 | cell = row->col + x - row->c0; |
376 | |
404 | |
377 | cell->darkness = 0; |
405 | CELL_CLEAR (cell); |
378 | cell->stat_hp = 0; |
|
|
379 | cell->flags = 0; |
|
|
380 | cell->player = 0; |
|
|
381 | } |
406 | } |
382 | } |
407 | } |
383 | } |
408 | } |
384 | |
409 | |
385 | typedef struct { |
410 | typedef struct { |
… | |
… | |
439 | n |= n >> 16; |
464 | n |= n >> 16; |
440 | |
465 | |
441 | return n + 1; |
466 | return n + 1; |
442 | } |
467 | } |
443 | |
468 | |
|
|
469 | static unsigned int |
|
|
470 | popcount (unsigned int n) |
|
|
471 | { |
|
|
472 | n -= (n >> 1) & 0x55555555U; |
|
|
473 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
474 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
475 | n *= 0x01010101U; |
|
|
476 | |
|
|
477 | return n >> 24; |
|
|
478 | } |
|
|
479 | |
444 | /* SDL should provide this, really. */ |
480 | /* SDL should provide this, really. */ |
445 | #define SDLK_MODIFIER_MIN 300 |
481 | #define SDLK_MODIFIER_MIN 300 |
446 | #define SDLK_MODIFIER_MAX 314 |
482 | #define SDLK_MODIFIER_MAX 314 |
447 | |
483 | |
448 | /******************************************************************************/ |
484 | /******************************************************************************/ |
… | |
… | |
486 | return 0; |
522 | return 0; |
487 | |
523 | |
488 | return 1; |
524 | return 1; |
489 | } |
525 | } |
490 | |
526 | |
491 | MODULE = CFPlus PACKAGE = CFPlus |
527 | MODULE = Deliantra::Client PACKAGE = DC |
492 | |
528 | |
493 | PROTOTYPES: ENABLE |
529 | PROTOTYPES: ENABLE |
494 | |
530 | |
495 | BOOT: |
531 | BOOT: |
496 | { |
532 | { |
497 | HV *stash = gv_stashpv ("CFPlus", 1); |
533 | HV *stash = gv_stashpv ("DC", 1); |
498 | static const struct { |
534 | static const struct { |
499 | const char *name; |
535 | const char *name; |
500 | IV iv; |
536 | IV iv; |
501 | } *civ, const_iv[] = { |
537 | } *civ, const_iv[] = { |
502 | # define const_iv(name) { # name, (IV)name } |
538 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
524 | |
560 | |
525 | const_iv (SDL_APPINPUTFOCUS), |
561 | const_iv (SDL_APPINPUTFOCUS), |
526 | const_iv (SDL_APPMOUSEFOCUS), |
562 | const_iv (SDL_APPMOUSEFOCUS), |
527 | const_iv (SDL_APPACTIVE), |
563 | const_iv (SDL_APPACTIVE), |
528 | |
564 | |
|
|
565 | const_iv (SDLK_FIRST), |
|
|
566 | const_iv (SDLK_LAST), |
529 | const_iv (SDLK_KP0), |
567 | const_iv (SDLK_KP0), |
530 | const_iv (SDLK_KP1), |
568 | const_iv (SDLK_KP1), |
531 | const_iv (SDLK_KP2), |
569 | const_iv (SDLK_KP2), |
532 | const_iv (SDLK_KP3), |
570 | const_iv (SDLK_KP3), |
533 | const_iv (SDLK_KP4), |
571 | const_iv (SDLK_KP4), |
… | |
… | |
605 | const_iv (KMOD_LMETA), |
643 | const_iv (KMOD_LMETA), |
606 | const_iv (KMOD_RMETA), |
644 | const_iv (KMOD_RMETA), |
607 | const_iv (KMOD_NUM), |
645 | const_iv (KMOD_NUM), |
608 | const_iv (KMOD_CAPS), |
646 | const_iv (KMOD_CAPS), |
609 | const_iv (KMOD_MODE), |
647 | const_iv (KMOD_MODE), |
|
|
648 | |
|
|
649 | const_iv (MIX_DEFAULT_FORMAT), |
|
|
650 | |
|
|
651 | const_iv (SDL_INIT_TIMER), |
|
|
652 | const_iv (SDL_INIT_AUDIO), |
|
|
653 | const_iv (SDL_INIT_VIDEO), |
|
|
654 | const_iv (SDL_INIT_CDROM), |
|
|
655 | const_iv (SDL_INIT_JOYSTICK), |
|
|
656 | const_iv (SDL_INIT_EVERYTHING), |
|
|
657 | const_iv (SDL_INIT_NOPARACHUTE), |
|
|
658 | const_iv (SDL_INIT_EVENTTHREAD), |
|
|
659 | |
|
|
660 | const_iv (SDL_GL_RED_SIZE), |
|
|
661 | const_iv (SDL_GL_GREEN_SIZE), |
|
|
662 | const_iv (SDL_GL_BLUE_SIZE), |
|
|
663 | const_iv (SDL_GL_ALPHA_SIZE), |
|
|
664 | const_iv (SDL_GL_DOUBLEBUFFER), |
|
|
665 | const_iv (SDL_GL_BUFFER_SIZE), |
|
|
666 | const_iv (SDL_GL_DEPTH_SIZE), |
|
|
667 | const_iv (SDL_GL_STENCIL_SIZE), |
|
|
668 | const_iv (SDL_GL_ACCUM_RED_SIZE), |
|
|
669 | const_iv (SDL_GL_ACCUM_GREEN_SIZE), |
|
|
670 | const_iv (SDL_GL_ACCUM_BLUE_SIZE), |
|
|
671 | const_iv (SDL_GL_ACCUM_ALPHA_SIZE), |
|
|
672 | const_iv (SDL_GL_STEREO), |
|
|
673 | const_iv (SDL_GL_MULTISAMPLEBUFFERS), |
|
|
674 | const_iv (SDL_GL_MULTISAMPLESAMPLES), |
|
|
675 | const_iv (SDL_GL_ACCELERATED_VISUAL), |
|
|
676 | const_iv (SDL_GL_SWAP_CONTROL) |
610 | # undef const_iv |
677 | # undef const_iv |
611 | }; |
678 | }; |
612 | |
679 | |
613 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
680 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
614 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
681 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
632 | |
699 | |
633 | NV floor (NV x) |
700 | NV floor (NV x) |
634 | |
701 | |
635 | NV ceil (NV x) |
702 | NV ceil (NV x) |
636 | |
703 | |
|
|
704 | IV minpot (UV n) |
|
|
705 | |
|
|
706 | IV popcount (UV n) |
|
|
707 | |
637 | void |
708 | void |
638 | pango_init () |
709 | pango_init () |
639 | CODE: |
710 | CODE: |
640 | { |
711 | { |
641 | opengl_fontmap = pango_opengl_font_map_new (); |
712 | opengl_fontmap = pango_opengl_font_map_new (); |
642 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
713 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
643 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
714 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
715 | /*pango_context_set_font_description (opengl_context, default_font);*/ |
|
|
716 | #if PANGO_VERSION_CHECK (1, 15, 2) |
|
|
717 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
718 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
719 | #endif |
644 | } |
720 | } |
645 | |
721 | |
646 | char * |
|
|
647 | SDL_GetError () |
722 | char *SDL_GetError () |
648 | |
723 | |
649 | int |
724 | int SDL_Init (U32 flags) |
650 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
|
|
651 | |
725 | |
652 | void |
726 | int SDL_InitSubSystem (U32 flags) |
|
|
727 | |
|
|
728 | void SDL_QuitSubSystem (U32 flags) |
|
|
729 | |
653 | SDL_Quit () |
730 | void SDL_Quit () |
|
|
731 | |
|
|
732 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
733 | |
|
|
734 | int SDL_GL_GetAttribute (int attr) |
|
|
735 | CODE: |
|
|
736 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
737 | XSRETURN_UNDEF; |
|
|
738 | OUTPUT: |
|
|
739 | RETVAL |
654 | |
740 | |
655 | void |
741 | void |
656 | SDL_ListModes (int rgb, int alpha) |
742 | SDL_ListModes (int rgb, int alpha) |
657 | PPCODE: |
743 | PPCODE: |
658 | { |
744 | { |
… | |
… | |
670 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
756 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
671 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
757 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
672 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
758 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
673 | |
759 | |
674 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
760 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
675 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
676 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
677 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
761 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
678 | #endif |
|
|
679 | |
762 | |
680 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
763 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
681 | |
764 | |
682 | if (m && m != (SDL_Rect **)-1) |
765 | if (m && m != (SDL_Rect **)-1) |
683 | while (*m) |
766 | while (*m) |
684 | { |
767 | { |
685 | if ((*m)->w >= 640 && (*m)->h >= 480) |
768 | if ((*m)->w >= 400 && (*m)->h >= 300) |
686 | { |
769 | { |
687 | AV *av = newAV (); |
770 | AV *av = newAV (); |
688 | av_push (av, newSViv ((*m)->w)); |
771 | av_push (av, newSViv ((*m)->w)); |
689 | av_push (av, newSViv ((*m)->h)); |
772 | av_push (av, newSViv ((*m)->h)); |
690 | av_push (av, newSViv (rgb)); |
773 | av_push (av, newSViv (rgb)); |
… | |
… | |
714 | |
797 | |
715 | if (RETVAL) |
798 | if (RETVAL) |
716 | { |
799 | { |
717 | av_clear (texture_av); |
800 | av_clear (texture_av); |
718 | |
801 | |
719 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
802 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
720 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
803 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
721 | #include "glfunc.h" |
804 | #include "glfunc.h" |
722 | #undef GL_FUNC |
805 | #undef GL_FUNC |
723 | } |
806 | } |
724 | } |
807 | } |
… | |
… | |
731 | char * |
814 | char * |
732 | SDL_GetKeyName (int sym) |
815 | SDL_GetKeyName (int sym) |
733 | |
816 | |
734 | int |
817 | int |
735 | SDL_GetAppState () |
818 | SDL_GetAppState () |
|
|
819 | |
|
|
820 | int |
|
|
821 | SDL_GetModState () |
736 | |
822 | |
737 | void |
823 | void |
738 | poll_events () |
824 | poll_events () |
739 | PPCODE: |
825 | PPCODE: |
740 | { |
826 | { |
… | |
… | |
750 | { |
836 | { |
751 | case SDL_KEYDOWN: |
837 | case SDL_KEYDOWN: |
752 | case SDL_KEYUP: |
838 | case SDL_KEYUP: |
753 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
839 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
754 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
840 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
755 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
841 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); |
756 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ |
842 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ |
757 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
843 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
758 | break; |
844 | break; |
759 | |
845 | |
760 | case SDL_ACTIVEEVENT: |
846 | case SDL_ACTIVEEVENT: |
761 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
847 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
779 | x = ev.motion.x; |
865 | x = ev.motion.x; |
780 | y = ev.motion.y; |
866 | y = ev.motion.y; |
781 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
867 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
782 | } |
868 | } |
783 | |
869 | |
784 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
870 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
785 | hv_store (hv, "state", 5, newSViv (state), 0); |
871 | hv_store (hv, "state", 5, newSViv (state), 0); |
786 | hv_store (hv, "x", 1, newSViv (x), 0); |
872 | hv_store (hv, "x", 1, newSViv (x), 0); |
787 | hv_store (hv, "y", 1, newSViv (y), 0); |
873 | hv_store (hv, "y", 1, newSViv (y), 0); |
788 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
874 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
789 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
875 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
790 | } |
876 | } |
791 | break; |
877 | break; |
792 | |
878 | |
793 | case SDL_MOUSEBUTTONDOWN: |
879 | case SDL_MOUSEBUTTONDOWN: |
794 | case SDL_MOUSEBUTTONUP: |
880 | case SDL_MOUSEBUTTONUP: |
795 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
881 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
796 | |
882 | |
797 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
883 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
798 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
884 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
799 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
885 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
800 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
886 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
805 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
891 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
806 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
892 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
807 | break; |
893 | break; |
808 | } |
894 | } |
809 | |
895 | |
810 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
896 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
811 | } |
897 | } |
812 | } |
898 | } |
813 | |
899 | |
814 | int |
900 | int |
815 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
901 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
816 | POSTCALL: |
902 | POSTCALL: |
817 | Mix_HookMusicFinished (music_finished); |
903 | Mix_HookMusicFinished (music_finished); |
818 | Mix_ChannelFinished (channel_finished); |
904 | Mix_ChannelFinished (channel_finished); |
|
|
905 | |
|
|
906 | void |
|
|
907 | Mix_QuerySpec () |
|
|
908 | PPCODE: |
|
|
909 | { |
|
|
910 | int freq, channels; |
|
|
911 | Uint16 format; |
|
|
912 | |
|
|
913 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
914 | { |
|
|
915 | EXTEND (SP, 3); |
|
|
916 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
917 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
918 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
919 | } |
|
|
920 | } |
819 | |
921 | |
820 | void |
922 | void |
821 | Mix_CloseAudio () |
923 | Mix_CloseAudio () |
822 | |
924 | |
823 | int |
925 | int |
… | |
… | |
858 | } |
960 | } |
859 | } |
961 | } |
860 | #endif |
962 | #endif |
861 | } |
963 | } |
862 | |
964 | |
863 | void |
965 | int |
864 | add_font (char *file) |
966 | add_font (char *file) |
865 | CODE: |
967 | CODE: |
866 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
968 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
|
|
969 | OUTPUT: |
|
|
970 | RETVAL |
867 | |
971 | |
868 | void |
972 | void |
869 | load_image_inline (SV *image_) |
973 | load_image_inline (SV *image_) |
870 | ALIAS: |
974 | ALIAS: |
871 | load_image_file = 1 |
975 | load_image_file = 1 |
… | |
… | |
957 | void |
1061 | void |
958 | error (char *message) |
1062 | error (char *message) |
959 | CODE: |
1063 | CODE: |
960 | fprintf (stderr, "ERROR: %s\n", message); |
1064 | fprintf (stderr, "ERROR: %s\n", message); |
961 | #ifdef _WIN32 |
1065 | #ifdef _WIN32 |
962 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1066 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
963 | #endif |
1067 | #endif |
964 | |
1068 | |
965 | void |
1069 | void |
966 | fatal (char *message) |
1070 | fatal (char *message) |
967 | CODE: |
1071 | CODE: |
968 | fprintf (stderr, "FATAL: %s\n", message); |
1072 | fprintf (stderr, "FATAL: %s\n", message); |
969 | #ifdef _WIN32 |
1073 | #ifdef _WIN32 |
970 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1074 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
971 | #endif |
1075 | #endif |
972 | _exit (1); |
1076 | _exit (1); |
973 | |
1077 | |
974 | void |
1078 | void |
975 | _exit (int retval = 0) |
1079 | _exit (int retval = 0) |
… | |
… | |
987 | #if DEBUG |
1091 | #if DEBUG |
988 | VALGRIND_DO_LEAK_CHECK; |
1092 | VALGRIND_DO_LEAK_CHECK; |
989 | #endif |
1093 | #endif |
990 | } |
1094 | } |
991 | |
1095 | |
992 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1096 | MODULE = Deliantra::Client PACKAGE = DC::Font |
993 | |
1097 | |
994 | PROTOTYPES: DISABLE |
1098 | PROTOTYPES: DISABLE |
995 | |
1099 | |
996 | CFPlus::Font |
1100 | DC::Font |
997 | new_from_file (SV *class, char *path, int id = 0) |
1101 | new_from_file (SV *class, char *path, int id = 0) |
998 | CODE: |
1102 | CODE: |
999 | { |
1103 | { |
1000 | int count; |
1104 | int count; |
1001 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1105 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1004 | } |
1108 | } |
1005 | OUTPUT: |
1109 | OUTPUT: |
1006 | RETVAL |
1110 | RETVAL |
1007 | |
1111 | |
1008 | void |
1112 | void |
1009 | DESTROY (CFPlus::Font self) |
1113 | DESTROY (DC::Font self) |
1010 | CODE: |
1114 | CODE: |
1011 | pango_font_description_free (self); |
1115 | pango_font_description_free (self); |
1012 | |
1116 | |
1013 | void |
1117 | void |
1014 | make_default (CFPlus::Font self) |
1118 | make_default (DC::Font self) |
1015 | PROTOTYPE: $ |
1119 | PROTOTYPE: $ |
1016 | CODE: |
1120 | CODE: |
1017 | default_font = self; |
1121 | default_font = self; |
1018 | |
1122 | |
1019 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1123 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1020 | |
1124 | |
1021 | PROTOTYPES: DISABLE |
1125 | PROTOTYPES: DISABLE |
1022 | |
1126 | |
1023 | void |
1127 | void |
1024 | reset_glyph_cache () |
1128 | glyph_cache_backup () |
1025 | PROTOTYPE: |
1129 | PROTOTYPE: |
1026 | CODE: |
1130 | CODE: |
|
|
1131 | tc_backup (); |
|
|
1132 | |
|
|
1133 | void |
|
|
1134 | glyph_cache_restore () |
|
|
1135 | PROTOTYPE: |
|
|
1136 | CODE: |
1027 | tc_clear (); |
1137 | tc_restore (); |
1028 | |
1138 | |
1029 | CFPlus::Layout |
1139 | DC::Layout |
1030 | new (SV *class) |
1140 | new (SV *class) |
1031 | CODE: |
1141 | CODE: |
1032 | New (0, RETVAL, 1, struct cf_layout); |
1142 | New (0, RETVAL, 1, struct cf_layout); |
1033 | |
1143 | |
1034 | RETVAL->pl = pango_layout_new (opengl_context); |
1144 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1036 | RETVAL->g = 1.; |
1146 | RETVAL->g = 1.; |
1037 | RETVAL->b = 1.; |
1147 | RETVAL->b = 1.; |
1038 | RETVAL->a = 1.; |
1148 | RETVAL->a = 1.; |
1039 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1149 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1040 | RETVAL->font = 0; |
1150 | RETVAL->font = 0; |
|
|
1151 | RETVAL->rc = rc_alloc (); |
1041 | |
1152 | |
1042 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1153 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1043 | layout_update_font (RETVAL); |
1154 | layout_update_font (RETVAL); |
1044 | OUTPUT: |
1155 | OUTPUT: |
1045 | RETVAL |
1156 | RETVAL |
1046 | |
1157 | |
1047 | void |
1158 | void |
1048 | DESTROY (CFPlus::Layout self) |
1159 | DESTROY (DC::Layout self) |
1049 | CODE: |
1160 | CODE: |
1050 | g_object_unref (self->pl); |
1161 | g_object_unref (self->pl); |
|
|
1162 | rc_free (self->rc); |
1051 | Safefree (self); |
1163 | Safefree (self); |
1052 | |
1164 | |
1053 | void |
1165 | void |
1054 | set_text (CFPlus::Layout self, SV *text_) |
1166 | set_text (DC::Layout self, SV *text_) |
1055 | CODE: |
1167 | CODE: |
1056 | { |
1168 | { |
1057 | STRLEN textlen; |
1169 | STRLEN textlen; |
1058 | char *text = SvPVutf8 (text_, textlen); |
1170 | char *text = SvPVutf8 (text_, textlen); |
1059 | |
1171 | |
1060 | pango_layout_set_text (self->pl, text, textlen); |
1172 | pango_layout_set_text (self->pl, text, textlen); |
1061 | } |
1173 | } |
1062 | |
1174 | |
1063 | void |
1175 | void |
1064 | set_markup (CFPlus::Layout self, SV *text_) |
1176 | set_markup (DC::Layout self, SV *text_) |
1065 | CODE: |
1177 | CODE: |
1066 | { |
1178 | { |
1067 | STRLEN textlen; |
1179 | STRLEN textlen; |
1068 | char *text = SvPVutf8 (text_, textlen); |
1180 | char *text = SvPVutf8 (text_, textlen); |
1069 | |
1181 | |
1070 | pango_layout_set_markup (self->pl, text, textlen); |
1182 | pango_layout_set_markup (self->pl, text, textlen); |
1071 | } |
1183 | } |
1072 | |
1184 | |
1073 | void |
1185 | void |
1074 | set_shapes (CFPlus::Layout self, ...) |
1186 | set_shapes (DC::Layout self, ...) |
1075 | CODE: |
1187 | CODE: |
1076 | { |
1188 | { |
1077 | PangoAttrList *attrs = 0; |
1189 | PangoAttrList *attrs = 0; |
1078 | const char *text = pango_layout_get_text (self->pl); |
1190 | const char *text = pango_layout_get_text (self->pl); |
1079 | const char *pos = text; |
1191 | const char *pos = text; |
… | |
… | |
1114 | if (attrs) |
1226 | if (attrs) |
1115 | pango_layout_set_attributes (self->pl, attrs); |
1227 | pango_layout_set_attributes (self->pl, attrs); |
1116 | } |
1228 | } |
1117 | |
1229 | |
1118 | void |
1230 | void |
1119 | get_shapes (CFPlus::Layout self) |
1231 | get_shapes (DC::Layout self) |
1120 | PPCODE: |
1232 | PPCODE: |
1121 | { |
1233 | { |
1122 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1234 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1123 | |
1235 | |
1124 | do |
1236 | do |
1125 | { |
1237 | { |
1126 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1238 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1127 | |
1239 | |
1128 | if (run && shape_attr_p (run)) |
1240 | if (run && shape_attr_p (run)) |
1129 | { |
1241 | { |
1130 | PangoRectangle extents; |
1242 | PangoRectangle extents; |
1131 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1243 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1139 | |
1251 | |
1140 | pango_layout_iter_free (iter); |
1252 | pango_layout_iter_free (iter); |
1141 | } |
1253 | } |
1142 | |
1254 | |
1143 | int |
1255 | int |
1144 | has_wrapped (CFPlus::Layout self) |
1256 | has_wrapped (DC::Layout self) |
1145 | CODE: |
1257 | CODE: |
1146 | { |
1258 | { |
1147 | int lines = 1; |
1259 | int lines = 1; |
1148 | const char *text = pango_layout_get_text (self->pl); |
1260 | const char *text = pango_layout_get_text (self->pl); |
1149 | |
1261 | |
… | |
… | |
1154 | } |
1266 | } |
1155 | OUTPUT: |
1267 | OUTPUT: |
1156 | RETVAL |
1268 | RETVAL |
1157 | |
1269 | |
1158 | SV * |
1270 | SV * |
1159 | get_text (CFPlus::Layout self) |
1271 | get_text (DC::Layout self) |
1160 | CODE: |
1272 | CODE: |
1161 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1273 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1162 | sv_utf8_decode (RETVAL); |
1274 | sv_utf8_decode (RETVAL); |
1163 | OUTPUT: |
1275 | OUTPUT: |
1164 | RETVAL |
1276 | RETVAL |
1165 | |
1277 | |
1166 | void |
1278 | void |
1167 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1279 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1168 | CODE: |
1280 | CODE: |
1169 | self->r = r; |
1281 | self->r = r; |
1170 | self->g = g; |
1282 | self->g = g; |
1171 | self->b = b; |
1283 | self->b = b; |
1172 | self->a = a; |
1284 | self->a = a; |
1173 | |
1285 | |
1174 | void |
1286 | void |
1175 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1287 | set_font (DC::Layout self, DC::Font font = 0) |
1176 | CODE: |
1288 | CODE: |
1177 | if (self->font != font) |
1289 | if (self->font != font) |
1178 | { |
1290 | { |
1179 | self->font = font; |
1291 | self->font = font; |
1180 | layout_update_font (self); |
1292 | layout_update_font (self); |
1181 | } |
1293 | } |
1182 | |
1294 | |
1183 | void |
1295 | void |
1184 | set_height (CFPlus::Layout self, int base_height) |
1296 | set_height (DC::Layout self, int base_height) |
1185 | CODE: |
1297 | CODE: |
1186 | if (self->base_height != base_height) |
1298 | if (self->base_height != base_height) |
1187 | { |
1299 | { |
1188 | self->base_height = base_height; |
1300 | self->base_height = base_height; |
1189 | layout_update_font (self); |
1301 | layout_update_font (self); |
1190 | } |
1302 | } |
1191 | |
1303 | |
1192 | void |
1304 | void |
1193 | set_width (CFPlus::Layout self, int max_width = -1) |
1305 | set_width (DC::Layout self, int max_width = -1) |
1194 | CODE: |
1306 | CODE: |
1195 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1307 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1196 | |
1308 | |
1197 | void |
1309 | void |
1198 | set_indent (CFPlus::Layout self, int indent) |
1310 | set_indent (DC::Layout self, int indent) |
1199 | CODE: |
1311 | CODE: |
1200 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1312 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1201 | |
1313 | |
1202 | void |
1314 | void |
1203 | set_spacing (CFPlus::Layout self, int spacing) |
1315 | set_spacing (DC::Layout self, int spacing) |
1204 | CODE: |
1316 | CODE: |
1205 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1317 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1206 | |
1318 | |
1207 | void |
1319 | void |
1208 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1320 | set_ellipsise (DC::Layout self, int ellipsise) |
1209 | CODE: |
1321 | CODE: |
1210 | pango_layout_set_ellipsize (self->pl, |
1322 | pango_layout_set_ellipsize (self->pl, |
1211 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1323 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1212 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1324 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1213 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1325 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1214 | : PANGO_ELLIPSIZE_NONE |
1326 | : PANGO_ELLIPSIZE_NONE |
1215 | ); |
1327 | ); |
1216 | |
1328 | |
1217 | void |
1329 | void |
1218 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1330 | set_single_paragraph_mode (DC::Layout self, int spm) |
1219 | CODE: |
1331 | CODE: |
1220 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1332 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1221 | |
1333 | |
1222 | void |
1334 | void |
1223 | size (CFPlus::Layout self) |
1335 | size (DC::Layout self) |
1224 | PPCODE: |
1336 | PPCODE: |
1225 | { |
1337 | { |
1226 | int w, h; |
1338 | int w, h; |
1227 | |
1339 | |
1228 | layout_get_pixel_size (self, &w, &h); |
1340 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1231 | PUSHs (sv_2mortal (newSViv (w))); |
1343 | PUSHs (sv_2mortal (newSViv (w))); |
1232 | PUSHs (sv_2mortal (newSViv (h))); |
1344 | PUSHs (sv_2mortal (newSViv (h))); |
1233 | } |
1345 | } |
1234 | |
1346 | |
1235 | int |
1347 | int |
1236 | descent (CFPlus::Layout self) |
1348 | descent (DC::Layout self) |
1237 | CODE: |
1349 | CODE: |
1238 | { |
1350 | { |
1239 | PangoRectangle rect; |
1351 | PangoRectangle rect; |
1240 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1352 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1241 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1353 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1242 | RETVAL = PANGO_DESCENT (rect); |
1354 | RETVAL = PANGO_DESCENT (rect); |
1243 | } |
1355 | } |
1244 | OUTPUT: |
1356 | OUTPUT: |
1245 | RETVAL |
1357 | RETVAL |
1246 | |
1358 | |
1247 | int |
1359 | int |
1248 | xy_to_index (CFPlus::Layout self, int x, int y) |
1360 | xy_to_index (DC::Layout self, int x, int y) |
1249 | CODE: |
1361 | CODE: |
1250 | { |
1362 | { |
1251 | int index, trailing; |
1363 | int index, trailing; |
1252 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1364 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1253 | RETVAL = index + trailing; |
1365 | RETVAL = index + trailing; |
1254 | } |
1366 | } |
1255 | OUTPUT: |
1367 | OUTPUT: |
1256 | RETVAL |
1368 | RETVAL |
1257 | |
1369 | |
1258 | void |
1370 | void |
1259 | cursor_pos (CFPlus::Layout self, int index) |
1371 | cursor_pos (DC::Layout self, int index) |
1260 | PPCODE: |
1372 | PPCODE: |
1261 | { |
1373 | { |
1262 | PangoRectangle strong_pos; |
1374 | PangoRectangle pos; |
1263 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1375 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1264 | |
1376 | |
1265 | EXTEND (SP, 3); |
1377 | EXTEND (SP, 3); |
1266 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1378 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1267 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1379 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1268 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1380 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1269 | } |
1381 | } |
1270 | |
1382 | |
1271 | void |
1383 | void |
1272 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1384 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1273 | PPCODE: |
1385 | PPCODE: |
1274 | { |
1386 | { |
1275 | int line, x; |
1387 | int line, x; |
1276 | |
1388 | |
1277 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1389 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1390 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1278 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1391 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1279 | |
1392 | --line; |
|
|
1393 | #endif |
1280 | EXTEND (SP, 2); |
1394 | EXTEND (SP, 2); |
1281 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1395 | PUSHs (sv_2mortal (newSViv (line))); |
1282 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1396 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1283 | } |
1397 | } |
1284 | |
1398 | |
1285 | void |
1399 | void |
1286 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1400 | line_x_to_index (DC::Layout self, int line, int x) |
1287 | PPCODE: |
1401 | PPCODE: |
1288 | { |
1402 | { |
1289 | PangoLayoutLine *lp; |
1403 | PangoLayoutLine *lp; |
1290 | int index, trailing; |
1404 | int index, trailing; |
1291 | |
1405 | |
1292 | if (line < 0) |
1406 | if (line < 0) |
1293 | XSRETURN_EMPTY; |
1407 | XSRETURN_EMPTY; |
1294 | |
1408 | |
1295 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1409 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1296 | XSRETURN_EMPTY; /* do better */ |
1410 | XSRETURN_EMPTY; /* do better */ |
1297 | |
1411 | |
1298 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1412 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1299 | |
1413 | |
1300 | EXTEND (SP, 2); |
1414 | EXTEND (SP, 2); |
… | |
… | |
1306 | PUSHs (sv_2mortal (newSViv (trailing))); |
1420 | PUSHs (sv_2mortal (newSViv (trailing))); |
1307 | } |
1421 | } |
1308 | } |
1422 | } |
1309 | |
1423 | |
1310 | void |
1424 | void |
1311 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1425 | render (DC::Layout self, float x, float y, int flags = 0) |
1312 | PPCODE: |
1426 | CODE: |
|
|
1427 | rc_clear (self->rc); |
1313 | pango_opengl_render_layout_subpixel ( |
1428 | pango_opengl_render_layout_subpixel ( |
1314 | self->pl, |
1429 | self->pl, |
|
|
1430 | self->rc, |
1315 | x * PANGO_SCALE, y * PANGO_SCALE, |
1431 | x * PANGO_SCALE, y * PANGO_SCALE, |
1316 | self->r, self->g, self->b, self->a, |
1432 | self->r, self->g, self->b, self->a, |
1317 | flags |
1433 | flags |
1318 | ); |
1434 | ); |
|
|
1435 | // we assume that context_change actually clears/frees stuff |
|
|
1436 | // and does not do any recomputation... |
|
|
1437 | pango_layout_context_changed (self->pl); |
1319 | |
1438 | |
1320 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1439 | void |
|
|
1440 | draw (DC::Layout self) |
|
|
1441 | CODE: |
|
|
1442 | { |
|
|
1443 | glEnable (GL_TEXTURE_2D); |
|
|
1444 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1445 | glEnable (GL_BLEND); |
|
|
1446 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
|
|
1447 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
|
|
1448 | glEnable (GL_ALPHA_TEST); |
|
|
1449 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
|
|
1450 | |
|
|
1451 | rc_draw (self->rc); |
|
|
1452 | |
|
|
1453 | glDisable (GL_ALPHA_TEST); |
|
|
1454 | glDisable (GL_BLEND); |
|
|
1455 | glDisable (GL_TEXTURE_2D); |
|
|
1456 | } |
|
|
1457 | |
|
|
1458 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1321 | |
1459 | |
1322 | PROTOTYPES: ENABLE |
1460 | PROTOTYPES: ENABLE |
1323 | |
|
|
1324 | int minpot (int n) |
|
|
1325 | |
1461 | |
1326 | void |
1462 | void |
1327 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1463 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1328 | CODE: |
1464 | CODE: |
1329 | { |
1465 | { |
… | |
… | |
1406 | RETVAL = width > 0; |
1542 | RETVAL = width > 0; |
1407 | } |
1543 | } |
1408 | OUTPUT: |
1544 | OUTPUT: |
1409 | RETVAL |
1545 | RETVAL |
1410 | |
1546 | |
1411 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1547 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1412 | |
1548 | |
1413 | PROTOTYPES: DISABLE |
1549 | PROTOTYPES: DISABLE |
1414 | |
1550 | |
1415 | CFPlus::Map |
1551 | DC::Map |
1416 | new (SV *class) |
1552 | new (SV *class) |
1417 | CODE: |
1553 | CODE: |
1418 | New (0, RETVAL, 1, struct map); |
1554 | New (0, RETVAL, 1, struct map); |
1419 | RETVAL->x = 0; |
1555 | RETVAL->x = 0; |
1420 | RETVAL->y = 0; |
1556 | RETVAL->y = 0; |
… | |
… | |
1428 | RETVAL->row = 0; |
1564 | RETVAL->row = 0; |
1429 | OUTPUT: |
1565 | OUTPUT: |
1430 | RETVAL |
1566 | RETVAL |
1431 | |
1567 | |
1432 | void |
1568 | void |
1433 | DESTROY (CFPlus::Map self) |
1569 | DESTROY (DC::Map self) |
1434 | CODE: |
1570 | CODE: |
1435 | { |
1571 | { |
1436 | map_clear (self); |
1572 | map_clear (self); |
1437 | Safefree (self->face2tile); |
1573 | Safefree (self->face2tile); |
1438 | Safefree (self->tex); |
1574 | Safefree (self->tex); |
1439 | Safefree (self); |
1575 | Safefree (self); |
1440 | } |
1576 | } |
1441 | |
1577 | |
1442 | void |
1578 | void |
1443 | resize (CFPlus::Map self, int map_width, int map_height) |
1579 | resize (DC::Map self, int map_width, int map_height) |
1444 | CODE: |
1580 | CODE: |
1445 | self->w = map_width; |
1581 | self->w = map_width; |
1446 | self->h = map_height; |
1582 | self->h = map_height; |
1447 | |
1583 | |
1448 | void |
1584 | void |
1449 | clear (CFPlus::Map self) |
1585 | clear (DC::Map self) |
1450 | CODE: |
1586 | CODE: |
1451 | map_clear (self); |
1587 | map_clear (self); |
1452 | |
1588 | |
1453 | void |
1589 | void |
1454 | set_tileid (CFPlus::Map self, int face, int tile) |
1590 | set_tileid (DC::Map self, int face, int tile) |
1455 | CODE: |
1591 | CODE: |
1456 | { |
1592 | { |
1457 | need_facenum (self, face); self->face2tile [face] = tile; |
1593 | need_facenum (self, face); self->face2tile [face] = tile; |
1458 | need_texid (self, tile); |
1594 | need_texid (self, tile); |
1459 | } |
1595 | } |
1460 | |
1596 | |
1461 | void |
1597 | void |
1462 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1598 | set_smooth (DC::Map self, int face, int smooth, int level) |
1463 | CODE: |
1599 | CODE: |
1464 | { |
1600 | { |
1465 | tileid texid; |
1601 | tileid texid; |
1466 | maptex *tex; |
1602 | maptex *tex; |
1467 | |
1603 | |
… | |
… | |
1480 | tex->smoothtile = self->face2tile [smooth]; |
1616 | tex->smoothtile = self->face2tile [smooth]; |
1481 | tex->smoothlevel = level; |
1617 | tex->smoothlevel = level; |
1482 | } |
1618 | } |
1483 | |
1619 | |
1484 | void |
1620 | void |
1485 | 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) |
1621 | 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) |
1486 | CODE: |
1622 | CODE: |
1487 | { |
1623 | { |
1488 | need_texid (self, texid); |
1624 | need_texid (self, texid); |
1489 | |
1625 | |
1490 | { |
1626 | { |
… | |
… | |
1510 | // from transparent color bleeding and ugly wrapping effects. |
1646 | // from transparent color bleeding and ugly wrapping effects. |
1511 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1647 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1512 | } |
1648 | } |
1513 | |
1649 | |
1514 | int |
1650 | int |
1515 | ox (CFPlus::Map self) |
1651 | ox (DC::Map self) |
1516 | ALIAS: |
1652 | ALIAS: |
1517 | oy = 1 |
1653 | oy = 1 |
1518 | x = 2 |
1654 | x = 2 |
1519 | y = 3 |
1655 | y = 3 |
1520 | w = 4 |
1656 | w = 4 |
… | |
… | |
1531 | } |
1667 | } |
1532 | OUTPUT: |
1668 | OUTPUT: |
1533 | RETVAL |
1669 | RETVAL |
1534 | |
1670 | |
1535 | void |
1671 | void |
1536 | scroll (CFPlus::Map self, int dx, int dy) |
1672 | scroll (DC::Map self, int dx, int dy) |
1537 | CODE: |
1673 | CODE: |
1538 | { |
1674 | { |
1539 | if (dx > 0) |
1675 | if (dx > 0) |
1540 | map_blank (self, self->x, self->y, dx, self->h); |
1676 | map_blank (self, self->x, self->y, dx, self->h); |
1541 | else if (dx < 0) |
1677 | else if (dx < 0) |
… | |
… | |
1557 | self->y += MAP_EXTEND_Y; |
1693 | self->y += MAP_EXTEND_Y; |
1558 | } |
1694 | } |
1559 | } |
1695 | } |
1560 | |
1696 | |
1561 | SV * |
1697 | SV * |
1562 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1698 | map1a_update (DC::Map self, SV *data_, int extmap) |
1563 | CODE: |
1699 | CODE: |
1564 | { |
1700 | { |
1565 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1701 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1566 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1702 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1567 | mapcell *cell; |
1703 | mapcell *cell; |
… | |
… | |
1595 | uint8_t ext, cmd; |
1731 | uint8_t ext, cmd; |
1596 | |
1732 | |
1597 | do |
1733 | do |
1598 | { |
1734 | { |
1599 | ext = *data++; |
1735 | ext = *data++; |
1600 | cmd = ext & 0x3f; |
1736 | cmd = ext & 0x7f; |
1601 | |
1737 | |
1602 | if (cmd < 4) |
1738 | if (cmd < 4) |
1603 | cell->darkness = 255 - ext * 64 + 1; |
1739 | cell->darkness = 255 - ext * 64 + 1; |
1604 | else if (cmd == 5) // health |
1740 | else if (cmd == 5) // health |
1605 | { |
1741 | { |
… | |
… | |
1608 | } |
1744 | } |
1609 | else if (cmd == 6) // monster width |
1745 | else if (cmd == 6) // monster width |
1610 | cell->stat_width = *data++ + 1; |
1746 | cell->stat_width = *data++ + 1; |
1611 | else if (cmd == 0x47) |
1747 | else if (cmd == 0x47) |
1612 | { |
1748 | { |
1613 | if (*data == 4) |
1749 | if (*data == 1) cell->player = data [1]; |
1614 | ; // decode player count |
1750 | else if (*data == 2) cell->player = data [2] + (data [1] << 8); |
|
|
1751 | else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); |
|
|
1752 | else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); |
1615 | |
1753 | |
1616 | data += *data + 1; |
1754 | data += *data + 1; |
1617 | } |
1755 | } |
1618 | else if (cmd == 8) // cell flags |
1756 | else if (cmd == 8) // cell flags |
1619 | cell->flags = *data++; |
1757 | cell->flags = *data++; |
… | |
… | |
1649 | } |
1787 | } |
1650 | } |
1788 | } |
1651 | } |
1789 | } |
1652 | } |
1790 | } |
1653 | else |
1791 | else |
1654 | cell->darkness = 0; |
1792 | CELL_CLEAR (cell); |
1655 | } |
1793 | } |
1656 | } |
1794 | } |
1657 | OUTPUT: |
1795 | OUTPUT: |
1658 | RETVAL |
1796 | RETVAL |
1659 | |
1797 | |
1660 | SV * |
1798 | SV * |
1661 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1799 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1662 | CODE: |
1800 | CODE: |
1663 | { |
1801 | { |
1664 | int x1, x; |
1802 | int x1, x; |
1665 | int y1, y; |
1803 | int y1, y; |
1666 | int z; |
1804 | int z; |
… | |
… | |
1711 | } |
1849 | } |
1712 | OUTPUT: |
1850 | OUTPUT: |
1713 | RETVAL |
1851 | RETVAL |
1714 | |
1852 | |
1715 | void |
1853 | void |
1716 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1854 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
1717 | CODE: |
1855 | CODE: |
1718 | { |
1856 | { |
1719 | int x, y, z; |
1857 | int x, y, z; |
1720 | |
1858 | |
1721 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1859 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1722 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1860 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1723 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1861 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1724 | smooth_key skey; |
1862 | smooth_key skey; |
1725 | |
1863 | int pl_x, pl_y; |
|
|
1864 | maptex pl_tex; |
1726 | rc_t *rc = rc_alloc (); |
1865 | rc_t *rc = rc_alloc (); |
1727 | rc_key_t key; |
1866 | rc_key_t key; |
1728 | rc_array_t *arr; |
1867 | rc_array_t *arr; |
|
|
1868 | |
|
|
1869 | pl_tex.name = 0; |
1729 | |
1870 | |
1730 | // thats current max. sorry. |
1871 | // thats current max. sorry. |
1731 | if (sw > 255) sw = 255; |
1872 | if (sw > 255) sw = 255; |
1732 | if (sh > 255) sh = 255; |
1873 | if (sh > 255) sh = 255; |
1733 | |
1874 | |
… | |
… | |
1788 | tileid tile = cell->tile [z]; |
1929 | tileid tile = cell->tile [z]; |
1789 | |
1930 | |
1790 | if (tile) |
1931 | if (tile) |
1791 | { |
1932 | { |
1792 | maptex tex = self->tex [tile]; |
1933 | maptex tex = self->tex [tile]; |
1793 | int px, py; |
1934 | int px = (x + 1) * T - tex.w; |
|
|
1935 | int py = (y + 1) * T - tex.h; |
1794 | |
1936 | |
1795 | // suppressing texture state switches here |
|
|
1796 | // is only moderately effective, but worth the extra effort |
|
|
1797 | if (key.texname != tex.name) |
1937 | if (key.texname != tex.name) |
1798 | { |
1938 | { |
1799 | if (!tex.name) |
1939 | if (!tex.name) |
1800 | tex = self->tex [2]; /* missing, replace by noface */ |
1940 | tex = self->tex [2]; /* missing, replace by noface */ |
1801 | |
1941 | |
1802 | key.texname = tex.name; |
1942 | key.texname = tex.name; |
1803 | arr = rc_array (rc, &key); |
1943 | arr = rc_array (rc, &key); |
1804 | } |
1944 | } |
1805 | |
1945 | |
1806 | px = (x + 1) * T - tex.w; |
1946 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
1807 | py = (y + 1) * T - tex.h; |
1947 | { |
|
|
1948 | pl_x = px; |
|
|
1949 | pl_y = py; |
|
|
1950 | pl_tex = tex; |
|
|
1951 | continue; |
|
|
1952 | } |
1808 | |
1953 | |
1809 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1954 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1810 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1955 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1811 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1956 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1812 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1957 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1813 | |
1958 | |
1814 | if (cell->flags && z == 2) |
1959 | if (expect_false (cell->flags) && expect_false (z == 2)) |
1815 | { |
1960 | { |
1816 | // overlays such as the speech bubble, probably more to come |
1961 | // overlays such as the speech bubble, probably more to come |
1817 | if (cell->flags & 1) |
1962 | if (cell->flags & 1) |
1818 | { |
1963 | { |
1819 | maptex tex = self->tex [1]; |
1964 | maptex tex = self->tex [1]; |
… | |
… | |
1876 | } |
2021 | } |
1877 | } |
2022 | } |
1878 | } |
2023 | } |
1879 | } |
2024 | } |
1880 | |
2025 | |
|
|
2026 | rc_draw (rc); |
|
|
2027 | rc_clear (rc); |
|
|
2028 | |
1881 | // go through all smoothlevels, lowest to highest, then draw. |
2029 | // go through all smoothlevels, lowest to highest, then draw. |
1882 | // this is basically counting sort |
2030 | // this is basically counting sort |
1883 | { |
2031 | { |
1884 | int w, b; |
2032 | int w, b; |
1885 | |
2033 | |
|
|
2034 | glEnable (GL_TEXTURE_2D); |
|
|
2035 | glBegin (GL_QUADS); |
1886 | for (w = 0; w < 256 / 32; ++w) |
2036 | for (w = 0; w < 256 / 32; ++w) |
1887 | { |
2037 | { |
1888 | uint32_t smask = smooth_level [w]; |
2038 | uint32_t smask = smooth_level [w]; |
1889 | if (smask) |
2039 | if (smask) |
1890 | for (b = 0; b < 32; ++b) |
2040 | for (b = 0; b < 32; ++b) |
… | |
… | |
1915 | { |
2065 | { |
1916 | // this time avoiding texture state changes |
2066 | // this time avoiding texture state changes |
1917 | // save gobs of state changes. |
2067 | // save gobs of state changes. |
1918 | if (key.texname != tex.name) |
2068 | if (key.texname != tex.name) |
1919 | { |
2069 | { |
|
|
2070 | glEnd (); |
1920 | key.texname = tex.name; |
2071 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1921 | arr = rc_array (rc, &key); |
2072 | glBegin (GL_QUADS); |
1922 | } |
2073 | } |
1923 | |
2074 | |
1924 | if (border) |
2075 | if (border) |
1925 | { |
2076 | { |
1926 | float ox = border * dx; |
2077 | float ox = border * dx; |
1927 | |
2078 | |
1928 | rc_t2f_v3f (arr, ox , 0.f , px , py , 0); |
2079 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1929 | rc_t2f_v3f (arr, ox , dy , px , py + T, 0); |
2080 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1930 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py + T, 0); |
2081 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1931 | rc_t2f_v3f (arr, ox + dx, 0.f , px + T, py , 0); |
2082 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1932 | } |
2083 | } |
1933 | |
2084 | |
1934 | if (corner) |
2085 | if (corner) |
1935 | { |
2086 | { |
1936 | float ox = corner * dx; |
2087 | float ox = corner * dx; |
1937 | |
2088 | |
1938 | rc_t2f_v3f (arr, ox , dy , px , py , 0); |
2089 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1939 | rc_t2f_v3f (arr, ox , dy * 2.f, px , py + T, 0); |
2090 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1940 | rc_t2f_v3f (arr, ox + dx, dy * 2.f, px + T, py + T, 0); |
2091 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1941 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py , 0); |
2092 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
1942 | } |
2093 | } |
1943 | } |
2094 | } |
1944 | } |
2095 | } |
1945 | } |
2096 | } |
1946 | } |
2097 | } |
1947 | } |
2098 | } |
|
|
2099 | |
|
|
2100 | glEnd (); |
|
|
2101 | glDisable (GL_TEXTURE_2D); |
|
|
2102 | key.texname = -1; |
1948 | } |
2103 | } |
1949 | |
2104 | |
1950 | hv_clear (smooth); |
2105 | hv_clear (smooth); |
|
|
2106 | } |
|
|
2107 | |
|
|
2108 | if (pl_tex.name) |
|
|
2109 | { |
|
|
2110 | maptex tex = pl_tex; |
|
|
2111 | int px = pl_x + sdx; |
|
|
2112 | int py = pl_y + sdy; |
|
|
2113 | |
|
|
2114 | key.texname = tex.name; |
|
|
2115 | arr = rc_array (rc, &key); |
|
|
2116 | |
|
|
2117 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
2118 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
|
|
2119 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
|
|
2120 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
|
|
2121 | |
1951 | rc_draw (rc); |
2122 | rc_draw (rc); |
1952 | rc_clear (rc); |
|
|
1953 | } |
2123 | } |
1954 | |
2124 | |
1955 | glDisable (GL_BLEND); |
2125 | glDisable (GL_BLEND); |
1956 | rc_free (rc); |
2126 | rc_free (rc); |
1957 | |
2127 | |
… | |
… | |
1986 | } |
2156 | } |
1987 | } |
2157 | } |
1988 | } |
2158 | } |
1989 | |
2159 | |
1990 | void |
2160 | void |
1991 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2161 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1992 | CODE: |
2162 | CODE: |
1993 | { |
2163 | { |
1994 | static float color[16][3] = { |
2164 | static float color[16][3] = { |
1995 | { 0.00F, 0.00F, 0.00F }, |
2165 | { 0.00F, 0.00F, 0.00F }, |
1996 | { 1.00F, 1.00F, 1.00F }, |
2166 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2046 | glDisable (GL_BLEND); |
2216 | glDisable (GL_BLEND); |
2047 | glDisable (GL_TEXTURE_2D); |
2217 | glDisable (GL_TEXTURE_2D); |
2048 | } |
2218 | } |
2049 | |
2219 | |
2050 | void |
2220 | void |
2051 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2221 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2052 | PPCODE: |
2222 | PPCODE: |
2053 | { |
2223 | { |
2054 | int x, y; |
2224 | int x, y; |
2055 | int sw1 = sw + 2; |
2225 | int sw1 = sw + 2; |
2056 | int sh1 = sh + 2; |
2226 | int sh1 = sh + 2; |
… | |
… | |
2127 | PUSHs (sv_2mortal (newSViv (sh3))); |
2297 | PUSHs (sv_2mortal (newSViv (sh3))); |
2128 | PUSHs (darkness3_sv); |
2298 | PUSHs (darkness3_sv); |
2129 | } |
2299 | } |
2130 | |
2300 | |
2131 | SV * |
2301 | SV * |
2132 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2302 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2133 | CODE: |
2303 | CODE: |
2134 | { |
2304 | { |
2135 | int x, y, x1, y1; |
2305 | int x, y, x1, y1; |
2136 | SV *data_sv = newSV (w * h * 7 + 5); |
2306 | SV *data_sv = newSV (w * h * 7 + 5); |
2137 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2307 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2194 | else |
2364 | else |
2195 | *data++ = 0; |
2365 | *data++ = 0; |
2196 | } |
2366 | } |
2197 | } |
2367 | } |
2198 | |
2368 | |
|
|
2369 | /* if size is w*h + 5 then no data has been found */ |
|
|
2370 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
|
|
2371 | { |
2199 | SvPOK_only (data_sv); |
2372 | SvPOK_only (data_sv); |
2200 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2373 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2374 | } |
|
|
2375 | |
2201 | RETVAL = data_sv; |
2376 | RETVAL = data_sv; |
2202 | } |
2377 | } |
2203 | OUTPUT: |
2378 | OUTPUT: |
2204 | RETVAL |
2379 | RETVAL |
2205 | |
2380 | |
2206 | void |
2381 | void |
2207 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2382 | set_rect (DC::Map self, int x0, int y0, SV *data_sv) |
2208 | PPCODE: |
2383 | PPCODE: |
2209 | { |
2384 | { |
2210 | int x, y, z; |
2385 | int x, y, z; |
2211 | int w, h; |
2386 | int w, h; |
2212 | int x1, y1; |
2387 | int x1, y1; |
|
|
2388 | STRLEN len; |
|
|
2389 | uint8_t *data, *end; |
|
|
2390 | |
|
|
2391 | len = SvLEN (data_sv); |
|
|
2392 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
|
|
2393 | data = SvPVbyte_nolen (data_sv); |
|
|
2394 | end = data + len + 8; |
|
|
2395 | |
|
|
2396 | if (len < 5) |
|
|
2397 | XSRETURN_EMPTY; |
2213 | |
2398 | |
2214 | if (*data++ != 0) |
2399 | if (*data++ != 0) |
2215 | return; /* version mismatch */ |
2400 | XSRETURN_EMPTY; /* version mismatch */ |
2216 | |
2401 | |
2217 | w = *data++ << 8; w |= *data++; |
2402 | w = *data++ << 8; w |= *data++; |
2218 | h = *data++ << 8; h |= *data++; |
2403 | h = *data++ << 8; h |= *data++; |
2219 | |
2404 | |
2220 | // we need to do this 'cause we don't keep an absolute coord system for rows |
2405 | // we need to do this 'cause we don't keep an absolute coord system for rows |
… | |
… | |
2232 | { |
2417 | { |
2233 | maprow *row = map_get_row (self, y); |
2418 | maprow *row = map_get_row (self, y); |
2234 | |
2419 | |
2235 | for (x = x0; x < x1; x++) |
2420 | for (x = x0; x < x1; x++) |
2236 | { |
2421 | { |
|
|
2422 | uint8_t flags; |
|
|
2423 | |
|
|
2424 | if (data + 7 >= end) |
|
|
2425 | XSRETURN_EMPTY; |
|
|
2426 | |
2237 | uint8_t flags = *data++; |
2427 | flags = *data++; |
2238 | |
2428 | |
2239 | if (flags) |
2429 | if (flags) |
2240 | { |
2430 | { |
2241 | mapcell *cell = row_get_cell (row, x); |
2431 | mapcell *cell = row_get_cell (row, x); |
2242 | tileid tile[3] = { 0, 0, 0 }; |
2432 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2245 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2435 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2246 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2436 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2247 | |
2437 | |
2248 | if (cell->darkness == 0) |
2438 | if (cell->darkness == 0) |
2249 | { |
2439 | { |
2250 | cell->darkness = 0; |
2440 | /*cell->darkness = 0;*/ |
|
|
2441 | EXTEND (SP, 3); |
2251 | |
2442 | |
2252 | for (z = 0; z <= 2; z++) |
2443 | for (z = 0; z <= 2; z++) |
2253 | { |
2444 | { |
2254 | tileid t = tile [z]; |
2445 | tileid t = tile [z]; |
2255 | |
2446 | |
2256 | if (t >= self->texs || (t && !self->tex [t].name)) |
2447 | if (t >= self->texs || (t && !self->tex [t].name)) |
2257 | { |
2448 | { |
2258 | XPUSHs (sv_2mortal (newSViv (t))); |
2449 | PUSHs (sv_2mortal (newSViv (t))); |
2259 | need_texid (self, t); |
2450 | need_texid (self, t); |
2260 | } |
2451 | } |
2261 | |
2452 | |
2262 | cell->tile [z] = t; |
2453 | cell->tile [z] = t; |
2263 | } |
2454 | } |
… | |
… | |
2265 | } |
2456 | } |
2266 | } |
2457 | } |
2267 | } |
2458 | } |
2268 | } |
2459 | } |
2269 | |
2460 | |
2270 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2461 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2271 | |
2462 | |
2272 | CFPlus::RW |
2463 | DC::RW |
2273 | new (SV *class, SV *data_sv) |
2464 | new (SV *class, SV *data_sv) |
2274 | CODE: |
2465 | CODE: |
2275 | { |
2466 | { |
2276 | STRLEN datalen; |
2467 | STRLEN datalen; |
2277 | char *data = SvPVbyte (data_sv, datalen); |
2468 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2279 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2470 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2280 | } |
2471 | } |
2281 | OUTPUT: |
2472 | OUTPUT: |
2282 | RETVAL |
2473 | RETVAL |
2283 | |
2474 | |
2284 | CFPlus::RW |
2475 | DC::RW |
2285 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2476 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2286 | CODE: |
2477 | CODE: |
2287 | RETVAL = SDL_RWFromFile (path, mode); |
2478 | RETVAL = SDL_RWFromFile (path, mode); |
2288 | OUTPUT: |
2479 | OUTPUT: |
2289 | RETVAL |
2480 | RETVAL |
2290 | |
2481 | |
2291 | # fails on win32: |
2482 | # fails on win32: |
2292 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2483 | # dc.xs(2268) : error C2059: syntax error : '(' |
2293 | #void |
2484 | #void |
2294 | #close (CFPlus::RW self) |
2485 | #close (DC::RW self) |
2295 | # CODE: |
2486 | # CODE: |
2296 | # (self->(close)) (self); |
2487 | # (self->(close)) (self); |
2297 | |
2488 | |
2298 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2489 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2299 | |
2490 | |
2300 | PROTOTYPES: DISABLE |
2491 | PROTOTYPES: DISABLE |
2301 | |
2492 | |
2302 | CFPlus::Channel |
2493 | DC::Channel |
2303 | find () |
2494 | find () |
2304 | CODE: |
2495 | CODE: |
2305 | { |
2496 | { |
2306 | RETVAL = Mix_GroupAvailable (-1); |
2497 | RETVAL = Mix_GroupAvailable (-1); |
2307 | |
2498 | |
… | |
… | |
2320 | } |
2511 | } |
2321 | OUTPUT: |
2512 | OUTPUT: |
2322 | RETVAL |
2513 | RETVAL |
2323 | |
2514 | |
2324 | void |
2515 | void |
2325 | halt (CFPlus::Channel self) |
2516 | halt (DC::Channel self) |
2326 | CODE: |
2517 | CODE: |
2327 | Mix_HaltChannel (self); |
2518 | Mix_HaltChannel (self); |
2328 | |
2519 | |
2329 | void |
2520 | void |
2330 | expire (CFPlus::Channel self, int ticks = -1) |
2521 | expire (DC::Channel self, int ticks = -1) |
2331 | CODE: |
2522 | CODE: |
2332 | Mix_ExpireChannel (self, ticks); |
2523 | Mix_ExpireChannel (self, ticks); |
2333 | |
2524 | |
2334 | void |
2525 | void |
2335 | fade_out (CFPlus::Channel self, int ticks = -1) |
2526 | fade_out (DC::Channel self, int ticks = -1) |
2336 | CODE: |
2527 | CODE: |
2337 | Mix_FadeOutChannel (self, ticks); |
2528 | Mix_FadeOutChannel (self, ticks); |
2338 | |
2529 | |
2339 | int |
2530 | int |
2340 | volume (CFPlus::Channel self, int volume) |
2531 | volume (DC::Channel self, int volume) |
2341 | CODE: |
2532 | CODE: |
2342 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2533 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2343 | OUTPUT: |
2534 | OUTPUT: |
2344 | RETVAL |
2535 | RETVAL |
2345 | |
2536 | |
2346 | void |
2537 | void |
2347 | unregister_all_effects (CFPlus::Channel self) |
2538 | unregister_all_effects (DC::Channel self) |
2348 | CODE: |
2539 | CODE: |
2349 | Mix_UnregisterAllEffects (self); |
2540 | Mix_UnregisterAllEffects (self); |
2350 | |
2541 | |
2351 | void |
2542 | void |
2352 | set_panning (CFPlus::Channel self, int left, int right) |
2543 | set_panning (DC::Channel self, int left, int right) |
2353 | CODE: |
2544 | CODE: |
2354 | left = CLAMP (left , 0, 255); |
2545 | left = CLAMP (left , 0, 255); |
2355 | right = CLAMP (right, 0, 255); |
2546 | right = CLAMP (right, 0, 255); |
2356 | Mix_SetPanning (self, left, right); |
2547 | Mix_SetPanning (self, left, right); |
2357 | |
2548 | |
2358 | void |
2549 | void |
2359 | set_distance (CFPlus::Channel self, int distance) |
2550 | set_distance (DC::Channel self, int distance) |
2360 | CODE: |
2551 | CODE: |
2361 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2552 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2362 | |
2553 | |
2363 | void |
2554 | void |
2364 | set_position (CFPlus::Channel self, int angle, int distance) |
2555 | set_position (DC::Channel self, int angle, int distance) |
2365 | CODE: |
2556 | CODE: |
2366 | |
2557 | |
2367 | void |
2558 | void |
2368 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2559 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2369 | CODE: |
2560 | CODE: |
2370 | { |
2561 | { |
2371 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2562 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2372 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2563 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2373 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2564 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2374 | } |
2565 | } |
2375 | |
2566 | |
2376 | void |
2567 | void |
2377 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2568 | set_reverse_stereo (DC::Channel self, int flip) |
2378 | CODE: |
2569 | CODE: |
2379 | Mix_SetReverseStereo (self, flip); |
2570 | Mix_SetReverseStereo (self, flip); |
2380 | |
2571 | |
2381 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2572 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2382 | |
2573 | |
2383 | PROTOTYPES: DISABLE |
2574 | PROTOTYPES: DISABLE |
2384 | |
2575 | |
2385 | CFPlus::MixChunk |
2576 | DC::MixChunk |
2386 | new (SV *class, CFPlus::RW rwops) |
2577 | new (SV *class, DC::RW rwops) |
2387 | CODE: |
2578 | CODE: |
2388 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2579 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2389 | OUTPUT: |
2580 | OUTPUT: |
2390 | RETVAL |
2581 | RETVAL |
2391 | |
2582 | |
2392 | void |
2583 | void |
2393 | DESTROY (CFPlus::MixChunk self) |
2584 | DESTROY (DC::MixChunk self) |
2394 | CODE: |
2585 | CODE: |
2395 | Mix_FreeChunk (self); |
2586 | Mix_FreeChunk (self); |
2396 | |
2587 | |
2397 | int |
2588 | int |
2398 | volume (CFPlus::MixChunk self, int volume = -1) |
2589 | volume (DC::MixChunk self, int volume = -1) |
2399 | CODE: |
2590 | CODE: |
2400 | if (items > 1) |
2591 | if (items > 1) |
2401 | volume = CLAMP (volume, 0, 128); |
2592 | volume = CLAMP (volume, 0, 128); |
2402 | RETVAL = Mix_VolumeChunk (self, volume); |
2593 | RETVAL = Mix_VolumeChunk (self, volume); |
2403 | OUTPUT: |
2594 | OUTPUT: |
2404 | RETVAL |
2595 | RETVAL |
2405 | |
2596 | |
2406 | CFPlus::Channel |
2597 | DC::Channel |
2407 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2598 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2408 | CODE: |
2599 | CODE: |
2409 | { |
2600 | { |
2410 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2601 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2411 | |
2602 | |
2412 | if (RETVAL < 0) |
2603 | if (RETVAL < 0) |
… | |
… | |
2419 | } |
2610 | } |
2420 | } |
2611 | } |
2421 | OUTPUT: |
2612 | OUTPUT: |
2422 | RETVAL |
2613 | RETVAL |
2423 | |
2614 | |
2424 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2615 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2425 | |
2616 | |
2426 | int |
2617 | int |
2427 | volume (int volume = -1) |
2618 | volume (int volume = -1) |
2428 | PROTOTYPE: ;$ |
2619 | PROTOTYPE: ;$ |
2429 | CODE: |
2620 | CODE: |
… | |
… | |
2441 | void |
2632 | void |
2442 | halt () |
2633 | halt () |
2443 | CODE: |
2634 | CODE: |
2444 | Mix_HaltMusic (); |
2635 | Mix_HaltMusic (); |
2445 | |
2636 | |
2446 | CFPlus::MixMusic |
2637 | DC::MixMusic |
2447 | new (SV *class, CFPlus::RW rwops) |
2638 | new (SV *class, DC::RW rwops) |
2448 | CODE: |
2639 | CODE: |
2449 | RETVAL = Mix_LoadMUS_RW (rwops); |
2640 | RETVAL = Mix_LoadMUS_RW (rwops); |
2450 | OUTPUT: |
2641 | OUTPUT: |
2451 | RETVAL |
2642 | RETVAL |
2452 | |
2643 | |
2453 | void |
2644 | void |
2454 | DESTROY (CFPlus::MixMusic self) |
2645 | DESTROY (DC::MixMusic self) |
2455 | CODE: |
2646 | CODE: |
2456 | Mix_FreeMusic (self); |
2647 | Mix_FreeMusic (self); |
2457 | |
2648 | |
2458 | int |
2649 | int |
2459 | play (CFPlus::MixMusic self, int loops = -1) |
2650 | play (DC::MixMusic self, int loops = -1) |
2460 | CODE: |
2651 | CODE: |
2461 | RETVAL = Mix_PlayMusic (self, loops); |
2652 | RETVAL = Mix_PlayMusic (self, loops); |
2462 | OUTPUT: |
2653 | OUTPUT: |
2463 | RETVAL |
2654 | RETVAL |
2464 | |
2655 | |
2465 | void |
2656 | void |
2466 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2657 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2467 | CODE: |
2658 | CODE: |
2468 | Mix_FadeInMusicPos (self, loops, ms, position); |
2659 | Mix_FadeInMusicPos (self, loops, ms, position); |
2469 | |
2660 | |
2470 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2661 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2471 | |
2662 | |
2472 | PROTOTYPES: ENABLE |
2663 | PROTOTYPES: ENABLE |
2473 | |
2664 | |
2474 | BOOT: |
2665 | BOOT: |
2475 | { |
2666 | { |
2476 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2667 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2477 | static const struct { |
2668 | static const struct { |
2478 | const char *name; |
2669 | const char *name; |
2479 | IV iv; |
2670 | IV iv; |
2480 | } *civ, const_iv[] = { |
2671 | } *civ, const_iv[] = { |
2481 | # define const_iv(name) { # name, (IV)name } |
2672 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2516 | const_iv (GL_INTENSITY), |
2707 | const_iv (GL_INTENSITY), |
2517 | const_iv (GL_LUMINANCE), |
2708 | const_iv (GL_LUMINANCE), |
2518 | const_iv (GL_LUMINANCE_ALPHA), |
2709 | const_iv (GL_LUMINANCE_ALPHA), |
2519 | const_iv (GL_FLOAT), |
2710 | const_iv (GL_FLOAT), |
2520 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2711 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2712 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2713 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2714 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2715 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2716 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2717 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2521 | const_iv (GL_COMPILE), |
2718 | const_iv (GL_COMPILE), |
2522 | const_iv (GL_PROXY_TEXTURE_1D), |
2719 | const_iv (GL_PROXY_TEXTURE_1D), |
2523 | const_iv (GL_PROXY_TEXTURE_2D), |
2720 | const_iv (GL_PROXY_TEXTURE_2D), |
2524 | const_iv (GL_TEXTURE_1D), |
2721 | const_iv (GL_TEXTURE_1D), |
2525 | const_iv (GL_TEXTURE_2D), |
2722 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2564 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2761 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2565 | const_iv (GL_POINT_SMOOTH_HINT), |
2762 | const_iv (GL_POINT_SMOOTH_HINT), |
2566 | const_iv (GL_LINE_SMOOTH_HINT), |
2763 | const_iv (GL_LINE_SMOOTH_HINT), |
2567 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2764 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2568 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2765 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2766 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2569 | const_iv (GL_FASTEST), |
2767 | const_iv (GL_FASTEST), |
2570 | const_iv (GL_DONT_CARE), |
2768 | const_iv (GL_DONT_CARE), |
2571 | const_iv (GL_NICEST), |
2769 | const_iv (GL_NICEST), |
2572 | const_iv (GL_V2F), |
2770 | const_iv (GL_V2F), |
2573 | const_iv (GL_V3F), |
2771 | const_iv (GL_V3F), |
… | |
… | |
2581 | |
2779 | |
2582 | texture_av = newAV (); |
2780 | texture_av = newAV (); |
2583 | AvREAL_off (texture_av); |
2781 | AvREAL_off (texture_av); |
2584 | } |
2782 | } |
2585 | |
2783 | |
|
|
2784 | void |
|
|
2785 | disable_GL_EXT_blend_func_separate () |
|
|
2786 | CODE: |
|
|
2787 | gl.BlendFuncSeparate = 0; |
|
|
2788 | gl.BlendFuncSeparateEXT = 0; |
|
|
2789 | |
2586 | char * |
2790 | char * |
2587 | gl_vendor () |
2791 | gl_vendor () |
2588 | CODE: |
2792 | CODE: |
2589 | RETVAL = (char *)glGetString (GL_VENDOR); |
2793 | RETVAL = (char *)glGetString (GL_VENDOR); |
2590 | OUTPUT: |
2794 | OUTPUT: |
… | |
… | |
2711 | |
2915 | |
2712 | void glRect (float x1, float y1, float x2, float y2) |
2916 | void glRect (float x1, float y1, float x2, float y2) |
2713 | CODE: |
2917 | CODE: |
2714 | glRectf (x1, y1, x2, y2); |
2918 | glRectf (x1, y1, x2, y2); |
2715 | |
2919 | |
|
|
2920 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2921 | CODE: |
|
|
2922 | glBegin (GL_LINE_LOOP); |
|
|
2923 | glVertex2f (x1, y1); |
|
|
2924 | glVertex2f (x2, y1); |
|
|
2925 | glVertex2f (x2, y2); |
|
|
2926 | glVertex2f (x1, y2); |
|
|
2927 | glEnd (); |
|
|
2928 | |
2716 | PROTOTYPES: ENABLE |
2929 | PROTOTYPES: ENABLE |
2717 | |
2930 | |
2718 | void glBegin (int mode) |
2931 | void glBegin (int mode) |
2719 | |
2932 | |
2720 | void glEnd () |
2933 | void glEnd () |
… | |
… | |
2752 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2965 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2753 | CODE: |
2966 | CODE: |
2754 | if (gl.SeparableFilter2D) |
2967 | if (gl.SeparableFilter2D) |
2755 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2968 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2756 | |
2969 | |
2757 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2970 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2758 | |
2971 | |
2759 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2972 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2760 | |
2973 | |
2761 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2974 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2762 | |
2975 | |
… | |
… | |
2788 | |
3001 | |
2789 | void glEndList () |
3002 | void glEndList () |
2790 | |
3003 | |
2791 | void glCallList (int list) |
3004 | void glCallList (int list) |
2792 | |
3005 | |
2793 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
3006 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2794 | |
3007 | |
2795 | PROTOTYPES: DISABLE |
3008 | PROTOTYPES: DISABLE |
2796 | |
3009 | |
2797 | void |
3010 | void |
2798 | find_widget (SV *self, NV x, NV y) |
3011 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2802 | XPUSHs (self); |
3015 | XPUSHs (self); |
2803 | } |
3016 | } |
2804 | |
3017 | |
2805 | BOOT: |
3018 | BOOT: |
2806 | { |
3019 | { |
2807 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
3020 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2808 | |
3021 | |
2809 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
3022 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2810 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
3023 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2811 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
3024 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2812 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
3025 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2813 | } |
3026 | } |
2814 | |
3027 | |
2815 | void |
3028 | void |
2816 | draw (SV *self) |
3029 | draw (SV *self) |
2817 | CODE: |
3030 | CODE: |
… | |
… | |
2821 | NV x, y, w, h; |
3034 | NV x, y, w, h; |
2822 | SV *draw_x_sv = GvSV (draw_x_gv); |
3035 | SV *draw_x_sv = GvSV (draw_x_gv); |
2823 | SV *draw_y_sv = GvSV (draw_y_gv); |
3036 | SV *draw_y_sv = GvSV (draw_y_gv); |
2824 | SV *draw_w_sv = GvSV (draw_w_gv); |
3037 | SV *draw_w_sv = GvSV (draw_w_gv); |
2825 | SV *draw_h_sv = GvSV (draw_h_gv); |
3038 | SV *draw_h_sv = GvSV (draw_h_gv); |
2826 | SV *hover; |
|
|
2827 | double draw_x, draw_y, draw_w, draw_h; |
3039 | double draw_x, draw_y; |
2828 | |
3040 | |
2829 | if (!SvROK (self)) |
3041 | if (!SvROK (self)) |
2830 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
3042 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2831 | |
3043 | |
2832 | hv = (HV *)SvRV (self); |
3044 | hv = (HV *)SvRV (self); |
2833 | |
3045 | |
2834 | if (SvTYPE (hv) != SVt_PVHV) |
3046 | if (SvTYPE (hv) != SVt_PVHV) |
2835 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
3047 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2836 | |
3048 | |
2837 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
3049 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2838 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
3050 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2839 | |
3051 | |
2840 | if (!h || !w) |
3052 | if (!h || !w) |
… | |
… | |
2860 | { |
3072 | { |
2861 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
3073 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2862 | |
3074 | |
2863 | if (svp && SvTRUE (*svp)) |
3075 | if (svp && SvTRUE (*svp)) |
2864 | { |
3076 | { |
2865 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
3077 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2866 | glEnable (GL_BLEND); |
3078 | glEnable (GL_BLEND); |
2867 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
3079 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2868 | glBegin (GL_QUADS); |
3080 | glBegin (GL_QUADS); |
2869 | glVertex2f (0, 0); |
3081 | glVertex2f (0, 0); |
2870 | glVertex2f (w, 0); |
3082 | glVertex2f (w, 0); |
… | |
… | |
2873 | glEnd (); |
3085 | glEnd (); |
2874 | glDisable (GL_BLEND); |
3086 | glDisable (GL_BLEND); |
2875 | } |
3087 | } |
2876 | } |
3088 | } |
2877 | #if 0 |
3089 | #if 0 |
2878 | if ($ENV{CFPLUS_DEBUG} & 1) { |
3090 | // draw borders, for debugging |
2879 | glPushMatrix; |
3091 | glPushMatrix (); |
2880 | glColor 1, 1, 0, 1; |
3092 | glColor4f (1., 1., 0., 1.); |
2881 | glTranslate 0.375, 0.375; |
3093 | glTranslatef (.5, .5, 0.); |
2882 | glBegin GL_LINE_LOOP; |
3094 | glBegin (GL_LINE_LOOP); |
2883 | glVertex 0 , 0; |
3095 | glVertex2f (0 , 0); |
2884 | glVertex $self->{w} - 1, 0; |
3096 | glVertex2f (w - 1, 0); |
2885 | glVertex $self->{w} - 1, $self->{h} - 1; |
3097 | glVertex2f (w - 1, h - 1); |
2886 | glVertex 0 , $self->{h} - 1; |
3098 | glVertex2f (0 , h - 1); |
2887 | glEnd; |
3099 | glEnd (); |
2888 | glPopMatrix; |
3100 | glPopMatrix (); |
2889 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2890 | } |
|
|
2891 | #endif |
3101 | #endif |
2892 | PUSHMARK (SP); |
3102 | PUSHMARK (SP); |
2893 | XPUSHs (self); |
3103 | XPUSHs (self); |
2894 | PUTBACK; |
3104 | PUTBACK; |
2895 | call_method ("_draw", G_VOID | G_DISCARD); |
3105 | call_method ("_draw", G_VOID | G_DISCARD); |