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.231 by root, Sun Aug 19 14:09:28 2007 UTC vs.
Revision 1.246 by root, Fri Dec 28 15:06:02 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines