… | |
… | |
83 | |
83 | |
84 | #include "pango-font.c" |
84 | #include "pango-font.c" |
85 | #include "pango-fontmap.c" |
85 | #include "pango-fontmap.c" |
86 | #include "pango-render.c" |
86 | #include "pango-render.c" |
87 | |
87 | |
88 | typedef Mix_Chunk *CFClient__MixChunk; |
88 | typedef Mix_Chunk *CFPlus__MixChunk; |
89 | typedef Mix_Music *CFClient__MixMusic; |
89 | typedef Mix_Music *CFPlus__MixMusic; |
90 | |
90 | |
91 | typedef PangoFontDescription *CFClient__Font; |
91 | typedef PangoFontDescription *CFPlus__Font; |
92 | |
92 | |
93 | static int |
93 | static int |
94 | shape_attr_p (PangoLayoutRun *run) |
94 | shape_attr_p (PangoLayoutRun *run) |
95 | { |
95 | { |
96 | GSList *attrs = run->item->analysis.extra_attrs; |
96 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
110 | |
110 | |
111 | typedef struct cf_layout { |
111 | typedef struct cf_layout { |
112 | PangoLayout *pl; |
112 | PangoLayout *pl; |
113 | float r, g, b, a; // default color for rgba mode |
113 | float r, g, b, a; // default color for rgba mode |
114 | int base_height; |
114 | int base_height; |
115 | CFClient__Font font; |
115 | CFPlus__Font font; |
116 | } *CFClient__Layout; |
116 | } *CFPlus__Layout; |
117 | |
117 | |
118 | static CFClient__Font default_font; |
118 | static CFPlus__Font default_font; |
119 | static PangoContext *opengl_context; |
119 | static PangoContext *opengl_context; |
120 | static PangoFontMap *opengl_fontmap; |
120 | static PangoFontMap *opengl_fontmap; |
121 | |
121 | |
122 | static void |
122 | static void |
123 | substitute_func (FcPattern *pattern, gpointer data) |
123 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
128 | #endif |
128 | #endif |
129 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
129 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
130 | } |
130 | } |
131 | |
131 | |
132 | static void |
132 | static void |
133 | layout_update_font (CFClient__Layout self) |
133 | layout_update_font (CFPlus__Layout self) |
134 | { |
134 | { |
135 | /* use a random scale factor to account for unknown descenders, 0.8 works |
135 | /* use a random scale factor to account for unknown descenders, 0.8 works |
136 | * reasonably well with bitstream vera |
136 | * reasonably well with bitstream vera |
137 | */ |
137 | */ |
138 | PangoFontDescription *font = self->font ? self->font : default_font; |
138 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
142 | |
142 | |
143 | pango_layout_set_font_description (self->pl, font); |
143 | pango_layout_set_font_description (self->pl, font); |
144 | } |
144 | } |
145 | |
145 | |
146 | static void |
146 | static void |
147 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
147 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
148 | { |
148 | { |
|
|
149 | PangoRectangle rect; |
|
|
150 | |
|
|
151 | // get_pixel_* wrongly rounds down |
149 | pango_layout_get_pixel_size (self->pl, w, h); |
152 | pango_layout_get_extents (self->pl, 0, &rect); |
150 | |
153 | |
151 | if (!*w) *w = 1; |
154 | rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; |
152 | if (!*h) *h = 1; |
155 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
153 | |
156 | |
154 | *w = (*w + 3) & ~3; |
157 | if (!rect.width) rect.width = 1; |
|
|
158 | if (!rect.height) rect.height = 1; |
|
|
159 | |
|
|
160 | *w = rect.width; |
|
|
161 | *h = rect.height; |
155 | } |
162 | } |
156 | |
163 | |
157 | typedef uint16_t mapface; |
164 | typedef uint16_t mapface; |
158 | |
165 | |
159 | typedef struct { |
166 | typedef struct { |
… | |
… | |
182 | int texs; |
189 | int texs; |
183 | maptex *tex; |
190 | maptex *tex; |
184 | |
191 | |
185 | int32_t rows; |
192 | int32_t rows; |
186 | maprow *row; |
193 | maprow *row; |
187 | } *CFClient__Map; |
194 | } *CFPlus__Map; |
188 | |
195 | |
189 | static char * |
196 | static char * |
190 | prepend (char *ptr, int sze, int inc) |
197 | prepend (char *ptr, int sze, int inc) |
191 | { |
198 | { |
192 | char *p; |
199 | char *p; |
… | |
… | |
210 | |
217 | |
211 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
218 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
212 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
219 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
213 | |
220 | |
214 | static maprow * |
221 | static maprow * |
215 | map_get_row (CFClient__Map self, int y) |
222 | map_get_row (CFPlus__Map self, int y) |
216 | { |
223 | { |
217 | if (0 > y) |
224 | if (0 > y) |
218 | { |
225 | { |
219 | int extend = - y + MAP_EXTEND_Y; |
226 | int extend = - y + MAP_EXTEND_Y; |
220 | Prepend (maprow, self->row, self->rows, extend); |
227 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
258 | |
265 | |
259 | return row->col + (x - row->c0); |
266 | return row->col + (x - row->c0); |
260 | } |
267 | } |
261 | |
268 | |
262 | static mapcell * |
269 | static mapcell * |
263 | map_get_cell (CFClient__Map self, int x, int y) |
270 | map_get_cell (CFPlus__Map self, int x, int y) |
264 | { |
271 | { |
265 | return row_get_cell (map_get_row (self, y), x); |
272 | return row_get_cell (map_get_row (self, y), x); |
266 | } |
273 | } |
267 | |
274 | |
268 | static void |
275 | static void |
269 | map_clear (CFClient__Map self) |
276 | map_clear (CFPlus__Map self) |
270 | { |
277 | { |
271 | int r; |
278 | int r; |
272 | |
279 | |
273 | for (r = 0; r < self->rows; r++) |
280 | for (r = 0; r < self->rows; r++) |
274 | Safefree (self->row[r].col); |
281 | Safefree (self->row[r].col); |
… | |
… | |
282 | self->row = 0; |
289 | self->row = 0; |
283 | self->rows = 0; |
290 | self->rows = 0; |
284 | } |
291 | } |
285 | |
292 | |
286 | static void |
293 | static void |
287 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
294 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
288 | { |
295 | { |
289 | int x, y; |
296 | int x, y; |
290 | maprow *row; |
297 | maprow *row; |
291 | |
298 | |
292 | for (y = y0; y < y0 + h; y++) |
299 | for (y = y0; y < y0 + h; y++) |
… | |
… | |
349 | n |= n >> 16; |
356 | n |= n >> 16; |
350 | |
357 | |
351 | return n + 1; |
358 | return n + 1; |
352 | } |
359 | } |
353 | |
360 | |
354 | MODULE = CFClient PACKAGE = CFClient |
361 | MODULE = CFPlus PACKAGE = CFPlus |
355 | |
362 | |
356 | PROTOTYPES: ENABLE |
363 | PROTOTYPES: ENABLE |
357 | |
364 | |
358 | BOOT: |
365 | BOOT: |
359 | { |
366 | { |
360 | HV *stash = gv_stashpv ("CFClient", 1); |
367 | HV *stash = gv_stashpv ("CFPlus", 1); |
361 | static const struct { |
368 | static const struct { |
362 | const char *name; |
369 | const char *name; |
363 | IV iv; |
370 | IV iv; |
364 | } *civ, const_iv[] = { |
371 | } *civ, const_iv[] = { |
365 | # define const_iv(name) { # name, (IV)name } |
372 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
512 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
519 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
513 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
520 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
514 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
521 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
515 | |
522 | |
516 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
523 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
524 | #if SDL_VERSION_ATLEAST(1,2,10) |
517 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
525 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
518 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
526 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
|
|
527 | #endif |
519 | |
528 | |
520 | SDL_EnableUNICODE (1); |
529 | SDL_EnableUNICODE (1); |
521 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
530 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
522 | |
531 | |
523 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
532 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
610 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
619 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
611 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
620 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
612 | break; |
621 | break; |
613 | } |
622 | } |
614 | |
623 | |
615 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFClient::UI::Event", 1)))); |
624 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
616 | } |
625 | } |
617 | } |
626 | } |
618 | |
627 | |
619 | int |
628 | int |
620 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
629 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
… | |
… | |
749 | void |
758 | void |
750 | _exit (int retval) |
759 | _exit (int retval) |
751 | CODE: |
760 | CODE: |
752 | _exit (retval); |
761 | _exit (retval); |
753 | |
762 | |
754 | MODULE = CFClient PACKAGE = CFClient::Font |
763 | MODULE = CFPlus PACKAGE = CFPlus::Font |
755 | |
764 | |
756 | CFClient::Font |
765 | CFPlus::Font |
757 | new_from_file (SV *class, char *path, int id = 0) |
766 | new_from_file (SV *class, char *path, int id = 0) |
758 | CODE: |
767 | CODE: |
759 | { |
768 | { |
760 | int count; |
769 | int count; |
761 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
770 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
764 | } |
773 | } |
765 | OUTPUT: |
774 | OUTPUT: |
766 | RETVAL |
775 | RETVAL |
767 | |
776 | |
768 | void |
777 | void |
769 | DESTROY (CFClient::Font self) |
778 | DESTROY (CFPlus::Font self) |
770 | CODE: |
779 | CODE: |
771 | pango_font_description_free (self); |
780 | pango_font_description_free (self); |
772 | |
781 | |
773 | void |
782 | void |
774 | make_default (CFClient::Font self) |
783 | make_default (CFPlus::Font self) |
775 | CODE: |
784 | CODE: |
776 | default_font = self; |
785 | default_font = self; |
777 | |
786 | |
778 | MODULE = CFClient PACKAGE = CFClient::Layout |
787 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
779 | |
788 | |
780 | void |
789 | void |
781 | reset_glyph_cache () |
790 | reset_glyph_cache () |
782 | CODE: |
791 | CODE: |
783 | tc_clear (); |
792 | tc_clear (); |
784 | |
793 | |
785 | CFClient::Layout |
794 | CFPlus::Layout |
786 | new (SV *class) |
795 | new (SV *class) |
787 | CODE: |
796 | CODE: |
788 | New (0, RETVAL, 1, struct cf_layout); |
797 | New (0, RETVAL, 1, struct cf_layout); |
789 | |
798 | |
790 | RETVAL->pl = pango_layout_new (opengl_context); |
799 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
799 | layout_update_font (RETVAL); |
808 | layout_update_font (RETVAL); |
800 | OUTPUT: |
809 | OUTPUT: |
801 | RETVAL |
810 | RETVAL |
802 | |
811 | |
803 | void |
812 | void |
804 | DESTROY (CFClient::Layout self) |
813 | DESTROY (CFPlus::Layout self) |
805 | CODE: |
814 | CODE: |
806 | g_object_unref (self->pl); |
815 | g_object_unref (self->pl); |
807 | Safefree (self); |
816 | Safefree (self); |
808 | |
817 | |
809 | void |
818 | void |
810 | set_text (CFClient::Layout self, SV *text_) |
819 | set_text (CFPlus::Layout self, SV *text_) |
811 | CODE: |
820 | CODE: |
812 | { |
821 | { |
813 | STRLEN textlen; |
822 | STRLEN textlen; |
814 | char *text = SvPVutf8 (text_, textlen); |
823 | char *text = SvPVutf8 (text_, textlen); |
815 | |
824 | |
816 | pango_layout_set_text (self->pl, text, textlen); |
825 | pango_layout_set_text (self->pl, text, textlen); |
817 | } |
826 | } |
818 | |
827 | |
819 | void |
828 | void |
820 | set_markup (CFClient::Layout self, SV *text_) |
829 | set_markup (CFPlus::Layout self, SV *text_) |
821 | CODE: |
830 | CODE: |
822 | { |
831 | { |
823 | STRLEN textlen; |
832 | STRLEN textlen; |
824 | char *text = SvPVutf8 (text_, textlen); |
833 | char *text = SvPVutf8 (text_, textlen); |
825 | |
834 | |
826 | pango_layout_set_markup (self->pl, text, textlen); |
835 | pango_layout_set_markup (self->pl, text, textlen); |
827 | } |
836 | } |
828 | |
837 | |
829 | void |
838 | void |
830 | set_shapes (CFClient::Layout self, ...) |
839 | set_shapes (CFPlus::Layout self, ...) |
831 | CODE: |
840 | CODE: |
832 | { |
841 | { |
833 | PangoAttrList *attrs = 0; |
842 | PangoAttrList *attrs = 0; |
834 | const char *text = pango_layout_get_text (self->pl); |
843 | const char *text = pango_layout_get_text (self->pl); |
835 | const char *pos = text; |
844 | const char *pos = text; |
… | |
… | |
870 | if (attrs) |
879 | if (attrs) |
871 | pango_layout_set_attributes (self->pl, attrs); |
880 | pango_layout_set_attributes (self->pl, attrs); |
872 | } |
881 | } |
873 | |
882 | |
874 | void |
883 | void |
875 | get_shapes (CFClient::Layout self) |
884 | get_shapes (CFPlus::Layout self) |
876 | PPCODE: |
885 | PPCODE: |
877 | { |
886 | { |
878 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
887 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
879 | |
888 | |
880 | do |
889 | do |
… | |
… | |
895 | |
904 | |
896 | pango_layout_iter_free (iter); |
905 | pango_layout_iter_free (iter); |
897 | } |
906 | } |
898 | |
907 | |
899 | int |
908 | int |
900 | has_wrapped (CFClient::Layout self) |
909 | has_wrapped (CFPlus::Layout self) |
901 | CODE: |
910 | CODE: |
902 | { |
911 | { |
903 | int lines = 1; |
912 | int lines = 1; |
904 | const char *text = pango_layout_get_text (self->pl); |
913 | const char *text = pango_layout_get_text (self->pl); |
905 | |
914 | |
… | |
… | |
910 | } |
919 | } |
911 | OUTPUT: |
920 | OUTPUT: |
912 | RETVAL |
921 | RETVAL |
913 | |
922 | |
914 | SV * |
923 | SV * |
915 | get_text (CFClient::Layout self) |
924 | get_text (CFPlus::Layout self) |
916 | CODE: |
925 | CODE: |
917 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
926 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
918 | sv_utf8_decode (RETVAL); |
927 | sv_utf8_decode (RETVAL); |
919 | OUTPUT: |
928 | OUTPUT: |
920 | RETVAL |
929 | RETVAL |
921 | |
930 | |
922 | void |
931 | void |
923 | set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) |
932 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
924 | CODE: |
933 | CODE: |
925 | self->r = r; |
934 | self->r = r; |
926 | self->g = g; |
935 | self->g = g; |
927 | self->b = b; |
936 | self->b = b; |
928 | self->a = a; |
937 | self->a = a; |
929 | |
938 | |
930 | void |
939 | void |
931 | set_font (CFClient::Layout self, CFClient::Font font = 0) |
940 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
932 | CODE: |
941 | CODE: |
933 | if (self->font != font) |
942 | if (self->font != font) |
934 | { |
943 | { |
935 | self->font = font; |
944 | self->font = font; |
936 | layout_update_font (self); |
945 | layout_update_font (self); |
937 | } |
946 | } |
938 | |
947 | |
939 | void |
948 | void |
940 | set_height (CFClient::Layout self, int base_height) |
949 | set_height (CFPlus::Layout self, int base_height) |
941 | CODE: |
950 | CODE: |
942 | if (self->base_height != base_height) |
951 | if (self->base_height != base_height) |
943 | { |
952 | { |
944 | self->base_height = base_height; |
953 | self->base_height = base_height; |
945 | layout_update_font (self); |
954 | layout_update_font (self); |
946 | } |
955 | } |
947 | |
956 | |
948 | void |
957 | void |
949 | set_width (CFClient::Layout self, int max_width = -1) |
958 | set_width (CFPlus::Layout self, int max_width = -1) |
950 | CODE: |
959 | CODE: |
951 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
960 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
952 | |
961 | |
953 | void |
962 | void |
954 | set_indent (CFClient::Layout self, int indent) |
963 | set_indent (CFPlus::Layout self, int indent) |
955 | CODE: |
964 | CODE: |
956 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
965 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
957 | |
966 | |
958 | void |
967 | void |
959 | set_spacing (CFClient::Layout self, int spacing) |
968 | set_spacing (CFPlus::Layout self, int spacing) |
960 | CODE: |
969 | CODE: |
961 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
970 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
962 | |
971 | |
963 | void |
972 | void |
964 | set_ellipsise (CFClient::Layout self, int ellipsise) |
973 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
965 | CODE: |
974 | CODE: |
966 | pango_layout_set_ellipsize (self->pl, |
975 | pango_layout_set_ellipsize (self->pl, |
967 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
976 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
968 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
977 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
969 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
978 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
970 | : PANGO_ELLIPSIZE_NONE |
979 | : PANGO_ELLIPSIZE_NONE |
971 | ); |
980 | ); |
972 | |
981 | |
973 | void |
982 | void |
974 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
983 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
975 | CODE: |
984 | CODE: |
976 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
985 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
977 | |
986 | |
978 | void |
987 | void |
979 | size (CFClient::Layout self) |
988 | size (CFPlus::Layout self) |
980 | PPCODE: |
989 | PPCODE: |
981 | { |
990 | { |
982 | int w, h; |
991 | int w, h; |
983 | |
992 | |
984 | layout_get_pixel_size (self, &w, &h); |
993 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
987 | PUSHs (sv_2mortal (newSViv (w))); |
996 | PUSHs (sv_2mortal (newSViv (w))); |
988 | PUSHs (sv_2mortal (newSViv (h))); |
997 | PUSHs (sv_2mortal (newSViv (h))); |
989 | } |
998 | } |
990 | |
999 | |
991 | int |
1000 | int |
992 | descent (CFClient::Layout self) |
1001 | descent (CFPlus::Layout self) |
993 | CODE: |
1002 | CODE: |
994 | { |
1003 | { |
995 | PangoRectangle rect; |
1004 | PangoRectangle rect; |
996 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1005 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
997 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1006 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
999 | } |
1008 | } |
1000 | OUTPUT: |
1009 | OUTPUT: |
1001 | RETVAL |
1010 | RETVAL |
1002 | |
1011 | |
1003 | int |
1012 | int |
1004 | xy_to_index (CFClient::Layout self, int x, int y) |
1013 | xy_to_index (CFPlus::Layout self, int x, int y) |
1005 | CODE: |
1014 | CODE: |
1006 | { |
1015 | { |
1007 | int index, trailing; |
1016 | int index, trailing; |
1008 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1017 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1009 | RETVAL = index; |
1018 | RETVAL = index; |
1010 | } |
1019 | } |
1011 | OUTPUT: |
1020 | OUTPUT: |
1012 | RETVAL |
1021 | RETVAL |
1013 | |
1022 | |
1014 | void |
1023 | void |
1015 | cursor_pos (CFClient::Layout self, int index) |
1024 | cursor_pos (CFPlus::Layout self, int index) |
1016 | PPCODE: |
1025 | PPCODE: |
1017 | { |
1026 | { |
1018 | PangoRectangle strong_pos; |
1027 | PangoRectangle strong_pos; |
1019 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1028 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1020 | |
1029 | |
… | |
… | |
1023 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1032 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1024 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1033 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1025 | } |
1034 | } |
1026 | |
1035 | |
1027 | void |
1036 | void |
1028 | render (CFClient::Layout self, float x, float y) |
1037 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1029 | PPCODE: |
1038 | PPCODE: |
1030 | pango_opengl_render_layout_subpixel ( |
1039 | pango_opengl_render_layout_subpixel ( |
1031 | self->pl, |
1040 | self->pl, |
1032 | x * PANGO_SCALE, y * PANGO_SCALE, |
1041 | x * PANGO_SCALE, y * PANGO_SCALE, |
1033 | self->r, self->g, self->b, self->a |
1042 | self->r, self->g, self->b, self->a, |
|
|
1043 | flags |
1034 | ); |
1044 | ); |
1035 | |
1045 | |
1036 | MODULE = CFClient PACKAGE = CFClient::Texture |
1046 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1037 | |
1047 | |
1038 | void |
1048 | void |
1039 | pad2pot (SV *data_, SV *w_, SV *h_) |
1049 | pad2pot (SV *data_, SV *w_, SV *h_) |
1040 | CODE: |
1050 | CODE: |
1041 | { |
1051 | { |
… | |
… | |
1119 | glDisable (GL_ALPHA_TEST); |
1129 | glDisable (GL_ALPHA_TEST); |
1120 | glDisable (GL_BLEND); |
1130 | glDisable (GL_BLEND); |
1121 | } |
1131 | } |
1122 | } |
1132 | } |
1123 | |
1133 | |
1124 | MODULE = CFClient PACKAGE = CFClient::Map |
1134 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1125 | |
1135 | |
1126 | CFClient::Map |
1136 | CFPlus::Map |
1127 | new (SV *class, int map_width, int map_height) |
1137 | new (SV *class, int map_width, int map_height) |
1128 | CODE: |
1138 | CODE: |
1129 | New (0, RETVAL, 1, struct map); |
1139 | New (0, RETVAL, 1, struct map); |
1130 | RETVAL->x = 0; |
1140 | RETVAL->x = 0; |
1131 | RETVAL->y = 0; |
1141 | RETVAL->y = 0; |
… | |
… | |
1141 | RETVAL->row = 0; |
1151 | RETVAL->row = 0; |
1142 | OUTPUT: |
1152 | OUTPUT: |
1143 | RETVAL |
1153 | RETVAL |
1144 | |
1154 | |
1145 | void |
1155 | void |
1146 | DESTROY (CFClient::Map self) |
1156 | DESTROY (CFPlus::Map self) |
1147 | CODE: |
1157 | CODE: |
1148 | { |
1158 | { |
1149 | map_clear (self); |
1159 | map_clear (self); |
1150 | Safefree (self->face); |
1160 | Safefree (self->face); |
1151 | Safefree (self->tex); |
1161 | Safefree (self->tex); |
1152 | Safefree (self); |
1162 | Safefree (self); |
1153 | } |
1163 | } |
1154 | |
1164 | |
1155 | void |
1165 | void |
1156 | clear (CFClient::Map self) |
1166 | clear (CFPlus::Map self) |
1157 | CODE: |
1167 | CODE: |
1158 | map_clear (self); |
1168 | map_clear (self); |
1159 | |
1169 | |
1160 | void |
1170 | void |
1161 | set_face (CFClient::Map self, int face, int texid) |
1171 | set_face (CFPlus::Map self, int face, int texid) |
1162 | CODE: |
1172 | CODE: |
1163 | { |
1173 | { |
1164 | while (self->faces <= face) |
1174 | while (self->faces <= face) |
1165 | { |
1175 | { |
1166 | Append (mapface, self->face, self->faces, self->faces); |
1176 | Append (mapface, self->face, self->faces, self->faces); |
… | |
… | |
1169 | |
1179 | |
1170 | self->face [face] = texid; |
1180 | self->face [face] = texid; |
1171 | } |
1181 | } |
1172 | |
1182 | |
1173 | void |
1183 | void |
1174 | set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1184 | 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) |
1175 | CODE: |
1185 | CODE: |
1176 | { |
1186 | { |
1177 | while (self->texs <= texid) |
1187 | while (self->texs <= texid) |
1178 | { |
1188 | { |
1179 | Append (maptex, self->tex, self->texs, self->texs); |
1189 | Append (maptex, self->tex, self->texs, self->texs); |
… | |
… | |
1203 | // from transparent color bleeding and ugly wrapping effects. |
1213 | // from transparent color bleeding and ugly wrapping effects. |
1204 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1214 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1205 | } |
1215 | } |
1206 | |
1216 | |
1207 | int |
1217 | int |
1208 | ox (CFClient::Map self) |
1218 | ox (CFPlus::Map self) |
1209 | ALIAS: |
1219 | ALIAS: |
1210 | oy = 1 |
1220 | oy = 1 |
1211 | x = 2 |
1221 | x = 2 |
1212 | y = 3 |
1222 | y = 3 |
1213 | w = 4 |
1223 | w = 4 |
… | |
… | |
1224 | } |
1234 | } |
1225 | OUTPUT: |
1235 | OUTPUT: |
1226 | RETVAL |
1236 | RETVAL |
1227 | |
1237 | |
1228 | void |
1238 | void |
1229 | scroll (CFClient::Map self, int dx, int dy) |
1239 | scroll (CFPlus::Map self, int dx, int dy) |
1230 | CODE: |
1240 | CODE: |
1231 | { |
1241 | { |
1232 | if (dx > 0) |
1242 | if (dx > 0) |
1233 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1243 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1234 | else if (dx < 0) |
1244 | else if (dx < 0) |
… | |
… | |
1250 | self->y += MAP_EXTEND_Y; |
1260 | self->y += MAP_EXTEND_Y; |
1251 | } |
1261 | } |
1252 | } |
1262 | } |
1253 | |
1263 | |
1254 | void |
1264 | void |
1255 | map1a_update (CFClient::Map self, SV *data_) |
1265 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1256 | CODE: |
1266 | CODE: |
1257 | { |
1267 | { |
1258 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1268 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1259 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1269 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1260 | mapcell *cell; |
1270 | mapcell *cell; |
… | |
… | |
1277 | cell->face [0] = 0; |
1287 | cell->face [0] = 0; |
1278 | cell->face [1] = 0; |
1288 | cell->face [1] = 0; |
1279 | cell->face [2] = 0; |
1289 | cell->face [2] = 0; |
1280 | } |
1290 | } |
1281 | |
1291 | |
|
|
1292 | if (flags & 8) |
|
|
1293 | { |
|
|
1294 | fprintf (stderr, "oi\n");//D |
|
|
1295 | if (extmap) |
|
|
1296 | { |
|
|
1297 | uint8_t ext, cmd; |
|
|
1298 | |
|
|
1299 | do |
|
|
1300 | { |
|
|
1301 | |
|
|
1302 | ext = *data++; |
|
|
1303 | cmd = ext & 0x7f; |
|
|
1304 | |
|
|
1305 | fprintf (stderr, "extcmd = %x\n", ext);//D |
|
|
1306 | |
|
|
1307 | if (ext < 4) |
|
|
1308 | cell->darkness = 255 - ext * 64; |
|
|
1309 | } |
|
|
1310 | while (cmd & 0x80); |
|
|
1311 | } |
|
|
1312 | else |
1282 | cell->darkness = flags & 8 ? *data++ : 255; |
1313 | cell->darkness = flags & 8 ? *data++ : 255; |
|
|
1314 | } |
1283 | |
1315 | |
1284 | //TODO: don't trust server data to be in-range(!) |
1316 | //TODO: don't trust server data to be in-range(!) |
1285 | |
1317 | |
1286 | if (flags & 4) |
1318 | if (flags & 4) |
1287 | { |
1319 | { |
… | |
… | |
1302 | cell->darkness = -1; |
1334 | cell->darkness = -1; |
1303 | } |
1335 | } |
1304 | } |
1336 | } |
1305 | |
1337 | |
1306 | SV * |
1338 | SV * |
1307 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
1339 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1308 | CODE: |
1340 | CODE: |
1309 | { |
1341 | { |
1310 | int x1, x; |
1342 | int x1, x; |
1311 | int y1, y; |
1343 | int y1, y; |
1312 | int z; |
1344 | int z; |
… | |
… | |
1362 | } |
1394 | } |
1363 | OUTPUT: |
1395 | OUTPUT: |
1364 | RETVAL |
1396 | RETVAL |
1365 | |
1397 | |
1366 | void |
1398 | void |
1367 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1399 | draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1368 | CODE: |
1400 | CODE: |
1369 | { |
1401 | { |
1370 | int vx, vy; |
1402 | int vx, vy; |
1371 | int x, y, z; |
1403 | int x, y, z; |
1372 | int last_name; |
1404 | int last_name; |
… | |
… | |
1437 | glDisable (GL_TEXTURE_2D); |
1469 | glDisable (GL_TEXTURE_2D); |
1438 | glDisable (GL_BLEND); |
1470 | glDisable (GL_BLEND); |
1439 | } |
1471 | } |
1440 | |
1472 | |
1441 | void |
1473 | void |
1442 | draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1474 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1443 | CODE: |
1475 | CODE: |
1444 | { |
1476 | { |
1445 | static float color[16][3] = { |
1477 | static float color[16][3] = { |
1446 | { 0.00F, 0.00F, 0.00F }, |
1478 | { 0.00F, 0.00F, 0.00F }, |
1447 | { 1.00F, 1.00F, 1.00F }, |
1479 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
1497 | glDisable (GL_BLEND); |
1529 | glDisable (GL_BLEND); |
1498 | glDisable (GL_TEXTURE_2D); |
1530 | glDisable (GL_TEXTURE_2D); |
1499 | } |
1531 | } |
1500 | |
1532 | |
1501 | void |
1533 | void |
1502 | fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1534 | fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1503 | PPCODE: |
1535 | PPCODE: |
1504 | { |
1536 | { |
1505 | int vx, vy; |
1537 | int vx, vy; |
1506 | int x, y; |
1538 | int x, y; |
1507 | int sw4 = (sw + 3) & ~3; |
1539 | int sw4 = (sw + 3) & ~3; |
… | |
… | |
1536 | PUSHs (sv_2mortal (newSViv (sh))); |
1568 | PUSHs (sv_2mortal (newSViv (sh))); |
1537 | PUSHs (darkness_sv); |
1569 | PUSHs (darkness_sv); |
1538 | } |
1570 | } |
1539 | |
1571 | |
1540 | SV * |
1572 | SV * |
1541 | get_rect (CFClient::Map self, int x0, int y0, int w, int h) |
1573 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
1542 | CODE: |
1574 | CODE: |
1543 | { |
1575 | { |
1544 | int x, y, x1, y1; |
1576 | int x, y, x1, y1; |
1545 | SV *data_sv = newSV (w * h * 7 + 5); |
1577 | SV *data_sv = newSV (w * h * 7 + 5); |
1546 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
1578 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
1608 | } |
1640 | } |
1609 | OUTPUT: |
1641 | OUTPUT: |
1610 | RETVAL |
1642 | RETVAL |
1611 | |
1643 | |
1612 | void |
1644 | void |
1613 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1645 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
1614 | PPCODE: |
1646 | PPCODE: |
1615 | { |
1647 | { |
1616 | int x, y, z; |
1648 | int x, y, z; |
1617 | int w, h; |
1649 | int w, h; |
1618 | int x1, y1; |
1650 | int x1, y1; |
… | |
… | |
1667 | } |
1699 | } |
1668 | } |
1700 | } |
1669 | } |
1701 | } |
1670 | } |
1702 | } |
1671 | |
1703 | |
1672 | MODULE = CFClient PACKAGE = CFClient::MixChunk |
1704 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
1673 | |
1705 | |
1674 | CFClient::MixChunk |
1706 | CFPlus::MixChunk |
1675 | new_from_file (SV *class, char *path) |
1707 | new_from_file (SV *class, char *path) |
1676 | CODE: |
1708 | CODE: |
1677 | RETVAL = Mix_LoadWAV (path); |
1709 | RETVAL = Mix_LoadWAV (path); |
1678 | OUTPUT: |
1710 | OUTPUT: |
1679 | RETVAL |
1711 | RETVAL |
1680 | |
1712 | |
1681 | void |
1713 | void |
1682 | DESTROY (CFClient::MixChunk self) |
1714 | DESTROY (CFPlus::MixChunk self) |
1683 | CODE: |
1715 | CODE: |
1684 | Mix_FreeChunk (self); |
1716 | Mix_FreeChunk (self); |
1685 | |
1717 | |
1686 | int |
1718 | int |
1687 | volume (CFClient::MixChunk self, int volume = -1) |
1719 | volume (CFPlus::MixChunk self, int volume = -1) |
1688 | CODE: |
1720 | CODE: |
1689 | RETVAL = Mix_VolumeChunk (self, volume); |
1721 | RETVAL = Mix_VolumeChunk (self, volume); |
1690 | OUTPUT: |
1722 | OUTPUT: |
1691 | RETVAL |
1723 | RETVAL |
1692 | |
1724 | |
1693 | int |
1725 | int |
1694 | play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1726 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1695 | CODE: |
1727 | CODE: |
1696 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1728 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1697 | OUTPUT: |
1729 | OUTPUT: |
1698 | RETVAL |
1730 | RETVAL |
1699 | |
1731 | |
1700 | MODULE = CFClient PACKAGE = CFClient::MixMusic |
1732 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
1701 | |
1733 | |
1702 | int |
1734 | int |
1703 | volume (int volume = -1) |
1735 | volume (int volume = -1) |
1704 | CODE: |
1736 | CODE: |
1705 | RETVAL = Mix_VolumeMusic (volume); |
1737 | RETVAL = Mix_VolumeMusic (volume); |
1706 | OUTPUT: |
1738 | OUTPUT: |
1707 | RETVAL |
1739 | RETVAL |
1708 | |
1740 | |
1709 | CFClient::MixMusic |
1741 | CFPlus::MixMusic |
1710 | new_from_file (SV *class, char *path) |
1742 | new_from_file (SV *class, char *path) |
1711 | CODE: |
1743 | CODE: |
1712 | RETVAL = Mix_LoadMUS (path); |
1744 | RETVAL = Mix_LoadMUS (path); |
1713 | OUTPUT: |
1745 | OUTPUT: |
1714 | RETVAL |
1746 | RETVAL |
1715 | |
1747 | |
1716 | void |
1748 | void |
1717 | DESTROY (CFClient::MixMusic self) |
1749 | DESTROY (CFPlus::MixMusic self) |
1718 | CODE: |
1750 | CODE: |
1719 | Mix_FreeMusic (self); |
1751 | Mix_FreeMusic (self); |
1720 | |
1752 | |
1721 | int |
1753 | int |
1722 | play (CFClient::MixMusic self, int loops = -1) |
1754 | play (CFPlus::MixMusic self, int loops = -1) |
1723 | CODE: |
1755 | CODE: |
1724 | RETVAL = Mix_PlayMusic (self, loops); |
1756 | RETVAL = Mix_PlayMusic (self, loops); |
1725 | OUTPUT: |
1757 | OUTPUT: |
1726 | RETVAL |
1758 | RETVAL |
1727 | |
1759 | |
1728 | MODULE = CFClient PACKAGE = CFClient::OpenGL |
1760 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
1729 | |
1761 | |
1730 | BOOT: |
1762 | BOOT: |
1731 | { |
1763 | { |
1732 | HV *stash = gv_stashpv ("CFClient::OpenGL", 1); |
1764 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
1733 | static const struct { |
1765 | static const struct { |
1734 | const char *name; |
1766 | const char *name; |
1735 | IV iv; |
1767 | IV iv; |
1736 | } *civ, const_iv[] = { |
1768 | } *civ, const_iv[] = { |
1737 | # define const_iv(name) { # name, (IV)name } |
1769 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
1800 | const_iv (GL_SEPARABLE_2D), |
1832 | const_iv (GL_SEPARABLE_2D), |
1801 | const_iv (GL_CONVOLUTION_2D), |
1833 | const_iv (GL_CONVOLUTION_2D), |
1802 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1834 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1803 | const_iv (GL_CONSTANT_BORDER), |
1835 | const_iv (GL_CONSTANT_BORDER), |
1804 | const_iv (GL_LINES), |
1836 | const_iv (GL_LINES), |
|
|
1837 | const_iv (GL_LINE_STRIP), |
1805 | const_iv (GL_LINE_LOOP), |
1838 | const_iv (GL_LINE_LOOP), |
1806 | const_iv (GL_QUADS), |
1839 | const_iv (GL_QUADS), |
1807 | const_iv (GL_QUAD_STRIP), |
1840 | const_iv (GL_QUAD_STRIP), |
1808 | const_iv (GL_TRIANGLES), |
1841 | const_iv (GL_TRIANGLES), |
1809 | const_iv (GL_TRIANGLE_STRIP), |
1842 | const_iv (GL_TRIANGLE_STRIP), |
… | |
… | |
2006 | |
2039 | |
2007 | void glEndList () |
2040 | void glEndList () |
2008 | |
2041 | |
2009 | void glCallList (int list) |
2042 | void glCallList (int list) |
2010 | |
2043 | |
2011 | |
|
|