… | |
… | |
120 | |
120 | |
121 | #include "pango-font.c" |
121 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
122 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
123 | #include "pango-render.c" |
124 | |
124 | |
125 | typedef IV CFPlus__Channel; |
125 | typedef IV dc__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
126 | typedef SDL_RWops *dc__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
127 | typedef Mix_Chunk *dc__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
128 | typedef Mix_Music *dc__MixMusic; |
129 | |
129 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
130 | typedef PangoFontDescription *dc__Font; |
131 | |
131 | |
132 | static int |
132 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
133 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
134 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
149 | |
150 | typedef struct cf_layout { |
150 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
151 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
152 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
153 | int base_height; |
154 | CFPlus__Font font; |
154 | dc__Font font; |
155 | rc_t *rc; |
155 | rc_t *rc; |
156 | } *CFPlus__Layout; |
156 | } *dc__Layout; |
157 | |
157 | |
158 | static CFPlus__Font default_font; |
158 | static dc__Font default_font; |
159 | static PangoContext *opengl_context; |
159 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
160 | static PangoFontMap *opengl_fontmap; |
161 | |
161 | |
162 | static void |
162 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
163 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
168 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
170 | } |
171 | |
171 | |
172 | static void |
172 | static void |
173 | layout_update_font (CFPlus__Layout self) |
173 | layout_update_font (dc__Layout self) |
174 | { |
174 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
176 | * reasonably well with bitstream vera |
177 | */ |
177 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
182 | |
182 | |
183 | pango_layout_set_font_description (self->pl, font); |
183 | pango_layout_set_font_description (self->pl, font); |
184 | } |
184 | } |
185 | |
185 | |
186 | static void |
186 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
187 | layout_get_pixel_size (dc__Layout self, int *w, int *h) |
188 | { |
188 | { |
189 | PangoRectangle rect; |
189 | PangoRectangle rect; |
190 | |
190 | |
191 | // get_pixel_* wrongly rounds down |
191 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
231 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
232 | int texs; maptex *tex; // [tileid] |
233 | |
233 | |
234 | int32_t rows; |
234 | int32_t rows; |
235 | maprow *row; |
235 | maprow *row; |
236 | } *CFPlus__Map; |
236 | } *dc__Map; |
237 | |
237 | |
238 | static char * |
238 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
239 | prepend (char *ptr, int sze, int inc) |
240 | { |
240 | { |
241 | char *p; |
241 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
279 | self->texs *= 2; |
280 | } |
280 | } |
281 | } |
281 | } |
282 | |
282 | |
283 | static maprow * |
283 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
284 | map_get_row (dc__Map self, int y) |
285 | { |
285 | { |
286 | if (0 > y) |
286 | if (0 > y) |
287 | { |
287 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
288 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
289 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
327 | |
328 | return row->col + (x - row->c0); |
328 | return row->col + (x - row->c0); |
329 | } |
329 | } |
330 | |
330 | |
331 | static mapcell * |
331 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
332 | map_get_cell (dc__Map self, int x, int y) |
333 | { |
333 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
334 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
335 | } |
336 | |
336 | |
337 | static void |
337 | static void |
338 | map_clear (CFPlus__Map self) |
338 | map_clear (dc__Map self) |
339 | { |
339 | { |
340 | int r; |
340 | int r; |
341 | |
341 | |
342 | for (r = 0; r < self->rows; r++) |
342 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
343 | Safefree (self->row[r].col); |
… | |
… | |
351 | self->row = 0; |
351 | self->row = 0; |
352 | self->rows = 0; |
352 | self->rows = 0; |
353 | } |
353 | } |
354 | |
354 | |
355 | static void |
355 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
356 | map_blank (dc__Map self, int x0, int y0, int w, int h) |
357 | { |
357 | { |
358 | int x, y; |
358 | int x, y; |
359 | maprow *row; |
359 | maprow *row; |
360 | mapcell *cell; |
360 | mapcell *cell; |
361 | |
361 | |
… | |
… | |
440 | n |= n >> 16; |
440 | n |= n >> 16; |
441 | |
441 | |
442 | return n + 1; |
442 | return n + 1; |
443 | } |
443 | } |
444 | |
444 | |
|
|
445 | static unsigned int |
|
|
446 | popcount (unsigned int n) |
|
|
447 | { |
|
|
448 | n -= (n >> 1) & 0x55555555U; |
|
|
449 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
450 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
451 | n *= 0x01010101U; |
|
|
452 | |
|
|
453 | return n >> 24; |
|
|
454 | } |
|
|
455 | |
445 | /* SDL should provide this, really. */ |
456 | /* SDL should provide this, really. */ |
446 | #define SDLK_MODIFIER_MIN 300 |
457 | #define SDLK_MODIFIER_MIN 300 |
447 | #define SDLK_MODIFIER_MAX 314 |
458 | #define SDLK_MODIFIER_MAX 314 |
448 | |
459 | |
449 | /******************************************************************************/ |
460 | /******************************************************************************/ |
… | |
… | |
487 | return 0; |
498 | return 0; |
488 | |
499 | |
489 | return 1; |
500 | return 1; |
490 | } |
501 | } |
491 | |
502 | |
492 | MODULE = CFPlus PACKAGE = CFPlus |
503 | MODULE = Deliantra::Client PACKAGE = dc |
493 | |
504 | |
494 | PROTOTYPES: ENABLE |
505 | PROTOTYPES: ENABLE |
495 | |
506 | |
496 | BOOT: |
507 | BOOT: |
497 | { |
508 | { |
498 | HV *stash = gv_stashpv ("CFPlus", 1); |
509 | HV *stash = gv_stashpv ("dc", 1); |
499 | static const struct { |
510 | static const struct { |
500 | const char *name; |
511 | const char *name; |
501 | IV iv; |
512 | IV iv; |
502 | } *civ, const_iv[] = { |
513 | } *civ, const_iv[] = { |
503 | # define const_iv(name) { # name, (IV)name } |
514 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
525 | |
536 | |
526 | const_iv (SDL_APPINPUTFOCUS), |
537 | const_iv (SDL_APPINPUTFOCUS), |
527 | const_iv (SDL_APPMOUSEFOCUS), |
538 | const_iv (SDL_APPMOUSEFOCUS), |
528 | const_iv (SDL_APPACTIVE), |
539 | const_iv (SDL_APPACTIVE), |
529 | |
540 | |
|
|
541 | const_iv (SDLK_FIRST), |
|
|
542 | const_iv (SDLK_LAST), |
530 | const_iv (SDLK_KP0), |
543 | const_iv (SDLK_KP0), |
531 | const_iv (SDLK_KP1), |
544 | const_iv (SDLK_KP1), |
532 | const_iv (SDLK_KP2), |
545 | const_iv (SDLK_KP2), |
533 | const_iv (SDLK_KP3), |
546 | const_iv (SDLK_KP3), |
534 | const_iv (SDLK_KP4), |
547 | const_iv (SDLK_KP4), |
… | |
… | |
606 | const_iv (KMOD_LMETA), |
619 | const_iv (KMOD_LMETA), |
607 | const_iv (KMOD_RMETA), |
620 | const_iv (KMOD_RMETA), |
608 | const_iv (KMOD_NUM), |
621 | const_iv (KMOD_NUM), |
609 | const_iv (KMOD_CAPS), |
622 | const_iv (KMOD_CAPS), |
610 | const_iv (KMOD_MODE), |
623 | const_iv (KMOD_MODE), |
|
|
624 | |
|
|
625 | const_iv (MIX_DEFAULT_FORMAT), |
611 | # undef const_iv |
626 | # undef const_iv |
612 | }; |
627 | }; |
613 | |
628 | |
614 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
629 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
615 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
630 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
632 | RETVAL |
647 | RETVAL |
633 | |
648 | |
634 | NV floor (NV x) |
649 | NV floor (NV x) |
635 | |
650 | |
636 | NV ceil (NV x) |
651 | NV ceil (NV x) |
|
|
652 | |
|
|
653 | IV minpot (UV n) |
|
|
654 | |
|
|
655 | IV popcount (UV n) |
637 | |
656 | |
638 | void |
657 | void |
639 | pango_init () |
658 | pango_init () |
640 | CODE: |
659 | CODE: |
641 | { |
660 | { |
… | |
… | |
681 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
700 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
682 | |
701 | |
683 | if (m && m != (SDL_Rect **)-1) |
702 | if (m && m != (SDL_Rect **)-1) |
684 | while (*m) |
703 | while (*m) |
685 | { |
704 | { |
686 | if ((*m)->w >= 640 && (*m)->h >= 480) |
705 | if ((*m)->w >= 800 && (*m)->h >= 600) |
687 | { |
706 | { |
688 | AV *av = newAV (); |
707 | AV *av = newAV (); |
689 | av_push (av, newSViv ((*m)->w)); |
708 | av_push (av, newSViv ((*m)->w)); |
690 | av_push (av, newSViv ((*m)->h)); |
709 | av_push (av, newSViv ((*m)->h)); |
691 | av_push (av, newSViv (rgb)); |
710 | av_push (av, newSViv (rgb)); |
… | |
… | |
715 | |
734 | |
716 | if (RETVAL) |
735 | if (RETVAL) |
717 | { |
736 | { |
718 | av_clear (texture_av); |
737 | av_clear (texture_av); |
719 | |
738 | |
720 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
739 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
721 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
740 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
722 | #include "glfunc.h" |
741 | #include "glfunc.h" |
723 | #undef GL_FUNC |
742 | #undef GL_FUNC |
724 | } |
743 | } |
725 | } |
744 | } |
… | |
… | |
806 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
825 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
807 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
826 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
808 | break; |
827 | break; |
809 | } |
828 | } |
810 | |
829 | |
811 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
830 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("dc::UI::Event", 1)))); |
812 | } |
831 | } |
813 | } |
832 | } |
814 | |
833 | |
815 | int |
834 | int |
816 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
835 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
817 | POSTCALL: |
836 | POSTCALL: |
818 | Mix_HookMusicFinished (music_finished); |
837 | Mix_HookMusicFinished (music_finished); |
819 | Mix_ChannelFinished (channel_finished); |
838 | Mix_ChannelFinished (channel_finished); |
|
|
839 | |
|
|
840 | void |
|
|
841 | Mix_QuerySpec () |
|
|
842 | PPCODE: |
|
|
843 | { |
|
|
844 | int freq, channels; |
|
|
845 | Uint16 format; |
|
|
846 | |
|
|
847 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
848 | { |
|
|
849 | EXTEND (SP, 3); |
|
|
850 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
851 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
852 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
853 | } |
|
|
854 | } |
820 | |
855 | |
821 | void |
856 | void |
822 | Mix_CloseAudio () |
857 | Mix_CloseAudio () |
823 | |
858 | |
824 | int |
859 | int |
… | |
… | |
958 | void |
993 | void |
959 | error (char *message) |
994 | error (char *message) |
960 | CODE: |
995 | CODE: |
961 | fprintf (stderr, "ERROR: %s\n", message); |
996 | fprintf (stderr, "ERROR: %s\n", message); |
962 | #ifdef _WIN32 |
997 | #ifdef _WIN32 |
963 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
998 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
964 | #endif |
999 | #endif |
965 | |
1000 | |
966 | void |
1001 | void |
967 | fatal (char *message) |
1002 | fatal (char *message) |
968 | CODE: |
1003 | CODE: |
969 | fprintf (stderr, "FATAL: %s\n", message); |
1004 | fprintf (stderr, "FATAL: %s\n", message); |
970 | #ifdef _WIN32 |
1005 | #ifdef _WIN32 |
971 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1006 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
972 | #endif |
1007 | #endif |
973 | _exit (1); |
1008 | _exit (1); |
974 | |
1009 | |
975 | void |
1010 | void |
976 | _exit (int retval = 0) |
1011 | _exit (int retval = 0) |
… | |
… | |
988 | #if DEBUG |
1023 | #if DEBUG |
989 | VALGRIND_DO_LEAK_CHECK; |
1024 | VALGRIND_DO_LEAK_CHECK; |
990 | #endif |
1025 | #endif |
991 | } |
1026 | } |
992 | |
1027 | |
993 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1028 | MODULE = Deliantra::Client PACKAGE = dc::Font |
994 | |
1029 | |
995 | PROTOTYPES: DISABLE |
1030 | PROTOTYPES: DISABLE |
996 | |
1031 | |
997 | CFPlus::Font |
1032 | dc::Font |
998 | new_from_file (SV *class, char *path, int id = 0) |
1033 | new_from_file (SV *class, char *path, int id = 0) |
999 | CODE: |
1034 | CODE: |
1000 | { |
1035 | { |
1001 | int count; |
1036 | int count; |
1002 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1037 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1005 | } |
1040 | } |
1006 | OUTPUT: |
1041 | OUTPUT: |
1007 | RETVAL |
1042 | RETVAL |
1008 | |
1043 | |
1009 | void |
1044 | void |
1010 | DESTROY (CFPlus::Font self) |
1045 | DESTROY (dc::Font self) |
1011 | CODE: |
1046 | CODE: |
1012 | pango_font_description_free (self); |
1047 | pango_font_description_free (self); |
1013 | |
1048 | |
1014 | void |
1049 | void |
1015 | make_default (CFPlus::Font self) |
1050 | make_default (dc::Font self) |
1016 | PROTOTYPE: $ |
1051 | PROTOTYPE: $ |
1017 | CODE: |
1052 | CODE: |
1018 | default_font = self; |
1053 | default_font = self; |
1019 | |
1054 | |
1020 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1055 | MODULE = Deliantra::Client PACKAGE = dc::Layout |
1021 | |
1056 | |
1022 | PROTOTYPES: DISABLE |
1057 | PROTOTYPES: DISABLE |
1023 | |
1058 | |
1024 | void |
1059 | void |
1025 | reset_glyph_cache () |
1060 | glyph_cache_backup () |
1026 | PROTOTYPE: |
1061 | PROTOTYPE: |
1027 | CODE: |
1062 | CODE: |
|
|
1063 | tc_backup (); |
|
|
1064 | |
|
|
1065 | void |
|
|
1066 | glyph_cache_restore () |
|
|
1067 | PROTOTYPE: |
|
|
1068 | CODE: |
1028 | tc_clear (); |
1069 | tc_restore (); |
1029 | |
1070 | |
1030 | CFPlus::Layout |
1071 | dc::Layout |
1031 | new (SV *class) |
1072 | new (SV *class) |
1032 | CODE: |
1073 | CODE: |
1033 | New (0, RETVAL, 1, struct cf_layout); |
1074 | New (0, RETVAL, 1, struct cf_layout); |
1034 | |
1075 | |
1035 | RETVAL->pl = pango_layout_new (opengl_context); |
1076 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1045 | layout_update_font (RETVAL); |
1086 | layout_update_font (RETVAL); |
1046 | OUTPUT: |
1087 | OUTPUT: |
1047 | RETVAL |
1088 | RETVAL |
1048 | |
1089 | |
1049 | void |
1090 | void |
1050 | DESTROY (CFPlus::Layout self) |
1091 | DESTROY (dc::Layout self) |
1051 | CODE: |
1092 | CODE: |
1052 | g_object_unref (self->pl); |
1093 | g_object_unref (self->pl); |
1053 | rc_free (self->rc); |
1094 | rc_free (self->rc); |
1054 | Safefree (self); |
1095 | Safefree (self); |
1055 | |
1096 | |
1056 | void |
1097 | void |
1057 | set_text (CFPlus::Layout self, SV *text_) |
1098 | set_text (dc::Layout self, SV *text_) |
1058 | CODE: |
1099 | CODE: |
1059 | { |
1100 | { |
1060 | STRLEN textlen; |
1101 | STRLEN textlen; |
1061 | char *text = SvPVutf8 (text_, textlen); |
1102 | char *text = SvPVutf8 (text_, textlen); |
1062 | |
1103 | |
1063 | pango_layout_set_text (self->pl, text, textlen); |
1104 | pango_layout_set_text (self->pl, text, textlen); |
1064 | } |
1105 | } |
1065 | |
1106 | |
1066 | void |
1107 | void |
1067 | set_markup (CFPlus::Layout self, SV *text_) |
1108 | set_markup (dc::Layout self, SV *text_) |
1068 | CODE: |
1109 | CODE: |
1069 | { |
1110 | { |
1070 | STRLEN textlen; |
1111 | STRLEN textlen; |
1071 | char *text = SvPVutf8 (text_, textlen); |
1112 | char *text = SvPVutf8 (text_, textlen); |
1072 | |
1113 | |
1073 | pango_layout_set_markup (self->pl, text, textlen); |
1114 | pango_layout_set_markup (self->pl, text, textlen); |
1074 | } |
1115 | } |
1075 | |
1116 | |
1076 | void |
1117 | void |
1077 | set_shapes (CFPlus::Layout self, ...) |
1118 | set_shapes (dc::Layout self, ...) |
1078 | CODE: |
1119 | CODE: |
1079 | { |
1120 | { |
1080 | PangoAttrList *attrs = 0; |
1121 | PangoAttrList *attrs = 0; |
1081 | const char *text = pango_layout_get_text (self->pl); |
1122 | const char *text = pango_layout_get_text (self->pl); |
1082 | const char *pos = text; |
1123 | const char *pos = text; |
… | |
… | |
1117 | if (attrs) |
1158 | if (attrs) |
1118 | pango_layout_set_attributes (self->pl, attrs); |
1159 | pango_layout_set_attributes (self->pl, attrs); |
1119 | } |
1160 | } |
1120 | |
1161 | |
1121 | void |
1162 | void |
1122 | get_shapes (CFPlus::Layout self) |
1163 | get_shapes (dc::Layout self) |
1123 | PPCODE: |
1164 | PPCODE: |
1124 | { |
1165 | { |
1125 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1166 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1126 | |
1167 | |
1127 | do |
1168 | do |
… | |
… | |
1142 | |
1183 | |
1143 | pango_layout_iter_free (iter); |
1184 | pango_layout_iter_free (iter); |
1144 | } |
1185 | } |
1145 | |
1186 | |
1146 | int |
1187 | int |
1147 | has_wrapped (CFPlus::Layout self) |
1188 | has_wrapped (dc::Layout self) |
1148 | CODE: |
1189 | CODE: |
1149 | { |
1190 | { |
1150 | int lines = 1; |
1191 | int lines = 1; |
1151 | const char *text = pango_layout_get_text (self->pl); |
1192 | const char *text = pango_layout_get_text (self->pl); |
1152 | |
1193 | |
… | |
… | |
1157 | } |
1198 | } |
1158 | OUTPUT: |
1199 | OUTPUT: |
1159 | RETVAL |
1200 | RETVAL |
1160 | |
1201 | |
1161 | SV * |
1202 | SV * |
1162 | get_text (CFPlus::Layout self) |
1203 | get_text (dc::Layout self) |
1163 | CODE: |
1204 | CODE: |
1164 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1205 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1165 | sv_utf8_decode (RETVAL); |
1206 | sv_utf8_decode (RETVAL); |
1166 | OUTPUT: |
1207 | OUTPUT: |
1167 | RETVAL |
1208 | RETVAL |
1168 | |
1209 | |
1169 | void |
1210 | void |
1170 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1211 | set_foreground (dc::Layout self, float r, float g, float b, float a = 1.) |
1171 | CODE: |
1212 | CODE: |
1172 | self->r = r; |
1213 | self->r = r; |
1173 | self->g = g; |
1214 | self->g = g; |
1174 | self->b = b; |
1215 | self->b = b; |
1175 | self->a = a; |
1216 | self->a = a; |
1176 | |
1217 | |
1177 | void |
1218 | void |
1178 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1219 | set_font (dc::Layout self, dc::Font font = 0) |
1179 | CODE: |
1220 | CODE: |
1180 | if (self->font != font) |
1221 | if (self->font != font) |
1181 | { |
1222 | { |
1182 | self->font = font; |
1223 | self->font = font; |
1183 | layout_update_font (self); |
1224 | layout_update_font (self); |
1184 | } |
1225 | } |
1185 | |
1226 | |
1186 | void |
1227 | void |
1187 | set_height (CFPlus::Layout self, int base_height) |
1228 | set_height (dc::Layout self, int base_height) |
1188 | CODE: |
1229 | CODE: |
1189 | if (self->base_height != base_height) |
1230 | if (self->base_height != base_height) |
1190 | { |
1231 | { |
1191 | self->base_height = base_height; |
1232 | self->base_height = base_height; |
1192 | layout_update_font (self); |
1233 | layout_update_font (self); |
1193 | } |
1234 | } |
1194 | |
1235 | |
1195 | void |
1236 | void |
1196 | set_width (CFPlus::Layout self, int max_width = -1) |
1237 | set_width (dc::Layout self, int max_width = -1) |
1197 | CODE: |
1238 | CODE: |
1198 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1239 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1199 | |
1240 | |
1200 | void |
1241 | void |
1201 | set_indent (CFPlus::Layout self, int indent) |
1242 | set_indent (dc::Layout self, int indent) |
1202 | CODE: |
1243 | CODE: |
1203 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1244 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1204 | |
1245 | |
1205 | void |
1246 | void |
1206 | set_spacing (CFPlus::Layout self, int spacing) |
1247 | set_spacing (dc::Layout self, int spacing) |
1207 | CODE: |
1248 | CODE: |
1208 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1249 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1209 | |
1250 | |
1210 | void |
1251 | void |
1211 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1252 | set_ellipsise (dc::Layout self, int ellipsise) |
1212 | CODE: |
1253 | CODE: |
1213 | pango_layout_set_ellipsize (self->pl, |
1254 | pango_layout_set_ellipsize (self->pl, |
1214 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1255 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1215 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1256 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1216 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1257 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1217 | : PANGO_ELLIPSIZE_NONE |
1258 | : PANGO_ELLIPSIZE_NONE |
1218 | ); |
1259 | ); |
1219 | |
1260 | |
1220 | void |
1261 | void |
1221 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1262 | set_single_paragraph_mode (dc::Layout self, int spm) |
1222 | CODE: |
1263 | CODE: |
1223 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1264 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1224 | |
1265 | |
1225 | void |
1266 | void |
1226 | size (CFPlus::Layout self) |
1267 | size (dc::Layout self) |
1227 | PPCODE: |
1268 | PPCODE: |
1228 | { |
1269 | { |
1229 | int w, h; |
1270 | int w, h; |
1230 | |
1271 | |
1231 | layout_get_pixel_size (self, &w, &h); |
1272 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1234 | PUSHs (sv_2mortal (newSViv (w))); |
1275 | PUSHs (sv_2mortal (newSViv (w))); |
1235 | PUSHs (sv_2mortal (newSViv (h))); |
1276 | PUSHs (sv_2mortal (newSViv (h))); |
1236 | } |
1277 | } |
1237 | |
1278 | |
1238 | int |
1279 | int |
1239 | descent (CFPlus::Layout self) |
1280 | descent (dc::Layout self) |
1240 | CODE: |
1281 | CODE: |
1241 | { |
1282 | { |
1242 | PangoRectangle rect; |
1283 | PangoRectangle rect; |
1243 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1284 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1244 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1285 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
1246 | } |
1287 | } |
1247 | OUTPUT: |
1288 | OUTPUT: |
1248 | RETVAL |
1289 | RETVAL |
1249 | |
1290 | |
1250 | int |
1291 | int |
1251 | xy_to_index (CFPlus::Layout self, int x, int y) |
1292 | xy_to_index (dc::Layout self, int x, int y) |
1252 | CODE: |
1293 | CODE: |
1253 | { |
1294 | { |
1254 | int index, trailing; |
1295 | int index, trailing; |
1255 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1296 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1256 | RETVAL = index + trailing; |
1297 | RETVAL = index + trailing; |
1257 | } |
1298 | } |
1258 | OUTPUT: |
1299 | OUTPUT: |
1259 | RETVAL |
1300 | RETVAL |
1260 | |
1301 | |
1261 | void |
1302 | void |
1262 | cursor_pos (CFPlus::Layout self, int index) |
1303 | cursor_pos (dc::Layout self, int index) |
1263 | PPCODE: |
1304 | PPCODE: |
1264 | { |
1305 | { |
1265 | PangoRectangle strong_pos; |
1306 | PangoRectangle strong_pos; |
1266 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1307 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1267 | |
1308 | |
… | |
… | |
1270 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1311 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1271 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1312 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1272 | } |
1313 | } |
1273 | |
1314 | |
1274 | void |
1315 | void |
1275 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1316 | index_to_line_x (dc::Layout self, int index, int trailing = 0) |
1276 | PPCODE: |
1317 | PPCODE: |
1277 | { |
1318 | { |
1278 | int line, x; |
1319 | int line, x; |
1279 | |
1320 | |
1280 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1321 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
… | |
… | |
1284 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1325 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1285 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1326 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1286 | } |
1327 | } |
1287 | |
1328 | |
1288 | void |
1329 | void |
1289 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1330 | line_x_to_index (dc::Layout self, int line, int x) |
1290 | PPCODE: |
1331 | PPCODE: |
1291 | { |
1332 | { |
1292 | PangoLayoutLine *lp; |
1333 | PangoLayoutLine *lp; |
1293 | int index, trailing; |
1334 | int index, trailing; |
1294 | |
1335 | |
… | |
… | |
1309 | PUSHs (sv_2mortal (newSViv (trailing))); |
1350 | PUSHs (sv_2mortal (newSViv (trailing))); |
1310 | } |
1351 | } |
1311 | } |
1352 | } |
1312 | |
1353 | |
1313 | void |
1354 | void |
1314 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1355 | render (dc::Layout self, float x, float y, int flags = 0) |
1315 | CODE: |
1356 | CODE: |
1316 | rc_clear (self->rc); |
1357 | rc_clear (self->rc); |
1317 | pango_opengl_render_layout_subpixel ( |
1358 | pango_opengl_render_layout_subpixel ( |
1318 | self->pl, |
1359 | self->pl, |
1319 | self->rc, |
1360 | self->rc, |
… | |
… | |
1324 | // we assume that context_change actually clears/frees stuff |
1365 | // we assume that context_change actually clears/frees stuff |
1325 | // and does not do any recomputation... |
1366 | // and does not do any recomputation... |
1326 | pango_layout_context_changed (self->pl); |
1367 | pango_layout_context_changed (self->pl); |
1327 | |
1368 | |
1328 | void |
1369 | void |
1329 | draw (CFPlus::Layout self) |
1370 | draw (dc::Layout self) |
1330 | CODE: |
1371 | CODE: |
1331 | { |
1372 | { |
1332 | glEnable (GL_TEXTURE_2D); |
1373 | glEnable (GL_TEXTURE_2D); |
1333 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1374 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1334 | glEnable (GL_BLEND); |
1375 | glEnable (GL_BLEND); |
… | |
… | |
1342 | glDisable (GL_ALPHA_TEST); |
1383 | glDisable (GL_ALPHA_TEST); |
1343 | glDisable (GL_BLEND); |
1384 | glDisable (GL_BLEND); |
1344 | glDisable (GL_TEXTURE_2D); |
1385 | glDisable (GL_TEXTURE_2D); |
1345 | } |
1386 | } |
1346 | |
1387 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1388 | MODULE = Deliantra::Client PACKAGE = dc::Texture |
1348 | |
1389 | |
1349 | PROTOTYPES: ENABLE |
1390 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1391 | |
1353 | void |
1392 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1393 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1394 | CODE: |
1356 | { |
1395 | { |
… | |
… | |
1433 | RETVAL = width > 0; |
1472 | RETVAL = width > 0; |
1434 | } |
1473 | } |
1435 | OUTPUT: |
1474 | OUTPUT: |
1436 | RETVAL |
1475 | RETVAL |
1437 | |
1476 | |
1438 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1477 | MODULE = Deliantra::Client PACKAGE = dc::Map |
1439 | |
1478 | |
1440 | PROTOTYPES: DISABLE |
1479 | PROTOTYPES: DISABLE |
1441 | |
1480 | |
1442 | CFPlus::Map |
1481 | dc::Map |
1443 | new (SV *class) |
1482 | new (SV *class) |
1444 | CODE: |
1483 | CODE: |
1445 | New (0, RETVAL, 1, struct map); |
1484 | New (0, RETVAL, 1, struct map); |
1446 | RETVAL->x = 0; |
1485 | RETVAL->x = 0; |
1447 | RETVAL->y = 0; |
1486 | RETVAL->y = 0; |
… | |
… | |
1455 | RETVAL->row = 0; |
1494 | RETVAL->row = 0; |
1456 | OUTPUT: |
1495 | OUTPUT: |
1457 | RETVAL |
1496 | RETVAL |
1458 | |
1497 | |
1459 | void |
1498 | void |
1460 | DESTROY (CFPlus::Map self) |
1499 | DESTROY (dc::Map self) |
1461 | CODE: |
1500 | CODE: |
1462 | { |
1501 | { |
1463 | map_clear (self); |
1502 | map_clear (self); |
1464 | Safefree (self->face2tile); |
1503 | Safefree (self->face2tile); |
1465 | Safefree (self->tex); |
1504 | Safefree (self->tex); |
1466 | Safefree (self); |
1505 | Safefree (self); |
1467 | } |
1506 | } |
1468 | |
1507 | |
1469 | void |
1508 | void |
1470 | resize (CFPlus::Map self, int map_width, int map_height) |
1509 | resize (dc::Map self, int map_width, int map_height) |
1471 | CODE: |
1510 | CODE: |
1472 | self->w = map_width; |
1511 | self->w = map_width; |
1473 | self->h = map_height; |
1512 | self->h = map_height; |
1474 | |
1513 | |
1475 | void |
1514 | void |
1476 | clear (CFPlus::Map self) |
1515 | clear (dc::Map self) |
1477 | CODE: |
1516 | CODE: |
1478 | map_clear (self); |
1517 | map_clear (self); |
1479 | |
1518 | |
1480 | void |
1519 | void |
1481 | set_tileid (CFPlus::Map self, int face, int tile) |
1520 | set_tileid (dc::Map self, int face, int tile) |
1482 | CODE: |
1521 | CODE: |
1483 | { |
1522 | { |
1484 | need_facenum (self, face); self->face2tile [face] = tile; |
1523 | need_facenum (self, face); self->face2tile [face] = tile; |
1485 | need_texid (self, tile); |
1524 | need_texid (self, tile); |
1486 | } |
1525 | } |
1487 | |
1526 | |
1488 | void |
1527 | void |
1489 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1528 | set_smooth (dc::Map self, int face, int smooth, int level) |
1490 | CODE: |
1529 | CODE: |
1491 | { |
1530 | { |
1492 | tileid texid; |
1531 | tileid texid; |
1493 | maptex *tex; |
1532 | maptex *tex; |
1494 | |
1533 | |
… | |
… | |
1507 | tex->smoothtile = self->face2tile [smooth]; |
1546 | tex->smoothtile = self->face2tile [smooth]; |
1508 | tex->smoothlevel = level; |
1547 | tex->smoothlevel = level; |
1509 | } |
1548 | } |
1510 | |
1549 | |
1511 | void |
1550 | 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) |
1551 | 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: |
1552 | CODE: |
1514 | { |
1553 | { |
1515 | need_texid (self, texid); |
1554 | need_texid (self, texid); |
1516 | |
1555 | |
1517 | { |
1556 | { |
… | |
… | |
1537 | // from transparent color bleeding and ugly wrapping effects. |
1576 | // from transparent color bleeding and ugly wrapping effects. |
1538 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1577 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1539 | } |
1578 | } |
1540 | |
1579 | |
1541 | int |
1580 | int |
1542 | ox (CFPlus::Map self) |
1581 | ox (dc::Map self) |
1543 | ALIAS: |
1582 | ALIAS: |
1544 | oy = 1 |
1583 | oy = 1 |
1545 | x = 2 |
1584 | x = 2 |
1546 | y = 3 |
1585 | y = 3 |
1547 | w = 4 |
1586 | w = 4 |
… | |
… | |
1558 | } |
1597 | } |
1559 | OUTPUT: |
1598 | OUTPUT: |
1560 | RETVAL |
1599 | RETVAL |
1561 | |
1600 | |
1562 | void |
1601 | void |
1563 | scroll (CFPlus::Map self, int dx, int dy) |
1602 | scroll (dc::Map self, int dx, int dy) |
1564 | CODE: |
1603 | CODE: |
1565 | { |
1604 | { |
1566 | if (dx > 0) |
1605 | if (dx > 0) |
1567 | map_blank (self, self->x, self->y, dx, self->h); |
1606 | map_blank (self, self->x, self->y, dx, self->h); |
1568 | else if (dx < 0) |
1607 | else if (dx < 0) |
… | |
… | |
1584 | self->y += MAP_EXTEND_Y; |
1623 | self->y += MAP_EXTEND_Y; |
1585 | } |
1624 | } |
1586 | } |
1625 | } |
1587 | |
1626 | |
1588 | SV * |
1627 | SV * |
1589 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1628 | map1a_update (dc::Map self, SV *data_, int extmap) |
1590 | CODE: |
1629 | CODE: |
1591 | { |
1630 | { |
1592 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1631 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1593 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1632 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1594 | mapcell *cell; |
1633 | mapcell *cell; |
… | |
… | |
1683 | } |
1722 | } |
1684 | OUTPUT: |
1723 | OUTPUT: |
1685 | RETVAL |
1724 | RETVAL |
1686 | |
1725 | |
1687 | SV * |
1726 | SV * |
1688 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1727 | mapmap (dc::Map self, int x0, int y0, int w, int h) |
1689 | CODE: |
1728 | CODE: |
1690 | { |
1729 | { |
1691 | int x1, x; |
1730 | int x1, x; |
1692 | int y1, y; |
1731 | int y1, y; |
1693 | int z; |
1732 | int z; |
… | |
… | |
1738 | } |
1777 | } |
1739 | OUTPUT: |
1778 | OUTPUT: |
1740 | RETVAL |
1779 | RETVAL |
1741 | |
1780 | |
1742 | void |
1781 | void |
1743 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1782 | draw (dc::Map self, int mx, int my, int sw, int sh, int T) |
1744 | CODE: |
1783 | CODE: |
1745 | { |
1784 | { |
1746 | int x, y, z; |
1785 | int x, y, z; |
1747 | |
1786 | |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1787 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2019 | } |
2058 | } |
2020 | } |
2059 | } |
2021 | } |
2060 | } |
2022 | |
2061 | |
2023 | void |
2062 | void |
2024 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2063 | draw_magicmap (dc::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2025 | CODE: |
2064 | CODE: |
2026 | { |
2065 | { |
2027 | static float color[16][3] = { |
2066 | static float color[16][3] = { |
2028 | { 0.00F, 0.00F, 0.00F }, |
2067 | { 0.00F, 0.00F, 0.00F }, |
2029 | { 1.00F, 1.00F, 1.00F }, |
2068 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2079 | glDisable (GL_BLEND); |
2118 | glDisable (GL_BLEND); |
2080 | glDisable (GL_TEXTURE_2D); |
2119 | glDisable (GL_TEXTURE_2D); |
2081 | } |
2120 | } |
2082 | |
2121 | |
2083 | void |
2122 | void |
2084 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2123 | fow_texture (dc::Map self, int mx, int my, int sw, int sh) |
2085 | PPCODE: |
2124 | PPCODE: |
2086 | { |
2125 | { |
2087 | int x, y; |
2126 | int x, y; |
2088 | int sw1 = sw + 2; |
2127 | int sw1 = sw + 2; |
2089 | int sh1 = sh + 2; |
2128 | int sh1 = sh + 2; |
… | |
… | |
2160 | PUSHs (sv_2mortal (newSViv (sh3))); |
2199 | PUSHs (sv_2mortal (newSViv (sh3))); |
2161 | PUSHs (darkness3_sv); |
2200 | PUSHs (darkness3_sv); |
2162 | } |
2201 | } |
2163 | |
2202 | |
2164 | SV * |
2203 | SV * |
2165 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2204 | get_rect (dc::Map self, int x0, int y0, int w, int h) |
2166 | CODE: |
2205 | CODE: |
2167 | { |
2206 | { |
2168 | int x, y, x1, y1; |
2207 | int x, y, x1, y1; |
2169 | SV *data_sv = newSV (w * h * 7 + 5); |
2208 | SV *data_sv = newSV (w * h * 7 + 5); |
2170 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2209 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2235 | } |
2274 | } |
2236 | OUTPUT: |
2275 | OUTPUT: |
2237 | RETVAL |
2276 | RETVAL |
2238 | |
2277 | |
2239 | void |
2278 | void |
2240 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2279 | set_rect (dc::Map self, int x0, int y0, uint8_t *data) |
2241 | PPCODE: |
2280 | PPCODE: |
2242 | { |
2281 | { |
2243 | int x, y, z; |
2282 | int x, y, z; |
2244 | int w, h; |
2283 | int w, h; |
2245 | int x1, y1; |
2284 | int x1, y1; |
… | |
… | |
2298 | } |
2337 | } |
2299 | } |
2338 | } |
2300 | } |
2339 | } |
2301 | } |
2340 | } |
2302 | |
2341 | |
2303 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2342 | MODULE = Deliantra::Client PACKAGE = dc::RW |
2304 | |
2343 | |
2305 | CFPlus::RW |
2344 | dc::RW |
2306 | new (SV *class, SV *data_sv) |
2345 | new (SV *class, SV *data_sv) |
2307 | CODE: |
2346 | CODE: |
2308 | { |
2347 | { |
2309 | STRLEN datalen; |
2348 | STRLEN datalen; |
2310 | char *data = SvPVbyte (data_sv, datalen); |
2349 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2312 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2351 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2313 | } |
2352 | } |
2314 | OUTPUT: |
2353 | OUTPUT: |
2315 | RETVAL |
2354 | RETVAL |
2316 | |
2355 | |
2317 | CFPlus::RW |
2356 | dc::RW |
2318 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2357 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2319 | CODE: |
2358 | CODE: |
2320 | RETVAL = SDL_RWFromFile (path, mode); |
2359 | RETVAL = SDL_RWFromFile (path, mode); |
2321 | OUTPUT: |
2360 | OUTPUT: |
2322 | RETVAL |
2361 | RETVAL |
2323 | |
2362 | |
2324 | # fails on win32: |
2363 | # fails on win32: |
2325 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2364 | # dc.xs(2268) : error C2059: syntax error : '(' |
2326 | #void |
2365 | #void |
2327 | #close (CFPlus::RW self) |
2366 | #close (dc::RW self) |
2328 | # CODE: |
2367 | # CODE: |
2329 | # (self->(close)) (self); |
2368 | # (self->(close)) (self); |
2330 | |
2369 | |
2331 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2370 | MODULE = Deliantra::Client PACKAGE = dc::Channel |
2332 | |
2371 | |
2333 | PROTOTYPES: DISABLE |
2372 | PROTOTYPES: DISABLE |
2334 | |
2373 | |
2335 | CFPlus::Channel |
2374 | dc::Channel |
2336 | find () |
2375 | find () |
2337 | CODE: |
2376 | CODE: |
2338 | { |
2377 | { |
2339 | RETVAL = Mix_GroupAvailable (-1); |
2378 | RETVAL = Mix_GroupAvailable (-1); |
2340 | |
2379 | |
… | |
… | |
2353 | } |
2392 | } |
2354 | OUTPUT: |
2393 | OUTPUT: |
2355 | RETVAL |
2394 | RETVAL |
2356 | |
2395 | |
2357 | void |
2396 | void |
2358 | halt (CFPlus::Channel self) |
2397 | halt (dc::Channel self) |
2359 | CODE: |
2398 | CODE: |
2360 | Mix_HaltChannel (self); |
2399 | Mix_HaltChannel (self); |
2361 | |
2400 | |
2362 | void |
2401 | void |
2363 | expire (CFPlus::Channel self, int ticks = -1) |
2402 | expire (dc::Channel self, int ticks = -1) |
2364 | CODE: |
2403 | CODE: |
2365 | Mix_ExpireChannel (self, ticks); |
2404 | Mix_ExpireChannel (self, ticks); |
2366 | |
2405 | |
2367 | void |
2406 | void |
2368 | fade_out (CFPlus::Channel self, int ticks = -1) |
2407 | fade_out (dc::Channel self, int ticks = -1) |
2369 | CODE: |
2408 | CODE: |
2370 | Mix_FadeOutChannel (self, ticks); |
2409 | Mix_FadeOutChannel (self, ticks); |
2371 | |
2410 | |
2372 | int |
2411 | int |
2373 | volume (CFPlus::Channel self, int volume) |
2412 | volume (dc::Channel self, int volume) |
2374 | CODE: |
2413 | CODE: |
2375 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2414 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2376 | OUTPUT: |
2415 | OUTPUT: |
2377 | RETVAL |
2416 | RETVAL |
2378 | |
2417 | |
2379 | void |
2418 | void |
2380 | unregister_all_effects (CFPlus::Channel self) |
2419 | unregister_all_effects (dc::Channel self) |
2381 | CODE: |
2420 | CODE: |
2382 | Mix_UnregisterAllEffects (self); |
2421 | Mix_UnregisterAllEffects (self); |
2383 | |
2422 | |
2384 | void |
2423 | void |
2385 | set_panning (CFPlus::Channel self, int left, int right) |
2424 | set_panning (dc::Channel self, int left, int right) |
2386 | CODE: |
2425 | CODE: |
2387 | left = CLAMP (left , 0, 255); |
2426 | left = CLAMP (left , 0, 255); |
2388 | right = CLAMP (right, 0, 255); |
2427 | right = CLAMP (right, 0, 255); |
2389 | Mix_SetPanning (self, left, right); |
2428 | Mix_SetPanning (self, left, right); |
2390 | |
2429 | |
2391 | void |
2430 | void |
2392 | set_distance (CFPlus::Channel self, int distance) |
2431 | set_distance (dc::Channel self, int distance) |
2393 | CODE: |
2432 | CODE: |
2394 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2433 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2395 | |
2434 | |
2396 | void |
2435 | void |
2397 | set_position (CFPlus::Channel self, int angle, int distance) |
2436 | set_position (dc::Channel self, int angle, int distance) |
2398 | CODE: |
2437 | CODE: |
2399 | |
2438 | |
2400 | void |
2439 | void |
2401 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2440 | set_position_r (dc::Channel self, int dx, int dy, int maxdistance) |
2402 | CODE: |
2441 | CODE: |
2403 | { |
2442 | { |
2404 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2443 | 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); |
2444 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2406 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2445 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2407 | } |
2446 | } |
2408 | |
2447 | |
2409 | void |
2448 | void |
2410 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2449 | set_reverse_stereo (dc::Channel self, int flip) |
2411 | CODE: |
2450 | CODE: |
2412 | Mix_SetReverseStereo (self, flip); |
2451 | Mix_SetReverseStereo (self, flip); |
2413 | |
2452 | |
2414 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2453 | MODULE = Deliantra::Client PACKAGE = dc::MixChunk |
2415 | |
2454 | |
2416 | PROTOTYPES: DISABLE |
2455 | PROTOTYPES: DISABLE |
2417 | |
2456 | |
2418 | CFPlus::MixChunk |
2457 | dc::MixChunk |
2419 | new (SV *class, CFPlus::RW rwops) |
2458 | new (SV *class, dc::RW rwops) |
2420 | CODE: |
2459 | CODE: |
2421 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2460 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2422 | OUTPUT: |
2461 | OUTPUT: |
2423 | RETVAL |
2462 | RETVAL |
2424 | |
2463 | |
2425 | void |
2464 | void |
2426 | DESTROY (CFPlus::MixChunk self) |
2465 | DESTROY (dc::MixChunk self) |
2427 | CODE: |
2466 | CODE: |
2428 | Mix_FreeChunk (self); |
2467 | Mix_FreeChunk (self); |
2429 | |
2468 | |
2430 | int |
2469 | int |
2431 | volume (CFPlus::MixChunk self, int volume = -1) |
2470 | volume (dc::MixChunk self, int volume = -1) |
2432 | CODE: |
2471 | CODE: |
2433 | if (items > 1) |
2472 | if (items > 1) |
2434 | volume = CLAMP (volume, 0, 128); |
2473 | volume = CLAMP (volume, 0, 128); |
2435 | RETVAL = Mix_VolumeChunk (self, volume); |
2474 | RETVAL = Mix_VolumeChunk (self, volume); |
2436 | OUTPUT: |
2475 | OUTPUT: |
2437 | RETVAL |
2476 | RETVAL |
2438 | |
2477 | |
2439 | CFPlus::Channel |
2478 | dc::Channel |
2440 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2479 | play (dc::MixChunk self, dc::Channel channel = -1, int loops = 0, int ticks = -1) |
2441 | CODE: |
2480 | CODE: |
2442 | { |
2481 | { |
2443 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2482 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2444 | |
2483 | |
2445 | if (RETVAL < 0) |
2484 | if (RETVAL < 0) |
… | |
… | |
2452 | } |
2491 | } |
2453 | } |
2492 | } |
2454 | OUTPUT: |
2493 | OUTPUT: |
2455 | RETVAL |
2494 | RETVAL |
2456 | |
2495 | |
2457 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2496 | MODULE = Deliantra::Client PACKAGE = dc::MixMusic |
2458 | |
2497 | |
2459 | int |
2498 | int |
2460 | volume (int volume = -1) |
2499 | volume (int volume = -1) |
2461 | PROTOTYPE: ;$ |
2500 | PROTOTYPE: ;$ |
2462 | CODE: |
2501 | CODE: |
… | |
… | |
2474 | void |
2513 | void |
2475 | halt () |
2514 | halt () |
2476 | CODE: |
2515 | CODE: |
2477 | Mix_HaltMusic (); |
2516 | Mix_HaltMusic (); |
2478 | |
2517 | |
2479 | CFPlus::MixMusic |
2518 | dc::MixMusic |
2480 | new (SV *class, CFPlus::RW rwops) |
2519 | new (SV *class, dc::RW rwops) |
2481 | CODE: |
2520 | CODE: |
2482 | RETVAL = Mix_LoadMUS_RW (rwops); |
2521 | RETVAL = Mix_LoadMUS_RW (rwops); |
2483 | OUTPUT: |
2522 | OUTPUT: |
2484 | RETVAL |
2523 | RETVAL |
2485 | |
2524 | |
2486 | void |
2525 | void |
2487 | DESTROY (CFPlus::MixMusic self) |
2526 | DESTROY (dc::MixMusic self) |
2488 | CODE: |
2527 | CODE: |
2489 | Mix_FreeMusic (self); |
2528 | Mix_FreeMusic (self); |
2490 | |
2529 | |
2491 | int |
2530 | int |
2492 | play (CFPlus::MixMusic self, int loops = -1) |
2531 | play (dc::MixMusic self, int loops = -1) |
2493 | CODE: |
2532 | CODE: |
2494 | RETVAL = Mix_PlayMusic (self, loops); |
2533 | RETVAL = Mix_PlayMusic (self, loops); |
2495 | OUTPUT: |
2534 | OUTPUT: |
2496 | RETVAL |
2535 | RETVAL |
2497 | |
2536 | |
2498 | void |
2537 | void |
2499 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2538 | fade_in_pos (dc::MixMusic self, int loops, int ms, double position) |
2500 | CODE: |
2539 | CODE: |
2501 | Mix_FadeInMusicPos (self, loops, ms, position); |
2540 | Mix_FadeInMusicPos (self, loops, ms, position); |
2502 | |
2541 | |
2503 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2542 | MODULE = Deliantra::Client PACKAGE = dc::OpenGL |
2504 | |
2543 | |
2505 | PROTOTYPES: ENABLE |
2544 | PROTOTYPES: ENABLE |
2506 | |
2545 | |
2507 | BOOT: |
2546 | BOOT: |
2508 | { |
2547 | { |
2509 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2548 | HV *stash = gv_stashpv ("dc::OpenGL", 1); |
2510 | static const struct { |
2549 | static const struct { |
2511 | const char *name; |
2550 | const char *name; |
2512 | IV iv; |
2551 | IV iv; |
2513 | } *civ, const_iv[] = { |
2552 | } *civ, const_iv[] = { |
2514 | # define const_iv(name) { # name, (IV)name } |
2553 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2549 | const_iv (GL_INTENSITY), |
2588 | const_iv (GL_INTENSITY), |
2550 | const_iv (GL_LUMINANCE), |
2589 | const_iv (GL_LUMINANCE), |
2551 | const_iv (GL_LUMINANCE_ALPHA), |
2590 | const_iv (GL_LUMINANCE_ALPHA), |
2552 | const_iv (GL_FLOAT), |
2591 | const_iv (GL_FLOAT), |
2553 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2592 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2593 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2594 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2595 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2596 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2597 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2598 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2554 | const_iv (GL_COMPILE), |
2599 | const_iv (GL_COMPILE), |
2555 | const_iv (GL_PROXY_TEXTURE_1D), |
2600 | const_iv (GL_PROXY_TEXTURE_1D), |
2556 | const_iv (GL_PROXY_TEXTURE_2D), |
2601 | const_iv (GL_PROXY_TEXTURE_2D), |
2557 | const_iv (GL_TEXTURE_1D), |
2602 | const_iv (GL_TEXTURE_1D), |
2558 | const_iv (GL_TEXTURE_2D), |
2603 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2597 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2642 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2598 | const_iv (GL_POINT_SMOOTH_HINT), |
2643 | const_iv (GL_POINT_SMOOTH_HINT), |
2599 | const_iv (GL_LINE_SMOOTH_HINT), |
2644 | const_iv (GL_LINE_SMOOTH_HINT), |
2600 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2645 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2601 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2646 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2647 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2602 | const_iv (GL_FASTEST), |
2648 | const_iv (GL_FASTEST), |
2603 | const_iv (GL_DONT_CARE), |
2649 | const_iv (GL_DONT_CARE), |
2604 | const_iv (GL_NICEST), |
2650 | const_iv (GL_NICEST), |
2605 | const_iv (GL_V2F), |
2651 | const_iv (GL_V2F), |
2606 | const_iv (GL_V3F), |
2652 | const_iv (GL_V3F), |
… | |
… | |
2614 | |
2660 | |
2615 | texture_av = newAV (); |
2661 | texture_av = newAV (); |
2616 | AvREAL_off (texture_av); |
2662 | AvREAL_off (texture_av); |
2617 | } |
2663 | } |
2618 | |
2664 | |
|
|
2665 | void |
|
|
2666 | disable_GL_EXT_blend_func_separate () |
|
|
2667 | CODE: |
|
|
2668 | gl.BlendFuncSeparate = 0; |
|
|
2669 | gl.BlendFuncSeparateEXT = 0; |
|
|
2670 | |
2619 | char * |
2671 | char * |
2620 | gl_vendor () |
2672 | gl_vendor () |
2621 | CODE: |
2673 | CODE: |
2622 | RETVAL = (char *)glGetString (GL_VENDOR); |
2674 | RETVAL = (char *)glGetString (GL_VENDOR); |
2623 | OUTPUT: |
2675 | OUTPUT: |
… | |
… | |
2744 | |
2796 | |
2745 | void glRect (float x1, float y1, float x2, float y2) |
2797 | void glRect (float x1, float y1, float x2, float y2) |
2746 | CODE: |
2798 | CODE: |
2747 | glRectf (x1, y1, x2, y2); |
2799 | glRectf (x1, y1, x2, y2); |
2748 | |
2800 | |
|
|
2801 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2802 | CODE: |
|
|
2803 | glBegin (GL_LINE_LOOP); |
|
|
2804 | glVertex2f (x1, y1); |
|
|
2805 | glVertex2f (x2, y1); |
|
|
2806 | glVertex2f (x2, y2); |
|
|
2807 | glVertex2f (x1, y2); |
|
|
2808 | glEnd (); |
|
|
2809 | |
2749 | PROTOTYPES: ENABLE |
2810 | PROTOTYPES: ENABLE |
2750 | |
2811 | |
2751 | void glBegin (int mode) |
2812 | void glBegin (int mode) |
2752 | |
2813 | |
2753 | void glEnd () |
2814 | void glEnd () |
… | |
… | |
2821 | |
2882 | |
2822 | void glEndList () |
2883 | void glEndList () |
2823 | |
2884 | |
2824 | void glCallList (int list) |
2885 | void glCallList (int list) |
2825 | |
2886 | |
2826 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2887 | MODULE = Deliantra::Client PACKAGE = dc::UI::Base |
2827 | |
2888 | |
2828 | PROTOTYPES: DISABLE |
2889 | PROTOTYPES: DISABLE |
2829 | |
2890 | |
2830 | void |
2891 | void |
2831 | find_widget (SV *self, NV x, NV y) |
2892 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2835 | XPUSHs (self); |
2896 | XPUSHs (self); |
2836 | } |
2897 | } |
2837 | |
2898 | |
2838 | BOOT: |
2899 | BOOT: |
2839 | { |
2900 | { |
2840 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2901 | hover_gv = gv_fetchpv ("dc::UI::HOVER", 1, SVt_NV); |
2841 | |
2902 | |
2842 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2903 | draw_x_gv = gv_fetchpv ("dc::UI::Base::draw_x", 1, SVt_NV); |
2843 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2904 | draw_y_gv = gv_fetchpv ("dc::UI::Base::draw_y", 1, SVt_NV); |
2844 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2905 | draw_w_gv = gv_fetchpv ("dc::UI::Base::draw_w", 1, SVt_NV); |
2845 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2906 | draw_h_gv = gv_fetchpv ("dc::UI::Base::draw_h", 1, SVt_NV); |
2846 | } |
2907 | } |
2847 | |
2908 | |
2848 | void |
2909 | void |
2849 | draw (SV *self) |
2910 | draw (SV *self) |
2850 | CODE: |
2911 | CODE: |
… | |
… | |
2857 | SV *draw_w_sv = GvSV (draw_w_gv); |
2918 | SV *draw_w_sv = GvSV (draw_w_gv); |
2858 | SV *draw_h_sv = GvSV (draw_h_gv); |
2919 | SV *draw_h_sv = GvSV (draw_h_gv); |
2859 | double draw_x, draw_y; |
2920 | double draw_x, draw_y; |
2860 | |
2921 | |
2861 | if (!SvROK (self)) |
2922 | if (!SvROK (self)) |
2862 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2923 | croak ("dc::Base::draw: %s not a reference", SvPV_nolen (self)); |
2863 | |
2924 | |
2864 | hv = (HV *)SvRV (self); |
2925 | hv = (HV *)SvRV (self); |
2865 | |
2926 | |
2866 | if (SvTYPE (hv) != SVt_PVHV) |
2927 | if (SvTYPE (hv) != SVt_PVHV) |
2867 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2928 | croak ("dc::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2868 | |
2929 | |
2869 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2930 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2870 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2931 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2871 | |
2932 | |
2872 | if (!h || !w) |
2933 | if (!h || !w) |
… | |
… | |
2905 | glEnd (); |
2966 | glEnd (); |
2906 | glDisable (GL_BLEND); |
2967 | glDisable (GL_BLEND); |
2907 | } |
2968 | } |
2908 | } |
2969 | } |
2909 | #if 0 |
2970 | #if 0 |
2910 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2971 | // draw borders, for debugging |
2911 | glPushMatrix; |
2972 | glPushMatrix (); |
2912 | glColor 1, 1, 0, 1; |
2973 | glColor4f (1., 1., 0., 1.); |
2913 | glTranslate 0.375, 0.375; |
2974 | glTranslatef (.5, .5, 0.); |
2914 | glBegin GL_LINE_LOOP; |
2975 | glBegin (GL_LINE_LOOP); |
2915 | glVertex 0 , 0; |
2976 | glVertex2f (0 , 0); |
2916 | glVertex $self->{w} - 1, 0; |
2977 | glVertex2f (w - 1, 0); |
2917 | glVertex $self->{w} - 1, $self->{h} - 1; |
2978 | glVertex2f (w - 1, h - 1); |
2918 | glVertex 0 , $self->{h} - 1; |
2979 | glVertex2f (0 , h - 1); |
2919 | glEnd; |
2980 | glEnd (); |
2920 | glPopMatrix; |
2981 | glPopMatrix (); |
2921 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2922 | } |
|
|
2923 | #endif |
2982 | #endif |
2924 | PUSHMARK (SP); |
2983 | PUSHMARK (SP); |
2925 | XPUSHs (self); |
2984 | XPUSHs (self); |
2926 | PUTBACK; |
2985 | PUTBACK; |
2927 | call_method ("_draw", G_VOID | G_DISCARD); |
2986 | call_method ("_draw", G_VOID | G_DISCARD); |