ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.131 by root, Thu Jul 13 01:54:18 2006 UTC vs.
Revision 1.139 by root, Mon Aug 14 03:04:17 2006 UTC

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
88typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
89typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
90 90
91typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
92 92
93static int 93static int
94shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
95{ 95{
96 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
110 110
111typedef struct cf_layout { 111typedef 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
118static CFClient__Font default_font; 118static CFPlus__Font default_font;
119static PangoContext *opengl_context; 119static PangoContext *opengl_context;
120static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
121 121
122static void 122static void
123substitute_func (FcPattern *pattern, gpointer data) 123substitute_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
132static void 132static void
133layout_update_font (CFClient__Layout self) 133layout_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
146static void 146static void
147layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_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 rect.width = (rect.width + 3) & ~3;
161
162 *w = rect.width;
163 *h = rect.height;
155} 164}
156 165
157typedef uint16_t mapface; 166typedef uint16_t mapface;
158 167
159typedef struct { 168typedef struct {
182 int texs; 191 int texs;
183 maptex *tex; 192 maptex *tex;
184 193
185 int32_t rows; 194 int32_t rows;
186 maprow *row; 195 maprow *row;
187} *CFClient__Map; 196} *CFPlus__Map;
188 197
189static char * 198static char *
190prepend (char *ptr, int sze, int inc) 199prepend (char *ptr, int sze, int inc)
191{ 200{
192 char *p; 201 char *p;
210 219
211#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 220#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)) 221#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
213 222
214static maprow * 223static maprow *
215map_get_row (CFClient__Map self, int y) 224map_get_row (CFPlus__Map self, int y)
216{ 225{
217 if (0 > y) 226 if (0 > y)
218 { 227 {
219 int extend = - y + MAP_EXTEND_Y; 228 int extend = - y + MAP_EXTEND_Y;
220 Prepend (maprow, self->row, self->rows, extend); 229 Prepend (maprow, self->row, self->rows, extend);
258 267
259 return row->col + (x - row->c0); 268 return row->col + (x - row->c0);
260} 269}
261 270
262static mapcell * 271static mapcell *
263map_get_cell (CFClient__Map self, int x, int y) 272map_get_cell (CFPlus__Map self, int x, int y)
264{ 273{
265 return row_get_cell (map_get_row (self, y), x); 274 return row_get_cell (map_get_row (self, y), x);
266} 275}
267 276
268static void 277static void
269map_clear (CFClient__Map self) 278map_clear (CFPlus__Map self)
270{ 279{
271 int r; 280 int r;
272 281
273 for (r = 0; r < self->rows; r++) 282 for (r = 0; r < self->rows; r++)
274 Safefree (self->row[r].col); 283 Safefree (self->row[r].col);
282 self->row = 0; 291 self->row = 0;
283 self->rows = 0; 292 self->rows = 0;
284} 293}
285 294
286static void 295static void
287map_blank (CFClient__Map self, int x0, int y0, int w, int h) 296map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
288{ 297{
289 int x, y; 298 int x, y;
290 maprow *row; 299 maprow *row;
291 300
292 for (y = y0; y < y0 + h; y++) 301 for (y = y0; y < y0 + h; y++)
349 n |= n >> 16; 358 n |= n >> 16;
350 359
351 return n + 1; 360 return n + 1;
352} 361}
353 362
354MODULE = CFClient PACKAGE = CFClient 363MODULE = CFPlus PACKAGE = CFPlus
355 364
356PROTOTYPES: ENABLE 365PROTOTYPES: ENABLE
357 366
358BOOT: 367BOOT:
359{ 368{
360 HV *stash = gv_stashpv ("CFClient", 1); 369 HV *stash = gv_stashpv ("CFPlus", 1);
361 static const struct { 370 static const struct {
362 const char *name; 371 const char *name;
363 IV iv; 372 IV iv;
364 } *civ, const_iv[] = { 373 } *civ, const_iv[] = {
365# define const_iv(name) { # name, (IV)name } 374# define const_iv(name) { # name, (IV)name }
512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 521 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 522 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 523 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
515 524
516 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 525 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
526#if SDL_VERSION_ATLEAST(1,2,10)
517 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); 527 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
518 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); 528 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
529#endif
519 530
520 SDL_EnableUNICODE (1); 531 SDL_EnableUNICODE (1);
521 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 532 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
522 533
523 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 534 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
610 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 621 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
611 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 622 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
612 break; 623 break;
613 } 624 }
614 625
615 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 626 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
616 } 627 }
617} 628}
618 629
619int 630int
620Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 631Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
749void 760void
750_exit (int retval) 761_exit (int retval)
751 CODE: 762 CODE:
752 _exit (retval); 763 _exit (retval);
753 764
754MODULE = CFClient PACKAGE = CFClient::Font 765MODULE = CFPlus PACKAGE = CFPlus::Font
755 766
756CFClient::Font 767CFPlus::Font
757new_from_file (SV *class, char *path, int id = 0) 768new_from_file (SV *class, char *path, int id = 0)
758 CODE: 769 CODE:
759{ 770{
760 int count; 771 int count;
761 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 772 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
764} 775}
765 OUTPUT: 776 OUTPUT:
766 RETVAL 777 RETVAL
767 778
768void 779void
769DESTROY (CFClient::Font self) 780DESTROY (CFPlus::Font self)
770 CODE: 781 CODE:
771 pango_font_description_free (self); 782 pango_font_description_free (self);
772 783
773void 784void
774make_default (CFClient::Font self) 785make_default (CFPlus::Font self)
775 CODE: 786 CODE:
776 default_font = self; 787 default_font = self;
777 788
778MODULE = CFClient PACKAGE = CFClient::Layout 789MODULE = CFPlus PACKAGE = CFPlus::Layout
779 790
780void 791void
781reset_glyph_cache () 792reset_glyph_cache ()
782 CODE: 793 CODE:
783 tc_clear (); 794 tc_clear ();
784 795
785CFClient::Layout 796CFPlus::Layout
786new (SV *class) 797new (SV *class)
787 CODE: 798 CODE:
788 New (0, RETVAL, 1, struct cf_layout); 799 New (0, RETVAL, 1, struct cf_layout);
789 800
790 RETVAL->pl = pango_layout_new (opengl_context); 801 RETVAL->pl = pango_layout_new (opengl_context);
799 layout_update_font (RETVAL); 810 layout_update_font (RETVAL);
800 OUTPUT: 811 OUTPUT:
801 RETVAL 812 RETVAL
802 813
803void 814void
804DESTROY (CFClient::Layout self) 815DESTROY (CFPlus::Layout self)
805 CODE: 816 CODE:
806 g_object_unref (self->pl); 817 g_object_unref (self->pl);
807 Safefree (self); 818 Safefree (self);
808 819
809void 820void
810set_text (CFClient::Layout self, SV *text_) 821set_text (CFPlus::Layout self, SV *text_)
811 CODE: 822 CODE:
812{ 823{
813 STRLEN textlen; 824 STRLEN textlen;
814 char *text = SvPVutf8 (text_, textlen); 825 char *text = SvPVutf8 (text_, textlen);
815 826
816 pango_layout_set_text (self->pl, text, textlen); 827 pango_layout_set_text (self->pl, text, textlen);
817} 828}
818 829
819void 830void
820set_markup (CFClient::Layout self, SV *text_) 831set_markup (CFPlus::Layout self, SV *text_)
821 CODE: 832 CODE:
822{ 833{
823 STRLEN textlen; 834 STRLEN textlen;
824 char *text = SvPVutf8 (text_, textlen); 835 char *text = SvPVutf8 (text_, textlen);
825 836
826 pango_layout_set_markup (self->pl, text, textlen); 837 pango_layout_set_markup (self->pl, text, textlen);
827} 838}
828 839
829void 840void
830set_shapes (CFClient::Layout self, ...) 841set_shapes (CFPlus::Layout self, ...)
831 CODE: 842 CODE:
832{ 843{
833 PangoAttrList *attrs = 0; 844 PangoAttrList *attrs = 0;
834 const char *text = pango_layout_get_text (self->pl); 845 const char *text = pango_layout_get_text (self->pl);
835 const char *pos = text; 846 const char *pos = text;
870 if (attrs) 881 if (attrs)
871 pango_layout_set_attributes (self->pl, attrs); 882 pango_layout_set_attributes (self->pl, attrs);
872} 883}
873 884
874void 885void
875get_shapes (CFClient::Layout self) 886get_shapes (CFPlus::Layout self)
876 PPCODE: 887 PPCODE:
877{ 888{
878 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 889 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
879 890
880 do 891 do
895 906
896 pango_layout_iter_free (iter); 907 pango_layout_iter_free (iter);
897} 908}
898 909
899int 910int
900has_wrapped (CFClient::Layout self) 911has_wrapped (CFPlus::Layout self)
901 CODE: 912 CODE:
902{ 913{
903 int lines = 1; 914 int lines = 1;
904 const char *text = pango_layout_get_text (self->pl); 915 const char *text = pango_layout_get_text (self->pl);
905 916
910} 921}
911 OUTPUT: 922 OUTPUT:
912 RETVAL 923 RETVAL
913 924
914SV * 925SV *
915get_text (CFClient::Layout self) 926get_text (CFPlus::Layout self)
916 CODE: 927 CODE:
917 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 928 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
918 sv_utf8_decode (RETVAL); 929 sv_utf8_decode (RETVAL);
919 OUTPUT: 930 OUTPUT:
920 RETVAL 931 RETVAL
921 932
922void 933void
923set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 934set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
924 CODE: 935 CODE:
925 self->r = r; 936 self->r = r;
926 self->g = g; 937 self->g = g;
927 self->b = b; 938 self->b = b;
928 self->a = a; 939 self->a = a;
929 940
930void 941void
931set_font (CFClient::Layout self, CFClient::Font font = 0) 942set_font (CFPlus::Layout self, CFPlus::Font font = 0)
932 CODE: 943 CODE:
933 if (self->font != font) 944 if (self->font != font)
934 { 945 {
935 self->font = font; 946 self->font = font;
936 layout_update_font (self); 947 layout_update_font (self);
937 } 948 }
938 949
939void 950void
940set_height (CFClient::Layout self, int base_height) 951set_height (CFPlus::Layout self, int base_height)
941 CODE: 952 CODE:
942 if (self->base_height != base_height) 953 if (self->base_height != base_height)
943 { 954 {
944 self->base_height = base_height; 955 self->base_height = base_height;
945 layout_update_font (self); 956 layout_update_font (self);
946 } 957 }
947 958
948void 959void
949set_width (CFClient::Layout self, int max_width = -1) 960set_width (CFPlus::Layout self, int max_width = -1)
950 CODE: 961 CODE:
951 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 962 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
952 963
953void 964void
954set_indent (CFClient::Layout self, int indent) 965set_indent (CFPlus::Layout self, int indent)
955 CODE: 966 CODE:
956 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 967 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
957 968
958void 969void
959set_spacing (CFClient::Layout self, int spacing) 970set_spacing (CFPlus::Layout self, int spacing)
960 CODE: 971 CODE:
961 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 972 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
962 973
963void 974void
964set_ellipsise (CFClient::Layout self, int ellipsise) 975set_ellipsise (CFPlus::Layout self, int ellipsise)
965 CODE: 976 CODE:
966 pango_layout_set_ellipsize (self->pl, 977 pango_layout_set_ellipsize (self->pl,
967 ellipsise == 1 ? PANGO_ELLIPSIZE_START 978 ellipsise == 1 ? PANGO_ELLIPSIZE_START
968 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 979 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
969 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 980 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
970 : PANGO_ELLIPSIZE_NONE 981 : PANGO_ELLIPSIZE_NONE
971 ); 982 );
972 983
973void 984void
974set_single_paragraph_mode (CFClient::Layout self, int spm) 985set_single_paragraph_mode (CFPlus::Layout self, int spm)
975 CODE: 986 CODE:
976 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 987 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
977 988
978void 989void
979size (CFClient::Layout self) 990size (CFPlus::Layout self)
980 PPCODE: 991 PPCODE:
981{ 992{
982 int w, h; 993 int w, h;
983 994
984 layout_get_pixel_size (self, &w, &h); 995 layout_get_pixel_size (self, &w, &h);
987 PUSHs (sv_2mortal (newSViv (w))); 998 PUSHs (sv_2mortal (newSViv (w)));
988 PUSHs (sv_2mortal (newSViv (h))); 999 PUSHs (sv_2mortal (newSViv (h)));
989} 1000}
990 1001
991int 1002int
992descent (CFClient::Layout self) 1003descent (CFPlus::Layout self)
993 CODE: 1004 CODE:
994{ 1005{
995 PangoRectangle rect; 1006 PangoRectangle rect;
996 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1007 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
997 pango_layout_line_get_pixel_extents (line, 0, &rect); 1008 pango_layout_line_get_pixel_extents (line, 0, &rect);
999} 1010}
1000 OUTPUT: 1011 OUTPUT:
1001 RETVAL 1012 RETVAL
1002 1013
1003int 1014int
1004xy_to_index (CFClient::Layout self, int x, int y) 1015xy_to_index (CFPlus::Layout self, int x, int y)
1005 CODE: 1016 CODE:
1006{ 1017{
1007 int index, trailing; 1018 int index, trailing;
1008 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1019 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1009 RETVAL = index; 1020 RETVAL = index;
1010} 1021}
1011 OUTPUT: 1022 OUTPUT:
1012 RETVAL 1023 RETVAL
1013 1024
1014void 1025void
1015cursor_pos (CFClient::Layout self, int index) 1026cursor_pos (CFPlus::Layout self, int index)
1016 PPCODE: 1027 PPCODE:
1017{ 1028{
1018 PangoRectangle strong_pos; 1029 PangoRectangle strong_pos;
1019 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1030 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1020 1031
1023 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1034 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1024 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1035 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1025} 1036}
1026 1037
1027void 1038void
1028render (CFClient::Layout self, float x, float y) 1039render (CFPlus::Layout self, float x, float y, int flags = 0)
1029 PPCODE: 1040 PPCODE:
1030 pango_opengl_render_layout_subpixel ( 1041 pango_opengl_render_layout_subpixel (
1031 self->pl, 1042 self->pl,
1032 x * PANGO_SCALE, y * PANGO_SCALE, 1043 x * PANGO_SCALE, y * PANGO_SCALE,
1033 self->r, self->g, self->b, self->a 1044 self->r, self->g, self->b, self->a,
1045 flags
1034 ); 1046 );
1035 1047
1036MODULE = CFClient PACKAGE = CFClient::Texture 1048MODULE = CFPlus PACKAGE = CFPlus::Texture
1037 1049
1038void 1050void
1039pad2pot (SV *data_, SV *w_, SV *h_) 1051pad2pot (SV *data_, SV *w_, SV *h_)
1040 CODE: 1052 CODE:
1041{ 1053{
1119 glDisable (GL_ALPHA_TEST); 1131 glDisable (GL_ALPHA_TEST);
1120 glDisable (GL_BLEND); 1132 glDisable (GL_BLEND);
1121 } 1133 }
1122} 1134}
1123 1135
1124MODULE = CFClient PACKAGE = CFClient::Map 1136MODULE = CFPlus PACKAGE = CFPlus::Map
1125 1137
1126CFClient::Map 1138CFPlus::Map
1127new (SV *class, int map_width, int map_height) 1139new (SV *class, int map_width, int map_height)
1128 CODE: 1140 CODE:
1129 New (0, RETVAL, 1, struct map); 1141 New (0, RETVAL, 1, struct map);
1130 RETVAL->x = 0; 1142 RETVAL->x = 0;
1131 RETVAL->y = 0; 1143 RETVAL->y = 0;
1141 RETVAL->row = 0; 1153 RETVAL->row = 0;
1142 OUTPUT: 1154 OUTPUT:
1143 RETVAL 1155 RETVAL
1144 1156
1145void 1157void
1146DESTROY (CFClient::Map self) 1158DESTROY (CFPlus::Map self)
1147 CODE: 1159 CODE:
1148{ 1160{
1149 map_clear (self); 1161 map_clear (self);
1150 Safefree (self->face); 1162 Safefree (self->face);
1151 Safefree (self->tex); 1163 Safefree (self->tex);
1152 Safefree (self); 1164 Safefree (self);
1153} 1165}
1154 1166
1155void 1167void
1156clear (CFClient::Map self) 1168clear (CFPlus::Map self)
1157 CODE: 1169 CODE:
1158 map_clear (self); 1170 map_clear (self);
1159 1171
1160void 1172void
1161set_face (CFClient::Map self, int face, int texid) 1173set_face (CFPlus::Map self, int face, int texid)
1162 CODE: 1174 CODE:
1163{ 1175{
1164 while (self->faces <= face) 1176 while (self->faces <= face)
1165 { 1177 {
1166 Append (mapface, self->face, self->faces, self->faces); 1178 Append (mapface, self->face, self->faces, self->faces);
1169 1181
1170 self->face [face] = texid; 1182 self->face [face] = texid;
1171} 1183}
1172 1184
1173void 1185void
1174set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1186set_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: 1187 CODE:
1176{ 1188{
1177 while (self->texs <= texid) 1189 while (self->texs <= texid)
1178 { 1190 {
1179 Append (maptex, self->tex, self->texs, self->texs); 1191 Append (maptex, self->tex, self->texs, self->texs);
1203 // from transparent color bleeding and ugly wrapping effects. 1215 // from transparent color bleeding and ugly wrapping effects.
1204 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1216 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1205} 1217}
1206 1218
1207int 1219int
1208ox (CFClient::Map self) 1220ox (CFPlus::Map self)
1209 ALIAS: 1221 ALIAS:
1210 oy = 1 1222 oy = 1
1211 x = 2 1223 x = 2
1212 y = 3 1224 y = 3
1213 w = 4 1225 w = 4
1224 } 1236 }
1225 OUTPUT: 1237 OUTPUT:
1226 RETVAL 1238 RETVAL
1227 1239
1228void 1240void
1229scroll (CFClient::Map self, int dx, int dy) 1241scroll (CFPlus::Map self, int dx, int dy)
1230 CODE: 1242 CODE:
1231{ 1243{
1232 if (dx > 0) 1244 if (dx > 0)
1233 map_blank (self, self->x, self->y, dx - 1, self->h); 1245 map_blank (self, self->x, self->y, dx - 1, self->h);
1234 else if (dx < 0) 1246 else if (dx < 0)
1250 self->y += MAP_EXTEND_Y; 1262 self->y += MAP_EXTEND_Y;
1251 } 1263 }
1252} 1264}
1253 1265
1254void 1266void
1255map1a_update (CFClient::Map self, SV *data_) 1267map1a_update (CFPlus::Map self, SV *data_)
1256 CODE: 1268 CODE:
1257{ 1269{
1258 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1270 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1259 uint8_t *data_end = (uint8_t *)SvEND (data_); 1271 uint8_t *data_end = (uint8_t *)SvEND (data_);
1260 mapcell *cell; 1272 mapcell *cell;
1302 cell->darkness = -1; 1314 cell->darkness = -1;
1303 } 1315 }
1304} 1316}
1305 1317
1306SV * 1318SV *
1307mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1319mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1308 CODE: 1320 CODE:
1309{ 1321{
1310 int x1, x; 1322 int x1, x;
1311 int y1, y; 1323 int y1, y;
1312 int z; 1324 int z;
1362} 1374}
1363 OUTPUT: 1375 OUTPUT:
1364 RETVAL 1376 RETVAL
1365 1377
1366void 1378void
1367draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1379draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1368 CODE: 1380 CODE:
1369{ 1381{
1370 int vx, vy; 1382 int vx, vy;
1371 int x, y, z; 1383 int x, y, z;
1372 int last_name; 1384 int last_name;
1437 glDisable (GL_TEXTURE_2D); 1449 glDisable (GL_TEXTURE_2D);
1438 glDisable (GL_BLEND); 1450 glDisable (GL_BLEND);
1439} 1451}
1440 1452
1441void 1453void
1442draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1454draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1443 CODE: 1455 CODE:
1444{ 1456{
1445 static float color[16][3] = { 1457 static float color[16][3] = {
1446 { 0.00F, 0.00F, 0.00F }, 1458 { 0.00F, 0.00F, 0.00F },
1447 { 1.00F, 1.00F, 1.00F }, 1459 { 1.00F, 1.00F, 1.00F },
1497 glDisable (GL_BLEND); 1509 glDisable (GL_BLEND);
1498 glDisable (GL_TEXTURE_2D); 1510 glDisable (GL_TEXTURE_2D);
1499} 1511}
1500 1512
1501void 1513void
1502fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1514fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1503 PPCODE: 1515 PPCODE:
1504{ 1516{
1505 int vx, vy; 1517 int vx, vy;
1506 int x, y; 1518 int x, y;
1507 int sw4 = (sw + 3) & ~3; 1519 int sw4 = (sw + 3) & ~3;
1536 PUSHs (sv_2mortal (newSViv (sh))); 1548 PUSHs (sv_2mortal (newSViv (sh)));
1537 PUSHs (darkness_sv); 1549 PUSHs (darkness_sv);
1538} 1550}
1539 1551
1540SV * 1552SV *
1541get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1553get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1542 CODE: 1554 CODE:
1543{ 1555{
1544 int x, y, x1, y1; 1556 int x, y, x1, y1;
1545 SV *data_sv = newSV (w * h * 7 + 5); 1557 SV *data_sv = newSV (w * h * 7 + 5);
1546 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1558 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1608} 1620}
1609 OUTPUT: 1621 OUTPUT:
1610 RETVAL 1622 RETVAL
1611 1623
1612void 1624void
1613set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1625set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1614 PPCODE: 1626 PPCODE:
1615{ 1627{
1616 int x, y, z; 1628 int x, y, z;
1617 int w, h; 1629 int w, h;
1618 int x1, y1; 1630 int x1, y1;
1667 } 1679 }
1668 } 1680 }
1669 } 1681 }
1670} 1682}
1671 1683
1672MODULE = CFClient PACKAGE = CFClient::MixChunk 1684MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1673 1685
1674CFClient::MixChunk 1686CFPlus::MixChunk
1675new_from_file (SV *class, char *path) 1687new_from_file (SV *class, char *path)
1676 CODE: 1688 CODE:
1677 RETVAL = Mix_LoadWAV (path); 1689 RETVAL = Mix_LoadWAV (path);
1678 OUTPUT: 1690 OUTPUT:
1679 RETVAL 1691 RETVAL
1680 1692
1681void 1693void
1682DESTROY (CFClient::MixChunk self) 1694DESTROY (CFPlus::MixChunk self)
1683 CODE: 1695 CODE:
1684 Mix_FreeChunk (self); 1696 Mix_FreeChunk (self);
1685 1697
1686int 1698int
1687volume (CFClient::MixChunk self, int volume = -1) 1699volume (CFPlus::MixChunk self, int volume = -1)
1688 CODE: 1700 CODE:
1689 RETVAL = Mix_VolumeChunk (self, volume); 1701 RETVAL = Mix_VolumeChunk (self, volume);
1690 OUTPUT: 1702 OUTPUT:
1691 RETVAL 1703 RETVAL
1692 1704
1693int 1705int
1694play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1706play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1695 CODE: 1707 CODE:
1696 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1708 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1697 OUTPUT: 1709 OUTPUT:
1698 RETVAL 1710 RETVAL
1699 1711
1700MODULE = CFClient PACKAGE = CFClient::MixMusic 1712MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1701 1713
1702int 1714int
1703volume (int volume = -1) 1715volume (int volume = -1)
1704 CODE: 1716 CODE:
1705 RETVAL = Mix_VolumeMusic (volume); 1717 RETVAL = Mix_VolumeMusic (volume);
1706 OUTPUT: 1718 OUTPUT:
1707 RETVAL 1719 RETVAL
1708 1720
1709CFClient::MixMusic 1721CFPlus::MixMusic
1710new_from_file (SV *class, char *path) 1722new_from_file (SV *class, char *path)
1711 CODE: 1723 CODE:
1712 RETVAL = Mix_LoadMUS (path); 1724 RETVAL = Mix_LoadMUS (path);
1713 OUTPUT: 1725 OUTPUT:
1714 RETVAL 1726 RETVAL
1715 1727
1716void 1728void
1717DESTROY (CFClient::MixMusic self) 1729DESTROY (CFPlus::MixMusic self)
1718 CODE: 1730 CODE:
1719 Mix_FreeMusic (self); 1731 Mix_FreeMusic (self);
1720 1732
1721int 1733int
1722play (CFClient::MixMusic self, int loops = -1) 1734play (CFPlus::MixMusic self, int loops = -1)
1723 CODE: 1735 CODE:
1724 RETVAL = Mix_PlayMusic (self, loops); 1736 RETVAL = Mix_PlayMusic (self, loops);
1725 OUTPUT: 1737 OUTPUT:
1726 RETVAL 1738 RETVAL
1727 1739
1728MODULE = CFClient PACKAGE = CFClient::OpenGL 1740MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1729 1741
1730BOOT: 1742BOOT:
1731{ 1743{
1732 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1744 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1733 static const struct { 1745 static const struct {
1734 const char *name; 1746 const char *name;
1735 IV iv; 1747 IV iv;
1736 } *civ, const_iv[] = { 1748 } *civ, const_iv[] = {
1737# define const_iv(name) { # name, (IV)name } 1749# define const_iv(name) { # name, (IV)name }
1800 const_iv (GL_SEPARABLE_2D), 1812 const_iv (GL_SEPARABLE_2D),
1801 const_iv (GL_CONVOLUTION_2D), 1813 const_iv (GL_CONVOLUTION_2D),
1802 const_iv (GL_CONVOLUTION_BORDER_MODE), 1814 const_iv (GL_CONVOLUTION_BORDER_MODE),
1803 const_iv (GL_CONSTANT_BORDER), 1815 const_iv (GL_CONSTANT_BORDER),
1804 const_iv (GL_LINES), 1816 const_iv (GL_LINES),
1817 const_iv (GL_LINE_STRIP),
1805 const_iv (GL_LINE_LOOP), 1818 const_iv (GL_LINE_LOOP),
1806 const_iv (GL_QUADS), 1819 const_iv (GL_QUADS),
1807 const_iv (GL_QUAD_STRIP), 1820 const_iv (GL_QUAD_STRIP),
1808 const_iv (GL_TRIANGLES), 1821 const_iv (GL_TRIANGLES),
1809 const_iv (GL_TRIANGLE_STRIP), 1822 const_iv (GL_TRIANGLE_STRIP),
2006 2019
2007void glEndList () 2020void glEndList ()
2008 2021
2009void glCallList (int list) 2022void glCallList (int list)
2010 2023
2011

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines