… | |
… | |
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 | |
… | |
… | |
498 | return 0; |
512 | return 0; |
499 | |
513 | |
500 | return 1; |
514 | return 1; |
501 | } |
515 | } |
502 | |
516 | |
503 | MODULE = CFPlus PACKAGE = CFPlus |
517 | MODULE = Deliantra::Client PACKAGE = DC |
504 | |
518 | |
505 | PROTOTYPES: ENABLE |
519 | PROTOTYPES: ENABLE |
506 | |
520 | |
507 | BOOT: |
521 | BOOT: |
508 | { |
522 | { |
509 | HV *stash = gv_stashpv ("CFPlus", 1); |
523 | HV *stash = gv_stashpv ("DC", 1); |
510 | static const struct { |
524 | static const struct { |
511 | const char *name; |
525 | const char *name; |
512 | IV iv; |
526 | IV iv; |
513 | } *civ, const_iv[] = { |
527 | } *civ, const_iv[] = { |
514 | # define const_iv(name) { # name, (IV)name } |
528 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
619 | const_iv (KMOD_LMETA), |
633 | const_iv (KMOD_LMETA), |
620 | const_iv (KMOD_RMETA), |
634 | const_iv (KMOD_RMETA), |
621 | const_iv (KMOD_NUM), |
635 | const_iv (KMOD_NUM), |
622 | const_iv (KMOD_CAPS), |
636 | const_iv (KMOD_CAPS), |
623 | const_iv (KMOD_MODE), |
637 | const_iv (KMOD_MODE), |
|
|
638 | |
|
|
639 | const_iv (MIX_DEFAULT_FORMAT), |
624 | # undef const_iv |
640 | # undef const_iv |
625 | }; |
641 | }; |
626 | |
642 | |
627 | 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; ) |
628 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
644 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
657 | CODE: |
673 | CODE: |
658 | { |
674 | { |
659 | opengl_fontmap = pango_opengl_font_map_new (); |
675 | opengl_fontmap = pango_opengl_font_map_new (); |
660 | 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); |
661 | 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 |
662 | } |
683 | } |
663 | |
684 | |
664 | char * |
685 | char * |
665 | SDL_GetError () |
686 | SDL_GetError () |
666 | |
687 | |
… | |
… | |
698 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
719 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
699 | |
720 | |
700 | if (m && m != (SDL_Rect **)-1) |
721 | if (m && m != (SDL_Rect **)-1) |
701 | while (*m) |
722 | while (*m) |
702 | { |
723 | { |
703 | if ((*m)->w >= 640 && (*m)->h >= 480) |
724 | if ((*m)->w >= 800 && (*m)->h >= 480) |
704 | { |
725 | { |
705 | AV *av = newAV (); |
726 | AV *av = newAV (); |
706 | av_push (av, newSViv ((*m)->w)); |
727 | av_push (av, newSViv ((*m)->w)); |
707 | av_push (av, newSViv ((*m)->h)); |
728 | av_push (av, newSViv ((*m)->h)); |
708 | av_push (av, newSViv (rgb)); |
729 | av_push (av, newSViv (rgb)); |
… | |
… | |
732 | |
753 | |
733 | if (RETVAL) |
754 | if (RETVAL) |
734 | { |
755 | { |
735 | av_clear (texture_av); |
756 | av_clear (texture_av); |
736 | |
757 | |
737 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
758 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
738 | #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); |
739 | #include "glfunc.h" |
760 | #include "glfunc.h" |
740 | #undef GL_FUNC |
761 | #undef GL_FUNC |
741 | } |
762 | } |
742 | } |
763 | } |
… | |
… | |
749 | char * |
770 | char * |
750 | SDL_GetKeyName (int sym) |
771 | SDL_GetKeyName (int sym) |
751 | |
772 | |
752 | int |
773 | int |
753 | SDL_GetAppState () |
774 | SDL_GetAppState () |
|
|
775 | |
|
|
776 | int |
|
|
777 | SDL_GetModState () |
754 | |
778 | |
755 | void |
779 | void |
756 | poll_events () |
780 | poll_events () |
757 | PPCODE: |
781 | PPCODE: |
758 | { |
782 | { |
… | |
… | |
768 | { |
792 | { |
769 | case SDL_KEYDOWN: |
793 | case SDL_KEYDOWN: |
770 | case SDL_KEYUP: |
794 | case SDL_KEYUP: |
771 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
795 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
772 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
796 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
773 | 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); |
774 | 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 */ |
775 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
799 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
776 | break; |
800 | break; |
777 | |
801 | |
778 | case SDL_ACTIVEEVENT: |
802 | case SDL_ACTIVEEVENT: |
779 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
803 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
797 | x = ev.motion.x; |
821 | x = ev.motion.x; |
798 | y = ev.motion.y; |
822 | y = ev.motion.y; |
799 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
823 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
800 | } |
824 | } |
801 | |
825 | |
802 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
826 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
803 | hv_store (hv, "state", 5, newSViv (state), 0); |
827 | hv_store (hv, "state", 5, newSViv (state), 0); |
804 | hv_store (hv, "x", 1, newSViv (x), 0); |
828 | hv_store (hv, "x", 1, newSViv (x), 0); |
805 | hv_store (hv, "y", 1, newSViv (y), 0); |
829 | hv_store (hv, "y", 1, newSViv (y), 0); |
806 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
830 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
807 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
831 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
808 | } |
832 | } |
809 | break; |
833 | break; |
810 | |
834 | |
811 | case SDL_MOUSEBUTTONDOWN: |
835 | case SDL_MOUSEBUTTONDOWN: |
812 | case SDL_MOUSEBUTTONUP: |
836 | case SDL_MOUSEBUTTONUP: |
813 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
837 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
814 | |
838 | |
815 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
839 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
816 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
840 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
817 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
841 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
818 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
842 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
823 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
847 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
824 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
848 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
825 | break; |
849 | break; |
826 | } |
850 | } |
827 | |
851 | |
828 | 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)))); |
829 | } |
853 | } |
830 | } |
854 | } |
831 | |
855 | |
832 | int |
856 | int |
833 | 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) |
834 | POSTCALL: |
858 | POSTCALL: |
835 | Mix_HookMusicFinished (music_finished); |
859 | Mix_HookMusicFinished (music_finished); |
836 | 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 | } |
837 | |
877 | |
838 | void |
878 | void |
839 | Mix_CloseAudio () |
879 | Mix_CloseAudio () |
840 | |
880 | |
841 | int |
881 | int |
… | |
… | |
876 | } |
916 | } |
877 | } |
917 | } |
878 | #endif |
918 | #endif |
879 | } |
919 | } |
880 | |
920 | |
881 | void |
921 | int |
882 | add_font (char *file) |
922 | add_font (char *file) |
883 | CODE: |
923 | CODE: |
884 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
924 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
|
|
925 | OUTPUT: |
|
|
926 | RETVAL |
885 | |
927 | |
886 | void |
928 | void |
887 | load_image_inline (SV *image_) |
929 | load_image_inline (SV *image_) |
888 | ALIAS: |
930 | ALIAS: |
889 | load_image_file = 1 |
931 | load_image_file = 1 |
… | |
… | |
975 | void |
1017 | void |
976 | error (char *message) |
1018 | error (char *message) |
977 | CODE: |
1019 | CODE: |
978 | fprintf (stderr, "ERROR: %s\n", message); |
1020 | fprintf (stderr, "ERROR: %s\n", message); |
979 | #ifdef _WIN32 |
1021 | #ifdef _WIN32 |
980 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1022 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
981 | #endif |
1023 | #endif |
982 | |
1024 | |
983 | void |
1025 | void |
984 | fatal (char *message) |
1026 | fatal (char *message) |
985 | CODE: |
1027 | CODE: |
986 | fprintf (stderr, "FATAL: %s\n", message); |
1028 | fprintf (stderr, "FATAL: %s\n", message); |
987 | #ifdef _WIN32 |
1029 | #ifdef _WIN32 |
988 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1030 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
989 | #endif |
1031 | #endif |
990 | _exit (1); |
1032 | _exit (1); |
991 | |
1033 | |
992 | void |
1034 | void |
993 | _exit (int retval = 0) |
1035 | _exit (int retval = 0) |
… | |
… | |
1005 | #if DEBUG |
1047 | #if DEBUG |
1006 | VALGRIND_DO_LEAK_CHECK; |
1048 | VALGRIND_DO_LEAK_CHECK; |
1007 | #endif |
1049 | #endif |
1008 | } |
1050 | } |
1009 | |
1051 | |
1010 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1052 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1011 | |
1053 | |
1012 | PROTOTYPES: DISABLE |
1054 | PROTOTYPES: DISABLE |
1013 | |
1055 | |
1014 | CFPlus::Font |
1056 | DC::Font |
1015 | new_from_file (SV *class, char *path, int id = 0) |
1057 | new_from_file (SV *class, char *path, int id = 0) |
1016 | CODE: |
1058 | CODE: |
1017 | { |
1059 | { |
1018 | int count; |
1060 | int count; |
1019 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1061 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1022 | } |
1064 | } |
1023 | OUTPUT: |
1065 | OUTPUT: |
1024 | RETVAL |
1066 | RETVAL |
1025 | |
1067 | |
1026 | void |
1068 | void |
1027 | DESTROY (CFPlus::Font self) |
1069 | DESTROY (DC::Font self) |
1028 | CODE: |
1070 | CODE: |
1029 | pango_font_description_free (self); |
1071 | pango_font_description_free (self); |
1030 | |
1072 | |
1031 | void |
1073 | void |
1032 | make_default (CFPlus::Font self) |
1074 | make_default (DC::Font self) |
1033 | PROTOTYPE: $ |
1075 | PROTOTYPE: $ |
1034 | CODE: |
1076 | CODE: |
1035 | default_font = self; |
1077 | default_font = self; |
1036 | |
1078 | |
1037 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1079 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1038 | |
1080 | |
1039 | PROTOTYPES: DISABLE |
1081 | PROTOTYPES: DISABLE |
1040 | |
1082 | |
1041 | void |
1083 | void |
1042 | reset_glyph_cache () |
1084 | glyph_cache_backup () |
1043 | PROTOTYPE: |
1085 | PROTOTYPE: |
1044 | CODE: |
1086 | CODE: |
|
|
1087 | tc_backup (); |
|
|
1088 | |
|
|
1089 | void |
|
|
1090 | glyph_cache_restore () |
|
|
1091 | PROTOTYPE: |
|
|
1092 | CODE: |
1045 | tc_clear (); |
1093 | tc_restore (); |
1046 | |
1094 | |
1047 | CFPlus::Layout |
1095 | DC::Layout |
1048 | new (SV *class) |
1096 | new (SV *class) |
1049 | CODE: |
1097 | CODE: |
1050 | New (0, RETVAL, 1, struct cf_layout); |
1098 | New (0, RETVAL, 1, struct cf_layout); |
1051 | |
1099 | |
1052 | RETVAL->pl = pango_layout_new (opengl_context); |
1100 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1062 | layout_update_font (RETVAL); |
1110 | layout_update_font (RETVAL); |
1063 | OUTPUT: |
1111 | OUTPUT: |
1064 | RETVAL |
1112 | RETVAL |
1065 | |
1113 | |
1066 | void |
1114 | void |
1067 | DESTROY (CFPlus::Layout self) |
1115 | DESTROY (DC::Layout self) |
1068 | CODE: |
1116 | CODE: |
1069 | g_object_unref (self->pl); |
1117 | g_object_unref (self->pl); |
1070 | rc_free (self->rc); |
1118 | rc_free (self->rc); |
1071 | Safefree (self); |
1119 | Safefree (self); |
1072 | |
1120 | |
1073 | void |
1121 | void |
1074 | set_text (CFPlus::Layout self, SV *text_) |
1122 | set_text (DC::Layout self, SV *text_) |
1075 | CODE: |
1123 | CODE: |
1076 | { |
1124 | { |
1077 | STRLEN textlen; |
1125 | STRLEN textlen; |
1078 | char *text = SvPVutf8 (text_, textlen); |
1126 | char *text = SvPVutf8 (text_, textlen); |
1079 | |
1127 | |
1080 | pango_layout_set_text (self->pl, text, textlen); |
1128 | pango_layout_set_text (self->pl, text, textlen); |
1081 | } |
1129 | } |
1082 | |
1130 | |
1083 | void |
1131 | void |
1084 | set_markup (CFPlus::Layout self, SV *text_) |
1132 | set_markup (DC::Layout self, SV *text_) |
1085 | CODE: |
1133 | CODE: |
1086 | { |
1134 | { |
1087 | STRLEN textlen; |
1135 | STRLEN textlen; |
1088 | char *text = SvPVutf8 (text_, textlen); |
1136 | char *text = SvPVutf8 (text_, textlen); |
1089 | |
1137 | |
1090 | pango_layout_set_markup (self->pl, text, textlen); |
1138 | pango_layout_set_markup (self->pl, text, textlen); |
1091 | } |
1139 | } |
1092 | |
1140 | |
1093 | void |
1141 | void |
1094 | set_shapes (CFPlus::Layout self, ...) |
1142 | set_shapes (DC::Layout self, ...) |
1095 | CODE: |
1143 | CODE: |
1096 | { |
1144 | { |
1097 | PangoAttrList *attrs = 0; |
1145 | PangoAttrList *attrs = 0; |
1098 | const char *text = pango_layout_get_text (self->pl); |
1146 | const char *text = pango_layout_get_text (self->pl); |
1099 | const char *pos = text; |
1147 | const char *pos = text; |
… | |
… | |
1134 | if (attrs) |
1182 | if (attrs) |
1135 | pango_layout_set_attributes (self->pl, attrs); |
1183 | pango_layout_set_attributes (self->pl, attrs); |
1136 | } |
1184 | } |
1137 | |
1185 | |
1138 | void |
1186 | void |
1139 | get_shapes (CFPlus::Layout self) |
1187 | get_shapes (DC::Layout self) |
1140 | PPCODE: |
1188 | PPCODE: |
1141 | { |
1189 | { |
1142 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1190 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1143 | |
1191 | |
1144 | do |
1192 | do |
1145 | { |
1193 | { |
1146 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1194 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1147 | |
1195 | |
1148 | if (run && shape_attr_p (run)) |
1196 | if (run && shape_attr_p (run)) |
1149 | { |
1197 | { |
1150 | PangoRectangle extents; |
1198 | PangoRectangle extents; |
1151 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1199 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1159 | |
1207 | |
1160 | pango_layout_iter_free (iter); |
1208 | pango_layout_iter_free (iter); |
1161 | } |
1209 | } |
1162 | |
1210 | |
1163 | int |
1211 | int |
1164 | has_wrapped (CFPlus::Layout self) |
1212 | has_wrapped (DC::Layout self) |
1165 | CODE: |
1213 | CODE: |
1166 | { |
1214 | { |
1167 | int lines = 1; |
1215 | int lines = 1; |
1168 | const char *text = pango_layout_get_text (self->pl); |
1216 | const char *text = pango_layout_get_text (self->pl); |
1169 | |
1217 | |
… | |
… | |
1174 | } |
1222 | } |
1175 | OUTPUT: |
1223 | OUTPUT: |
1176 | RETVAL |
1224 | RETVAL |
1177 | |
1225 | |
1178 | SV * |
1226 | SV * |
1179 | get_text (CFPlus::Layout self) |
1227 | get_text (DC::Layout self) |
1180 | CODE: |
1228 | CODE: |
1181 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1229 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1182 | sv_utf8_decode (RETVAL); |
1230 | sv_utf8_decode (RETVAL); |
1183 | OUTPUT: |
1231 | OUTPUT: |
1184 | RETVAL |
1232 | RETVAL |
1185 | |
1233 | |
1186 | void |
1234 | void |
1187 | 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.) |
1188 | CODE: |
1236 | CODE: |
1189 | self->r = r; |
1237 | self->r = r; |
1190 | self->g = g; |
1238 | self->g = g; |
1191 | self->b = b; |
1239 | self->b = b; |
1192 | self->a = a; |
1240 | self->a = a; |
1193 | |
1241 | |
1194 | void |
1242 | void |
1195 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1243 | set_font (DC::Layout self, DC::Font font = 0) |
1196 | CODE: |
1244 | CODE: |
1197 | if (self->font != font) |
1245 | if (self->font != font) |
1198 | { |
1246 | { |
1199 | self->font = font; |
1247 | self->font = font; |
1200 | layout_update_font (self); |
1248 | layout_update_font (self); |
1201 | } |
1249 | } |
1202 | |
1250 | |
1203 | void |
1251 | void |
1204 | set_height (CFPlus::Layout self, int base_height) |
1252 | set_height (DC::Layout self, int base_height) |
1205 | CODE: |
1253 | CODE: |
1206 | if (self->base_height != base_height) |
1254 | if (self->base_height != base_height) |
1207 | { |
1255 | { |
1208 | self->base_height = base_height; |
1256 | self->base_height = base_height; |
1209 | layout_update_font (self); |
1257 | layout_update_font (self); |
1210 | } |
1258 | } |
1211 | |
1259 | |
1212 | void |
1260 | void |
1213 | set_width (CFPlus::Layout self, int max_width = -1) |
1261 | set_width (DC::Layout self, int max_width = -1) |
1214 | CODE: |
1262 | CODE: |
1215 | 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); |
1216 | |
1264 | |
1217 | void |
1265 | void |
1218 | set_indent (CFPlus::Layout self, int indent) |
1266 | set_indent (DC::Layout self, int indent) |
1219 | CODE: |
1267 | CODE: |
1220 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1268 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1221 | |
1269 | |
1222 | void |
1270 | void |
1223 | set_spacing (CFPlus::Layout self, int spacing) |
1271 | set_spacing (DC::Layout self, int spacing) |
1224 | CODE: |
1272 | CODE: |
1225 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1273 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1226 | |
1274 | |
1227 | void |
1275 | void |
1228 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1276 | set_ellipsise (DC::Layout self, int ellipsise) |
1229 | CODE: |
1277 | CODE: |
1230 | pango_layout_set_ellipsize (self->pl, |
1278 | pango_layout_set_ellipsize (self->pl, |
1231 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1279 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1232 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1280 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1233 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1281 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1234 | : PANGO_ELLIPSIZE_NONE |
1282 | : PANGO_ELLIPSIZE_NONE |
1235 | ); |
1283 | ); |
1236 | |
1284 | |
1237 | void |
1285 | void |
1238 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1286 | set_single_paragraph_mode (DC::Layout self, int spm) |
1239 | CODE: |
1287 | CODE: |
1240 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1288 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1241 | |
1289 | |
1242 | void |
1290 | void |
1243 | size (CFPlus::Layout self) |
1291 | size (DC::Layout self) |
1244 | PPCODE: |
1292 | PPCODE: |
1245 | { |
1293 | { |
1246 | int w, h; |
1294 | int w, h; |
1247 | |
1295 | |
1248 | layout_get_pixel_size (self, &w, &h); |
1296 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1251 | PUSHs (sv_2mortal (newSViv (w))); |
1299 | PUSHs (sv_2mortal (newSViv (w))); |
1252 | PUSHs (sv_2mortal (newSViv (h))); |
1300 | PUSHs (sv_2mortal (newSViv (h))); |
1253 | } |
1301 | } |
1254 | |
1302 | |
1255 | int |
1303 | int |
1256 | descent (CFPlus::Layout self) |
1304 | descent (DC::Layout self) |
1257 | CODE: |
1305 | CODE: |
1258 | { |
1306 | { |
1259 | PangoRectangle rect; |
1307 | PangoRectangle rect; |
1260 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1308 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1261 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1309 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1262 | RETVAL = PANGO_DESCENT (rect); |
1310 | RETVAL = PANGO_DESCENT (rect); |
1263 | } |
1311 | } |
1264 | OUTPUT: |
1312 | OUTPUT: |
1265 | RETVAL |
1313 | RETVAL |
1266 | |
1314 | |
1267 | int |
1315 | int |
1268 | xy_to_index (CFPlus::Layout self, int x, int y) |
1316 | xy_to_index (DC::Layout self, int x, int y) |
1269 | CODE: |
1317 | CODE: |
1270 | { |
1318 | { |
1271 | int index, trailing; |
1319 | int index, trailing; |
1272 | 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); |
1273 | RETVAL = index + trailing; |
1321 | RETVAL = index + trailing; |
1274 | } |
1322 | } |
1275 | OUTPUT: |
1323 | OUTPUT: |
1276 | RETVAL |
1324 | RETVAL |
1277 | |
1325 | |
1278 | void |
1326 | void |
1279 | cursor_pos (CFPlus::Layout self, int index) |
1327 | cursor_pos (DC::Layout self, int index) |
1280 | PPCODE: |
1328 | PPCODE: |
1281 | { |
1329 | { |
1282 | PangoRectangle strong_pos; |
1330 | PangoRectangle pos; |
1283 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1331 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1284 | |
1332 | |
1285 | EXTEND (SP, 3); |
1333 | EXTEND (SP, 3); |
1286 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1334 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1287 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1335 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1288 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1336 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1289 | } |
1337 | } |
1290 | |
1338 | |
1291 | void |
1339 | void |
1292 | 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) |
1293 | PPCODE: |
1341 | PPCODE: |
1294 | { |
1342 | { |
1295 | int line, x; |
1343 | int line, x; |
1296 | |
1344 | |
1297 | 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) |
1298 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1347 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1299 | |
1348 | --line; |
|
|
1349 | #endif |
1300 | EXTEND (SP, 2); |
1350 | EXTEND (SP, 2); |
1301 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1351 | PUSHs (sv_2mortal (newSViv (line))); |
1302 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1352 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1303 | } |
1353 | } |
1304 | |
1354 | |
1305 | void |
1355 | void |
1306 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1356 | line_x_to_index (DC::Layout self, int line, int x) |
1307 | PPCODE: |
1357 | PPCODE: |
1308 | { |
1358 | { |
1309 | PangoLayoutLine *lp; |
1359 | PangoLayoutLine *lp; |
1310 | int index, trailing; |
1360 | int index, trailing; |
1311 | |
1361 | |
1312 | if (line < 0) |
1362 | if (line < 0) |
1313 | XSRETURN_EMPTY; |
1363 | XSRETURN_EMPTY; |
1314 | |
1364 | |
1315 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1365 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1316 | XSRETURN_EMPTY; /* do better */ |
1366 | XSRETURN_EMPTY; /* do better */ |
1317 | |
1367 | |
1318 | 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); |
1319 | |
1369 | |
1320 | EXTEND (SP, 2); |
1370 | EXTEND (SP, 2); |
… | |
… | |
1326 | PUSHs (sv_2mortal (newSViv (trailing))); |
1376 | PUSHs (sv_2mortal (newSViv (trailing))); |
1327 | } |
1377 | } |
1328 | } |
1378 | } |
1329 | |
1379 | |
1330 | void |
1380 | void |
1331 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1381 | render (DC::Layout self, float x, float y, int flags = 0) |
1332 | CODE: |
1382 | CODE: |
1333 | rc_clear (self->rc); |
1383 | rc_clear (self->rc); |
1334 | pango_opengl_render_layout_subpixel ( |
1384 | pango_opengl_render_layout_subpixel ( |
1335 | self->pl, |
1385 | self->pl, |
1336 | self->rc, |
1386 | self->rc, |
… | |
… | |
1341 | // we assume that context_change actually clears/frees stuff |
1391 | // we assume that context_change actually clears/frees stuff |
1342 | // and does not do any recomputation... |
1392 | // and does not do any recomputation... |
1343 | pango_layout_context_changed (self->pl); |
1393 | pango_layout_context_changed (self->pl); |
1344 | |
1394 | |
1345 | void |
1395 | void |
1346 | draw (CFPlus::Layout self) |
1396 | draw (DC::Layout self) |
1347 | CODE: |
1397 | CODE: |
1348 | { |
1398 | { |
1349 | glEnable (GL_TEXTURE_2D); |
1399 | glEnable (GL_TEXTURE_2D); |
1350 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1400 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1351 | glEnable (GL_BLEND); |
1401 | glEnable (GL_BLEND); |
… | |
… | |
1359 | glDisable (GL_ALPHA_TEST); |
1409 | glDisable (GL_ALPHA_TEST); |
1360 | glDisable (GL_BLEND); |
1410 | glDisable (GL_BLEND); |
1361 | glDisable (GL_TEXTURE_2D); |
1411 | glDisable (GL_TEXTURE_2D); |
1362 | } |
1412 | } |
1363 | |
1413 | |
1364 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1414 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1365 | |
1415 | |
1366 | PROTOTYPES: ENABLE |
1416 | PROTOTYPES: ENABLE |
1367 | |
1417 | |
1368 | void |
1418 | void |
1369 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1419 | pad (SV *data_, int ow, int oh, int nw, int nh) |
… | |
… | |
1448 | RETVAL = width > 0; |
1498 | RETVAL = width > 0; |
1449 | } |
1499 | } |
1450 | OUTPUT: |
1500 | OUTPUT: |
1451 | RETVAL |
1501 | RETVAL |
1452 | |
1502 | |
1453 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1503 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1454 | |
1504 | |
1455 | PROTOTYPES: DISABLE |
1505 | PROTOTYPES: DISABLE |
1456 | |
1506 | |
1457 | CFPlus::Map |
1507 | DC::Map |
1458 | new (SV *class) |
1508 | new (SV *class) |
1459 | CODE: |
1509 | CODE: |
1460 | New (0, RETVAL, 1, struct map); |
1510 | New (0, RETVAL, 1, struct map); |
1461 | RETVAL->x = 0; |
1511 | RETVAL->x = 0; |
1462 | RETVAL->y = 0; |
1512 | RETVAL->y = 0; |
… | |
… | |
1470 | RETVAL->row = 0; |
1520 | RETVAL->row = 0; |
1471 | OUTPUT: |
1521 | OUTPUT: |
1472 | RETVAL |
1522 | RETVAL |
1473 | |
1523 | |
1474 | void |
1524 | void |
1475 | DESTROY (CFPlus::Map self) |
1525 | DESTROY (DC::Map self) |
1476 | CODE: |
1526 | CODE: |
1477 | { |
1527 | { |
1478 | map_clear (self); |
1528 | map_clear (self); |
1479 | Safefree (self->face2tile); |
1529 | Safefree (self->face2tile); |
1480 | Safefree (self->tex); |
1530 | Safefree (self->tex); |
1481 | Safefree (self); |
1531 | Safefree (self); |
1482 | } |
1532 | } |
1483 | |
1533 | |
1484 | void |
1534 | void |
1485 | resize (CFPlus::Map self, int map_width, int map_height) |
1535 | resize (DC::Map self, int map_width, int map_height) |
1486 | CODE: |
1536 | CODE: |
1487 | self->w = map_width; |
1537 | self->w = map_width; |
1488 | self->h = map_height; |
1538 | self->h = map_height; |
1489 | |
1539 | |
1490 | void |
1540 | void |
1491 | clear (CFPlus::Map self) |
1541 | clear (DC::Map self) |
1492 | CODE: |
1542 | CODE: |
1493 | map_clear (self); |
1543 | map_clear (self); |
1494 | |
1544 | |
1495 | void |
1545 | void |
1496 | set_tileid (CFPlus::Map self, int face, int tile) |
1546 | set_tileid (DC::Map self, int face, int tile) |
1497 | CODE: |
1547 | CODE: |
1498 | { |
1548 | { |
1499 | need_facenum (self, face); self->face2tile [face] = tile; |
1549 | need_facenum (self, face); self->face2tile [face] = tile; |
1500 | need_texid (self, tile); |
1550 | need_texid (self, tile); |
1501 | } |
1551 | } |
1502 | |
1552 | |
1503 | void |
1553 | void |
1504 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1554 | set_smooth (DC::Map self, int face, int smooth, int level) |
1505 | CODE: |
1555 | CODE: |
1506 | { |
1556 | { |
1507 | tileid texid; |
1557 | tileid texid; |
1508 | maptex *tex; |
1558 | maptex *tex; |
1509 | |
1559 | |
… | |
… | |
1522 | tex->smoothtile = self->face2tile [smooth]; |
1572 | tex->smoothtile = self->face2tile [smooth]; |
1523 | tex->smoothlevel = level; |
1573 | tex->smoothlevel = level; |
1524 | } |
1574 | } |
1525 | |
1575 | |
1526 | void |
1576 | void |
1527 | 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) |
1528 | CODE: |
1578 | CODE: |
1529 | { |
1579 | { |
1530 | need_texid (self, texid); |
1580 | need_texid (self, texid); |
1531 | |
1581 | |
1532 | { |
1582 | { |
… | |
… | |
1552 | // from transparent color bleeding and ugly wrapping effects. |
1602 | // from transparent color bleeding and ugly wrapping effects. |
1553 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1603 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1554 | } |
1604 | } |
1555 | |
1605 | |
1556 | int |
1606 | int |
1557 | ox (CFPlus::Map self) |
1607 | ox (DC::Map self) |
1558 | ALIAS: |
1608 | ALIAS: |
1559 | oy = 1 |
1609 | oy = 1 |
1560 | x = 2 |
1610 | x = 2 |
1561 | y = 3 |
1611 | y = 3 |
1562 | w = 4 |
1612 | w = 4 |
… | |
… | |
1573 | } |
1623 | } |
1574 | OUTPUT: |
1624 | OUTPUT: |
1575 | RETVAL |
1625 | RETVAL |
1576 | |
1626 | |
1577 | void |
1627 | void |
1578 | scroll (CFPlus::Map self, int dx, int dy) |
1628 | scroll (DC::Map self, int dx, int dy) |
1579 | CODE: |
1629 | CODE: |
1580 | { |
1630 | { |
1581 | if (dx > 0) |
1631 | if (dx > 0) |
1582 | map_blank (self, self->x, self->y, dx, self->h); |
1632 | map_blank (self, self->x, self->y, dx, self->h); |
1583 | else if (dx < 0) |
1633 | else if (dx < 0) |
… | |
… | |
1599 | self->y += MAP_EXTEND_Y; |
1649 | self->y += MAP_EXTEND_Y; |
1600 | } |
1650 | } |
1601 | } |
1651 | } |
1602 | |
1652 | |
1603 | SV * |
1653 | SV * |
1604 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1654 | map1a_update (DC::Map self, SV *data_, int extmap) |
1605 | CODE: |
1655 | CODE: |
1606 | { |
1656 | { |
1607 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1657 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1608 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1658 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1609 | mapcell *cell; |
1659 | mapcell *cell; |
… | |
… | |
1698 | } |
1748 | } |
1699 | OUTPUT: |
1749 | OUTPUT: |
1700 | RETVAL |
1750 | RETVAL |
1701 | |
1751 | |
1702 | SV * |
1752 | SV * |
1703 | 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) |
1704 | CODE: |
1754 | CODE: |
1705 | { |
1755 | { |
1706 | int x1, x; |
1756 | int x1, x; |
1707 | int y1, y; |
1757 | int y1, y; |
1708 | int z; |
1758 | int z; |
… | |
… | |
1753 | } |
1803 | } |
1754 | OUTPUT: |
1804 | OUTPUT: |
1755 | RETVAL |
1805 | RETVAL |
1756 | |
1806 | |
1757 | void |
1807 | void |
1758 | 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) |
1759 | CODE: |
1809 | CODE: |
1760 | { |
1810 | { |
1761 | int x, y, z; |
1811 | int x, y, z; |
1762 | |
1812 | |
1763 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1813 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2034 | } |
2084 | } |
2035 | } |
2085 | } |
2036 | } |
2086 | } |
2037 | |
2087 | |
2038 | void |
2088 | void |
2039 | 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) |
2040 | CODE: |
2090 | CODE: |
2041 | { |
2091 | { |
2042 | static float color[16][3] = { |
2092 | static float color[16][3] = { |
2043 | { 0.00F, 0.00F, 0.00F }, |
2093 | { 0.00F, 0.00F, 0.00F }, |
2044 | { 1.00F, 1.00F, 1.00F }, |
2094 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2094 | glDisable (GL_BLEND); |
2144 | glDisable (GL_BLEND); |
2095 | glDisable (GL_TEXTURE_2D); |
2145 | glDisable (GL_TEXTURE_2D); |
2096 | } |
2146 | } |
2097 | |
2147 | |
2098 | void |
2148 | void |
2099 | 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) |
2100 | PPCODE: |
2150 | PPCODE: |
2101 | { |
2151 | { |
2102 | int x, y; |
2152 | int x, y; |
2103 | int sw1 = sw + 2; |
2153 | int sw1 = sw + 2; |
2104 | int sh1 = sh + 2; |
2154 | int sh1 = sh + 2; |
… | |
… | |
2175 | PUSHs (sv_2mortal (newSViv (sh3))); |
2225 | PUSHs (sv_2mortal (newSViv (sh3))); |
2176 | PUSHs (darkness3_sv); |
2226 | PUSHs (darkness3_sv); |
2177 | } |
2227 | } |
2178 | |
2228 | |
2179 | SV * |
2229 | SV * |
2180 | 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) |
2181 | CODE: |
2231 | CODE: |
2182 | { |
2232 | { |
2183 | int x, y, x1, y1; |
2233 | int x, y, x1, y1; |
2184 | SV *data_sv = newSV (w * h * 7 + 5); |
2234 | SV *data_sv = newSV (w * h * 7 + 5); |
2185 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2235 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2242 | else |
2292 | else |
2243 | *data++ = 0; |
2293 | *data++ = 0; |
2244 | } |
2294 | } |
2245 | } |
2295 | } |
2246 | |
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 | { |
2247 | SvPOK_only (data_sv); |
2300 | SvPOK_only (data_sv); |
2248 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2301 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2302 | } |
|
|
2303 | |
2249 | RETVAL = data_sv; |
2304 | RETVAL = data_sv; |
2250 | } |
2305 | } |
2251 | OUTPUT: |
2306 | OUTPUT: |
2252 | RETVAL |
2307 | RETVAL |
2253 | |
2308 | |
2254 | void |
2309 | void |
2255 | 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) |
2256 | PPCODE: |
2311 | PPCODE: |
2257 | { |
2312 | { |
2258 | int x, y, z; |
2313 | int x, y, z; |
2259 | int w, h; |
2314 | int w, h; |
2260 | 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; |
2261 | |
2326 | |
2262 | if (*data++ != 0) |
2327 | if (*data++ != 0) |
2263 | XSRETURN_EMPTY; /* version mismatch */ |
2328 | XSRETURN_EMPTY; /* version mismatch */ |
2264 | |
2329 | |
2265 | w = *data++ << 8; w |= *data++; |
2330 | w = *data++ << 8; w |= *data++; |
… | |
… | |
2280 | { |
2345 | { |
2281 | maprow *row = map_get_row (self, y); |
2346 | maprow *row = map_get_row (self, y); |
2282 | |
2347 | |
2283 | for (x = x0; x < x1; x++) |
2348 | for (x = x0; x < x1; x++) |
2284 | { |
2349 | { |
|
|
2350 | uint8_t flags; |
|
|
2351 | |
|
|
2352 | if (data + 7 >= end) |
|
|
2353 | XSRETURN_EMPTY; |
|
|
2354 | |
2285 | uint8_t flags = *data++; |
2355 | flags = *data++; |
2286 | |
2356 | |
2287 | if (flags) |
2357 | if (flags) |
2288 | { |
2358 | { |
2289 | mapcell *cell = row_get_cell (row, x); |
2359 | mapcell *cell = row_get_cell (row, x); |
2290 | tileid tile[3] = { 0, 0, 0 }; |
2360 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2293 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2363 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2294 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2364 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2295 | |
2365 | |
2296 | if (cell->darkness == 0) |
2366 | if (cell->darkness == 0) |
2297 | { |
2367 | { |
2298 | cell->darkness = 0; |
2368 | /*cell->darkness = 0;*/ |
|
|
2369 | EXTEND (SP, 3); |
2299 | |
2370 | |
2300 | for (z = 0; z <= 2; z++) |
2371 | for (z = 0; z <= 2; z++) |
2301 | { |
2372 | { |
2302 | tileid t = tile [z]; |
2373 | tileid t = tile [z]; |
2303 | |
2374 | |
2304 | if (t >= self->texs || (t && !self->tex [t].name)) |
2375 | if (t >= self->texs || (t && !self->tex [t].name)) |
2305 | { |
2376 | { |
2306 | XPUSHs (sv_2mortal (newSViv (t))); |
2377 | PUSHs (sv_2mortal (newSViv (t))); |
2307 | need_texid (self, t); |
2378 | need_texid (self, t); |
2308 | } |
2379 | } |
2309 | |
2380 | |
2310 | cell->tile [z] = t; |
2381 | cell->tile [z] = t; |
2311 | } |
2382 | } |
… | |
… | |
2313 | } |
2384 | } |
2314 | } |
2385 | } |
2315 | } |
2386 | } |
2316 | } |
2387 | } |
2317 | |
2388 | |
2318 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2389 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2319 | |
2390 | |
2320 | CFPlus::RW |
2391 | DC::RW |
2321 | new (SV *class, SV *data_sv) |
2392 | new (SV *class, SV *data_sv) |
2322 | CODE: |
2393 | CODE: |
2323 | { |
2394 | { |
2324 | STRLEN datalen; |
2395 | STRLEN datalen; |
2325 | char *data = SvPVbyte (data_sv, datalen); |
2396 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2327 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2398 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2328 | } |
2399 | } |
2329 | OUTPUT: |
2400 | OUTPUT: |
2330 | RETVAL |
2401 | RETVAL |
2331 | |
2402 | |
2332 | CFPlus::RW |
2403 | DC::RW |
2333 | 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") |
2334 | CODE: |
2405 | CODE: |
2335 | RETVAL = SDL_RWFromFile (path, mode); |
2406 | RETVAL = SDL_RWFromFile (path, mode); |
2336 | OUTPUT: |
2407 | OUTPUT: |
2337 | RETVAL |
2408 | RETVAL |
2338 | |
2409 | |
2339 | # fails on win32: |
2410 | # fails on win32: |
2340 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2411 | # dc.xs(2268) : error C2059: syntax error : '(' |
2341 | #void |
2412 | #void |
2342 | #close (CFPlus::RW self) |
2413 | #close (DC::RW self) |
2343 | # CODE: |
2414 | # CODE: |
2344 | # (self->(close)) (self); |
2415 | # (self->(close)) (self); |
2345 | |
2416 | |
2346 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2417 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2347 | |
2418 | |
2348 | PROTOTYPES: DISABLE |
2419 | PROTOTYPES: DISABLE |
2349 | |
2420 | |
2350 | CFPlus::Channel |
2421 | DC::Channel |
2351 | find () |
2422 | find () |
2352 | CODE: |
2423 | CODE: |
2353 | { |
2424 | { |
2354 | RETVAL = Mix_GroupAvailable (-1); |
2425 | RETVAL = Mix_GroupAvailable (-1); |
2355 | |
2426 | |
… | |
… | |
2368 | } |
2439 | } |
2369 | OUTPUT: |
2440 | OUTPUT: |
2370 | RETVAL |
2441 | RETVAL |
2371 | |
2442 | |
2372 | void |
2443 | void |
2373 | halt (CFPlus::Channel self) |
2444 | halt (DC::Channel self) |
2374 | CODE: |
2445 | CODE: |
2375 | Mix_HaltChannel (self); |
2446 | Mix_HaltChannel (self); |
2376 | |
2447 | |
2377 | void |
2448 | void |
2378 | expire (CFPlus::Channel self, int ticks = -1) |
2449 | expire (DC::Channel self, int ticks = -1) |
2379 | CODE: |
2450 | CODE: |
2380 | Mix_ExpireChannel (self, ticks); |
2451 | Mix_ExpireChannel (self, ticks); |
2381 | |
2452 | |
2382 | void |
2453 | void |
2383 | fade_out (CFPlus::Channel self, int ticks = -1) |
2454 | fade_out (DC::Channel self, int ticks = -1) |
2384 | CODE: |
2455 | CODE: |
2385 | Mix_FadeOutChannel (self, ticks); |
2456 | Mix_FadeOutChannel (self, ticks); |
2386 | |
2457 | |
2387 | int |
2458 | int |
2388 | volume (CFPlus::Channel self, int volume) |
2459 | volume (DC::Channel self, int volume) |
2389 | CODE: |
2460 | CODE: |
2390 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2461 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2391 | OUTPUT: |
2462 | OUTPUT: |
2392 | RETVAL |
2463 | RETVAL |
2393 | |
2464 | |
2394 | void |
2465 | void |
2395 | unregister_all_effects (CFPlus::Channel self) |
2466 | unregister_all_effects (DC::Channel self) |
2396 | CODE: |
2467 | CODE: |
2397 | Mix_UnregisterAllEffects (self); |
2468 | Mix_UnregisterAllEffects (self); |
2398 | |
2469 | |
2399 | void |
2470 | void |
2400 | set_panning (CFPlus::Channel self, int left, int right) |
2471 | set_panning (DC::Channel self, int left, int right) |
2401 | CODE: |
2472 | CODE: |
2402 | left = CLAMP (left , 0, 255); |
2473 | left = CLAMP (left , 0, 255); |
2403 | right = CLAMP (right, 0, 255); |
2474 | right = CLAMP (right, 0, 255); |
2404 | Mix_SetPanning (self, left, right); |
2475 | Mix_SetPanning (self, left, right); |
2405 | |
2476 | |
2406 | void |
2477 | void |
2407 | set_distance (CFPlus::Channel self, int distance) |
2478 | set_distance (DC::Channel self, int distance) |
2408 | CODE: |
2479 | CODE: |
2409 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2480 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2410 | |
2481 | |
2411 | void |
2482 | void |
2412 | set_position (CFPlus::Channel self, int angle, int distance) |
2483 | set_position (DC::Channel self, int angle, int distance) |
2413 | CODE: |
2484 | CODE: |
2414 | |
2485 | |
2415 | void |
2486 | void |
2416 | 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) |
2417 | CODE: |
2488 | CODE: |
2418 | { |
2489 | { |
2419 | 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)); |
2420 | 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); |
2421 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2492 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2422 | } |
2493 | } |
2423 | |
2494 | |
2424 | void |
2495 | void |
2425 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2496 | set_reverse_stereo (DC::Channel self, int flip) |
2426 | CODE: |
2497 | CODE: |
2427 | Mix_SetReverseStereo (self, flip); |
2498 | Mix_SetReverseStereo (self, flip); |
2428 | |
2499 | |
2429 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2500 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2430 | |
2501 | |
2431 | PROTOTYPES: DISABLE |
2502 | PROTOTYPES: DISABLE |
2432 | |
2503 | |
2433 | CFPlus::MixChunk |
2504 | DC::MixChunk |
2434 | new (SV *class, CFPlus::RW rwops) |
2505 | new (SV *class, DC::RW rwops) |
2435 | CODE: |
2506 | CODE: |
2436 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2507 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2437 | OUTPUT: |
2508 | OUTPUT: |
2438 | RETVAL |
2509 | RETVAL |
2439 | |
2510 | |
2440 | void |
2511 | void |
2441 | DESTROY (CFPlus::MixChunk self) |
2512 | DESTROY (DC::MixChunk self) |
2442 | CODE: |
2513 | CODE: |
2443 | Mix_FreeChunk (self); |
2514 | Mix_FreeChunk (self); |
2444 | |
2515 | |
2445 | int |
2516 | int |
2446 | volume (CFPlus::MixChunk self, int volume = -1) |
2517 | volume (DC::MixChunk self, int volume = -1) |
2447 | CODE: |
2518 | CODE: |
2448 | if (items > 1) |
2519 | if (items > 1) |
2449 | volume = CLAMP (volume, 0, 128); |
2520 | volume = CLAMP (volume, 0, 128); |
2450 | RETVAL = Mix_VolumeChunk (self, volume); |
2521 | RETVAL = Mix_VolumeChunk (self, volume); |
2451 | OUTPUT: |
2522 | OUTPUT: |
2452 | RETVAL |
2523 | RETVAL |
2453 | |
2524 | |
2454 | CFPlus::Channel |
2525 | DC::Channel |
2455 | 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) |
2456 | CODE: |
2527 | CODE: |
2457 | { |
2528 | { |
2458 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2529 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2459 | |
2530 | |
2460 | if (RETVAL < 0) |
2531 | if (RETVAL < 0) |
… | |
… | |
2467 | } |
2538 | } |
2468 | } |
2539 | } |
2469 | OUTPUT: |
2540 | OUTPUT: |
2470 | RETVAL |
2541 | RETVAL |
2471 | |
2542 | |
2472 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2543 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2473 | |
2544 | |
2474 | int |
2545 | int |
2475 | volume (int volume = -1) |
2546 | volume (int volume = -1) |
2476 | PROTOTYPE: ;$ |
2547 | PROTOTYPE: ;$ |
2477 | CODE: |
2548 | CODE: |
… | |
… | |
2489 | void |
2560 | void |
2490 | halt () |
2561 | halt () |
2491 | CODE: |
2562 | CODE: |
2492 | Mix_HaltMusic (); |
2563 | Mix_HaltMusic (); |
2493 | |
2564 | |
2494 | CFPlus::MixMusic |
2565 | DC::MixMusic |
2495 | new (SV *class, CFPlus::RW rwops) |
2566 | new (SV *class, DC::RW rwops) |
2496 | CODE: |
2567 | CODE: |
2497 | RETVAL = Mix_LoadMUS_RW (rwops); |
2568 | RETVAL = Mix_LoadMUS_RW (rwops); |
2498 | OUTPUT: |
2569 | OUTPUT: |
2499 | RETVAL |
2570 | RETVAL |
2500 | |
2571 | |
2501 | void |
2572 | void |
2502 | DESTROY (CFPlus::MixMusic self) |
2573 | DESTROY (DC::MixMusic self) |
2503 | CODE: |
2574 | CODE: |
2504 | Mix_FreeMusic (self); |
2575 | Mix_FreeMusic (self); |
2505 | |
2576 | |
2506 | int |
2577 | int |
2507 | play (CFPlus::MixMusic self, int loops = -1) |
2578 | play (DC::MixMusic self, int loops = -1) |
2508 | CODE: |
2579 | CODE: |
2509 | RETVAL = Mix_PlayMusic (self, loops); |
2580 | RETVAL = Mix_PlayMusic (self, loops); |
2510 | OUTPUT: |
2581 | OUTPUT: |
2511 | RETVAL |
2582 | RETVAL |
2512 | |
2583 | |
2513 | void |
2584 | void |
2514 | 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) |
2515 | CODE: |
2586 | CODE: |
2516 | Mix_FadeInMusicPos (self, loops, ms, position); |
2587 | Mix_FadeInMusicPos (self, loops, ms, position); |
2517 | |
2588 | |
2518 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2589 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2519 | |
2590 | |
2520 | PROTOTYPES: ENABLE |
2591 | PROTOTYPES: ENABLE |
2521 | |
2592 | |
2522 | BOOT: |
2593 | BOOT: |
2523 | { |
2594 | { |
2524 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2595 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2525 | static const struct { |
2596 | static const struct { |
2526 | const char *name; |
2597 | const char *name; |
2527 | IV iv; |
2598 | IV iv; |
2528 | } *civ, const_iv[] = { |
2599 | } *civ, const_iv[] = { |
2529 | # define const_iv(name) { # name, (IV)name } |
2600 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2822 | 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) |
2823 | CODE: |
2894 | CODE: |
2824 | if (gl.SeparableFilter2D) |
2895 | if (gl.SeparableFilter2D) |
2825 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2896 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2826 | |
2897 | |
2827 | 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) |
2828 | |
2899 | |
2829 | 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) |
2830 | |
2901 | |
2831 | 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) |
2832 | |
2903 | |
… | |
… | |
2858 | |
2929 | |
2859 | void glEndList () |
2930 | void glEndList () |
2860 | |
2931 | |
2861 | void glCallList (int list) |
2932 | void glCallList (int list) |
2862 | |
2933 | |
2863 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2934 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2864 | |
2935 | |
2865 | PROTOTYPES: DISABLE |
2936 | PROTOTYPES: DISABLE |
2866 | |
2937 | |
2867 | void |
2938 | void |
2868 | find_widget (SV *self, NV x, NV y) |
2939 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2872 | XPUSHs (self); |
2943 | XPUSHs (self); |
2873 | } |
2944 | } |
2874 | |
2945 | |
2875 | BOOT: |
2946 | BOOT: |
2876 | { |
2947 | { |
2877 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2948 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2878 | |
2949 | |
2879 | 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); |
2880 | 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); |
2881 | 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); |
2882 | 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); |
2883 | } |
2954 | } |
2884 | |
2955 | |
2885 | void |
2956 | void |
2886 | draw (SV *self) |
2957 | draw (SV *self) |
2887 | CODE: |
2958 | CODE: |
… | |
… | |
2894 | SV *draw_w_sv = GvSV (draw_w_gv); |
2965 | SV *draw_w_sv = GvSV (draw_w_gv); |
2895 | SV *draw_h_sv = GvSV (draw_h_gv); |
2966 | SV *draw_h_sv = GvSV (draw_h_gv); |
2896 | double draw_x, draw_y; |
2967 | double draw_x, draw_y; |
2897 | |
2968 | |
2898 | if (!SvROK (self)) |
2969 | if (!SvROK (self)) |
2899 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2970 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2900 | |
2971 | |
2901 | hv = (HV *)SvRV (self); |
2972 | hv = (HV *)SvRV (self); |
2902 | |
2973 | |
2903 | if (SvTYPE (hv) != SVt_PVHV) |
2974 | if (SvTYPE (hv) != SVt_PVHV) |
2904 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2975 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2905 | |
2976 | |
2906 | 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.; |
2907 | 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.; |
2908 | |
2979 | |
2909 | if (!h || !w) |
2980 | if (!h || !w) |