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.226 by root, Sat Aug 11 13:05:58 2007 UTC vs.
Revision 1.245 by root, Fri Dec 28 15:05:20 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);
203 203
204typedef uint16_t tileid; 204typedef uint16_t tileid;
205typedef uint16_t faceid; 205typedef uint16_t faceid;
206 206
207typedef struct { 207typedef struct {
208 int name; 208 GLuint name;
209 int w, h; 209 int w, h;
210 float s, t; 210 float s, t;
211 uint8_t r, g, b, a; 211 uint8_t r, g, b, a;
212 tileid smoothtile; 212 tileid smoothtile;
213 uint8_t smoothlevel; 213 uint8_t smoothlevel;
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+ Client " VERSION, "Crossfire+"); 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
1323#if !PANGO_VERSION_CHECK (1, 17. 3)
1281 /* pango bug: line is between 1..numlines, not 0..numlines-1 */ 1324 /* pango bug: line is between 1..numlines, not 0..numlines-1 */
1325 --line;
1326#endif
1282 1327
1283 EXTEND (SP, 2); 1328 EXTEND (SP, 2);
1284 PUSHs (sv_2mortal (newSViv (line - 1))); 1329 PUSHs (sv_2mortal (newSViv (line)));
1285 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); 1330 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE)));
1286} 1331}
1287 1332
1288void 1333void
1289line_x_to_index (CFPlus::Layout self, int line, int x) 1334line_x_to_index (DC::Layout self, int line, int x)
1290 PPCODE: 1335 PPCODE:
1291{ 1336{
1292 PangoLayoutLine *lp; 1337 PangoLayoutLine *lp;
1293 int index, trailing; 1338 int index, trailing;
1294 1339
1309 PUSHs (sv_2mortal (newSViv (trailing))); 1354 PUSHs (sv_2mortal (newSViv (trailing)));
1310 } 1355 }
1311} 1356}
1312 1357
1313void 1358void
1314render (CFPlus::Layout self, float x, float y, int flags = 0) 1359render (DC::Layout self, float x, float y, int flags = 0)
1315 CODE: 1360 CODE:
1316 rc_clear (self->rc); 1361 rc_clear (self->rc);
1317 pango_opengl_render_layout_subpixel ( 1362 pango_opengl_render_layout_subpixel (
1318 self->pl, 1363 self->pl,
1319 self->rc, 1364 self->rc,
1324 // we assume that context_change actually clears/frees stuff 1369 // we assume that context_change actually clears/frees stuff
1325 // and does not do any recomputation... 1370 // and does not do any recomputation...
1326 pango_layout_context_changed (self->pl); 1371 pango_layout_context_changed (self->pl);
1327 1372
1328void 1373void
1329draw (CFPlus::Layout self) 1374draw (DC::Layout self)
1330 CODE: 1375 CODE:
1331{ 1376{
1332 glEnable (GL_TEXTURE_2D); 1377 glEnable (GL_TEXTURE_2D);
1333 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 1378 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1334 glEnable (GL_BLEND); 1379 glEnable (GL_BLEND);
1342 glDisable (GL_ALPHA_TEST); 1387 glDisable (GL_ALPHA_TEST);
1343 glDisable (GL_BLEND); 1388 glDisable (GL_BLEND);
1344 glDisable (GL_TEXTURE_2D); 1389 glDisable (GL_TEXTURE_2D);
1345} 1390}
1346 1391
1347MODULE = CFPlus PACKAGE = CFPlus::Texture 1392MODULE = Deliantra::Client PACKAGE = DC::Texture
1348 1393
1349PROTOTYPES: ENABLE 1394PROTOTYPES: ENABLE
1350
1351int minpot (int n)
1352 1395
1353void 1396void
1354pad (SV *data_, int ow, int oh, int nw, int nh) 1397pad (SV *data_, int ow, int oh, int nw, int nh)
1355 CODE: 1398 CODE:
1356{ 1399{
1433 RETVAL = width > 0; 1476 RETVAL = width > 0;
1434} 1477}
1435 OUTPUT: 1478 OUTPUT:
1436 RETVAL 1479 RETVAL
1437 1480
1438MODULE = CFPlus PACKAGE = CFPlus::Map 1481MODULE = Deliantra::Client PACKAGE = DC::Map
1439 1482
1440PROTOTYPES: DISABLE 1483PROTOTYPES: DISABLE
1441 1484
1442CFPlus::Map 1485DC::Map
1443new (SV *class) 1486new (SV *class)
1444 CODE: 1487 CODE:
1445 New (0, RETVAL, 1, struct map); 1488 New (0, RETVAL, 1, struct map);
1446 RETVAL->x = 0; 1489 RETVAL->x = 0;
1447 RETVAL->y = 0; 1490 RETVAL->y = 0;
1455 RETVAL->row = 0; 1498 RETVAL->row = 0;
1456 OUTPUT: 1499 OUTPUT:
1457 RETVAL 1500 RETVAL
1458 1501
1459void 1502void
1460DESTROY (CFPlus::Map self) 1503DESTROY (DC::Map self)
1461 CODE: 1504 CODE:
1462{ 1505{
1463 map_clear (self); 1506 map_clear (self);
1464 Safefree (self->face2tile); 1507 Safefree (self->face2tile);
1465 Safefree (self->tex); 1508 Safefree (self->tex);
1466 Safefree (self); 1509 Safefree (self);
1467} 1510}
1468 1511
1469void 1512void
1470resize (CFPlus::Map self, int map_width, int map_height) 1513resize (DC::Map self, int map_width, int map_height)
1471 CODE: 1514 CODE:
1472 self->w = map_width; 1515 self->w = map_width;
1473 self->h = map_height; 1516 self->h = map_height;
1474 1517
1475void 1518void
1476clear (CFPlus::Map self) 1519clear (DC::Map self)
1477 CODE: 1520 CODE:
1478 map_clear (self); 1521 map_clear (self);
1479 1522
1480void 1523void
1481set_tileid (CFPlus::Map self, int face, int tile) 1524set_tileid (DC::Map self, int face, int tile)
1482 CODE: 1525 CODE:
1483{ 1526{
1484 need_facenum (self, face); self->face2tile [face] = tile; 1527 need_facenum (self, face); self->face2tile [face] = tile;
1485 need_texid (self, tile); 1528 need_texid (self, tile);
1486} 1529}
1487 1530
1488void 1531void
1489set_smooth (CFPlus::Map self, int face, int smooth, int level) 1532set_smooth (DC::Map self, int face, int smooth, int level)
1490 CODE: 1533 CODE:
1491{ 1534{
1492 tileid texid; 1535 tileid texid;
1493 maptex *tex; 1536 maptex *tex;
1494 1537
1507 tex->smoothtile = self->face2tile [smooth]; 1550 tex->smoothtile = self->face2tile [smooth];
1508 tex->smoothlevel = level; 1551 tex->smoothlevel = level;
1509} 1552}
1510 1553
1511void 1554void
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) 1555set_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: 1556 CODE:
1514{ 1557{
1515 need_texid (self, texid); 1558 need_texid (self, texid);
1516 1559
1517 { 1560 {
1537 // from transparent color bleeding and ugly wrapping effects. 1580 // from transparent color bleeding and ugly wrapping effects.
1538 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1581 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1539} 1582}
1540 1583
1541int 1584int
1542ox (CFPlus::Map self) 1585ox (DC::Map self)
1543 ALIAS: 1586 ALIAS:
1544 oy = 1 1587 oy = 1
1545 x = 2 1588 x = 2
1546 y = 3 1589 y = 3
1547 w = 4 1590 w = 4
1558 } 1601 }
1559 OUTPUT: 1602 OUTPUT:
1560 RETVAL 1603 RETVAL
1561 1604
1562void 1605void
1563scroll (CFPlus::Map self, int dx, int dy) 1606scroll (DC::Map self, int dx, int dy)
1564 CODE: 1607 CODE:
1565{ 1608{
1566 if (dx > 0) 1609 if (dx > 0)
1567 map_blank (self, self->x, self->y, dx, self->h); 1610 map_blank (self, self->x, self->y, dx, self->h);
1568 else if (dx < 0) 1611 else if (dx < 0)
1584 self->y += MAP_EXTEND_Y; 1627 self->y += MAP_EXTEND_Y;
1585 } 1628 }
1586} 1629}
1587 1630
1588SV * 1631SV *
1589map1a_update (CFPlus::Map self, SV *data_, int extmap) 1632map1a_update (DC::Map self, SV *data_, int extmap)
1590 CODE: 1633 CODE:
1591{ 1634{
1592 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1635 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1593 uint8_t *data_end = (uint8_t *)SvEND (data_); 1636 uint8_t *data_end = (uint8_t *)SvEND (data_);
1594 mapcell *cell; 1637 mapcell *cell;
1683} 1726}
1684 OUTPUT: 1727 OUTPUT:
1685 RETVAL 1728 RETVAL
1686 1729
1687SV * 1730SV *
1688mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1731mapmap (DC::Map self, int x0, int y0, int w, int h)
1689 CODE: 1732 CODE:
1690{ 1733{
1691 int x1, x; 1734 int x1, x;
1692 int y1, y; 1735 int y1, y;
1693 int z; 1736 int z;
1738} 1781}
1739 OUTPUT: 1782 OUTPUT:
1740 RETVAL 1783 RETVAL
1741 1784
1742void 1785void
1743draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) 1786draw (DC::Map self, int mx, int my, int sw, int sh, int T)
1744 CODE: 1787 CODE:
1745{ 1788{
1746 int x, y, z; 1789 int x, y, z;
1747 1790
1748 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1791 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
2019 } 2062 }
2020 } 2063 }
2021} 2064}
2022 2065
2023void 2066void
2024draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 2067draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data)
2025 CODE: 2068 CODE:
2026{ 2069{
2027 static float color[16][3] = { 2070 static float color[16][3] = {
2028 { 0.00F, 0.00F, 0.00F }, 2071 { 0.00F, 0.00F, 0.00F },
2029 { 1.00F, 1.00F, 1.00F }, 2072 { 1.00F, 1.00F, 1.00F },
2079 glDisable (GL_BLEND); 2122 glDisable (GL_BLEND);
2080 glDisable (GL_TEXTURE_2D); 2123 glDisable (GL_TEXTURE_2D);
2081} 2124}
2082 2125
2083void 2126void
2084fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) 2127fow_texture (DC::Map self, int mx, int my, int sw, int sh)
2085 PPCODE: 2128 PPCODE:
2086{ 2129{
2087 int x, y; 2130 int x, y;
2088 int sw1 = sw + 2; 2131 int sw1 = sw + 2;
2089 int sh1 = sh + 2; 2132 int sh1 = sh + 2;
2160 PUSHs (sv_2mortal (newSViv (sh3))); 2203 PUSHs (sv_2mortal (newSViv (sh3)));
2161 PUSHs (darkness3_sv); 2204 PUSHs (darkness3_sv);
2162} 2205}
2163 2206
2164SV * 2207SV *
2165get_rect (CFPlus::Map self, int x0, int y0, int w, int h) 2208get_rect (DC::Map self, int x0, int y0, int w, int h)
2166 CODE: 2209 CODE:
2167{ 2210{
2168 int x, y, x1, y1; 2211 int x, y, x1, y1;
2169 SV *data_sv = newSV (w * h * 7 + 5); 2212 SV *data_sv = newSV (w * h * 7 + 5);
2170 uint8_t *data = (uint8_t *)SvPVX (data_sv); 2213 uint8_t *data = (uint8_t *)SvPVX (data_sv);
2235} 2278}
2236 OUTPUT: 2279 OUTPUT:
2237 RETVAL 2280 RETVAL
2238 2281
2239void 2282void
2240set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) 2283set_rect (DC::Map self, int x0, int y0, uint8_t *data)
2241 PPCODE: 2284 PPCODE:
2242{ 2285{
2243 int x, y, z; 2286 int x, y, z;
2244 int w, h; 2287 int w, h;
2245 int x1, y1; 2288 int x1, y1;
2246 2289
2247 if (*data++ != 0) 2290 if (*data++ != 0)
2248 return; /* version mismatch */ 2291 XSRETURN_EMPTY; /* version mismatch */
2249 2292
2250 w = *data++ << 8; w |= *data++; 2293 w = *data++ << 8; w |= *data++;
2251 h = *data++ << 8; h |= *data++; 2294 h = *data++ << 8; h |= *data++;
2252 2295
2253 // we need to do this 'cause we don't keep an absolute coord system for rows 2296 // we need to do this 'cause we don't keep an absolute coord system for rows
2298 } 2341 }
2299 } 2342 }
2300 } 2343 }
2301} 2344}
2302 2345
2303MODULE = CFPlus PACKAGE = CFPlus::RW 2346MODULE = Deliantra::Client PACKAGE = DC::RW
2304 2347
2305CFPlus::RW 2348DC::RW
2306new (SV *class, SV *data_sv) 2349new (SV *class, SV *data_sv)
2307 CODE: 2350 CODE:
2308{ 2351{
2309 STRLEN datalen; 2352 STRLEN datalen;
2310 char *data = SvPVbyte (data_sv, datalen); 2353 char *data = SvPVbyte (data_sv, datalen);
2312 RETVAL = SDL_RWFromConstMem (data, datalen); 2355 RETVAL = SDL_RWFromConstMem (data, datalen);
2313} 2356}
2314 OUTPUT: 2357 OUTPUT:
2315 RETVAL 2358 RETVAL
2316 2359
2317CFPlus::RW 2360DC::RW
2318new_from_file (SV *class, const char *path, const char *mode = "rb") 2361new_from_file (SV *class, const char *path, const char *mode = "rb")
2319 CODE: 2362 CODE:
2320 RETVAL = SDL_RWFromFile (path, mode); 2363 RETVAL = SDL_RWFromFile (path, mode);
2321 OUTPUT: 2364 OUTPUT:
2322 RETVAL 2365 RETVAL
2323 2366
2324# fails on win32: 2367# fails on win32:
2325# CFPlus.xs(2268) : error C2059: syntax error : '(' 2368# dc.xs(2268) : error C2059: syntax error : '('
2326#void 2369#void
2327#close (CFPlus::RW self) 2370#close (DC::RW self)
2328# CODE: 2371# CODE:
2329# (self->(close)) (self); 2372# (self->(close)) (self);
2330 2373
2331MODULE = CFPlus PACKAGE = CFPlus::Channel 2374MODULE = Deliantra::Client PACKAGE = DC::Channel
2332 2375
2333PROTOTYPES: DISABLE 2376PROTOTYPES: DISABLE
2334 2377
2335CFPlus::Channel 2378DC::Channel
2336find () 2379find ()
2337 CODE: 2380 CODE:
2338{ 2381{
2339 RETVAL = Mix_GroupAvailable (-1); 2382 RETVAL = Mix_GroupAvailable (-1);
2340 2383
2353} 2396}
2354 OUTPUT: 2397 OUTPUT:
2355 RETVAL 2398 RETVAL
2356 2399
2357void 2400void
2358halt (CFPlus::Channel self) 2401halt (DC::Channel self)
2359 CODE: 2402 CODE:
2360 Mix_HaltChannel (self); 2403 Mix_HaltChannel (self);
2361 2404
2362void 2405void
2363expire (CFPlus::Channel self, int ticks = -1) 2406expire (DC::Channel self, int ticks = -1)
2364 CODE: 2407 CODE:
2365 Mix_ExpireChannel (self, ticks); 2408 Mix_ExpireChannel (self, ticks);
2366 2409
2367void 2410void
2368fade_out (CFPlus::Channel self, int ticks = -1) 2411fade_out (DC::Channel self, int ticks = -1)
2369 CODE: 2412 CODE:
2370 Mix_FadeOutChannel (self, ticks); 2413 Mix_FadeOutChannel (self, ticks);
2371 2414
2372int 2415int
2373volume (CFPlus::Channel self, int volume) 2416volume (DC::Channel self, int volume)
2374 CODE: 2417 CODE:
2375 RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); 2418 RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128));
2376 OUTPUT: 2419 OUTPUT:
2377 RETVAL 2420 RETVAL
2378 2421
2379void 2422void
2380unregister_all_effects (CFPlus::Channel self) 2423unregister_all_effects (DC::Channel self)
2381 CODE: 2424 CODE:
2382 Mix_UnregisterAllEffects (self); 2425 Mix_UnregisterAllEffects (self);
2383 2426
2384void 2427void
2385set_panning (CFPlus::Channel self, int left, int right) 2428set_panning (DC::Channel self, int left, int right)
2386 CODE: 2429 CODE:
2387 left = CLAMP (left , 0, 255); 2430 left = CLAMP (left , 0, 255);
2388 right = CLAMP (right, 0, 255); 2431 right = CLAMP (right, 0, 255);
2389 Mix_SetPanning (self, left, right); 2432 Mix_SetPanning (self, left, right);
2390 2433
2391void 2434void
2392set_distance (CFPlus::Channel self, int distance) 2435set_distance (DC::Channel self, int distance)
2393 CODE: 2436 CODE:
2394 Mix_SetDistance (self, CLAMP (distance, 0, 255)); 2437 Mix_SetDistance (self, CLAMP (distance, 0, 255));
2395 2438
2396void 2439void
2397set_position (CFPlus::Channel self, int angle, int distance) 2440set_position (DC::Channel self, int angle, int distance)
2398 CODE: 2441 CODE:
2399 2442
2400void 2443void
2401set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) 2444set_position_r (DC::Channel self, int dx, int dy, int maxdistance)
2402 CODE: 2445 CODE:
2403{ 2446{
2404 int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); 2447 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); 2448 int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI);
2406 Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); 2449 Mix_SetPosition (self, angle, CLAMP (distance, 0, 255));
2407} 2450}
2408 2451
2409void 2452void
2410set_reverse_stereo (CFPlus::Channel self, int flip) 2453set_reverse_stereo (DC::Channel self, int flip)
2411 CODE: 2454 CODE:
2412 Mix_SetReverseStereo (self, flip); 2455 Mix_SetReverseStereo (self, flip);
2413 2456
2414MODULE = CFPlus PACKAGE = CFPlus::MixChunk 2457MODULE = Deliantra::Client PACKAGE = DC::MixChunk
2415 2458
2416PROTOTYPES: DISABLE 2459PROTOTYPES: DISABLE
2417 2460
2418CFPlus::MixChunk 2461DC::MixChunk
2419new (SV *class, CFPlus::RW rwops) 2462new (SV *class, DC::RW rwops)
2420 CODE: 2463 CODE:
2421 RETVAL = Mix_LoadWAV_RW (rwops, 1); 2464 RETVAL = Mix_LoadWAV_RW (rwops, 1);
2422 OUTPUT: 2465 OUTPUT:
2423 RETVAL 2466 RETVAL
2424 2467
2425void 2468void
2426DESTROY (CFPlus::MixChunk self) 2469DESTROY (DC::MixChunk self)
2427 CODE: 2470 CODE:
2428 Mix_FreeChunk (self); 2471 Mix_FreeChunk (self);
2429 2472
2430int 2473int
2431volume (CFPlus::MixChunk self, int volume = -1) 2474volume (DC::MixChunk self, int volume = -1)
2432 CODE: 2475 CODE:
2433 if (items > 1) 2476 if (items > 1)
2434 volume = CLAMP (volume, 0, 128); 2477 volume = CLAMP (volume, 0, 128);
2435 RETVAL = Mix_VolumeChunk (self, volume); 2478 RETVAL = Mix_VolumeChunk (self, volume);
2436 OUTPUT: 2479 OUTPUT:
2437 RETVAL 2480 RETVAL
2438 2481
2439CFPlus::Channel 2482DC::Channel
2440play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) 2483play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1)
2441 CODE: 2484 CODE:
2442{ 2485{
2443 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 2486 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
2444 2487
2445 if (RETVAL < 0) 2488 if (RETVAL < 0)
2452 } 2495 }
2453} 2496}
2454 OUTPUT: 2497 OUTPUT:
2455 RETVAL 2498 RETVAL
2456 2499
2457MODULE = CFPlus PACKAGE = CFPlus::MixMusic 2500MODULE = Deliantra::Client PACKAGE = DC::MixMusic
2458 2501
2459int 2502int
2460volume (int volume = -1) 2503volume (int volume = -1)
2461 PROTOTYPE: ;$ 2504 PROTOTYPE: ;$
2462 CODE: 2505 CODE:
2474void 2517void
2475halt () 2518halt ()
2476 CODE: 2519 CODE:
2477 Mix_HaltMusic (); 2520 Mix_HaltMusic ();
2478 2521
2479CFPlus::MixMusic 2522DC::MixMusic
2480new (SV *class, CFPlus::RW rwops) 2523new (SV *class, DC::RW rwops)
2481 CODE: 2524 CODE:
2482 RETVAL = Mix_LoadMUS_RW (rwops); 2525 RETVAL = Mix_LoadMUS_RW (rwops);
2483 OUTPUT: 2526 OUTPUT:
2484 RETVAL 2527 RETVAL
2485 2528
2486void 2529void
2487DESTROY (CFPlus::MixMusic self) 2530DESTROY (DC::MixMusic self)
2488 CODE: 2531 CODE:
2489 Mix_FreeMusic (self); 2532 Mix_FreeMusic (self);
2490 2533
2491int 2534int
2492play (CFPlus::MixMusic self, int loops = -1) 2535play (DC::MixMusic self, int loops = -1)
2493 CODE: 2536 CODE:
2494 RETVAL = Mix_PlayMusic (self, loops); 2537 RETVAL = Mix_PlayMusic (self, loops);
2495 OUTPUT: 2538 OUTPUT:
2496 RETVAL 2539 RETVAL
2497 2540
2498void 2541void
2499fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) 2542fade_in_pos (DC::MixMusic self, int loops, int ms, double position)
2500 CODE: 2543 CODE:
2501 Mix_FadeInMusicPos (self, loops, ms, position); 2544 Mix_FadeInMusicPos (self, loops, ms, position);
2502 2545
2503MODULE = CFPlus PACKAGE = CFPlus::OpenGL 2546MODULE = Deliantra::Client PACKAGE = DC::OpenGL
2504 2547
2505PROTOTYPES: ENABLE 2548PROTOTYPES: ENABLE
2506 2549
2507BOOT: 2550BOOT:
2508{ 2551{
2509 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); 2552 HV *stash = gv_stashpv ("DC::OpenGL", 1);
2510 static const struct { 2553 static const struct {
2511 const char *name; 2554 const char *name;
2512 IV iv; 2555 IV iv;
2513 } *civ, const_iv[] = { 2556 } *civ, const_iv[] = {
2514# define const_iv(name) { # name, (IV)name } 2557# define const_iv(name) { # name, (IV)name }
2549 const_iv (GL_INTENSITY), 2592 const_iv (GL_INTENSITY),
2550 const_iv (GL_LUMINANCE), 2593 const_iv (GL_LUMINANCE),
2551 const_iv (GL_LUMINANCE_ALPHA), 2594 const_iv (GL_LUMINANCE_ALPHA),
2552 const_iv (GL_FLOAT), 2595 const_iv (GL_FLOAT),
2553 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), 2596 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV),
2597 const_iv (GL_COMPRESSED_ALPHA_ARB),
2598 const_iv (GL_COMPRESSED_LUMINANCE_ARB),
2599 const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB),
2600 const_iv (GL_COMPRESSED_INTENSITY_ARB),
2601 const_iv (GL_COMPRESSED_RGB_ARB),
2602 const_iv (GL_COMPRESSED_RGBA_ARB),
2554 const_iv (GL_COMPILE), 2603 const_iv (GL_COMPILE),
2555 const_iv (GL_PROXY_TEXTURE_1D), 2604 const_iv (GL_PROXY_TEXTURE_1D),
2556 const_iv (GL_PROXY_TEXTURE_2D), 2605 const_iv (GL_PROXY_TEXTURE_2D),
2557 const_iv (GL_TEXTURE_1D), 2606 const_iv (GL_TEXTURE_1D),
2558 const_iv (GL_TEXTURE_2D), 2607 const_iv (GL_TEXTURE_2D),
2597 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 2646 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
2598 const_iv (GL_POINT_SMOOTH_HINT), 2647 const_iv (GL_POINT_SMOOTH_HINT),
2599 const_iv (GL_LINE_SMOOTH_HINT), 2648 const_iv (GL_LINE_SMOOTH_HINT),
2600 const_iv (GL_POLYGON_SMOOTH_HINT), 2649 const_iv (GL_POLYGON_SMOOTH_HINT),
2601 const_iv (GL_GENERATE_MIPMAP_HINT), 2650 const_iv (GL_GENERATE_MIPMAP_HINT),
2651 const_iv (GL_TEXTURE_COMPRESSION_HINT),
2602 const_iv (GL_FASTEST), 2652 const_iv (GL_FASTEST),
2603 const_iv (GL_DONT_CARE), 2653 const_iv (GL_DONT_CARE),
2604 const_iv (GL_NICEST), 2654 const_iv (GL_NICEST),
2605 const_iv (GL_V2F), 2655 const_iv (GL_V2F),
2606 const_iv (GL_V3F), 2656 const_iv (GL_V3F),
2614 2664
2615 texture_av = newAV (); 2665 texture_av = newAV ();
2616 AvREAL_off (texture_av); 2666 AvREAL_off (texture_av);
2617} 2667}
2618 2668
2669void
2670disable_GL_EXT_blend_func_separate ()
2671 CODE:
2672 gl.BlendFuncSeparate = 0;
2673 gl.BlendFuncSeparateEXT = 0;
2674
2619char * 2675char *
2620gl_vendor () 2676gl_vendor ()
2621 CODE: 2677 CODE:
2622 RETVAL = (char *)glGetString (GL_VENDOR); 2678 RETVAL = (char *)glGetString (GL_VENDOR);
2623 OUTPUT: 2679 OUTPUT:
2744 2800
2745void glRect (float x1, float y1, float x2, float y2) 2801void glRect (float x1, float y1, float x2, float y2)
2746 CODE: 2802 CODE:
2747 glRectf (x1, y1, x2, y2); 2803 glRectf (x1, y1, x2, y2);
2748 2804
2805void glRect_lineloop (float x1, float y1, float x2, float y2)
2806 CODE:
2807 glBegin (GL_LINE_LOOP);
2808 glVertex2f (x1, y1);
2809 glVertex2f (x2, y1);
2810 glVertex2f (x2, y2);
2811 glVertex2f (x1, y2);
2812 glEnd ();
2813
2749PROTOTYPES: ENABLE 2814PROTOTYPES: ENABLE
2750 2815
2751void glBegin (int mode) 2816void glBegin (int mode)
2752 2817
2753void glEnd () 2818void glEnd ()
2785void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) 2850void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column)
2786 CODE: 2851 CODE:
2787 if (gl.SeparableFilter2D) 2852 if (gl.SeparableFilter2D)
2788 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); 2853 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column);
2789 2854
2790void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) 2855void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0)
2791 2856
2792void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) 2857void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border)
2793 2858
2794void glDrawPixels (int width, int height, int format, int type, char *pixels) 2859void glDrawPixels (int width, int height, int format, int type, char *pixels)
2795 2860
2821 2886
2822void glEndList () 2887void glEndList ()
2823 2888
2824void glCallList (int list) 2889void glCallList (int list)
2825 2890
2826MODULE = CFPlus PACKAGE = CFPlus::UI::Base 2891MODULE = Deliantra::Client PACKAGE = DC::UI::Base
2827 2892
2828PROTOTYPES: DISABLE 2893PROTOTYPES: DISABLE
2829 2894
2830void 2895void
2831find_widget (SV *self, NV x, NV y) 2896find_widget (SV *self, NV x, NV y)
2835 XPUSHs (self); 2900 XPUSHs (self);
2836} 2901}
2837 2902
2838BOOT: 2903BOOT:
2839{ 2904{
2840 hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); 2905 hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV);
2841 2906
2842 draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); 2907 draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV);
2843 draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); 2908 draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV);
2844 draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); 2909 draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV);
2845 draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); 2910 draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV);
2846} 2911}
2847 2912
2848void 2913void
2849draw (SV *self) 2914draw (SV *self)
2850 CODE: 2915 CODE:
2854 NV x, y, w, h; 2919 NV x, y, w, h;
2855 SV *draw_x_sv = GvSV (draw_x_gv); 2920 SV *draw_x_sv = GvSV (draw_x_gv);
2856 SV *draw_y_sv = GvSV (draw_y_gv); 2921 SV *draw_y_sv = GvSV (draw_y_gv);
2857 SV *draw_w_sv = GvSV (draw_w_gv); 2922 SV *draw_w_sv = GvSV (draw_w_gv);
2858 SV *draw_h_sv = GvSV (draw_h_gv); 2923 SV *draw_h_sv = GvSV (draw_h_gv);
2859 SV *hover;
2860 double draw_x, draw_y, draw_w, draw_h; 2924 double draw_x, draw_y;
2861 2925
2862 if (!SvROK (self)) 2926 if (!SvROK (self))
2863 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); 2927 croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self));
2864 2928
2865 hv = (HV *)SvRV (self); 2929 hv = (HV *)SvRV (self);
2866 2930
2867 if (SvTYPE (hv) != SVt_PVHV) 2931 if (SvTYPE (hv) != SVt_PVHV)
2868 croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); 2932 croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self));
2869 2933
2870 svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; 2934 svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.;
2871 svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; 2935 svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.;
2872 2936
2873 if (!h || !w) 2937 if (!h || !w)
2893 { 2957 {
2894 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); 2958 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0);
2895 2959
2896 if (svp && SvTRUE (*svp)) 2960 if (svp && SvTRUE (*svp))
2897 { 2961 {
2898 glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); 2962 glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f);
2899 glEnable (GL_BLEND); 2963 glEnable (GL_BLEND);
2900 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 2964 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
2901 glBegin (GL_QUADS); 2965 glBegin (GL_QUADS);
2902 glVertex2f (0, 0); 2966 glVertex2f (0, 0);
2903 glVertex2f (w, 0); 2967 glVertex2f (w, 0);
2906 glEnd (); 2970 glEnd ();
2907 glDisable (GL_BLEND); 2971 glDisable (GL_BLEND);
2908 } 2972 }
2909 } 2973 }
2910#if 0 2974#if 0
2911 if ($ENV{CFPLUS_DEBUG} & 1) { 2975 // draw borders, for debugging
2912 glPushMatrix; 2976 glPushMatrix ();
2913 glColor 1, 1, 0, 1; 2977 glColor4f (1., 1., 0., 1.);
2914 glTranslate 0.375, 0.375; 2978 glTranslatef (.5, .5, 0.);
2915 glBegin GL_LINE_LOOP; 2979 glBegin (GL_LINE_LOOP);
2916 glVertex 0 , 0; 2980 glVertex2f (0 , 0);
2917 glVertex $self->{w} - 1, 0; 2981 glVertex2f (w - 1, 0);
2918 glVertex $self->{w} - 1, $self->{h} - 1; 2982 glVertex2f (w - 1, h - 1);
2919 glVertex 0 , $self->{h} - 1; 2983 glVertex2f (0 , h - 1);
2920 glEnd; 2984 glEnd ();
2921 glPopMatrix; 2985 glPopMatrix ();
2922 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
2923 }
2924#endif 2986#endif
2925 PUSHMARK (SP); 2987 PUSHMARK (SP);
2926 XPUSHs (self); 2988 XPUSHs (self);
2927 PUTBACK; 2989 PUTBACK;
2928 call_method ("_draw", G_VOID | G_DISCARD); 2990 call_method ("_draw", G_VOID | G_DISCARD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines