… | |
… | |
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 | pango_layout_get_pixel_size (self->pl, w, h); |
149 | pango_layout_get_pixel_size (self->pl, w, h); |
150 | |
150 | |
151 | if (!*w) *w = 1; |
151 | if (!*w) *w = 1; |
152 | if (!*h) *h = 1; |
152 | if (!*h) *h = 1; |
… | |
… | |
182 | int texs; |
182 | int texs; |
183 | maptex *tex; |
183 | maptex *tex; |
184 | |
184 | |
185 | int32_t rows; |
185 | int32_t rows; |
186 | maprow *row; |
186 | maprow *row; |
187 | } *CFClient__Map; |
187 | } *CFPlus__Map; |
188 | |
188 | |
189 | static char * |
189 | static char * |
190 | prepend (char *ptr, int sze, int inc) |
190 | prepend (char *ptr, int sze, int inc) |
191 | { |
191 | { |
192 | char *p; |
192 | char *p; |
… | |
… | |
210 | |
210 | |
211 | #define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
211 | #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)) |
212 | #define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) |
213 | |
213 | |
214 | static maprow * |
214 | static maprow * |
215 | map_get_row (CFClient__Map self, int y) |
215 | map_get_row (CFPlus__Map self, int y) |
216 | { |
216 | { |
217 | if (0 > y) |
217 | if (0 > y) |
218 | { |
218 | { |
219 | int extend = - y + MAP_EXTEND_Y; |
219 | int extend = - y + MAP_EXTEND_Y; |
220 | Prepend (maprow, self->row, self->rows, extend); |
220 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
258 | |
258 | |
259 | return row->col + (x - row->c0); |
259 | return row->col + (x - row->c0); |
260 | } |
260 | } |
261 | |
261 | |
262 | static mapcell * |
262 | static mapcell * |
263 | map_get_cell (CFClient__Map self, int x, int y) |
263 | map_get_cell (CFPlus__Map self, int x, int y) |
264 | { |
264 | { |
265 | return row_get_cell (map_get_row (self, y), x); |
265 | return row_get_cell (map_get_row (self, y), x); |
266 | } |
266 | } |
267 | |
267 | |
268 | static void |
268 | static void |
269 | map_clear (CFClient__Map self) |
269 | map_clear (CFPlus__Map self) |
270 | { |
270 | { |
271 | int r; |
271 | int r; |
272 | |
272 | |
273 | for (r = 0; r < self->rows; r++) |
273 | for (r = 0; r < self->rows; r++) |
274 | Safefree (self->row[r].col); |
274 | Safefree (self->row[r].col); |
… | |
… | |
282 | self->row = 0; |
282 | self->row = 0; |
283 | self->rows = 0; |
283 | self->rows = 0; |
284 | } |
284 | } |
285 | |
285 | |
286 | static void |
286 | static void |
287 | map_blank (CFClient__Map self, int x0, int y0, int w, int h) |
287 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
288 | { |
288 | { |
289 | int x, y; |
289 | int x, y; |
290 | maprow *row; |
290 | maprow *row; |
291 | |
291 | |
292 | for (y = y0; y < y0 + h; y++) |
292 | for (y = y0; y < y0 + h; y++) |
… | |
… | |
349 | n |= n >> 16; |
349 | n |= n >> 16; |
350 | |
350 | |
351 | return n + 1; |
351 | return n + 1; |
352 | } |
352 | } |
353 | |
353 | |
354 | MODULE = CFClient PACKAGE = CFClient |
354 | MODULE = CFPlus PACKAGE = CFPlus |
355 | |
355 | |
356 | PROTOTYPES: ENABLE |
356 | PROTOTYPES: ENABLE |
357 | |
357 | |
358 | BOOT: |
358 | BOOT: |
359 | { |
359 | { |
360 | HV *stash = gv_stashpv ("CFClient", 1); |
360 | HV *stash = gv_stashpv ("CFPlus", 1); |
361 | static const struct { |
361 | static const struct { |
362 | const char *name; |
362 | const char *name; |
363 | IV iv; |
363 | IV iv; |
364 | } *civ, const_iv[] = { |
364 | } *civ, const_iv[] = { |
365 | # define const_iv(name) { # name, (IV)name } |
365 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
512 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
512 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
513 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
513 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
514 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
514 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
515 | |
515 | |
516 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
516 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
517 | #if SDL_VERSION_ATLEAST(1,2,10) |
517 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
518 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
518 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
519 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
|
|
520 | #endif |
519 | |
521 | |
520 | SDL_EnableUNICODE (1); |
522 | SDL_EnableUNICODE (1); |
521 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
523 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
522 | |
524 | |
523 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
525 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
610 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
612 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
611 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
613 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
612 | break; |
614 | break; |
613 | } |
615 | } |
614 | |
616 | |
615 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFClient::UI::Event", 1)))); |
617 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
616 | } |
618 | } |
617 | } |
619 | } |
618 | |
620 | |
619 | int |
621 | int |
620 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
622 | Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) |
… | |
… | |
749 | void |
751 | void |
750 | _exit (int retval) |
752 | _exit (int retval) |
751 | CODE: |
753 | CODE: |
752 | _exit (retval); |
754 | _exit (retval); |
753 | |
755 | |
754 | MODULE = CFClient PACKAGE = CFClient::Font |
756 | MODULE = CFPlus PACKAGE = CFPlus::Font |
755 | |
757 | |
756 | CFClient::Font |
758 | CFPlus::Font |
757 | new_from_file (SV *class, char *path, int id = 0) |
759 | new_from_file (SV *class, char *path, int id = 0) |
758 | CODE: |
760 | CODE: |
759 | { |
761 | { |
760 | int count; |
762 | int count; |
761 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
763 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
764 | } |
766 | } |
765 | OUTPUT: |
767 | OUTPUT: |
766 | RETVAL |
768 | RETVAL |
767 | |
769 | |
768 | void |
770 | void |
769 | DESTROY (CFClient::Font self) |
771 | DESTROY (CFPlus::Font self) |
770 | CODE: |
772 | CODE: |
771 | pango_font_description_free (self); |
773 | pango_font_description_free (self); |
772 | |
774 | |
773 | void |
775 | void |
774 | make_default (CFClient::Font self) |
776 | make_default (CFPlus::Font self) |
775 | CODE: |
777 | CODE: |
776 | default_font = self; |
778 | default_font = self; |
777 | |
779 | |
778 | MODULE = CFClient PACKAGE = CFClient::Layout |
780 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
779 | |
781 | |
780 | void |
782 | void |
781 | reset_glyph_cache () |
783 | reset_glyph_cache () |
782 | CODE: |
784 | CODE: |
783 | tc_clear (); |
785 | tc_clear (); |
784 | |
786 | |
785 | CFClient::Layout |
787 | CFPlus::Layout |
786 | new (SV *class) |
788 | new (SV *class) |
787 | CODE: |
789 | CODE: |
788 | New (0, RETVAL, 1, struct cf_layout); |
790 | New (0, RETVAL, 1, struct cf_layout); |
789 | |
791 | |
790 | RETVAL->pl = pango_layout_new (opengl_context); |
792 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
799 | layout_update_font (RETVAL); |
801 | layout_update_font (RETVAL); |
800 | OUTPUT: |
802 | OUTPUT: |
801 | RETVAL |
803 | RETVAL |
802 | |
804 | |
803 | void |
805 | void |
804 | DESTROY (CFClient::Layout self) |
806 | DESTROY (CFPlus::Layout self) |
805 | CODE: |
807 | CODE: |
806 | g_object_unref (self->pl); |
808 | g_object_unref (self->pl); |
807 | Safefree (self); |
809 | Safefree (self); |
808 | |
810 | |
809 | void |
811 | void |
810 | set_text (CFClient::Layout self, SV *text_) |
812 | set_text (CFPlus::Layout self, SV *text_) |
811 | CODE: |
813 | CODE: |
812 | { |
814 | { |
813 | STRLEN textlen; |
815 | STRLEN textlen; |
814 | char *text = SvPVutf8 (text_, textlen); |
816 | char *text = SvPVutf8 (text_, textlen); |
815 | |
817 | |
816 | pango_layout_set_text (self->pl, text, textlen); |
818 | pango_layout_set_text (self->pl, text, textlen); |
817 | } |
819 | } |
818 | |
820 | |
819 | void |
821 | void |
820 | set_markup (CFClient::Layout self, SV *text_) |
822 | set_markup (CFPlus::Layout self, SV *text_) |
821 | CODE: |
823 | CODE: |
822 | { |
824 | { |
823 | STRLEN textlen; |
825 | STRLEN textlen; |
824 | char *text = SvPVutf8 (text_, textlen); |
826 | char *text = SvPVutf8 (text_, textlen); |
825 | |
827 | |
826 | pango_layout_set_markup (self->pl, text, textlen); |
828 | pango_layout_set_markup (self->pl, text, textlen); |
827 | } |
829 | } |
828 | |
830 | |
829 | void |
831 | void |
830 | set_shapes (CFClient::Layout self, ...) |
832 | set_shapes (CFPlus::Layout self, ...) |
831 | CODE: |
833 | CODE: |
832 | { |
834 | { |
833 | PangoAttrList *attrs = 0; |
835 | PangoAttrList *attrs = 0; |
834 | const char *text = pango_layout_get_text (self->pl); |
836 | const char *text = pango_layout_get_text (self->pl); |
835 | const char *pos = text; |
837 | const char *pos = text; |
… | |
… | |
870 | if (attrs) |
872 | if (attrs) |
871 | pango_layout_set_attributes (self->pl, attrs); |
873 | pango_layout_set_attributes (self->pl, attrs); |
872 | } |
874 | } |
873 | |
875 | |
874 | void |
876 | void |
875 | get_shapes (CFClient::Layout self) |
877 | get_shapes (CFPlus::Layout self) |
876 | PPCODE: |
878 | PPCODE: |
877 | { |
879 | { |
878 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
880 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
879 | |
881 | |
880 | do |
882 | do |
… | |
… | |
895 | |
897 | |
896 | pango_layout_iter_free (iter); |
898 | pango_layout_iter_free (iter); |
897 | } |
899 | } |
898 | |
900 | |
899 | int |
901 | int |
900 | has_wrapped (CFClient::Layout self) |
902 | has_wrapped (CFPlus::Layout self) |
901 | CODE: |
903 | CODE: |
902 | { |
904 | { |
903 | int lines = 1; |
905 | int lines = 1; |
904 | const char *text = pango_layout_get_text (self->pl); |
906 | const char *text = pango_layout_get_text (self->pl); |
905 | |
907 | |
… | |
… | |
910 | } |
912 | } |
911 | OUTPUT: |
913 | OUTPUT: |
912 | RETVAL |
914 | RETVAL |
913 | |
915 | |
914 | SV * |
916 | SV * |
915 | get_text (CFClient::Layout self) |
917 | get_text (CFPlus::Layout self) |
916 | CODE: |
918 | CODE: |
917 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
919 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
918 | sv_utf8_decode (RETVAL); |
920 | sv_utf8_decode (RETVAL); |
919 | OUTPUT: |
921 | OUTPUT: |
920 | RETVAL |
922 | RETVAL |
921 | |
923 | |
922 | void |
924 | void |
923 | set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) |
925 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
924 | CODE: |
926 | CODE: |
925 | self->r = r; |
927 | self->r = r; |
926 | self->g = g; |
928 | self->g = g; |
927 | self->b = b; |
929 | self->b = b; |
928 | self->a = a; |
930 | self->a = a; |
929 | |
931 | |
930 | void |
932 | void |
931 | set_font (CFClient::Layout self, CFClient::Font font = 0) |
933 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
932 | CODE: |
934 | CODE: |
933 | if (self->font != font) |
935 | if (self->font != font) |
934 | { |
936 | { |
935 | self->font = font; |
937 | self->font = font; |
936 | layout_update_font (self); |
938 | layout_update_font (self); |
937 | } |
939 | } |
938 | |
940 | |
939 | void |
941 | void |
940 | set_height (CFClient::Layout self, int base_height) |
942 | set_height (CFPlus::Layout self, int base_height) |
941 | CODE: |
943 | CODE: |
942 | if (self->base_height != base_height) |
944 | if (self->base_height != base_height) |
943 | { |
945 | { |
944 | self->base_height = base_height; |
946 | self->base_height = base_height; |
945 | layout_update_font (self); |
947 | layout_update_font (self); |
946 | } |
948 | } |
947 | |
949 | |
948 | void |
950 | void |
949 | set_width (CFClient::Layout self, int max_width = -1) |
951 | set_width (CFPlus::Layout self, int max_width = -1) |
950 | CODE: |
952 | CODE: |
951 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
953 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
952 | |
954 | |
953 | void |
955 | void |
954 | set_indent (CFClient::Layout self, int indent) |
956 | set_indent (CFPlus::Layout self, int indent) |
955 | CODE: |
957 | CODE: |
956 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
958 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
957 | |
959 | |
958 | void |
960 | void |
959 | set_spacing (CFClient::Layout self, int spacing) |
961 | set_spacing (CFPlus::Layout self, int spacing) |
960 | CODE: |
962 | CODE: |
961 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
963 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
962 | |
964 | |
963 | void |
965 | void |
964 | set_ellipsise (CFClient::Layout self, int ellipsise) |
966 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
965 | CODE: |
967 | CODE: |
966 | pango_layout_set_ellipsize (self->pl, |
968 | pango_layout_set_ellipsize (self->pl, |
967 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
969 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
968 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
970 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
969 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
971 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
970 | : PANGO_ELLIPSIZE_NONE |
972 | : PANGO_ELLIPSIZE_NONE |
971 | ); |
973 | ); |
972 | |
974 | |
973 | void |
975 | void |
974 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
976 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
975 | CODE: |
977 | CODE: |
976 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
978 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
977 | |
979 | |
978 | void |
980 | void |
979 | size (CFClient::Layout self) |
981 | size (CFPlus::Layout self) |
980 | PPCODE: |
982 | PPCODE: |
981 | { |
983 | { |
982 | int w, h; |
984 | int w, h; |
983 | |
985 | |
984 | layout_get_pixel_size (self, &w, &h); |
986 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
987 | PUSHs (sv_2mortal (newSViv (w))); |
989 | PUSHs (sv_2mortal (newSViv (w))); |
988 | PUSHs (sv_2mortal (newSViv (h))); |
990 | PUSHs (sv_2mortal (newSViv (h))); |
989 | } |
991 | } |
990 | |
992 | |
991 | int |
993 | int |
992 | descent (CFClient::Layout self) |
994 | descent (CFPlus::Layout self) |
993 | CODE: |
995 | CODE: |
994 | { |
996 | { |
995 | PangoRectangle rect; |
997 | PangoRectangle rect; |
996 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
998 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
997 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
999 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
999 | } |
1001 | } |
1000 | OUTPUT: |
1002 | OUTPUT: |
1001 | RETVAL |
1003 | RETVAL |
1002 | |
1004 | |
1003 | int |
1005 | int |
1004 | xy_to_index (CFClient::Layout self, int x, int y) |
1006 | xy_to_index (CFPlus::Layout self, int x, int y) |
1005 | CODE: |
1007 | CODE: |
1006 | { |
1008 | { |
1007 | int index, trailing; |
1009 | int index, trailing; |
1008 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1010 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1009 | RETVAL = index; |
1011 | RETVAL = index; |
1010 | } |
1012 | } |
1011 | OUTPUT: |
1013 | OUTPUT: |
1012 | RETVAL |
1014 | RETVAL |
1013 | |
1015 | |
1014 | void |
1016 | void |
1015 | cursor_pos (CFClient::Layout self, int index) |
1017 | cursor_pos (CFPlus::Layout self, int index) |
1016 | PPCODE: |
1018 | PPCODE: |
1017 | { |
1019 | { |
1018 | PangoRectangle strong_pos; |
1020 | PangoRectangle strong_pos; |
1019 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1021 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1020 | |
1022 | |
… | |
… | |
1023 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1025 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1024 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1026 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1025 | } |
1027 | } |
1026 | |
1028 | |
1027 | void |
1029 | void |
1028 | render (CFClient::Layout self, float x, float y) |
1030 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1029 | PPCODE: |
1031 | PPCODE: |
1030 | pango_opengl_render_layout_subpixel ( |
1032 | pango_opengl_render_layout_subpixel ( |
1031 | self->pl, |
1033 | self->pl, |
1032 | x * PANGO_SCALE, y * PANGO_SCALE, |
1034 | x * PANGO_SCALE, y * PANGO_SCALE, |
1033 | self->r, self->g, self->b, self->a |
1035 | self->r, self->g, self->b, self->a, |
|
|
1036 | flags |
1034 | ); |
1037 | ); |
1035 | |
1038 | |
1036 | MODULE = CFClient PACKAGE = CFClient::Texture |
1039 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1037 | |
1040 | |
1038 | void |
1041 | void |
1039 | pad2pot (SV *data_, SV *w_, SV *h_) |
1042 | pad2pot (SV *data_, SV *w_, SV *h_) |
1040 | CODE: |
1043 | CODE: |
1041 | { |
1044 | { |
… | |
… | |
1119 | glDisable (GL_ALPHA_TEST); |
1122 | glDisable (GL_ALPHA_TEST); |
1120 | glDisable (GL_BLEND); |
1123 | glDisable (GL_BLEND); |
1121 | } |
1124 | } |
1122 | } |
1125 | } |
1123 | |
1126 | |
1124 | MODULE = CFClient PACKAGE = CFClient::Map |
1127 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1125 | |
1128 | |
1126 | CFClient::Map |
1129 | CFPlus::Map |
1127 | new (SV *class, int map_width, int map_height) |
1130 | new (SV *class, int map_width, int map_height) |
1128 | CODE: |
1131 | CODE: |
1129 | New (0, RETVAL, 1, struct map); |
1132 | New (0, RETVAL, 1, struct map); |
1130 | RETVAL->x = 0; |
1133 | RETVAL->x = 0; |
1131 | RETVAL->y = 0; |
1134 | RETVAL->y = 0; |
… | |
… | |
1141 | RETVAL->row = 0; |
1144 | RETVAL->row = 0; |
1142 | OUTPUT: |
1145 | OUTPUT: |
1143 | RETVAL |
1146 | RETVAL |
1144 | |
1147 | |
1145 | void |
1148 | void |
1146 | DESTROY (CFClient::Map self) |
1149 | DESTROY (CFPlus::Map self) |
1147 | CODE: |
1150 | CODE: |
1148 | { |
1151 | { |
1149 | map_clear (self); |
1152 | map_clear (self); |
1150 | Safefree (self->face); |
1153 | Safefree (self->face); |
1151 | Safefree (self->tex); |
1154 | Safefree (self->tex); |
1152 | Safefree (self); |
1155 | Safefree (self); |
1153 | } |
1156 | } |
1154 | |
1157 | |
1155 | void |
1158 | void |
1156 | clear (CFClient::Map self) |
1159 | clear (CFPlus::Map self) |
1157 | CODE: |
1160 | CODE: |
1158 | map_clear (self); |
1161 | map_clear (self); |
1159 | |
1162 | |
1160 | void |
1163 | void |
1161 | set_face (CFClient::Map self, int face, int texid) |
1164 | set_face (CFPlus::Map self, int face, int texid) |
1162 | CODE: |
1165 | CODE: |
1163 | { |
1166 | { |
1164 | while (self->faces <= face) |
1167 | while (self->faces <= face) |
1165 | { |
1168 | { |
1166 | Append (mapface, self->face, self->faces, self->faces); |
1169 | Append (mapface, self->face, self->faces, self->faces); |
… | |
… | |
1169 | |
1172 | |
1170 | self->face [face] = texid; |
1173 | self->face [face] = texid; |
1171 | } |
1174 | } |
1172 | |
1175 | |
1173 | void |
1176 | 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) |
1177 | 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: |
1178 | CODE: |
1176 | { |
1179 | { |
1177 | while (self->texs <= texid) |
1180 | while (self->texs <= texid) |
1178 | { |
1181 | { |
1179 | Append (maptex, self->tex, self->texs, self->texs); |
1182 | Append (maptex, self->tex, self->texs, self->texs); |
… | |
… | |
1203 | // from transparent color bleeding and ugly wrapping effects. |
1206 | // from transparent color bleeding and ugly wrapping effects. |
1204 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1207 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1205 | } |
1208 | } |
1206 | |
1209 | |
1207 | int |
1210 | int |
1208 | ox (CFClient::Map self) |
1211 | ox (CFPlus::Map self) |
1209 | ALIAS: |
1212 | ALIAS: |
1210 | oy = 1 |
1213 | oy = 1 |
1211 | x = 2 |
1214 | x = 2 |
1212 | y = 3 |
1215 | y = 3 |
1213 | w = 4 |
1216 | w = 4 |
… | |
… | |
1224 | } |
1227 | } |
1225 | OUTPUT: |
1228 | OUTPUT: |
1226 | RETVAL |
1229 | RETVAL |
1227 | |
1230 | |
1228 | void |
1231 | void |
1229 | scroll (CFClient::Map self, int dx, int dy) |
1232 | scroll (CFPlus::Map self, int dx, int dy) |
1230 | CODE: |
1233 | CODE: |
1231 | { |
1234 | { |
1232 | if (dx > 0) |
1235 | if (dx > 0) |
1233 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1236 | map_blank (self, self->x, self->y, dx - 1, self->h); |
1234 | else if (dx < 0) |
1237 | else if (dx < 0) |
… | |
… | |
1250 | self->y += MAP_EXTEND_Y; |
1253 | self->y += MAP_EXTEND_Y; |
1251 | } |
1254 | } |
1252 | } |
1255 | } |
1253 | |
1256 | |
1254 | void |
1257 | void |
1255 | map1a_update (CFClient::Map self, SV *data_) |
1258 | map1a_update (CFPlus::Map self, SV *data_) |
1256 | CODE: |
1259 | CODE: |
1257 | { |
1260 | { |
1258 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1261 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1259 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1262 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1260 | mapcell *cell; |
1263 | mapcell *cell; |
… | |
… | |
1302 | cell->darkness = -1; |
1305 | cell->darkness = -1; |
1303 | } |
1306 | } |
1304 | } |
1307 | } |
1305 | |
1308 | |
1306 | SV * |
1309 | SV * |
1307 | mapmap (CFClient::Map self, int x0, int y0, int w, int h) |
1310 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1308 | CODE: |
1311 | CODE: |
1309 | { |
1312 | { |
1310 | int x1, x; |
1313 | int x1, x; |
1311 | int y1, y; |
1314 | int y1, y; |
1312 | int z; |
1315 | int z; |
… | |
… | |
1362 | } |
1365 | } |
1363 | OUTPUT: |
1366 | OUTPUT: |
1364 | RETVAL |
1367 | RETVAL |
1365 | |
1368 | |
1366 | void |
1369 | void |
1367 | draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1370 | draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1368 | CODE: |
1371 | CODE: |
1369 | { |
1372 | { |
1370 | int vx, vy; |
1373 | int vx, vy; |
1371 | int x, y, z; |
1374 | int x, y, z; |
1372 | int last_name; |
1375 | int last_name; |
… | |
… | |
1437 | glDisable (GL_TEXTURE_2D); |
1440 | glDisable (GL_TEXTURE_2D); |
1438 | glDisable (GL_BLEND); |
1441 | glDisable (GL_BLEND); |
1439 | } |
1442 | } |
1440 | |
1443 | |
1441 | void |
1444 | void |
1442 | draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1445 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1443 | CODE: |
1446 | CODE: |
1444 | { |
1447 | { |
1445 | static float color[16][3] = { |
1448 | static float color[16][3] = { |
1446 | { 0.00F, 0.00F, 0.00F }, |
1449 | { 0.00F, 0.00F, 0.00F }, |
1447 | { 1.00F, 1.00F, 1.00F }, |
1450 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
1497 | glDisable (GL_BLEND); |
1500 | glDisable (GL_BLEND); |
1498 | glDisable (GL_TEXTURE_2D); |
1501 | glDisable (GL_TEXTURE_2D); |
1499 | } |
1502 | } |
1500 | |
1503 | |
1501 | void |
1504 | void |
1502 | fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1505 | fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) |
1503 | PPCODE: |
1506 | PPCODE: |
1504 | { |
1507 | { |
1505 | int vx, vy; |
1508 | int vx, vy; |
1506 | int x, y; |
1509 | int x, y; |
1507 | int sw4 = (sw + 3) & ~3; |
1510 | int sw4 = (sw + 3) & ~3; |
… | |
… | |
1536 | PUSHs (sv_2mortal (newSViv (sh))); |
1539 | PUSHs (sv_2mortal (newSViv (sh))); |
1537 | PUSHs (darkness_sv); |
1540 | PUSHs (darkness_sv); |
1538 | } |
1541 | } |
1539 | |
1542 | |
1540 | SV * |
1543 | SV * |
1541 | get_rect (CFClient::Map self, int x0, int y0, int w, int h) |
1544 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
1542 | CODE: |
1545 | CODE: |
1543 | { |
1546 | { |
1544 | int x, y, x1, y1; |
1547 | int x, y, x1, y1; |
1545 | SV *data_sv = newSV (w * h * 7 + 5); |
1548 | SV *data_sv = newSV (w * h * 7 + 5); |
1546 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
1549 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
1608 | } |
1611 | } |
1609 | OUTPUT: |
1612 | OUTPUT: |
1610 | RETVAL |
1613 | RETVAL |
1611 | |
1614 | |
1612 | void |
1615 | void |
1613 | set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) |
1616 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
1614 | PPCODE: |
1617 | PPCODE: |
1615 | { |
1618 | { |
1616 | int x, y, z; |
1619 | int x, y, z; |
1617 | int w, h; |
1620 | int w, h; |
1618 | int x1, y1; |
1621 | int x1, y1; |
… | |
… | |
1667 | } |
1670 | } |
1668 | } |
1671 | } |
1669 | } |
1672 | } |
1670 | } |
1673 | } |
1671 | |
1674 | |
1672 | MODULE = CFClient PACKAGE = CFClient::MixChunk |
1675 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
1673 | |
1676 | |
1674 | CFClient::MixChunk |
1677 | CFPlus::MixChunk |
1675 | new_from_file (SV *class, char *path) |
1678 | new_from_file (SV *class, char *path) |
1676 | CODE: |
1679 | CODE: |
1677 | RETVAL = Mix_LoadWAV (path); |
1680 | RETVAL = Mix_LoadWAV (path); |
1678 | OUTPUT: |
1681 | OUTPUT: |
1679 | RETVAL |
1682 | RETVAL |
1680 | |
1683 | |
1681 | void |
1684 | void |
1682 | DESTROY (CFClient::MixChunk self) |
1685 | DESTROY (CFPlus::MixChunk self) |
1683 | CODE: |
1686 | CODE: |
1684 | Mix_FreeChunk (self); |
1687 | Mix_FreeChunk (self); |
1685 | |
1688 | |
1686 | int |
1689 | int |
1687 | volume (CFClient::MixChunk self, int volume = -1) |
1690 | volume (CFPlus::MixChunk self, int volume = -1) |
1688 | CODE: |
1691 | CODE: |
1689 | RETVAL = Mix_VolumeChunk (self, volume); |
1692 | RETVAL = Mix_VolumeChunk (self, volume); |
1690 | OUTPUT: |
1693 | OUTPUT: |
1691 | RETVAL |
1694 | RETVAL |
1692 | |
1695 | |
1693 | int |
1696 | int |
1694 | play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1697 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
1695 | CODE: |
1698 | CODE: |
1696 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1699 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
1697 | OUTPUT: |
1700 | OUTPUT: |
1698 | RETVAL |
1701 | RETVAL |
1699 | |
1702 | |
1700 | MODULE = CFClient PACKAGE = CFClient::MixMusic |
1703 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
1701 | |
1704 | |
1702 | int |
1705 | int |
1703 | volume (int volume = -1) |
1706 | volume (int volume = -1) |
1704 | CODE: |
1707 | CODE: |
1705 | RETVAL = Mix_VolumeMusic (volume); |
1708 | RETVAL = Mix_VolumeMusic (volume); |
1706 | OUTPUT: |
1709 | OUTPUT: |
1707 | RETVAL |
1710 | RETVAL |
1708 | |
1711 | |
1709 | CFClient::MixMusic |
1712 | CFPlus::MixMusic |
1710 | new_from_file (SV *class, char *path) |
1713 | new_from_file (SV *class, char *path) |
1711 | CODE: |
1714 | CODE: |
1712 | RETVAL = Mix_LoadMUS (path); |
1715 | RETVAL = Mix_LoadMUS (path); |
1713 | OUTPUT: |
1716 | OUTPUT: |
1714 | RETVAL |
1717 | RETVAL |
1715 | |
1718 | |
1716 | void |
1719 | void |
1717 | DESTROY (CFClient::MixMusic self) |
1720 | DESTROY (CFPlus::MixMusic self) |
1718 | CODE: |
1721 | CODE: |
1719 | Mix_FreeMusic (self); |
1722 | Mix_FreeMusic (self); |
1720 | |
1723 | |
1721 | int |
1724 | int |
1722 | play (CFClient::MixMusic self, int loops = -1) |
1725 | play (CFPlus::MixMusic self, int loops = -1) |
1723 | CODE: |
1726 | CODE: |
1724 | RETVAL = Mix_PlayMusic (self, loops); |
1727 | RETVAL = Mix_PlayMusic (self, loops); |
1725 | OUTPUT: |
1728 | OUTPUT: |
1726 | RETVAL |
1729 | RETVAL |
1727 | |
1730 | |
1728 | MODULE = CFClient PACKAGE = CFClient::OpenGL |
1731 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
1729 | |
1732 | |
1730 | BOOT: |
1733 | BOOT: |
1731 | { |
1734 | { |
1732 | HV *stash = gv_stashpv ("CFClient::OpenGL", 1); |
1735 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
1733 | static const struct { |
1736 | static const struct { |
1734 | const char *name; |
1737 | const char *name; |
1735 | IV iv; |
1738 | IV iv; |
1736 | } *civ, const_iv[] = { |
1739 | } *civ, const_iv[] = { |
1737 | # define const_iv(name) { # name, (IV)name } |
1740 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
1800 | const_iv (GL_SEPARABLE_2D), |
1803 | const_iv (GL_SEPARABLE_2D), |
1801 | const_iv (GL_CONVOLUTION_2D), |
1804 | const_iv (GL_CONVOLUTION_2D), |
1802 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1805 | const_iv (GL_CONVOLUTION_BORDER_MODE), |
1803 | const_iv (GL_CONSTANT_BORDER), |
1806 | const_iv (GL_CONSTANT_BORDER), |
1804 | const_iv (GL_LINES), |
1807 | const_iv (GL_LINES), |
|
|
1808 | const_iv (GL_LINE_STRIP), |
1805 | const_iv (GL_LINE_LOOP), |
1809 | const_iv (GL_LINE_LOOP), |
1806 | const_iv (GL_QUADS), |
1810 | const_iv (GL_QUADS), |
1807 | const_iv (GL_QUAD_STRIP), |
1811 | const_iv (GL_QUAD_STRIP), |
1808 | const_iv (GL_TRIANGLES), |
1812 | const_iv (GL_TRIANGLES), |
1809 | const_iv (GL_TRIANGLE_STRIP), |
1813 | const_iv (GL_TRIANGLE_STRIP), |
… | |
… | |
2006 | |
2010 | |
2007 | void glEndList () |
2011 | void glEndList () |
2008 | |
2012 | |
2009 | void glCallList (int list) |
2013 | void glCallList (int list) |
2010 | |
2014 | |
2011 | |
|
|