… | |
… | |
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> |
… | |
… | |
63 | #define MAP_EXTEND_X 32 |
74 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
75 | #define MAP_EXTEND_Y 512 |
65 | |
76 | |
66 | #define MIN_FONT_HEIGHT 10 |
77 | #define MIN_FONT_HEIGHT 10 |
67 | |
78 | |
|
|
79 | /* mask out modifiers we are not interested in */ |
|
|
80 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
|
|
81 | |
68 | #if 0 |
82 | #if 0 |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
83 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
70 | #else |
84 | #else |
71 | # define PARACHUTE 0 |
85 | # define PARACHUTE 0 |
72 | #endif |
86 | #endif |
… | |
… | |
120 | |
134 | |
121 | #include "pango-font.c" |
135 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
136 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
137 | #include "pango-render.c" |
124 | |
138 | |
125 | typedef IV CFPlus__Channel; |
139 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
140 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
141 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
142 | typedef Mix_Music *DC__MixMusic; |
129 | |
143 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
144 | typedef PangoFontDescription *DC__Font; |
131 | |
145 | |
132 | static int |
146 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
147 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
148 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
149 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
163 | |
150 | typedef struct cf_layout { |
164 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
165 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
166 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
167 | int base_height; |
154 | CFPlus__Font font; |
168 | DC__Font font; |
155 | rc_t *rc; |
169 | rc_t *rc; |
156 | } *CFPlus__Layout; |
170 | } *DC__Layout; |
157 | |
171 | |
158 | static CFPlus__Font default_font; |
172 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
173 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
174 | static PangoFontMap *opengl_fontmap; |
161 | |
175 | |
162 | static void |
176 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
177 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
182 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
183 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
184 | } |
171 | |
185 | |
172 | static void |
186 | static void |
173 | layout_update_font (CFPlus__Layout self) |
187 | layout_update_font (DC__Layout self) |
174 | { |
188 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
189 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
190 | * reasonably well with dejavu/bistream fonts |
177 | */ |
191 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
192 | PangoFontDescription *font = self->font ? self->font : default_font; |
179 | |
193 | |
180 | pango_font_description_set_absolute_size (font, |
194 | pango_font_description_set_absolute_size (font, |
181 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
195 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
182 | |
196 | |
183 | pango_layout_set_font_description (self->pl, font); |
197 | pango_layout_set_font_description (self->pl, font); |
184 | } |
198 | } |
185 | |
199 | |
186 | static void |
200 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
201 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
202 | { |
189 | PangoRectangle rect; |
203 | PangoRectangle rect; |
190 | |
204 | |
191 | // get_pixel_* wrongly rounds down |
205 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
206 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
245 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
246 | int texs; maptex *tex; // [tileid] |
233 | |
247 | |
234 | int32_t rows; |
248 | int32_t rows; |
235 | maprow *row; |
249 | maprow *row; |
236 | } *CFPlus__Map; |
250 | } *DC__Map; |
237 | |
251 | |
238 | static char * |
252 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
253 | prepend (char *ptr, int sze, int inc) |
240 | { |
254 | { |
241 | char *p; |
255 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
293 | self->texs *= 2; |
280 | } |
294 | } |
281 | } |
295 | } |
282 | |
296 | |
283 | static maprow * |
297 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
298 | map_get_row (DC__Map self, int y) |
285 | { |
299 | { |
286 | if (0 > y) |
300 | if (0 > y) |
287 | { |
301 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
302 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
303 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
341 | |
328 | return row->col + (x - row->c0); |
342 | return row->col + (x - row->c0); |
329 | } |
343 | } |
330 | |
344 | |
331 | static mapcell * |
345 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
346 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
347 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
348 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
349 | } |
336 | |
350 | |
337 | static void |
351 | static void |
338 | map_clear (CFPlus__Map self) |
352 | map_clear (DC__Map self) |
339 | { |
353 | { |
340 | int r; |
354 | int r; |
341 | |
355 | |
342 | for (r = 0; r < self->rows; r++) |
356 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
357 | Safefree (self->row[r].col); |
… | |
… | |
351 | self->row = 0; |
365 | self->row = 0; |
352 | self->rows = 0; |
366 | self->rows = 0; |
353 | } |
367 | } |
354 | |
368 | |
355 | static void |
369 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
370 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
371 | { |
358 | int x, y; |
372 | int x, y; |
359 | maprow *row; |
373 | maprow *row; |
360 | mapcell *cell; |
374 | mapcell *cell; |
361 | |
375 | |
… | |
… | |
440 | n |= n >> 16; |
454 | n |= n >> 16; |
441 | |
455 | |
442 | return n + 1; |
456 | return n + 1; |
443 | } |
457 | } |
444 | |
458 | |
|
|
459 | static unsigned int |
|
|
460 | popcount (unsigned int n) |
|
|
461 | { |
|
|
462 | n -= (n >> 1) & 0x55555555U; |
|
|
463 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
464 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
465 | n *= 0x01010101U; |
|
|
466 | |
|
|
467 | return n >> 24; |
|
|
468 | } |
|
|
469 | |
445 | /* SDL should provide this, really. */ |
470 | /* SDL should provide this, really. */ |
446 | #define SDLK_MODIFIER_MIN 300 |
471 | #define SDLK_MODIFIER_MIN 300 |
447 | #define SDLK_MODIFIER_MAX 314 |
472 | #define SDLK_MODIFIER_MAX 314 |
448 | |
473 | |
449 | /******************************************************************************/ |
474 | /******************************************************************************/ |
… | |
… | |
487 | return 0; |
512 | return 0; |
488 | |
513 | |
489 | return 1; |
514 | return 1; |
490 | } |
515 | } |
491 | |
516 | |
492 | MODULE = CFPlus PACKAGE = CFPlus |
517 | MODULE = Deliantra::Client PACKAGE = DC |
493 | |
518 | |
494 | PROTOTYPES: ENABLE |
519 | PROTOTYPES: ENABLE |
495 | |
520 | |
496 | BOOT: |
521 | BOOT: |
497 | { |
522 | { |
498 | HV *stash = gv_stashpv ("CFPlus", 1); |
523 | HV *stash = gv_stashpv ("DC", 1); |
499 | static const struct { |
524 | static const struct { |
500 | const char *name; |
525 | const char *name; |
501 | IV iv; |
526 | IV iv; |
502 | } *civ, const_iv[] = { |
527 | } *civ, const_iv[] = { |
503 | # define const_iv(name) { # name, (IV)name } |
528 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
525 | |
550 | |
526 | const_iv (SDL_APPINPUTFOCUS), |
551 | const_iv (SDL_APPINPUTFOCUS), |
527 | const_iv (SDL_APPMOUSEFOCUS), |
552 | const_iv (SDL_APPMOUSEFOCUS), |
528 | const_iv (SDL_APPACTIVE), |
553 | const_iv (SDL_APPACTIVE), |
529 | |
554 | |
|
|
555 | const_iv (SDLK_FIRST), |
|
|
556 | const_iv (SDLK_LAST), |
530 | const_iv (SDLK_KP0), |
557 | const_iv (SDLK_KP0), |
531 | const_iv (SDLK_KP1), |
558 | const_iv (SDLK_KP1), |
532 | const_iv (SDLK_KP2), |
559 | const_iv (SDLK_KP2), |
533 | const_iv (SDLK_KP3), |
560 | const_iv (SDLK_KP3), |
534 | const_iv (SDLK_KP4), |
561 | const_iv (SDLK_KP4), |
… | |
… | |
606 | const_iv (KMOD_LMETA), |
633 | const_iv (KMOD_LMETA), |
607 | const_iv (KMOD_RMETA), |
634 | const_iv (KMOD_RMETA), |
608 | const_iv (KMOD_NUM), |
635 | const_iv (KMOD_NUM), |
609 | const_iv (KMOD_CAPS), |
636 | const_iv (KMOD_CAPS), |
610 | const_iv (KMOD_MODE), |
637 | const_iv (KMOD_MODE), |
|
|
638 | |
|
|
639 | const_iv (MIX_DEFAULT_FORMAT), |
611 | # undef const_iv |
640 | # undef const_iv |
612 | }; |
641 | }; |
613 | |
642 | |
614 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
643 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
615 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
644 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
633 | |
662 | |
634 | NV floor (NV x) |
663 | NV floor (NV x) |
635 | |
664 | |
636 | NV ceil (NV x) |
665 | NV ceil (NV x) |
637 | |
666 | |
|
|
667 | IV minpot (UV n) |
|
|
668 | |
|
|
669 | IV popcount (UV n) |
|
|
670 | |
638 | void |
671 | void |
639 | pango_init () |
672 | pango_init () |
640 | CODE: |
673 | CODE: |
641 | { |
674 | { |
642 | opengl_fontmap = pango_opengl_font_map_new (); |
675 | opengl_fontmap = pango_opengl_font_map_new (); |
643 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
676 | 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); |
677 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
678 | /*pango_context_set_font_description (opengl_context, default_font);*/ |
|
|
679 | #if PANGO_VERSION_CHECK (1, 15, 2) |
|
|
680 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
681 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
682 | #endif |
645 | } |
683 | } |
646 | |
684 | |
647 | char * |
685 | char * |
648 | SDL_GetError () |
686 | SDL_GetError () |
649 | |
687 | |
… | |
… | |
681 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
719 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
682 | |
720 | |
683 | if (m && m != (SDL_Rect **)-1) |
721 | if (m && m != (SDL_Rect **)-1) |
684 | while (*m) |
722 | while (*m) |
685 | { |
723 | { |
686 | if ((*m)->w >= 640 && (*m)->h >= 480) |
724 | if ((*m)->w >= 800 && (*m)->h >= 480) |
687 | { |
725 | { |
688 | AV *av = newAV (); |
726 | AV *av = newAV (); |
689 | av_push (av, newSViv ((*m)->w)); |
727 | av_push (av, newSViv ((*m)->w)); |
690 | av_push (av, newSViv ((*m)->h)); |
728 | av_push (av, newSViv ((*m)->h)); |
691 | av_push (av, newSViv (rgb)); |
729 | av_push (av, newSViv (rgb)); |
… | |
… | |
715 | |
753 | |
716 | if (RETVAL) |
754 | if (RETVAL) |
717 | { |
755 | { |
718 | av_clear (texture_av); |
756 | av_clear (texture_av); |
719 | |
757 | |
720 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
758 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
721 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
759 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
722 | #include "glfunc.h" |
760 | #include "glfunc.h" |
723 | #undef GL_FUNC |
761 | #undef GL_FUNC |
724 | } |
762 | } |
725 | } |
763 | } |
… | |
… | |
732 | char * |
770 | char * |
733 | SDL_GetKeyName (int sym) |
771 | SDL_GetKeyName (int sym) |
734 | |
772 | |
735 | int |
773 | int |
736 | SDL_GetAppState () |
774 | SDL_GetAppState () |
|
|
775 | |
|
|
776 | int |
|
|
777 | SDL_GetModState () |
737 | |
778 | |
738 | void |
779 | void |
739 | poll_events () |
780 | poll_events () |
740 | PPCODE: |
781 | PPCODE: |
741 | { |
782 | { |
… | |
… | |
751 | { |
792 | { |
752 | case SDL_KEYDOWN: |
793 | case SDL_KEYDOWN: |
753 | case SDL_KEYUP: |
794 | case SDL_KEYUP: |
754 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
795 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
755 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
796 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
756 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
797 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); |
757 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ |
798 | hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ |
758 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
799 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
759 | break; |
800 | break; |
760 | |
801 | |
761 | case SDL_ACTIVEEVENT: |
802 | case SDL_ACTIVEEVENT: |
762 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
803 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
780 | x = ev.motion.x; |
821 | x = ev.motion.x; |
781 | y = ev.motion.y; |
822 | y = ev.motion.y; |
782 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
823 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
783 | } |
824 | } |
784 | |
825 | |
785 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
826 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
786 | hv_store (hv, "state", 5, newSViv (state), 0); |
827 | hv_store (hv, "state", 5, newSViv (state), 0); |
787 | hv_store (hv, "x", 1, newSViv (x), 0); |
828 | hv_store (hv, "x", 1, newSViv (x), 0); |
788 | hv_store (hv, "y", 1, newSViv (y), 0); |
829 | hv_store (hv, "y", 1, newSViv (y), 0); |
789 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
830 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
790 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
831 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
791 | } |
832 | } |
792 | break; |
833 | break; |
793 | |
834 | |
794 | case SDL_MOUSEBUTTONDOWN: |
835 | case SDL_MOUSEBUTTONDOWN: |
795 | case SDL_MOUSEBUTTONUP: |
836 | case SDL_MOUSEBUTTONUP: |
796 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
837 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
797 | |
838 | |
798 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
839 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
799 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
840 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
800 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
841 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
801 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
842 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
806 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
847 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
807 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
848 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
808 | break; |
849 | break; |
809 | } |
850 | } |
810 | |
851 | |
811 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
852 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
812 | } |
853 | } |
813 | } |
854 | } |
814 | |
855 | |
815 | int |
856 | int |
816 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
857 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
817 | POSTCALL: |
858 | POSTCALL: |
818 | Mix_HookMusicFinished (music_finished); |
859 | Mix_HookMusicFinished (music_finished); |
819 | Mix_ChannelFinished (channel_finished); |
860 | Mix_ChannelFinished (channel_finished); |
|
|
861 | |
|
|
862 | void |
|
|
863 | Mix_QuerySpec () |
|
|
864 | PPCODE: |
|
|
865 | { |
|
|
866 | int freq, channels; |
|
|
867 | Uint16 format; |
|
|
868 | |
|
|
869 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
870 | { |
|
|
871 | EXTEND (SP, 3); |
|
|
872 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
873 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
874 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
875 | } |
|
|
876 | } |
820 | |
877 | |
821 | void |
878 | void |
822 | Mix_CloseAudio () |
879 | Mix_CloseAudio () |
823 | |
880 | |
824 | int |
881 | int |
… | |
… | |
859 | } |
916 | } |
860 | } |
917 | } |
861 | #endif |
918 | #endif |
862 | } |
919 | } |
863 | |
920 | |
864 | void |
921 | int |
865 | add_font (char *file) |
922 | add_font (char *file) |
866 | CODE: |
923 | CODE: |
867 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
924 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
|
|
925 | OUTPUT: |
|
|
926 | RETVAL |
868 | |
927 | |
869 | void |
928 | void |
870 | load_image_inline (SV *image_) |
929 | load_image_inline (SV *image_) |
871 | ALIAS: |
930 | ALIAS: |
872 | load_image_file = 1 |
931 | load_image_file = 1 |
… | |
… | |
958 | void |
1017 | void |
959 | error (char *message) |
1018 | error (char *message) |
960 | CODE: |
1019 | CODE: |
961 | fprintf (stderr, "ERROR: %s\n", message); |
1020 | fprintf (stderr, "ERROR: %s\n", message); |
962 | #ifdef _WIN32 |
1021 | #ifdef _WIN32 |
963 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1022 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
964 | #endif |
1023 | #endif |
965 | |
1024 | |
966 | void |
1025 | void |
967 | fatal (char *message) |
1026 | fatal (char *message) |
968 | CODE: |
1027 | CODE: |
969 | fprintf (stderr, "FATAL: %s\n", message); |
1028 | fprintf (stderr, "FATAL: %s\n", message); |
970 | #ifdef _WIN32 |
1029 | #ifdef _WIN32 |
971 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1030 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
972 | #endif |
1031 | #endif |
973 | _exit (1); |
1032 | _exit (1); |
974 | |
1033 | |
975 | void |
1034 | void |
976 | _exit (int retval = 0) |
1035 | _exit (int retval = 0) |
… | |
… | |
988 | #if DEBUG |
1047 | #if DEBUG |
989 | VALGRIND_DO_LEAK_CHECK; |
1048 | VALGRIND_DO_LEAK_CHECK; |
990 | #endif |
1049 | #endif |
991 | } |
1050 | } |
992 | |
1051 | |
993 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1052 | MODULE = Deliantra::Client PACKAGE = DC::Font |
994 | |
1053 | |
995 | PROTOTYPES: DISABLE |
1054 | PROTOTYPES: DISABLE |
996 | |
1055 | |
997 | CFPlus::Font |
1056 | DC::Font |
998 | new_from_file (SV *class, char *path, int id = 0) |
1057 | new_from_file (SV *class, char *path, int id = 0) |
999 | CODE: |
1058 | CODE: |
1000 | { |
1059 | { |
1001 | int count; |
1060 | int count; |
1002 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1061 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1005 | } |
1064 | } |
1006 | OUTPUT: |
1065 | OUTPUT: |
1007 | RETVAL |
1066 | RETVAL |
1008 | |
1067 | |
1009 | void |
1068 | void |
1010 | DESTROY (CFPlus::Font self) |
1069 | DESTROY (DC::Font self) |
1011 | CODE: |
1070 | CODE: |
1012 | pango_font_description_free (self); |
1071 | pango_font_description_free (self); |
1013 | |
1072 | |
1014 | void |
1073 | void |
1015 | make_default (CFPlus::Font self) |
1074 | make_default (DC::Font self) |
1016 | PROTOTYPE: $ |
1075 | PROTOTYPE: $ |
1017 | CODE: |
1076 | CODE: |
1018 | default_font = self; |
1077 | default_font = self; |
1019 | |
1078 | |
1020 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1079 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1021 | |
1080 | |
1022 | PROTOTYPES: DISABLE |
1081 | PROTOTYPES: DISABLE |
1023 | |
1082 | |
1024 | void |
1083 | void |
1025 | reset_glyph_cache () |
1084 | glyph_cache_backup () |
1026 | PROTOTYPE: |
1085 | PROTOTYPE: |
1027 | CODE: |
1086 | CODE: |
|
|
1087 | tc_backup (); |
|
|
1088 | |
|
|
1089 | void |
|
|
1090 | glyph_cache_restore () |
|
|
1091 | PROTOTYPE: |
|
|
1092 | CODE: |
1028 | tc_clear (); |
1093 | tc_restore (); |
1029 | |
1094 | |
1030 | CFPlus::Layout |
1095 | DC::Layout |
1031 | new (SV *class) |
1096 | new (SV *class) |
1032 | CODE: |
1097 | CODE: |
1033 | New (0, RETVAL, 1, struct cf_layout); |
1098 | New (0, RETVAL, 1, struct cf_layout); |
1034 | |
1099 | |
1035 | RETVAL->pl = pango_layout_new (opengl_context); |
1100 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1045 | layout_update_font (RETVAL); |
1110 | layout_update_font (RETVAL); |
1046 | OUTPUT: |
1111 | OUTPUT: |
1047 | RETVAL |
1112 | RETVAL |
1048 | |
1113 | |
1049 | void |
1114 | void |
1050 | DESTROY (CFPlus::Layout self) |
1115 | DESTROY (DC::Layout self) |
1051 | CODE: |
1116 | CODE: |
1052 | g_object_unref (self->pl); |
1117 | g_object_unref (self->pl); |
1053 | rc_free (self->rc); |
1118 | rc_free (self->rc); |
1054 | Safefree (self); |
1119 | Safefree (self); |
1055 | |
1120 | |
1056 | void |
1121 | void |
1057 | set_text (CFPlus::Layout self, SV *text_) |
1122 | set_text (DC::Layout self, SV *text_) |
1058 | CODE: |
1123 | CODE: |
1059 | { |
1124 | { |
1060 | STRLEN textlen; |
1125 | STRLEN textlen; |
1061 | char *text = SvPVutf8 (text_, textlen); |
1126 | char *text = SvPVutf8 (text_, textlen); |
1062 | |
1127 | |
1063 | pango_layout_set_text (self->pl, text, textlen); |
1128 | pango_layout_set_text (self->pl, text, textlen); |
1064 | } |
1129 | } |
1065 | |
1130 | |
1066 | void |
1131 | void |
1067 | set_markup (CFPlus::Layout self, SV *text_) |
1132 | set_markup (DC::Layout self, SV *text_) |
1068 | CODE: |
1133 | CODE: |
1069 | { |
1134 | { |
1070 | STRLEN textlen; |
1135 | STRLEN textlen; |
1071 | char *text = SvPVutf8 (text_, textlen); |
1136 | char *text = SvPVutf8 (text_, textlen); |
1072 | |
1137 | |
1073 | pango_layout_set_markup (self->pl, text, textlen); |
1138 | pango_layout_set_markup (self->pl, text, textlen); |
1074 | } |
1139 | } |
1075 | |
1140 | |
1076 | void |
1141 | void |
1077 | set_shapes (CFPlus::Layout self, ...) |
1142 | set_shapes (DC::Layout self, ...) |
1078 | CODE: |
1143 | CODE: |
1079 | { |
1144 | { |
1080 | PangoAttrList *attrs = 0; |
1145 | PangoAttrList *attrs = 0; |
1081 | const char *text = pango_layout_get_text (self->pl); |
1146 | const char *text = pango_layout_get_text (self->pl); |
1082 | const char *pos = text; |
1147 | const char *pos = text; |
… | |
… | |
1117 | if (attrs) |
1182 | if (attrs) |
1118 | pango_layout_set_attributes (self->pl, attrs); |
1183 | pango_layout_set_attributes (self->pl, attrs); |
1119 | } |
1184 | } |
1120 | |
1185 | |
1121 | void |
1186 | void |
1122 | get_shapes (CFPlus::Layout self) |
1187 | get_shapes (DC::Layout self) |
1123 | PPCODE: |
1188 | PPCODE: |
1124 | { |
1189 | { |
1125 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1190 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1126 | |
1191 | |
1127 | do |
1192 | do |
1128 | { |
1193 | { |
1129 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1194 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1130 | |
1195 | |
1131 | if (run && shape_attr_p (run)) |
1196 | if (run && shape_attr_p (run)) |
1132 | { |
1197 | { |
1133 | PangoRectangle extents; |
1198 | PangoRectangle extents; |
1134 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1199 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1142 | |
1207 | |
1143 | pango_layout_iter_free (iter); |
1208 | pango_layout_iter_free (iter); |
1144 | } |
1209 | } |
1145 | |
1210 | |
1146 | int |
1211 | int |
1147 | has_wrapped (CFPlus::Layout self) |
1212 | has_wrapped (DC::Layout self) |
1148 | CODE: |
1213 | CODE: |
1149 | { |
1214 | { |
1150 | int lines = 1; |
1215 | int lines = 1; |
1151 | const char *text = pango_layout_get_text (self->pl); |
1216 | const char *text = pango_layout_get_text (self->pl); |
1152 | |
1217 | |
… | |
… | |
1157 | } |
1222 | } |
1158 | OUTPUT: |
1223 | OUTPUT: |
1159 | RETVAL |
1224 | RETVAL |
1160 | |
1225 | |
1161 | SV * |
1226 | SV * |
1162 | get_text (CFPlus::Layout self) |
1227 | get_text (DC::Layout self) |
1163 | CODE: |
1228 | CODE: |
1164 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1229 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1165 | sv_utf8_decode (RETVAL); |
1230 | sv_utf8_decode (RETVAL); |
1166 | OUTPUT: |
1231 | OUTPUT: |
1167 | RETVAL |
1232 | RETVAL |
1168 | |
1233 | |
1169 | void |
1234 | void |
1170 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1235 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1171 | CODE: |
1236 | CODE: |
1172 | self->r = r; |
1237 | self->r = r; |
1173 | self->g = g; |
1238 | self->g = g; |
1174 | self->b = b; |
1239 | self->b = b; |
1175 | self->a = a; |
1240 | self->a = a; |
1176 | |
1241 | |
1177 | void |
1242 | void |
1178 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1243 | set_font (DC::Layout self, DC::Font font = 0) |
1179 | CODE: |
1244 | CODE: |
1180 | if (self->font != font) |
1245 | if (self->font != font) |
1181 | { |
1246 | { |
1182 | self->font = font; |
1247 | self->font = font; |
1183 | layout_update_font (self); |
1248 | layout_update_font (self); |
1184 | } |
1249 | } |
1185 | |
1250 | |
1186 | void |
1251 | void |
1187 | set_height (CFPlus::Layout self, int base_height) |
1252 | set_height (DC::Layout self, int base_height) |
1188 | CODE: |
1253 | CODE: |
1189 | if (self->base_height != base_height) |
1254 | if (self->base_height != base_height) |
1190 | { |
1255 | { |
1191 | self->base_height = base_height; |
1256 | self->base_height = base_height; |
1192 | layout_update_font (self); |
1257 | layout_update_font (self); |
1193 | } |
1258 | } |
1194 | |
1259 | |
1195 | void |
1260 | void |
1196 | set_width (CFPlus::Layout self, int max_width = -1) |
1261 | set_width (DC::Layout self, int max_width = -1) |
1197 | CODE: |
1262 | CODE: |
1198 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1263 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1199 | |
1264 | |
1200 | void |
1265 | void |
1201 | set_indent (CFPlus::Layout self, int indent) |
1266 | set_indent (DC::Layout self, int indent) |
1202 | CODE: |
1267 | CODE: |
1203 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1268 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1204 | |
1269 | |
1205 | void |
1270 | void |
1206 | set_spacing (CFPlus::Layout self, int spacing) |
1271 | set_spacing (DC::Layout self, int spacing) |
1207 | CODE: |
1272 | CODE: |
1208 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1273 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1209 | |
1274 | |
1210 | void |
1275 | void |
1211 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1276 | set_ellipsise (DC::Layout self, int ellipsise) |
1212 | CODE: |
1277 | CODE: |
1213 | pango_layout_set_ellipsize (self->pl, |
1278 | pango_layout_set_ellipsize (self->pl, |
1214 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1279 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1215 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1280 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1216 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1281 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1217 | : PANGO_ELLIPSIZE_NONE |
1282 | : PANGO_ELLIPSIZE_NONE |
1218 | ); |
1283 | ); |
1219 | |
1284 | |
1220 | void |
1285 | void |
1221 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1286 | set_single_paragraph_mode (DC::Layout self, int spm) |
1222 | CODE: |
1287 | CODE: |
1223 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1288 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1224 | |
1289 | |
1225 | void |
1290 | void |
1226 | size (CFPlus::Layout self) |
1291 | size (DC::Layout self) |
1227 | PPCODE: |
1292 | PPCODE: |
1228 | { |
1293 | { |
1229 | int w, h; |
1294 | int w, h; |
1230 | |
1295 | |
1231 | layout_get_pixel_size (self, &w, &h); |
1296 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1234 | PUSHs (sv_2mortal (newSViv (w))); |
1299 | PUSHs (sv_2mortal (newSViv (w))); |
1235 | PUSHs (sv_2mortal (newSViv (h))); |
1300 | PUSHs (sv_2mortal (newSViv (h))); |
1236 | } |
1301 | } |
1237 | |
1302 | |
1238 | int |
1303 | int |
1239 | descent (CFPlus::Layout self) |
1304 | descent (DC::Layout self) |
1240 | CODE: |
1305 | CODE: |
1241 | { |
1306 | { |
1242 | PangoRectangle rect; |
1307 | PangoRectangle rect; |
1243 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1308 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1244 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1309 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1245 | RETVAL = PANGO_DESCENT (rect); |
1310 | RETVAL = PANGO_DESCENT (rect); |
1246 | } |
1311 | } |
1247 | OUTPUT: |
1312 | OUTPUT: |
1248 | RETVAL |
1313 | RETVAL |
1249 | |
1314 | |
1250 | int |
1315 | int |
1251 | xy_to_index (CFPlus::Layout self, int x, int y) |
1316 | xy_to_index (DC::Layout self, int x, int y) |
1252 | CODE: |
1317 | CODE: |
1253 | { |
1318 | { |
1254 | int index, trailing; |
1319 | int index, trailing; |
1255 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1320 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1256 | RETVAL = index + trailing; |
1321 | RETVAL = index + trailing; |
1257 | } |
1322 | } |
1258 | OUTPUT: |
1323 | OUTPUT: |
1259 | RETVAL |
1324 | RETVAL |
1260 | |
1325 | |
1261 | void |
1326 | void |
1262 | cursor_pos (CFPlus::Layout self, int index) |
1327 | cursor_pos (DC::Layout self, int index) |
1263 | PPCODE: |
1328 | PPCODE: |
1264 | { |
1329 | { |
1265 | PangoRectangle strong_pos; |
1330 | PangoRectangle pos; |
1266 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1331 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1267 | |
1332 | |
1268 | EXTEND (SP, 3); |
1333 | EXTEND (SP, 3); |
1269 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1334 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1270 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1335 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1271 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1336 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1272 | } |
1337 | } |
1273 | |
1338 | |
1274 | void |
1339 | void |
1275 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1340 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1276 | PPCODE: |
1341 | PPCODE: |
1277 | { |
1342 | { |
1278 | int line, x; |
1343 | int line, x; |
1279 | |
1344 | |
1280 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1345 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1346 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1281 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1347 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1282 | |
1348 | --line; |
|
|
1349 | #endif |
1283 | EXTEND (SP, 2); |
1350 | EXTEND (SP, 2); |
1284 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1351 | PUSHs (sv_2mortal (newSViv (line))); |
1285 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1352 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1286 | } |
1353 | } |
1287 | |
1354 | |
1288 | void |
1355 | void |
1289 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1356 | line_x_to_index (DC::Layout self, int line, int x) |
1290 | PPCODE: |
1357 | PPCODE: |
1291 | { |
1358 | { |
1292 | PangoLayoutLine *lp; |
1359 | PangoLayoutLine *lp; |
1293 | int index, trailing; |
1360 | int index, trailing; |
1294 | |
1361 | |
1295 | if (line < 0) |
1362 | if (line < 0) |
1296 | XSRETURN_EMPTY; |
1363 | XSRETURN_EMPTY; |
1297 | |
1364 | |
1298 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1365 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1299 | XSRETURN_EMPTY; /* do better */ |
1366 | XSRETURN_EMPTY; /* do better */ |
1300 | |
1367 | |
1301 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1368 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1302 | |
1369 | |
1303 | EXTEND (SP, 2); |
1370 | EXTEND (SP, 2); |
… | |
… | |
1309 | PUSHs (sv_2mortal (newSViv (trailing))); |
1376 | PUSHs (sv_2mortal (newSViv (trailing))); |
1310 | } |
1377 | } |
1311 | } |
1378 | } |
1312 | |
1379 | |
1313 | void |
1380 | void |
1314 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1381 | render (DC::Layout self, float x, float y, int flags = 0) |
1315 | CODE: |
1382 | CODE: |
1316 | rc_clear (self->rc); |
1383 | rc_clear (self->rc); |
1317 | pango_opengl_render_layout_subpixel ( |
1384 | pango_opengl_render_layout_subpixel ( |
1318 | self->pl, |
1385 | self->pl, |
1319 | self->rc, |
1386 | self->rc, |
… | |
… | |
1324 | // we assume that context_change actually clears/frees stuff |
1391 | // we assume that context_change actually clears/frees stuff |
1325 | // and does not do any recomputation... |
1392 | // and does not do any recomputation... |
1326 | pango_layout_context_changed (self->pl); |
1393 | pango_layout_context_changed (self->pl); |
1327 | |
1394 | |
1328 | void |
1395 | void |
1329 | draw (CFPlus::Layout self) |
1396 | draw (DC::Layout self) |
1330 | CODE: |
1397 | CODE: |
1331 | { |
1398 | { |
1332 | glEnable (GL_TEXTURE_2D); |
1399 | glEnable (GL_TEXTURE_2D); |
1333 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1400 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1334 | glEnable (GL_BLEND); |
1401 | glEnable (GL_BLEND); |
… | |
… | |
1342 | glDisable (GL_ALPHA_TEST); |
1409 | glDisable (GL_ALPHA_TEST); |
1343 | glDisable (GL_BLEND); |
1410 | glDisable (GL_BLEND); |
1344 | glDisable (GL_TEXTURE_2D); |
1411 | glDisable (GL_TEXTURE_2D); |
1345 | } |
1412 | } |
1346 | |
1413 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1414 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1348 | |
1415 | |
1349 | PROTOTYPES: ENABLE |
1416 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1417 | |
1353 | void |
1418 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1419 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1420 | CODE: |
1356 | { |
1421 | { |
… | |
… | |
1433 | RETVAL = width > 0; |
1498 | RETVAL = width > 0; |
1434 | } |
1499 | } |
1435 | OUTPUT: |
1500 | OUTPUT: |
1436 | RETVAL |
1501 | RETVAL |
1437 | |
1502 | |
1438 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1503 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1439 | |
1504 | |
1440 | PROTOTYPES: DISABLE |
1505 | PROTOTYPES: DISABLE |
1441 | |
1506 | |
1442 | CFPlus::Map |
1507 | DC::Map |
1443 | new (SV *class) |
1508 | new (SV *class) |
1444 | CODE: |
1509 | CODE: |
1445 | New (0, RETVAL, 1, struct map); |
1510 | New (0, RETVAL, 1, struct map); |
1446 | RETVAL->x = 0; |
1511 | RETVAL->x = 0; |
1447 | RETVAL->y = 0; |
1512 | RETVAL->y = 0; |
… | |
… | |
1455 | RETVAL->row = 0; |
1520 | RETVAL->row = 0; |
1456 | OUTPUT: |
1521 | OUTPUT: |
1457 | RETVAL |
1522 | RETVAL |
1458 | |
1523 | |
1459 | void |
1524 | void |
1460 | DESTROY (CFPlus::Map self) |
1525 | DESTROY (DC::Map self) |
1461 | CODE: |
1526 | CODE: |
1462 | { |
1527 | { |
1463 | map_clear (self); |
1528 | map_clear (self); |
1464 | Safefree (self->face2tile); |
1529 | Safefree (self->face2tile); |
1465 | Safefree (self->tex); |
1530 | Safefree (self->tex); |
1466 | Safefree (self); |
1531 | Safefree (self); |
1467 | } |
1532 | } |
1468 | |
1533 | |
1469 | void |
1534 | void |
1470 | resize (CFPlus::Map self, int map_width, int map_height) |
1535 | resize (DC::Map self, int map_width, int map_height) |
1471 | CODE: |
1536 | CODE: |
1472 | self->w = map_width; |
1537 | self->w = map_width; |
1473 | self->h = map_height; |
1538 | self->h = map_height; |
1474 | |
1539 | |
1475 | void |
1540 | void |
1476 | clear (CFPlus::Map self) |
1541 | clear (DC::Map self) |
1477 | CODE: |
1542 | CODE: |
1478 | map_clear (self); |
1543 | map_clear (self); |
1479 | |
1544 | |
1480 | void |
1545 | void |
1481 | set_tileid (CFPlus::Map self, int face, int tile) |
1546 | set_tileid (DC::Map self, int face, int tile) |
1482 | CODE: |
1547 | CODE: |
1483 | { |
1548 | { |
1484 | need_facenum (self, face); self->face2tile [face] = tile; |
1549 | need_facenum (self, face); self->face2tile [face] = tile; |
1485 | need_texid (self, tile); |
1550 | need_texid (self, tile); |
1486 | } |
1551 | } |
1487 | |
1552 | |
1488 | void |
1553 | void |
1489 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1554 | set_smooth (DC::Map self, int face, int smooth, int level) |
1490 | CODE: |
1555 | CODE: |
1491 | { |
1556 | { |
1492 | tileid texid; |
1557 | tileid texid; |
1493 | maptex *tex; |
1558 | maptex *tex; |
1494 | |
1559 | |
… | |
… | |
1507 | tex->smoothtile = self->face2tile [smooth]; |
1572 | tex->smoothtile = self->face2tile [smooth]; |
1508 | tex->smoothlevel = level; |
1573 | tex->smoothlevel = level; |
1509 | } |
1574 | } |
1510 | |
1575 | |
1511 | void |
1576 | 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) |
1577 | 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: |
1578 | CODE: |
1514 | { |
1579 | { |
1515 | need_texid (self, texid); |
1580 | need_texid (self, texid); |
1516 | |
1581 | |
1517 | { |
1582 | { |
… | |
… | |
1537 | // from transparent color bleeding and ugly wrapping effects. |
1602 | // from transparent color bleeding and ugly wrapping effects. |
1538 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1603 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1539 | } |
1604 | } |
1540 | |
1605 | |
1541 | int |
1606 | int |
1542 | ox (CFPlus::Map self) |
1607 | ox (DC::Map self) |
1543 | ALIAS: |
1608 | ALIAS: |
1544 | oy = 1 |
1609 | oy = 1 |
1545 | x = 2 |
1610 | x = 2 |
1546 | y = 3 |
1611 | y = 3 |
1547 | w = 4 |
1612 | w = 4 |
… | |
… | |
1558 | } |
1623 | } |
1559 | OUTPUT: |
1624 | OUTPUT: |
1560 | RETVAL |
1625 | RETVAL |
1561 | |
1626 | |
1562 | void |
1627 | void |
1563 | scroll (CFPlus::Map self, int dx, int dy) |
1628 | scroll (DC::Map self, int dx, int dy) |
1564 | CODE: |
1629 | CODE: |
1565 | { |
1630 | { |
1566 | if (dx > 0) |
1631 | if (dx > 0) |
1567 | map_blank (self, self->x, self->y, dx, self->h); |
1632 | map_blank (self, self->x, self->y, dx, self->h); |
1568 | else if (dx < 0) |
1633 | else if (dx < 0) |
… | |
… | |
1584 | self->y += MAP_EXTEND_Y; |
1649 | self->y += MAP_EXTEND_Y; |
1585 | } |
1650 | } |
1586 | } |
1651 | } |
1587 | |
1652 | |
1588 | SV * |
1653 | SV * |
1589 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1654 | map1a_update (DC::Map self, SV *data_, int extmap) |
1590 | CODE: |
1655 | CODE: |
1591 | { |
1656 | { |
1592 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1657 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1593 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1658 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1594 | mapcell *cell; |
1659 | mapcell *cell; |
… | |
… | |
1683 | } |
1748 | } |
1684 | OUTPUT: |
1749 | OUTPUT: |
1685 | RETVAL |
1750 | RETVAL |
1686 | |
1751 | |
1687 | SV * |
1752 | SV * |
1688 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1753 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1689 | CODE: |
1754 | CODE: |
1690 | { |
1755 | { |
1691 | int x1, x; |
1756 | int x1, x; |
1692 | int y1, y; |
1757 | int y1, y; |
1693 | int z; |
1758 | int z; |
… | |
… | |
1738 | } |
1803 | } |
1739 | OUTPUT: |
1804 | OUTPUT: |
1740 | RETVAL |
1805 | RETVAL |
1741 | |
1806 | |
1742 | void |
1807 | void |
1743 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1808 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1744 | CODE: |
1809 | CODE: |
1745 | { |
1810 | { |
1746 | int x, y, z; |
1811 | int x, y, z; |
1747 | |
1812 | |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1813 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2019 | } |
2084 | } |
2020 | } |
2085 | } |
2021 | } |
2086 | } |
2022 | |
2087 | |
2023 | void |
2088 | void |
2024 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2089 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2025 | CODE: |
2090 | CODE: |
2026 | { |
2091 | { |
2027 | static float color[16][3] = { |
2092 | static float color[16][3] = { |
2028 | { 0.00F, 0.00F, 0.00F }, |
2093 | { 0.00F, 0.00F, 0.00F }, |
2029 | { 1.00F, 1.00F, 1.00F }, |
2094 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2079 | glDisable (GL_BLEND); |
2144 | glDisable (GL_BLEND); |
2080 | glDisable (GL_TEXTURE_2D); |
2145 | glDisable (GL_TEXTURE_2D); |
2081 | } |
2146 | } |
2082 | |
2147 | |
2083 | void |
2148 | void |
2084 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2149 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2085 | PPCODE: |
2150 | PPCODE: |
2086 | { |
2151 | { |
2087 | int x, y; |
2152 | int x, y; |
2088 | int sw1 = sw + 2; |
2153 | int sw1 = sw + 2; |
2089 | int sh1 = sh + 2; |
2154 | int sh1 = sh + 2; |
… | |
… | |
2160 | PUSHs (sv_2mortal (newSViv (sh3))); |
2225 | PUSHs (sv_2mortal (newSViv (sh3))); |
2161 | PUSHs (darkness3_sv); |
2226 | PUSHs (darkness3_sv); |
2162 | } |
2227 | } |
2163 | |
2228 | |
2164 | SV * |
2229 | SV * |
2165 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2230 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2166 | CODE: |
2231 | CODE: |
2167 | { |
2232 | { |
2168 | int x, y, x1, y1; |
2233 | int x, y, x1, y1; |
2169 | SV *data_sv = newSV (w * h * 7 + 5); |
2234 | SV *data_sv = newSV (w * h * 7 + 5); |
2170 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2235 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2227 | else |
2292 | else |
2228 | *data++ = 0; |
2293 | *data++ = 0; |
2229 | } |
2294 | } |
2230 | } |
2295 | } |
2231 | |
2296 | |
|
|
2297 | /* if size is w*h + 5 then no data has been found */ |
|
|
2298 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
|
|
2299 | { |
2232 | SvPOK_only (data_sv); |
2300 | SvPOK_only (data_sv); |
2233 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2301 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2302 | } |
|
|
2303 | |
2234 | RETVAL = data_sv; |
2304 | RETVAL = data_sv; |
2235 | } |
2305 | } |
2236 | OUTPUT: |
2306 | OUTPUT: |
2237 | RETVAL |
2307 | RETVAL |
2238 | |
2308 | |
2239 | void |
2309 | void |
2240 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2310 | set_rect (DC::Map self, int x0, int y0, SV *data_sv) |
2241 | PPCODE: |
2311 | PPCODE: |
2242 | { |
2312 | { |
2243 | int x, y, z; |
2313 | int x, y, z; |
2244 | int w, h; |
2314 | int w, h; |
2245 | int x1, y1; |
2315 | int x1, y1; |
|
|
2316 | STRLEN len; |
|
|
2317 | uint8_t *data, *end; |
|
|
2318 | |
|
|
2319 | len = SvLEN (data_sv); |
|
|
2320 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
|
|
2321 | data = SvPVbyte_nolen (data_sv); |
|
|
2322 | end = data + len + 8; |
|
|
2323 | |
|
|
2324 | if (len < 5) |
|
|
2325 | XSRETURN_EMPTY; |
2246 | |
2326 | |
2247 | if (*data++ != 0) |
2327 | if (*data++ != 0) |
2248 | XSRETURN_EMPTY; /* version mismatch */ |
2328 | XSRETURN_EMPTY; /* version mismatch */ |
2249 | |
2329 | |
2250 | w = *data++ << 8; w |= *data++; |
2330 | w = *data++ << 8; w |= *data++; |
… | |
… | |
2265 | { |
2345 | { |
2266 | maprow *row = map_get_row (self, y); |
2346 | maprow *row = map_get_row (self, y); |
2267 | |
2347 | |
2268 | for (x = x0; x < x1; x++) |
2348 | for (x = x0; x < x1; x++) |
2269 | { |
2349 | { |
|
|
2350 | uint8_t flags; |
|
|
2351 | |
|
|
2352 | if (data + 7 >= end) |
|
|
2353 | XSRETURN_EMPTY; |
|
|
2354 | |
2270 | uint8_t flags = *data++; |
2355 | flags = *data++; |
2271 | |
2356 | |
2272 | if (flags) |
2357 | if (flags) |
2273 | { |
2358 | { |
2274 | mapcell *cell = row_get_cell (row, x); |
2359 | mapcell *cell = row_get_cell (row, x); |
2275 | tileid tile[3] = { 0, 0, 0 }; |
2360 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2278 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2363 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2279 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2364 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2280 | |
2365 | |
2281 | if (cell->darkness == 0) |
2366 | if (cell->darkness == 0) |
2282 | { |
2367 | { |
2283 | cell->darkness = 0; |
2368 | /*cell->darkness = 0;*/ |
|
|
2369 | EXTEND (SP, 3); |
2284 | |
2370 | |
2285 | for (z = 0; z <= 2; z++) |
2371 | for (z = 0; z <= 2; z++) |
2286 | { |
2372 | { |
2287 | tileid t = tile [z]; |
2373 | tileid t = tile [z]; |
2288 | |
2374 | |
2289 | if (t >= self->texs || (t && !self->tex [t].name)) |
2375 | if (t >= self->texs || (t && !self->tex [t].name)) |
2290 | { |
2376 | { |
2291 | XPUSHs (sv_2mortal (newSViv (t))); |
2377 | PUSHs (sv_2mortal (newSViv (t))); |
2292 | need_texid (self, t); |
2378 | need_texid (self, t); |
2293 | } |
2379 | } |
2294 | |
2380 | |
2295 | cell->tile [z] = t; |
2381 | cell->tile [z] = t; |
2296 | } |
2382 | } |
… | |
… | |
2298 | } |
2384 | } |
2299 | } |
2385 | } |
2300 | } |
2386 | } |
2301 | } |
2387 | } |
2302 | |
2388 | |
2303 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2389 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2304 | |
2390 | |
2305 | CFPlus::RW |
2391 | DC::RW |
2306 | new (SV *class, SV *data_sv) |
2392 | new (SV *class, SV *data_sv) |
2307 | CODE: |
2393 | CODE: |
2308 | { |
2394 | { |
2309 | STRLEN datalen; |
2395 | STRLEN datalen; |
2310 | char *data = SvPVbyte (data_sv, datalen); |
2396 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2312 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2398 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2313 | } |
2399 | } |
2314 | OUTPUT: |
2400 | OUTPUT: |
2315 | RETVAL |
2401 | RETVAL |
2316 | |
2402 | |
2317 | CFPlus::RW |
2403 | DC::RW |
2318 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2404 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2319 | CODE: |
2405 | CODE: |
2320 | RETVAL = SDL_RWFromFile (path, mode); |
2406 | RETVAL = SDL_RWFromFile (path, mode); |
2321 | OUTPUT: |
2407 | OUTPUT: |
2322 | RETVAL |
2408 | RETVAL |
2323 | |
2409 | |
2324 | # fails on win32: |
2410 | # fails on win32: |
2325 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2411 | # dc.xs(2268) : error C2059: syntax error : '(' |
2326 | #void |
2412 | #void |
2327 | #close (CFPlus::RW self) |
2413 | #close (DC::RW self) |
2328 | # CODE: |
2414 | # CODE: |
2329 | # (self->(close)) (self); |
2415 | # (self->(close)) (self); |
2330 | |
2416 | |
2331 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2417 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2332 | |
2418 | |
2333 | PROTOTYPES: DISABLE |
2419 | PROTOTYPES: DISABLE |
2334 | |
2420 | |
2335 | CFPlus::Channel |
2421 | DC::Channel |
2336 | find () |
2422 | find () |
2337 | CODE: |
2423 | CODE: |
2338 | { |
2424 | { |
2339 | RETVAL = Mix_GroupAvailable (-1); |
2425 | RETVAL = Mix_GroupAvailable (-1); |
2340 | |
2426 | |
… | |
… | |
2353 | } |
2439 | } |
2354 | OUTPUT: |
2440 | OUTPUT: |
2355 | RETVAL |
2441 | RETVAL |
2356 | |
2442 | |
2357 | void |
2443 | void |
2358 | halt (CFPlus::Channel self) |
2444 | halt (DC::Channel self) |
2359 | CODE: |
2445 | CODE: |
2360 | Mix_HaltChannel (self); |
2446 | Mix_HaltChannel (self); |
2361 | |
2447 | |
2362 | void |
2448 | void |
2363 | expire (CFPlus::Channel self, int ticks = -1) |
2449 | expire (DC::Channel self, int ticks = -1) |
2364 | CODE: |
2450 | CODE: |
2365 | Mix_ExpireChannel (self, ticks); |
2451 | Mix_ExpireChannel (self, ticks); |
2366 | |
2452 | |
2367 | void |
2453 | void |
2368 | fade_out (CFPlus::Channel self, int ticks = -1) |
2454 | fade_out (DC::Channel self, int ticks = -1) |
2369 | CODE: |
2455 | CODE: |
2370 | Mix_FadeOutChannel (self, ticks); |
2456 | Mix_FadeOutChannel (self, ticks); |
2371 | |
2457 | |
2372 | int |
2458 | int |
2373 | volume (CFPlus::Channel self, int volume) |
2459 | volume (DC::Channel self, int volume) |
2374 | CODE: |
2460 | CODE: |
2375 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2461 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2376 | OUTPUT: |
2462 | OUTPUT: |
2377 | RETVAL |
2463 | RETVAL |
2378 | |
2464 | |
2379 | void |
2465 | void |
2380 | unregister_all_effects (CFPlus::Channel self) |
2466 | unregister_all_effects (DC::Channel self) |
2381 | CODE: |
2467 | CODE: |
2382 | Mix_UnregisterAllEffects (self); |
2468 | Mix_UnregisterAllEffects (self); |
2383 | |
2469 | |
2384 | void |
2470 | void |
2385 | set_panning (CFPlus::Channel self, int left, int right) |
2471 | set_panning (DC::Channel self, int left, int right) |
2386 | CODE: |
2472 | CODE: |
2387 | left = CLAMP (left , 0, 255); |
2473 | left = CLAMP (left , 0, 255); |
2388 | right = CLAMP (right, 0, 255); |
2474 | right = CLAMP (right, 0, 255); |
2389 | Mix_SetPanning (self, left, right); |
2475 | Mix_SetPanning (self, left, right); |
2390 | |
2476 | |
2391 | void |
2477 | void |
2392 | set_distance (CFPlus::Channel self, int distance) |
2478 | set_distance (DC::Channel self, int distance) |
2393 | CODE: |
2479 | CODE: |
2394 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2480 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2395 | |
2481 | |
2396 | void |
2482 | void |
2397 | set_position (CFPlus::Channel self, int angle, int distance) |
2483 | set_position (DC::Channel self, int angle, int distance) |
2398 | CODE: |
2484 | CODE: |
2399 | |
2485 | |
2400 | void |
2486 | void |
2401 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2487 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2402 | CODE: |
2488 | CODE: |
2403 | { |
2489 | { |
2404 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2490 | 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); |
2491 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2406 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2492 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2407 | } |
2493 | } |
2408 | |
2494 | |
2409 | void |
2495 | void |
2410 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2496 | set_reverse_stereo (DC::Channel self, int flip) |
2411 | CODE: |
2497 | CODE: |
2412 | Mix_SetReverseStereo (self, flip); |
2498 | Mix_SetReverseStereo (self, flip); |
2413 | |
2499 | |
2414 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2500 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2415 | |
2501 | |
2416 | PROTOTYPES: DISABLE |
2502 | PROTOTYPES: DISABLE |
2417 | |
2503 | |
2418 | CFPlus::MixChunk |
2504 | DC::MixChunk |
2419 | new (SV *class, CFPlus::RW rwops) |
2505 | new (SV *class, DC::RW rwops) |
2420 | CODE: |
2506 | CODE: |
2421 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2507 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2422 | OUTPUT: |
2508 | OUTPUT: |
2423 | RETVAL |
2509 | RETVAL |
2424 | |
2510 | |
2425 | void |
2511 | void |
2426 | DESTROY (CFPlus::MixChunk self) |
2512 | DESTROY (DC::MixChunk self) |
2427 | CODE: |
2513 | CODE: |
2428 | Mix_FreeChunk (self); |
2514 | Mix_FreeChunk (self); |
2429 | |
2515 | |
2430 | int |
2516 | int |
2431 | volume (CFPlus::MixChunk self, int volume = -1) |
2517 | volume (DC::MixChunk self, int volume = -1) |
2432 | CODE: |
2518 | CODE: |
2433 | if (items > 1) |
2519 | if (items > 1) |
2434 | volume = CLAMP (volume, 0, 128); |
2520 | volume = CLAMP (volume, 0, 128); |
2435 | RETVAL = Mix_VolumeChunk (self, volume); |
2521 | RETVAL = Mix_VolumeChunk (self, volume); |
2436 | OUTPUT: |
2522 | OUTPUT: |
2437 | RETVAL |
2523 | RETVAL |
2438 | |
2524 | |
2439 | CFPlus::Channel |
2525 | DC::Channel |
2440 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2526 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2441 | CODE: |
2527 | CODE: |
2442 | { |
2528 | { |
2443 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2529 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2444 | |
2530 | |
2445 | if (RETVAL < 0) |
2531 | if (RETVAL < 0) |
… | |
… | |
2452 | } |
2538 | } |
2453 | } |
2539 | } |
2454 | OUTPUT: |
2540 | OUTPUT: |
2455 | RETVAL |
2541 | RETVAL |
2456 | |
2542 | |
2457 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2543 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2458 | |
2544 | |
2459 | int |
2545 | int |
2460 | volume (int volume = -1) |
2546 | volume (int volume = -1) |
2461 | PROTOTYPE: ;$ |
2547 | PROTOTYPE: ;$ |
2462 | CODE: |
2548 | CODE: |
… | |
… | |
2474 | void |
2560 | void |
2475 | halt () |
2561 | halt () |
2476 | CODE: |
2562 | CODE: |
2477 | Mix_HaltMusic (); |
2563 | Mix_HaltMusic (); |
2478 | |
2564 | |
2479 | CFPlus::MixMusic |
2565 | DC::MixMusic |
2480 | new (SV *class, CFPlus::RW rwops) |
2566 | new (SV *class, DC::RW rwops) |
2481 | CODE: |
2567 | CODE: |
2482 | RETVAL = Mix_LoadMUS_RW (rwops); |
2568 | RETVAL = Mix_LoadMUS_RW (rwops); |
2483 | OUTPUT: |
2569 | OUTPUT: |
2484 | RETVAL |
2570 | RETVAL |
2485 | |
2571 | |
2486 | void |
2572 | void |
2487 | DESTROY (CFPlus::MixMusic self) |
2573 | DESTROY (DC::MixMusic self) |
2488 | CODE: |
2574 | CODE: |
2489 | Mix_FreeMusic (self); |
2575 | Mix_FreeMusic (self); |
2490 | |
2576 | |
2491 | int |
2577 | int |
2492 | play (CFPlus::MixMusic self, int loops = -1) |
2578 | play (DC::MixMusic self, int loops = -1) |
2493 | CODE: |
2579 | CODE: |
2494 | RETVAL = Mix_PlayMusic (self, loops); |
2580 | RETVAL = Mix_PlayMusic (self, loops); |
2495 | OUTPUT: |
2581 | OUTPUT: |
2496 | RETVAL |
2582 | RETVAL |
2497 | |
2583 | |
2498 | void |
2584 | void |
2499 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2585 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2500 | CODE: |
2586 | CODE: |
2501 | Mix_FadeInMusicPos (self, loops, ms, position); |
2587 | Mix_FadeInMusicPos (self, loops, ms, position); |
2502 | |
2588 | |
2503 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2589 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2504 | |
2590 | |
2505 | PROTOTYPES: ENABLE |
2591 | PROTOTYPES: ENABLE |
2506 | |
2592 | |
2507 | BOOT: |
2593 | BOOT: |
2508 | { |
2594 | { |
2509 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2595 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2510 | static const struct { |
2596 | static const struct { |
2511 | const char *name; |
2597 | const char *name; |
2512 | IV iv; |
2598 | IV iv; |
2513 | } *civ, const_iv[] = { |
2599 | } *civ, const_iv[] = { |
2514 | # define const_iv(name) { # name, (IV)name } |
2600 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2603 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2689 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2604 | const_iv (GL_POINT_SMOOTH_HINT), |
2690 | const_iv (GL_POINT_SMOOTH_HINT), |
2605 | const_iv (GL_LINE_SMOOTH_HINT), |
2691 | const_iv (GL_LINE_SMOOTH_HINT), |
2606 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2692 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2607 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2693 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2694 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2608 | const_iv (GL_FASTEST), |
2695 | const_iv (GL_FASTEST), |
2609 | const_iv (GL_DONT_CARE), |
2696 | const_iv (GL_DONT_CARE), |
2610 | const_iv (GL_NICEST), |
2697 | const_iv (GL_NICEST), |
2611 | const_iv (GL_V2F), |
2698 | const_iv (GL_V2F), |
2612 | const_iv (GL_V3F), |
2699 | const_iv (GL_V3F), |
… | |
… | |
2756 | |
2843 | |
2757 | void glRect (float x1, float y1, float x2, float y2) |
2844 | void glRect (float x1, float y1, float x2, float y2) |
2758 | CODE: |
2845 | CODE: |
2759 | glRectf (x1, y1, x2, y2); |
2846 | glRectf (x1, y1, x2, y2); |
2760 | |
2847 | |
|
|
2848 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2849 | CODE: |
|
|
2850 | glBegin (GL_LINE_LOOP); |
|
|
2851 | glVertex2f (x1, y1); |
|
|
2852 | glVertex2f (x2, y1); |
|
|
2853 | glVertex2f (x2, y2); |
|
|
2854 | glVertex2f (x1, y2); |
|
|
2855 | glEnd (); |
|
|
2856 | |
2761 | PROTOTYPES: ENABLE |
2857 | PROTOTYPES: ENABLE |
2762 | |
2858 | |
2763 | void glBegin (int mode) |
2859 | void glBegin (int mode) |
2764 | |
2860 | |
2765 | void glEnd () |
2861 | void glEnd () |
… | |
… | |
2797 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2893 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2798 | CODE: |
2894 | CODE: |
2799 | if (gl.SeparableFilter2D) |
2895 | if (gl.SeparableFilter2D) |
2800 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2896 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2801 | |
2897 | |
2802 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2898 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2803 | |
2899 | |
2804 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2900 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2805 | |
2901 | |
2806 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2902 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2807 | |
2903 | |
… | |
… | |
2833 | |
2929 | |
2834 | void glEndList () |
2930 | void glEndList () |
2835 | |
2931 | |
2836 | void glCallList (int list) |
2932 | void glCallList (int list) |
2837 | |
2933 | |
2838 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2934 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2839 | |
2935 | |
2840 | PROTOTYPES: DISABLE |
2936 | PROTOTYPES: DISABLE |
2841 | |
2937 | |
2842 | void |
2938 | void |
2843 | find_widget (SV *self, NV x, NV y) |
2939 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2847 | XPUSHs (self); |
2943 | XPUSHs (self); |
2848 | } |
2944 | } |
2849 | |
2945 | |
2850 | BOOT: |
2946 | BOOT: |
2851 | { |
2947 | { |
2852 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2948 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2853 | |
2949 | |
2854 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2950 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2855 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2951 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2856 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2952 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2857 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2953 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2858 | } |
2954 | } |
2859 | |
2955 | |
2860 | void |
2956 | void |
2861 | draw (SV *self) |
2957 | draw (SV *self) |
2862 | CODE: |
2958 | CODE: |
… | |
… | |
2869 | SV *draw_w_sv = GvSV (draw_w_gv); |
2965 | SV *draw_w_sv = GvSV (draw_w_gv); |
2870 | SV *draw_h_sv = GvSV (draw_h_gv); |
2966 | SV *draw_h_sv = GvSV (draw_h_gv); |
2871 | double draw_x, draw_y; |
2967 | double draw_x, draw_y; |
2872 | |
2968 | |
2873 | if (!SvROK (self)) |
2969 | if (!SvROK (self)) |
2874 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2970 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2875 | |
2971 | |
2876 | hv = (HV *)SvRV (self); |
2972 | hv = (HV *)SvRV (self); |
2877 | |
2973 | |
2878 | if (SvTYPE (hv) != SVt_PVHV) |
2974 | if (SvTYPE (hv) != SVt_PVHV) |
2879 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2975 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2880 | |
2976 | |
2881 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2977 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2882 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2978 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2883 | |
2979 | |
2884 | if (!h || !w) |
2980 | if (!h || !w) |
… | |
… | |
2917 | glEnd (); |
3013 | glEnd (); |
2918 | glDisable (GL_BLEND); |
3014 | glDisable (GL_BLEND); |
2919 | } |
3015 | } |
2920 | } |
3016 | } |
2921 | #if 0 |
3017 | #if 0 |
2922 | if ($ENV{CFPLUS_DEBUG} & 1) { |
3018 | // draw borders, for debugging |
2923 | glPushMatrix; |
3019 | glPushMatrix (); |
2924 | glColor 1, 1, 0, 1; |
3020 | glColor4f (1., 1., 0., 1.); |
2925 | glTranslate 0.375, 0.375; |
3021 | glTranslatef (.5, .5, 0.); |
2926 | glBegin GL_LINE_LOOP; |
3022 | glBegin (GL_LINE_LOOP); |
2927 | glVertex 0 , 0; |
3023 | glVertex2f (0 , 0); |
2928 | glVertex $self->{w} - 1, 0; |
3024 | glVertex2f (w - 1, 0); |
2929 | glVertex $self->{w} - 1, $self->{h} - 1; |
3025 | glVertex2f (w - 1, h - 1); |
2930 | glVertex 0 , $self->{h} - 1; |
3026 | glVertex2f (0 , h - 1); |
2931 | glEnd; |
3027 | glEnd (); |
2932 | glPopMatrix; |
3028 | glPopMatrix (); |
2933 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2934 | } |
|
|
2935 | #endif |
3029 | #endif |
2936 | PUSHMARK (SP); |
3030 | PUSHMARK (SP); |
2937 | XPUSHs (self); |
3031 | XPUSHs (self); |
2938 | PUTBACK; |
3032 | PUTBACK; |
2939 | call_method ("_draw", G_VOID | G_DISCARD); |
3033 | call_method ("_draw", G_VOID | G_DISCARD); |