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.129 by root, Wed Jul 12 17:20:04 2006 UTC vs.
Revision 1.139 by root, Mon Aug 14 03:04:17 2006 UTC

1#ifdef _WIN32 1#ifdef _WIN32
2# define WIN32_LEAN_AND_MEAN
2# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls 3# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls
3# include <malloc.h> 4# include <malloc.h>
4# include <windows.h> 5# include <windows.h>
5# pragma warning(disable:4244) 6# pragma warning(disable:4244)
6#endif 7#endif
7 8
8#include "EXTERN.h" 9#include "EXTERN.h"
9#include "perl.h" 10#include "perl.h"
10#include "XSUB.h" 11#include "XSUB.h"
12
13#ifdef _WIN32
14# undef pipe
15#endif
11 16
12#include <math.h> 17#include <math.h>
13#include <string.h> 18#include <string.h>
14#include <stdio.h> 19#include <stdio.h>
15#include <stdlib.h> 20#include <stdlib.h>
40 typedef signed char int8_t; 45 typedef signed char int8_t;
41 typedef signed short int16_t; 46 typedef signed short int16_t;
42 typedef signed int int32_t; 47 typedef signed int int32_t;
43#endif 48#endif
44 49
45#include "glext.h"
46
47#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ 50#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */
48 51
49#define FOW_DARKNESS 32 52#define FOW_DARKNESS 32
50 53
51#define MAP_EXTEND_X 32 54#define MAP_EXTEND_X 32
80 83
81#include "pango-font.c" 84#include "pango-font.c"
82#include "pango-fontmap.c" 85#include "pango-fontmap.c"
83#include "pango-render.c" 86#include "pango-render.c"
84 87
85typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
86typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
87 90
88typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
89 92
90static int 93static int
91shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
92{ 95{
93 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
107 110
108typedef struct cf_layout { 111typedef struct cf_layout {
109 PangoLayout *pl; 112 PangoLayout *pl;
110 float r, g, b, a; // default color for rgba mode 113 float r, g, b, a; // default color for rgba mode
111 int base_height; 114 int base_height;
112 CFClient__Font font; 115 CFPlus__Font font;
113} *CFClient__Layout; 116} *CFPlus__Layout;
114 117
115static CFClient__Font default_font; 118static CFPlus__Font default_font;
116static PangoContext *opengl_context; 119static PangoContext *opengl_context;
117static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
118 121
119static void 122static void
120substitute_func (FcPattern *pattern, gpointer data) 123substitute_func (FcPattern *pattern, gpointer data)
125#endif 128#endif
126 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 129 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
127} 130}
128 131
129static void 132static void
130layout_update_font (CFClient__Layout self) 133layout_update_font (CFPlus__Layout self)
131{ 134{
132 /* 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
133 * reasonably well with bitstream vera 136 * reasonably well with bitstream vera
134 */ 137 */
135 PangoFontDescription *font = self->font ? self->font : default_font; 138 PangoFontDescription *font = self->font ? self->font : default_font;
139 142
140 pango_layout_set_font_description (self->pl, font); 143 pango_layout_set_font_description (self->pl, font);
141} 144}
142 145
143static void 146static void
144layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
145{ 148{
149 PangoRectangle rect;
150
151 // get_pixel_* wrongly rounds down
146 pango_layout_get_pixel_size (self->pl, w, h); 152 pango_layout_get_extents (self->pl, 0, &rect);
147 153
148 if (!*w) *w = 1; 154 rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE;
149 if (!*h) *h = 1; 155 rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE;
150 156
151 *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;
152} 164}
153 165
154typedef uint16_t mapface; 166typedef uint16_t mapface;
155 167
156typedef struct { 168typedef struct {
179 int texs; 191 int texs;
180 maptex *tex; 192 maptex *tex;
181 193
182 int32_t rows; 194 int32_t rows;
183 maprow *row; 195 maprow *row;
184} *CFClient__Map; 196} *CFPlus__Map;
185 197
186static char * 198static char *
187prepend (char *ptr, int sze, int inc) 199prepend (char *ptr, int sze, int inc)
188{ 200{
189 char *p; 201 char *p;
207 219
208#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))
209#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))
210 222
211static maprow * 223static maprow *
212map_get_row (CFClient__Map self, int y) 224map_get_row (CFPlus__Map self, int y)
213{ 225{
214 if (0 > y) 226 if (0 > y)
215 { 227 {
216 int extend = - y + MAP_EXTEND_Y; 228 int extend = - y + MAP_EXTEND_Y;
217 Prepend (maprow, self->row, self->rows, extend); 229 Prepend (maprow, self->row, self->rows, extend);
255 267
256 return row->col + (x - row->c0); 268 return row->col + (x - row->c0);
257} 269}
258 270
259static mapcell * 271static mapcell *
260map_get_cell (CFClient__Map self, int x, int y) 272map_get_cell (CFPlus__Map self, int x, int y)
261{ 273{
262 return row_get_cell (map_get_row (self, y), x); 274 return row_get_cell (map_get_row (self, y), x);
263} 275}
264 276
265static void 277static void
266map_clear (CFClient__Map self) 278map_clear (CFPlus__Map self)
267{ 279{
268 int r; 280 int r;
269 281
270 for (r = 0; r < self->rows; r++) 282 for (r = 0; r < self->rows; r++)
271 Safefree (self->row[r].col); 283 Safefree (self->row[r].col);
279 self->row = 0; 291 self->row = 0;
280 self->rows = 0; 292 self->rows = 0;
281} 293}
282 294
283static void 295static void
284map_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)
285{ 297{
286 int x, y; 298 int x, y;
287 maprow *row; 299 maprow *row;
288 300
289 for (y = y0; y < y0 + h; y++) 301 for (y = y0; y < y0 + h; y++)
346 n |= n >> 16; 358 n |= n >> 16;
347 359
348 return n + 1; 360 return n + 1;
349} 361}
350 362
351MODULE = CFClient PACKAGE = CFClient 363MODULE = CFPlus PACKAGE = CFPlus
352 364
353PROTOTYPES: ENABLE 365PROTOTYPES: ENABLE
354 366
355BOOT: 367BOOT:
356{ 368{
357 HV *stash = gv_stashpv ("CFClient", 1); 369 HV *stash = gv_stashpv ("CFPlus", 1);
358 static const struct { 370 static const struct {
359 const char *name; 371 const char *name;
360 IV iv; 372 IV iv;
361 } *civ, const_iv[] = { 373 } *civ, const_iv[] = {
362# define const_iv(name) { # name, (IV)name } 374# define const_iv(name) { # name, (IV)name }
509 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 521 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
510 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 522 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
511 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 523 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
512 524
513 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 525 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
526#if SDL_VERSION_ATLEAST(1,2,10)
527 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
528 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
529#endif
514 530
515 SDL_EnableUNICODE (1); 531 SDL_EnableUNICODE (1);
516 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 532 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
517 533
518 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 534 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
605 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 621 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
606 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 622 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
607 break; 623 break;
608 } 624 }
609 625
610 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 626 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
611 } 627 }
612} 628}
613 629
614int 630int
615Mix_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)
744void 760void
745_exit (int retval) 761_exit (int retval)
746 CODE: 762 CODE:
747 _exit (retval); 763 _exit (retval);
748 764
749MODULE = CFClient PACKAGE = CFClient::Font 765MODULE = CFPlus PACKAGE = CFPlus::Font
750 766
751CFClient::Font 767CFPlus::Font
752new_from_file (SV *class, char *path, int id = 0) 768new_from_file (SV *class, char *path, int id = 0)
753 CODE: 769 CODE:
754{ 770{
755 int count; 771 int count;
756 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 772 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
759} 775}
760 OUTPUT: 776 OUTPUT:
761 RETVAL 777 RETVAL
762 778
763void 779void
764DESTROY (CFClient::Font self) 780DESTROY (CFPlus::Font self)
765 CODE: 781 CODE:
766 pango_font_description_free (self); 782 pango_font_description_free (self);
767 783
768void 784void
769make_default (CFClient::Font self) 785make_default (CFPlus::Font self)
770 CODE: 786 CODE:
771 default_font = self; 787 default_font = self;
772 788
773MODULE = CFClient PACKAGE = CFClient::Layout 789MODULE = CFPlus PACKAGE = CFPlus::Layout
774 790
775void 791void
776reset_glyph_cache () 792reset_glyph_cache ()
777 CODE: 793 CODE:
778 tc_clear (); 794 tc_clear ();
779 795
780CFClient::Layout 796CFPlus::Layout
781new (SV *class) 797new (SV *class)
782 CODE: 798 CODE:
783 New (0, RETVAL, 1, struct cf_layout); 799 New (0, RETVAL, 1, struct cf_layout);
784 800
785 RETVAL->pl = pango_layout_new (opengl_context); 801 RETVAL->pl = pango_layout_new (opengl_context);
794 layout_update_font (RETVAL); 810 layout_update_font (RETVAL);
795 OUTPUT: 811 OUTPUT:
796 RETVAL 812 RETVAL
797 813
798void 814void
799DESTROY (CFClient::Layout self) 815DESTROY (CFPlus::Layout self)
800 CODE: 816 CODE:
801 g_object_unref (self->pl); 817 g_object_unref (self->pl);
802 Safefree (self); 818 Safefree (self);
803 819
804void 820void
805set_text (CFClient::Layout self, SV *text_) 821set_text (CFPlus::Layout self, SV *text_)
806 CODE: 822 CODE:
807{ 823{
808 STRLEN textlen; 824 STRLEN textlen;
809 char *text = SvPVutf8 (text_, textlen); 825 char *text = SvPVutf8 (text_, textlen);
810 826
811 pango_layout_set_text (self->pl, text, textlen); 827 pango_layout_set_text (self->pl, text, textlen);
812} 828}
813 829
814void 830void
815set_markup (CFClient::Layout self, SV *text_) 831set_markup (CFPlus::Layout self, SV *text_)
816 CODE: 832 CODE:
817{ 833{
818 STRLEN textlen; 834 STRLEN textlen;
819 char *text = SvPVutf8 (text_, textlen); 835 char *text = SvPVutf8 (text_, textlen);
820 836
821 pango_layout_set_markup (self->pl, text, textlen); 837 pango_layout_set_markup (self->pl, text, textlen);
822} 838}
823 839
824void 840void
825set_shapes (CFClient::Layout self, ...) 841set_shapes (CFPlus::Layout self, ...)
826 CODE: 842 CODE:
827{ 843{
828 PangoAttrList *attrs = 0; 844 PangoAttrList *attrs = 0;
829 const char *text = pango_layout_get_text (self->pl); 845 const char *text = pango_layout_get_text (self->pl);
830 const char *pos = text; 846 const char *pos = text;
865 if (attrs) 881 if (attrs)
866 pango_layout_set_attributes (self->pl, attrs); 882 pango_layout_set_attributes (self->pl, attrs);
867} 883}
868 884
869void 885void
870get_shapes (CFClient::Layout self) 886get_shapes (CFPlus::Layout self)
871 PPCODE: 887 PPCODE:
872{ 888{
873 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 889 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
874 890
875 do 891 do
890 906
891 pango_layout_iter_free (iter); 907 pango_layout_iter_free (iter);
892} 908}
893 909
894int 910int
895has_wrapped (CFClient::Layout self) 911has_wrapped (CFPlus::Layout self)
896 CODE: 912 CODE:
897{ 913{
898 int lines = 1; 914 int lines = 1;
899 const char *text = pango_layout_get_text (self->pl); 915 const char *text = pango_layout_get_text (self->pl);
900 916
905} 921}
906 OUTPUT: 922 OUTPUT:
907 RETVAL 923 RETVAL
908 924
909SV * 925SV *
910get_text (CFClient::Layout self) 926get_text (CFPlus::Layout self)
911 CODE: 927 CODE:
912 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 928 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
913 sv_utf8_decode (RETVAL); 929 sv_utf8_decode (RETVAL);
914 OUTPUT: 930 OUTPUT:
915 RETVAL 931 RETVAL
916 932
917void 933void
918set_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.)
919 CODE: 935 CODE:
920 self->r = r; 936 self->r = r;
921 self->g = g; 937 self->g = g;
922 self->b = b; 938 self->b = b;
923 self->a = a; 939 self->a = a;
924 940
925void 941void
926set_font (CFClient::Layout self, CFClient::Font font = 0) 942set_font (CFPlus::Layout self, CFPlus::Font font = 0)
927 CODE: 943 CODE:
928 if (self->font != font) 944 if (self->font != font)
929 { 945 {
930 self->font = font; 946 self->font = font;
931 layout_update_font (self); 947 layout_update_font (self);
932 } 948 }
933 949
934void 950void
935set_height (CFClient::Layout self, int base_height) 951set_height (CFPlus::Layout self, int base_height)
936 CODE: 952 CODE:
937 if (self->base_height != base_height) 953 if (self->base_height != base_height)
938 { 954 {
939 self->base_height = base_height; 955 self->base_height = base_height;
940 layout_update_font (self); 956 layout_update_font (self);
941 } 957 }
942 958
943void 959void
944set_width (CFClient::Layout self, int max_width = -1) 960set_width (CFPlus::Layout self, int max_width = -1)
945 CODE: 961 CODE:
946 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);
947 963
948void 964void
949set_indent (CFClient::Layout self, int indent) 965set_indent (CFPlus::Layout self, int indent)
950 CODE: 966 CODE:
951 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 967 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
952 968
953void 969void
954set_spacing (CFClient::Layout self, int spacing) 970set_spacing (CFPlus::Layout self, int spacing)
955 CODE: 971 CODE:
956 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 972 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
957 973
958void 974void
959set_ellipsise (CFClient::Layout self, int ellipsise) 975set_ellipsise (CFPlus::Layout self, int ellipsise)
960 CODE: 976 CODE:
961 pango_layout_set_ellipsize (self->pl, 977 pango_layout_set_ellipsize (self->pl,
962 ellipsise == 1 ? PANGO_ELLIPSIZE_START 978 ellipsise == 1 ? PANGO_ELLIPSIZE_START
963 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 979 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
964 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 980 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
965 : PANGO_ELLIPSIZE_NONE 981 : PANGO_ELLIPSIZE_NONE
966 ); 982 );
967 983
968void 984void
969set_single_paragraph_mode (CFClient::Layout self, int spm) 985set_single_paragraph_mode (CFPlus::Layout self, int spm)
970 CODE: 986 CODE:
971 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 987 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
972 988
973void 989void
974size (CFClient::Layout self) 990size (CFPlus::Layout self)
975 PPCODE: 991 PPCODE:
976{ 992{
977 int w, h; 993 int w, h;
978 994
979 layout_get_pixel_size (self, &w, &h); 995 layout_get_pixel_size (self, &w, &h);
982 PUSHs (sv_2mortal (newSViv (w))); 998 PUSHs (sv_2mortal (newSViv (w)));
983 PUSHs (sv_2mortal (newSViv (h))); 999 PUSHs (sv_2mortal (newSViv (h)));
984} 1000}
985 1001
986int 1002int
987descent (CFClient::Layout self) 1003descent (CFPlus::Layout self)
988 CODE: 1004 CODE:
989{ 1005{
990 PangoRectangle rect; 1006 PangoRectangle rect;
991 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1007 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
992 pango_layout_line_get_pixel_extents (line, 0, &rect); 1008 pango_layout_line_get_pixel_extents (line, 0, &rect);
994} 1010}
995 OUTPUT: 1011 OUTPUT:
996 RETVAL 1012 RETVAL
997 1013
998int 1014int
999xy_to_index (CFClient::Layout self, int x, int y) 1015xy_to_index (CFPlus::Layout self, int x, int y)
1000 CODE: 1016 CODE:
1001{ 1017{
1002 int index, trailing; 1018 int index, trailing;
1003 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);
1004 RETVAL = index; 1020 RETVAL = index;
1005} 1021}
1006 OUTPUT: 1022 OUTPUT:
1007 RETVAL 1023 RETVAL
1008 1024
1009void 1025void
1010cursor_pos (CFClient::Layout self, int index) 1026cursor_pos (CFPlus::Layout self, int index)
1011 PPCODE: 1027 PPCODE:
1012{ 1028{
1013 PangoRectangle strong_pos; 1029 PangoRectangle strong_pos;
1014 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1030 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1015 1031
1018 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1034 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1019 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1035 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1020} 1036}
1021 1037
1022void 1038void
1023render (CFClient::Layout self, float x, float y) 1039render (CFPlus::Layout self, float x, float y, int flags = 0)
1024 PPCODE: 1040 PPCODE:
1025 pango_opengl_render_layout_subpixel ( 1041 pango_opengl_render_layout_subpixel (
1026 self->pl, 1042 self->pl,
1027 x * PANGO_SCALE, y * PANGO_SCALE, 1043 x * PANGO_SCALE, y * PANGO_SCALE,
1028 self->r, self->g, self->b, self->a 1044 self->r, self->g, self->b, self->a,
1045 flags
1029 ); 1046 );
1030 1047
1031MODULE = CFClient PACKAGE = CFClient::Texture 1048MODULE = CFPlus PACKAGE = CFPlus::Texture
1032 1049
1033void 1050void
1034pad2pot (SV *data_, SV *w_, SV *h_) 1051pad2pot (SV *data_, SV *w_, SV *h_)
1035 CODE: 1052 CODE:
1036{ 1053{
1114 glDisable (GL_ALPHA_TEST); 1131 glDisable (GL_ALPHA_TEST);
1115 glDisable (GL_BLEND); 1132 glDisable (GL_BLEND);
1116 } 1133 }
1117} 1134}
1118 1135
1119MODULE = CFClient PACKAGE = CFClient::Map 1136MODULE = CFPlus PACKAGE = CFPlus::Map
1120 1137
1121CFClient::Map 1138CFPlus::Map
1122new (SV *class, int map_width, int map_height) 1139new (SV *class, int map_width, int map_height)
1123 CODE: 1140 CODE:
1124 New (0, RETVAL, 1, struct map); 1141 New (0, RETVAL, 1, struct map);
1125 RETVAL->x = 0; 1142 RETVAL->x = 0;
1126 RETVAL->y = 0; 1143 RETVAL->y = 0;
1136 RETVAL->row = 0; 1153 RETVAL->row = 0;
1137 OUTPUT: 1154 OUTPUT:
1138 RETVAL 1155 RETVAL
1139 1156
1140void 1157void
1141DESTROY (CFClient::Map self) 1158DESTROY (CFPlus::Map self)
1142 CODE: 1159 CODE:
1143{ 1160{
1144 map_clear (self); 1161 map_clear (self);
1145 Safefree (self->face); 1162 Safefree (self->face);
1146 Safefree (self->tex); 1163 Safefree (self->tex);
1147 Safefree (self); 1164 Safefree (self);
1148} 1165}
1149 1166
1150void 1167void
1151clear (CFClient::Map self) 1168clear (CFPlus::Map self)
1152 CODE: 1169 CODE:
1153 map_clear (self); 1170 map_clear (self);
1154 1171
1155void 1172void
1156set_face (CFClient::Map self, int face, int texid) 1173set_face (CFPlus::Map self, int face, int texid)
1157 CODE: 1174 CODE:
1158{ 1175{
1159 while (self->faces <= face) 1176 while (self->faces <= face)
1160 { 1177 {
1161 Append (mapface, self->face, self->faces, self->faces); 1178 Append (mapface, self->face, self->faces, self->faces);
1164 1181
1165 self->face [face] = texid; 1182 self->face [face] = texid;
1166} 1183}
1167 1184
1168void 1185void
1169set_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)
1170 CODE: 1187 CODE:
1171{ 1188{
1172 while (self->texs <= texid) 1189 while (self->texs <= texid)
1173 { 1190 {
1174 Append (maptex, self->tex, self->texs, self->texs); 1191 Append (maptex, self->tex, self->texs, self->texs);
1198 // from transparent color bleeding and ugly wrapping effects. 1215 // from transparent color bleeding and ugly wrapping effects.
1199 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1216 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1200} 1217}
1201 1218
1202int 1219int
1203ox (CFClient::Map self) 1220ox (CFPlus::Map self)
1204 ALIAS: 1221 ALIAS:
1205 oy = 1 1222 oy = 1
1206 x = 2 1223 x = 2
1207 y = 3 1224 y = 3
1208 w = 4 1225 w = 4
1219 } 1236 }
1220 OUTPUT: 1237 OUTPUT:
1221 RETVAL 1238 RETVAL
1222 1239
1223void 1240void
1224scroll (CFClient::Map self, int dx, int dy) 1241scroll (CFPlus::Map self, int dx, int dy)
1225 CODE: 1242 CODE:
1226{ 1243{
1227 if (dx > 0) 1244 if (dx > 0)
1228 map_blank (self, self->x, self->y, dx - 1, self->h); 1245 map_blank (self, self->x, self->y, dx - 1, self->h);
1229 else if (dx < 0) 1246 else if (dx < 0)
1245 self->y += MAP_EXTEND_Y; 1262 self->y += MAP_EXTEND_Y;
1246 } 1263 }
1247} 1264}
1248 1265
1249void 1266void
1250map1a_update (CFClient::Map self, SV *data_) 1267map1a_update (CFPlus::Map self, SV *data_)
1251 CODE: 1268 CODE:
1252{ 1269{
1253 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1270 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1254 uint8_t *data_end = (uint8_t *)SvEND (data_); 1271 uint8_t *data_end = (uint8_t *)SvEND (data_);
1255 mapcell *cell; 1272 mapcell *cell;
1297 cell->darkness = -1; 1314 cell->darkness = -1;
1298 } 1315 }
1299} 1316}
1300 1317
1301SV * 1318SV *
1302mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1319mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1303 CODE: 1320 CODE:
1304{ 1321{
1305 int x1, x; 1322 int x1, x;
1306 int y1, y; 1323 int y1, y;
1307 int z; 1324 int z;
1357} 1374}
1358 OUTPUT: 1375 OUTPUT:
1359 RETVAL 1376 RETVAL
1360 1377
1361void 1378void
1362draw (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)
1363 CODE: 1380 CODE:
1364{ 1381{
1365 int vx, vy; 1382 int vx, vy;
1366 int x, y, z; 1383 int x, y, z;
1367 int last_name; 1384 int last_name;
1432 glDisable (GL_TEXTURE_2D); 1449 glDisable (GL_TEXTURE_2D);
1433 glDisable (GL_BLEND); 1450 glDisable (GL_BLEND);
1434} 1451}
1435 1452
1436void 1453void
1437draw_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)
1438 CODE: 1455 CODE:
1439{ 1456{
1440 static float color[16][3] = { 1457 static float color[16][3] = {
1441 { 0.00F, 0.00F, 0.00F }, 1458 { 0.00F, 0.00F, 0.00F },
1442 { 1.00F, 1.00F, 1.00F }, 1459 { 1.00F, 1.00F, 1.00F },
1492 glDisable (GL_BLEND); 1509 glDisable (GL_BLEND);
1493 glDisable (GL_TEXTURE_2D); 1510 glDisable (GL_TEXTURE_2D);
1494} 1511}
1495 1512
1496void 1513void
1497fow_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)
1498 PPCODE: 1515 PPCODE:
1499{ 1516{
1500 int vx, vy; 1517 int vx, vy;
1501 int x, y; 1518 int x, y;
1502 int sw4 = (sw + 3) & ~3; 1519 int sw4 = (sw + 3) & ~3;
1531 PUSHs (sv_2mortal (newSViv (sh))); 1548 PUSHs (sv_2mortal (newSViv (sh)));
1532 PUSHs (darkness_sv); 1549 PUSHs (darkness_sv);
1533} 1550}
1534 1551
1535SV * 1552SV *
1536get_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)
1537 CODE: 1554 CODE:
1538{ 1555{
1539 int x, y, x1, y1; 1556 int x, y, x1, y1;
1540 SV *data_sv = newSV (w * h * 7 + 5); 1557 SV *data_sv = newSV (w * h * 7 + 5);
1541 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1558 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1603} 1620}
1604 OUTPUT: 1621 OUTPUT:
1605 RETVAL 1622 RETVAL
1606 1623
1607void 1624void
1608set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1625set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1609 PPCODE: 1626 PPCODE:
1610{ 1627{
1611 int x, y, z; 1628 int x, y, z;
1612 int w, h; 1629 int w, h;
1613 int x1, y1; 1630 int x1, y1;
1662 } 1679 }
1663 } 1680 }
1664 } 1681 }
1665} 1682}
1666 1683
1667MODULE = CFClient PACKAGE = CFClient::MixChunk 1684MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1668 1685
1669CFClient::MixChunk 1686CFPlus::MixChunk
1670new_from_file (SV *class, char *path) 1687new_from_file (SV *class, char *path)
1671 CODE: 1688 CODE:
1672 RETVAL = Mix_LoadWAV (path); 1689 RETVAL = Mix_LoadWAV (path);
1673 OUTPUT: 1690 OUTPUT:
1674 RETVAL 1691 RETVAL
1675 1692
1676void 1693void
1677DESTROY (CFClient::MixChunk self) 1694DESTROY (CFPlus::MixChunk self)
1678 CODE: 1695 CODE:
1679 Mix_FreeChunk (self); 1696 Mix_FreeChunk (self);
1680 1697
1681int 1698int
1682volume (CFClient::MixChunk self, int volume = -1) 1699volume (CFPlus::MixChunk self, int volume = -1)
1683 CODE: 1700 CODE:
1684 RETVAL = Mix_VolumeChunk (self, volume); 1701 RETVAL = Mix_VolumeChunk (self, volume);
1685 OUTPUT: 1702 OUTPUT:
1686 RETVAL 1703 RETVAL
1687 1704
1688int 1705int
1689play (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)
1690 CODE: 1707 CODE:
1691 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1708 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1692 OUTPUT: 1709 OUTPUT:
1693 RETVAL 1710 RETVAL
1694 1711
1695MODULE = CFClient PACKAGE = CFClient::MixMusic 1712MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1696 1713
1697int 1714int
1698volume (int volume = -1) 1715volume (int volume = -1)
1699 CODE: 1716 CODE:
1700 RETVAL = Mix_VolumeMusic (volume); 1717 RETVAL = Mix_VolumeMusic (volume);
1701 OUTPUT: 1718 OUTPUT:
1702 RETVAL 1719 RETVAL
1703 1720
1704CFClient::MixMusic 1721CFPlus::MixMusic
1705new_from_file (SV *class, char *path) 1722new_from_file (SV *class, char *path)
1706 CODE: 1723 CODE:
1707 RETVAL = Mix_LoadMUS (path); 1724 RETVAL = Mix_LoadMUS (path);
1708 OUTPUT: 1725 OUTPUT:
1709 RETVAL 1726 RETVAL
1710 1727
1711void 1728void
1712DESTROY (CFClient::MixMusic self) 1729DESTROY (CFPlus::MixMusic self)
1713 CODE: 1730 CODE:
1714 Mix_FreeMusic (self); 1731 Mix_FreeMusic (self);
1715 1732
1716int 1733int
1717play (CFClient::MixMusic self, int loops = -1) 1734play (CFPlus::MixMusic self, int loops = -1)
1718 CODE: 1735 CODE:
1719 RETVAL = Mix_PlayMusic (self, loops); 1736 RETVAL = Mix_PlayMusic (self, loops);
1720 OUTPUT: 1737 OUTPUT:
1721 RETVAL 1738 RETVAL
1722 1739
1723MODULE = CFClient PACKAGE = CFClient::OpenGL 1740MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1724 1741
1725BOOT: 1742BOOT:
1726{ 1743{
1727 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1744 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1728 static const struct { 1745 static const struct {
1729 const char *name; 1746 const char *name;
1730 IV iv; 1747 IV iv;
1731 } *civ, const_iv[] = { 1748 } *civ, const_iv[] = {
1732# define const_iv(name) { # name, (IV)name } 1749# define const_iv(name) { # name, (IV)name }
1795 const_iv (GL_SEPARABLE_2D), 1812 const_iv (GL_SEPARABLE_2D),
1796 const_iv (GL_CONVOLUTION_2D), 1813 const_iv (GL_CONVOLUTION_2D),
1797 const_iv (GL_CONVOLUTION_BORDER_MODE), 1814 const_iv (GL_CONVOLUTION_BORDER_MODE),
1798 const_iv (GL_CONSTANT_BORDER), 1815 const_iv (GL_CONSTANT_BORDER),
1799 const_iv (GL_LINES), 1816 const_iv (GL_LINES),
1817 const_iv (GL_LINE_STRIP),
1800 const_iv (GL_LINE_LOOP), 1818 const_iv (GL_LINE_LOOP),
1801 const_iv (GL_QUADS), 1819 const_iv (GL_QUADS),
1802 const_iv (GL_QUAD_STRIP), 1820 const_iv (GL_QUAD_STRIP),
1803 const_iv (GL_TRIANGLES), 1821 const_iv (GL_TRIANGLES),
1804 const_iv (GL_TRIANGLE_STRIP), 1822 const_iv (GL_TRIANGLE_STRIP),
1914 r *= a; 1932 r *= a;
1915 g *= a; 1933 g *= a;
1916 b *= a; 1934 b *= a;
1917 } 1935 }
1918 // microsoft visual "c" rounds instead of truncating... 1936 // microsoft visual "c" rounds instead of truncating...
1919 glColor4ub (MIN ((int)(r * 256.f), 255), 1937 glColor4f (r, g, b, a);
1920 MIN ((int)(g * 256.f), 255),
1921 MIN ((int)(b * 256.f), 255),
1922 MIN ((int)(a * 256.f), 255));
1923 1938
1924void glInterleavedArrays (int format, int stride, char *data) 1939void glInterleavedArrays (int format, int stride, char *data)
1925 1940
1926void glDrawElements (int mode, int count, int type, char *indices) 1941void glDrawElements (int mode, int count, int type, char *indices)
1927 1942
2004 2019
2005void glEndList () 2020void glEndList ()
2006 2021
2007void glCallList (int list) 2022void glCallList (int list)
2008 2023
2009

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines