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.219 by root, Mon Aug 6 05:06:32 2007 UTC vs.
Revision 1.268 by root, Sun Jul 20 02:57:43 2008 UTC

17#include "perl.h" 17#include "perl.h"
18#include "XSUB.h" 18#include "XSUB.h"
19 19
20#ifdef _WIN32 20#ifdef _WIN32
21# undef pipe 21# undef pipe
22// microsoft vs. C
23# define sqrtf(x) sqrt(x)
24# define roundf(x) (int)(x)
25# define atan2f(x,y) atan2(x,y)
26# define M_PI 3.14159265f
22#endif 27#endif
23 28
24#include <assert.h> 29#include <assert.h>
25#include <math.h> 30#include <math.h>
26#include <string.h> 31#include <string.h>
40#define G_DISABLE_CAST_CHECKS 45#define G_DISABLE_CAST_CHECKS
41 46
42#include <glib/gmacros.h> 47#include <glib/gmacros.h>
43 48
44#include <pango/pango.h> 49#include <pango/pango.h>
50
51#ifndef PANGO_VERSION_CHECK
52# define PANGO_VERSION_CHECK(a,b,c) 0
53#endif
54
55#if !PANGO_VERSION_CHECK (1, 15, 2)
56# define pango_layout_get_line_readonly pango_layout_get_line
57# define pango_layout_get_lines_readonly pango_layout_get_lines
58# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line
59# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run
60#endif
45 61
46#ifndef _WIN32 62#ifndef _WIN32
47# include <sys/types.h> 63# include <sys/types.h>
48# include <sys/socket.h> 64# include <sys/socket.h>
49# include <netinet/in.h> 65# include <netinet/in.h>
50# include <netinet/tcp.h> 66# include <netinet/tcp.h>
51# include <inttypes.h> 67# include <inttypes.h>
52#endif 68#endif
53 69
70#if __GNUC__ >= 4
71# define expect(expr,value) __builtin_expect ((expr),(value))
72#else
73# define expect(expr,value) (expr)
74#endif
75
76#define expect_false(expr) expect ((expr) != 0, 0)
77#define expect_true(expr) expect ((expr) != 0, 1)
78
54#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 79#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
55 80
56#define FOW_DARKNESS 32 81#define FOW_DARKNESS 32
57 82
58#define MAP_EXTEND_X 32 83#define MAP_EXTEND_X 32
59#define MAP_EXTEND_Y 512 84#define MAP_EXTEND_Y 512
60 85
61#define MIN_FONT_HEIGHT 10 86#define MIN_FONT_HEIGHT 10
62 87
63#if 0 88/* mask out modifiers we are not interested in */
64# define PARACHUTE SDL_INIT_NOPARACHUTE 89#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META)
65#else
66# define PARACHUTE 0
67#endif
68 90
69static AV *texture_av; 91static AV *texture_av;
70 92
71static struct 93static struct
72{ 94{
109 av_push (texture_av, (SV *)(size_t)name); 131 av_push (texture_av, (SV *)(size_t)name);
110 glDeleteTextures (1, &name); 132 glDeleteTextures (1, &name);
111} 133}
112 134
113#include "texcache.c" 135#include "texcache.c"
136#include "rendercache.c"
114 137
115#include "pango-font.c" 138#include "pango-font.c"
116#include "pango-fontmap.c" 139#include "pango-fontmap.c"
117#include "pango-render.c" 140#include "pango-render.c"
118 141
119typedef IV CFPlus__Channel; 142typedef IV DC__Channel;
120typedef SDL_RWops *CFPlus__RW; 143typedef SDL_RWops *DC__RW;
121typedef Mix_Chunk *CFPlus__MixChunk; 144typedef Mix_Chunk *DC__MixChunk;
122typedef Mix_Music *CFPlus__MixMusic; 145typedef Mix_Music *DC__MixMusic;
123 146
124typedef PangoFontDescription *CFPlus__Font; 147typedef PangoFontDescription *DC__Font;
125 148
126static int 149static int
127shape_attr_p (PangoLayoutRun *run) 150shape_attr_p (PangoLayoutRun *run)
128{ 151{
129 GSList *attrs = run->item->analysis.extra_attrs; 152 GSList *attrs = run->item->analysis.extra_attrs;
143 166
144typedef struct cf_layout { 167typedef struct cf_layout {
145 PangoLayout *pl; 168 PangoLayout *pl;
146 float r, g, b, a; // default color for rgba mode 169 float r, g, b, a; // default color for rgba mode
147 int base_height; 170 int base_height;
148 CFPlus__Font font; 171 DC__Font font;
172 rc_t *rc;
149} *CFPlus__Layout; 173} *DC__Layout;
150 174
151static CFPlus__Font default_font; 175static DC__Font default_font;
152static PangoContext *opengl_context; 176static PangoContext *opengl_context;
153static PangoFontMap *opengl_fontmap; 177static PangoFontMap *opengl_fontmap;
154 178
155static void 179static void
156substitute_func (FcPattern *pattern, gpointer data) 180substitute_func (FcPattern *pattern, gpointer data)
161#endif 185#endif
162 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 186 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
163} 187}
164 188
165static void 189static void
166layout_update_font (CFPlus__Layout self) 190layout_update_font (DC__Layout self)
167{ 191{
168 /* use a random scale factor to account for unknown descenders, 0.8 works 192 /* use a random scale factor to account for unknown descenders, 0.8 works
169 * reasonably well with bitstream vera 193 * reasonably well with dejavu/bistream fonts
170 */ 194 */
171 PangoFontDescription *font = self->font ? self->font : default_font; 195 PangoFontDescription *font = self->font ? self->font : default_font;
172 196
173 pango_font_description_set_absolute_size (font, 197 pango_font_description_set_absolute_size (font,
174 MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); 198 MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10));
175 199
176 pango_layout_set_font_description (self->pl, font); 200 pango_layout_set_font_description (self->pl, font);
177} 201}
178 202
179static void 203static void
180layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) 204layout_get_pixel_size (DC__Layout self, int *w, int *h)
181{ 205{
182 PangoRectangle rect; 206 PangoRectangle rect;
183 207
184 // get_pixel_* wrongly rounds down 208 // get_pixel_* wrongly rounds down
185 pango_layout_get_extents (self->pl, 0, &rect); 209 pango_layout_get_extents (self->pl, 0, &rect);
196 220
197typedef uint16_t tileid; 221typedef uint16_t tileid;
198typedef uint16_t faceid; 222typedef uint16_t faceid;
199 223
200typedef struct { 224typedef struct {
201 int name; 225 GLuint name;
202 int w, h; 226 int w, h;
203 float s, t; 227 float s, t;
204 uint8_t r, g, b, a; 228 uint8_t r, g, b, a;
205 tileid smoothtile; 229 tileid smoothtile;
206 uint8_t smoothlevel; 230 uint8_t smoothlevel;
224 int faces; tileid *face2tile; // [faceid] 248 int faces; tileid *face2tile; // [faceid]
225 int texs; maptex *tex; // [tileid] 249 int texs; maptex *tex; // [tileid]
226 250
227 int32_t rows; 251 int32_t rows;
228 maprow *row; 252 maprow *row;
229} *CFPlus__Map; 253} *DC__Map;
230 254
231static char * 255static char *
232prepend (char *ptr, int sze, int inc) 256prepend (char *ptr, int sze, int inc)
233{ 257{
234 char *p; 258 char *p;
272 self->texs *= 2; 296 self->texs *= 2;
273 } 297 }
274} 298}
275 299
276static maprow * 300static maprow *
277map_get_row (CFPlus__Map self, int y) 301map_get_row (DC__Map self, int y)
278{ 302{
279 if (0 > y) 303 if (0 > y)
280 { 304 {
281 int extend = - y + MAP_EXTEND_Y; 305 int extend = - y + MAP_EXTEND_Y;
282 Prepend (maprow, self->row, self->rows, extend); 306 Prepend (maprow, self->row, self->rows, extend);
320 344
321 return row->col + (x - row->c0); 345 return row->col + (x - row->c0);
322} 346}
323 347
324static mapcell * 348static mapcell *
325map_get_cell (CFPlus__Map self, int x, int y) 349map_get_cell (DC__Map self, int x, int y)
326{ 350{
327 return row_get_cell (map_get_row (self, y), x); 351 return row_get_cell (map_get_row (self, y), x);
328} 352}
329 353
330static void 354static void
331map_clear (CFPlus__Map self) 355map_clear (DC__Map self)
332{ 356{
333 int r; 357 int r;
334 358
335 for (r = 0; r < self->rows; r++) 359 for (r = 0; r < self->rows; r++)
336 Safefree (self->row[r].col); 360 Safefree (self->row[r].col);
343 self->oy = 0; 367 self->oy = 0;
344 self->row = 0; 368 self->row = 0;
345 self->rows = 0; 369 self->rows = 0;
346} 370}
347 371
372#define CELL_CLEAR(cell) \
373 do { \
374 if ((cell)->player) \
375 (cell)->tile [2] = 0; \
376 (cell)->darkness = 0; \
377 (cell)->stat_hp = 0; \
378 (cell)->flags = 0; \
379 (cell)->player = 0; \
380 } while (0)
381
348static void 382static void
349map_blank (CFPlus__Map self, int x0, int y0, int w, int h) 383map_blank (DC__Map self, int x0, int y0, int w, int h)
350{ 384{
351 int x, y; 385 int x, y;
352 maprow *row; 386 maprow *row;
353 mapcell *cell; 387 mapcell *cell;
354 388
366 if (x >= row->c1) 400 if (x >= row->c1)
367 break; 401 break;
368 402
369 cell = row->col + x - row->c0; 403 cell = row->col + x - row->c0;
370 404
371 cell->darkness = 0; 405 CELL_CLEAR (cell);
372 cell->stat_hp = 0;
373 cell->flags = 0;
374 cell->player = 0;
375 } 406 }
376 } 407 }
377} 408}
378 409
379typedef struct { 410typedef struct {
433 n |= n >> 16; 464 n |= n >> 16;
434 465
435 return n + 1; 466 return n + 1;
436} 467}
437 468
469static unsigned int
470popcount (unsigned int n)
471{
472 n -= (n >> 1) & 0x55555555U;
473 n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U);
474 n = ((n >> 4) + n) & 0x0f0f0f0fU;
475 n *= 0x01010101U;
476
477 return n >> 24;
478}
479
438/* SDL should provide this, really. */ 480/* SDL should provide this, really. */
439#define SDLK_MODIFIER_MIN 300 481#define SDLK_MODIFIER_MIN 300
440#define SDLK_MODIFIER_MAX 314 482#define SDLK_MODIFIER_MAX 314
441 483
442/******************************************************************************/ 484/******************************************************************************/
480 return 0; 522 return 0;
481 523
482 return 1; 524 return 1;
483} 525}
484 526
485MODULE = CFPlus PACKAGE = CFPlus 527MODULE = Deliantra::Client PACKAGE = DC
486 528
487PROTOTYPES: ENABLE 529PROTOTYPES: ENABLE
488 530
489BOOT: 531BOOT:
490{ 532{
491 HV *stash = gv_stashpv ("CFPlus", 1); 533 HV *stash = gv_stashpv ("DC", 1);
492 static const struct { 534 static const struct {
493 const char *name; 535 const char *name;
494 IV iv; 536 IV iv;
495 } *civ, const_iv[] = { 537 } *civ, const_iv[] = {
496# define const_iv(name) { # name, (IV)name } 538# define const_iv(name) { # name, (IV)name }
518 560
519 const_iv (SDL_APPINPUTFOCUS), 561 const_iv (SDL_APPINPUTFOCUS),
520 const_iv (SDL_APPMOUSEFOCUS), 562 const_iv (SDL_APPMOUSEFOCUS),
521 const_iv (SDL_APPACTIVE), 563 const_iv (SDL_APPACTIVE),
522 564
565 const_iv (SDLK_FIRST),
566 const_iv (SDLK_LAST),
523 const_iv (SDLK_KP0), 567 const_iv (SDLK_KP0),
524 const_iv (SDLK_KP1), 568 const_iv (SDLK_KP1),
525 const_iv (SDLK_KP2), 569 const_iv (SDLK_KP2),
526 const_iv (SDLK_KP3), 570 const_iv (SDLK_KP3),
527 const_iv (SDLK_KP4), 571 const_iv (SDLK_KP4),
599 const_iv (KMOD_LMETA), 643 const_iv (KMOD_LMETA),
600 const_iv (KMOD_RMETA), 644 const_iv (KMOD_RMETA),
601 const_iv (KMOD_NUM), 645 const_iv (KMOD_NUM),
602 const_iv (KMOD_CAPS), 646 const_iv (KMOD_CAPS),
603 const_iv (KMOD_MODE), 647 const_iv (KMOD_MODE),
648
649 const_iv (MIX_DEFAULT_FORMAT),
650
651 const_iv (SDL_INIT_TIMER),
652 const_iv (SDL_INIT_AUDIO),
653 const_iv (SDL_INIT_VIDEO),
654 const_iv (SDL_INIT_CDROM),
655 const_iv (SDL_INIT_JOYSTICK),
656 const_iv (SDL_INIT_EVERYTHING),
657 const_iv (SDL_INIT_NOPARACHUTE),
658 const_iv (SDL_INIT_EVENTTHREAD),
659
660 const_iv (SDL_GL_RED_SIZE),
661 const_iv (SDL_GL_GREEN_SIZE),
662 const_iv (SDL_GL_BLUE_SIZE),
663 const_iv (SDL_GL_ALPHA_SIZE),
664 const_iv (SDL_GL_DOUBLEBUFFER),
665 const_iv (SDL_GL_BUFFER_SIZE),
666 const_iv (SDL_GL_DEPTH_SIZE),
667 const_iv (SDL_GL_STENCIL_SIZE),
668 const_iv (SDL_GL_ACCUM_RED_SIZE),
669 const_iv (SDL_GL_ACCUM_GREEN_SIZE),
670 const_iv (SDL_GL_ACCUM_BLUE_SIZE),
671 const_iv (SDL_GL_ACCUM_ALPHA_SIZE),
672 const_iv (SDL_GL_STEREO),
673 const_iv (SDL_GL_MULTISAMPLEBUFFERS),
674 const_iv (SDL_GL_MULTISAMPLESAMPLES),
675 const_iv (SDL_GL_ACCELERATED_VISUAL),
676 const_iv (SDL_GL_SWAP_CONTROL)
604# undef const_iv 677# undef const_iv
605 }; 678 };
606 679
607 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 680 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
608 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 681 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
626 699
627NV floor (NV x) 700NV floor (NV x)
628 701
629NV ceil (NV x) 702NV ceil (NV x)
630 703
704IV minpot (UV n)
705
706IV popcount (UV n)
707
631void 708void
632pango_init () 709pango_init ()
633 CODE: 710 CODE:
634{ 711{
635 opengl_fontmap = pango_opengl_font_map_new (); 712 opengl_fontmap = pango_opengl_font_map_new ();
636 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); 713 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0);
637 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); 714 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap);
715 /*pango_context_set_font_description (opengl_context, default_font);*/
716#if PANGO_VERSION_CHECK (1, 15, 2)
717 pango_context_set_language (opengl_context, pango_language_from_string ("en"));
718 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/
719#endif
638} 720}
639 721
640char *
641SDL_GetError () 722char *SDL_GetError ()
642 723
643int 724int SDL_Init (U32 flags)
644SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE)
645 725
646void 726int SDL_InitSubSystem (U32 flags)
727
728void SDL_QuitSubSystem (U32 flags)
729
647SDL_Quit () 730void SDL_Quit ()
731
732int SDL_GL_SetAttribute (int attr, int value)
733
734int SDL_GL_GetAttribute (int attr)
735 CODE:
736 if (SDL_GL_GetAttribute (attr, &RETVAL))
737 XSRETURN_UNDEF;
738 OUTPUT:
739 RETVAL
648 740
649void 741void
650SDL_ListModes (int rgb, int alpha) 742SDL_ListModes (int rgb, int alpha)
651 PPCODE: 743 PPCODE:
652{ 744{
664 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 756 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
665 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); 757 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0);
666 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 758 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
667 759
668 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 760 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
669#if SDL_VERSION_ATLEAST(1,2,10)
670 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
671 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); 761 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
672#endif
673 762
674 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 763 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
675 764
676 if (m && m != (SDL_Rect **)-1) 765 if (m && m != (SDL_Rect **)-1)
677 while (*m) 766 while (*m)
678 { 767 {
679 if ((*m)->w >= 640 && (*m)->h >= 480) 768 if ((*m)->w >= 400 && (*m)->h >= 300)
680 { 769 {
681 AV *av = newAV (); 770 AV *av = newAV ();
682 av_push (av, newSViv ((*m)->w)); 771 av_push (av, newSViv ((*m)->w));
683 av_push (av, newSViv ((*m)->h)); 772 av_push (av, newSViv ((*m)->h));
684 av_push (av, newSViv (rgb)); 773 av_push (av, newSViv (rgb));
708 797
709 if (RETVAL) 798 if (RETVAL)
710 { 799 {
711 av_clear (texture_av); 800 av_clear (texture_av);
712 801
713 SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); 802 SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra");
714#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); 803#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name);
715#include "glfunc.h" 804#include "glfunc.h"
716#undef GL_FUNC 805#undef GL_FUNC
717 } 806 }
718} 807}
725char * 814char *
726SDL_GetKeyName (int sym) 815SDL_GetKeyName (int sym)
727 816
728int 817int
729SDL_GetAppState () 818SDL_GetAppState ()
819
820int
821SDL_GetModState ()
730 822
731void 823void
732poll_events () 824poll_events ()
733 PPCODE: 825 PPCODE:
734{ 826{
744 { 836 {
745 case SDL_KEYDOWN: 837 case SDL_KEYDOWN:
746 case SDL_KEYUP: 838 case SDL_KEYUP:
747 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 839 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
748 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 840 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
749 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); 841 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0);
750 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ 842 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */
751 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 843 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
752 break; 844 break;
753 845
754 case SDL_ACTIVEEVENT: 846 case SDL_ACTIVEEVENT:
755 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 847 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
773 x = ev.motion.x; 865 x = ev.motion.x;
774 y = ev.motion.y; 866 y = ev.motion.y;
775 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); 867 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
776 } 868 }
777 869
778 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 870 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0);
779 hv_store (hv, "state", 5, newSViv (state), 0); 871 hv_store (hv, "state", 5, newSViv (state), 0);
780 hv_store (hv, "x", 1, newSViv (x), 0); 872 hv_store (hv, "x", 1, newSViv (x), 0);
781 hv_store (hv, "y", 1, newSViv (y), 0); 873 hv_store (hv, "y", 1, newSViv (y), 0);
782 hv_store (hv, "xrel", 4, newSViv (xrel), 0); 874 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
783 hv_store (hv, "yrel", 4, newSViv (yrel), 0); 875 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
784 } 876 }
785 break; 877 break;
786 878
787 case SDL_MOUSEBUTTONDOWN: 879 case SDL_MOUSEBUTTONDOWN:
788 case SDL_MOUSEBUTTONUP: 880 case SDL_MOUSEBUTTONUP:
789 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 881 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0);
790 882
791 hv_store (hv, "button", 6, newSViv (ev.button.button), 0); 883 hv_store (hv, "button", 6, newSViv (ev.button.button), 0);
792 hv_store (hv, "state", 5, newSViv (ev.button.state), 0); 884 hv_store (hv, "state", 5, newSViv (ev.button.state), 0);
793 hv_store (hv, "x", 1, newSViv (ev.button.x), 0); 885 hv_store (hv, "x", 1, newSViv (ev.button.x), 0);
794 hv_store (hv, "y", 1, newSViv (ev.button.y), 0); 886 hv_store (hv, "y", 1, newSViv (ev.button.y), 0);
799 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 891 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
800 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 892 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
801 break; 893 break;
802 } 894 }
803 895
804 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); 896 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1))));
805 } 897 }
806} 898}
807 899
808int 900int
809Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) 901Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096)
810 POSTCALL: 902 POSTCALL:
811 Mix_HookMusicFinished (music_finished); 903 Mix_HookMusicFinished (music_finished);
812 Mix_ChannelFinished (channel_finished); 904 Mix_ChannelFinished (channel_finished);
905
906void
907Mix_QuerySpec ()
908 PPCODE:
909{
910 int freq, channels;
911 Uint16 format;
912
913 if (Mix_QuerySpec (&freq, &format, &channels))
914 {
915 EXTEND (SP, 3);
916 PUSHs (sv_2mortal (newSViv (freq)));
917 PUSHs (sv_2mortal (newSViv (format)));
918 PUSHs (sv_2mortal (newSViv (channels)));
919 }
920}
813 921
814void 922void
815Mix_CloseAudio () 923Mix_CloseAudio ()
816 924
817int 925int
852 } 960 }
853 } 961 }
854#endif 962#endif
855} 963}
856 964
857void 965int
858add_font (char *file) 966add_font (char *file)
859 CODE: 967 CODE:
860 FcConfigAppFontAddFile (0, (const FcChar8 *)file); 968 RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file);
969 OUTPUT:
970 RETVAL
861 971
862void 972void
863load_image_inline (SV *image_) 973load_image_inline (SV *image_)
864 ALIAS: 974 ALIAS:
865 load_image_file = 1 975 load_image_file = 1
951void 1061void
952error (char *message) 1062error (char *message)
953 CODE: 1063 CODE:
954 fprintf (stderr, "ERROR: %s\n", message); 1064 fprintf (stderr, "ERROR: %s\n", message);
955#ifdef _WIN32 1065#ifdef _WIN32
956 MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); 1066 MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR);
957#endif 1067#endif
958 1068
959void 1069void
960fatal (char *message) 1070fatal (char *message)
961 CODE: 1071 CODE:
962 fprintf (stderr, "FATAL: %s\n", message); 1072 fprintf (stderr, "FATAL: %s\n", message);
963#ifdef _WIN32 1073#ifdef _WIN32
964 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); 1074 MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR);
965#endif 1075#endif
966 _exit (1); 1076 _exit (1);
967 1077
968void 1078void
969_exit (int retval = 0) 1079_exit (int retval = 0)
981#if DEBUG 1091#if DEBUG
982 VALGRIND_DO_LEAK_CHECK; 1092 VALGRIND_DO_LEAK_CHECK;
983#endif 1093#endif
984} 1094}
985 1095
986MODULE = CFPlus PACKAGE = CFPlus::Font 1096MODULE = Deliantra::Client PACKAGE = DC::Font
987 1097
988PROTOTYPES: DISABLE 1098PROTOTYPES: DISABLE
989 1099
990CFPlus::Font 1100DC::Font
991new_from_file (SV *class, char *path, int id = 0) 1101new_from_file (SV *class, char *path, int id = 0)
992 CODE: 1102 CODE:
993{ 1103{
994 int count; 1104 int count;
995 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 1105 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
998} 1108}
999 OUTPUT: 1109 OUTPUT:
1000 RETVAL 1110 RETVAL
1001 1111
1002void 1112void
1003DESTROY (CFPlus::Font self) 1113DESTROY (DC::Font self)
1004 CODE: 1114 CODE:
1005 pango_font_description_free (self); 1115 pango_font_description_free (self);
1006 1116
1007void 1117void
1008make_default (CFPlus::Font self) 1118make_default (DC::Font self)
1009 PROTOTYPE: $ 1119 PROTOTYPE: $
1010 CODE: 1120 CODE:
1011 default_font = self; 1121 default_font = self;
1012 1122
1013MODULE = CFPlus PACKAGE = CFPlus::Layout 1123MODULE = Deliantra::Client PACKAGE = DC::Layout
1014 1124
1015PROTOTYPES: DISABLE 1125PROTOTYPES: DISABLE
1016 1126
1017void 1127void
1018reset_glyph_cache () 1128glyph_cache_backup ()
1019 PROTOTYPE: 1129 PROTOTYPE:
1020 CODE: 1130 CODE:
1131 tc_backup ();
1132
1133void
1134glyph_cache_restore ()
1135 PROTOTYPE:
1136 CODE:
1021 tc_clear (); 1137 tc_restore ();
1022 1138
1023CFPlus::Layout 1139DC::Layout
1024new (SV *class) 1140new (SV *class)
1025 CODE: 1141 CODE:
1026 New (0, RETVAL, 1, struct cf_layout); 1142 New (0, RETVAL, 1, struct cf_layout);
1027 1143
1028 RETVAL->pl = pango_layout_new (opengl_context); 1144 RETVAL->pl = pango_layout_new (opengl_context);
1030 RETVAL->g = 1.; 1146 RETVAL->g = 1.;
1031 RETVAL->b = 1.; 1147 RETVAL->b = 1.;
1032 RETVAL->a = 1.; 1148 RETVAL->a = 1.;
1033 RETVAL->base_height = MIN_FONT_HEIGHT; 1149 RETVAL->base_height = MIN_FONT_HEIGHT;
1034 RETVAL->font = 0; 1150 RETVAL->font = 0;
1151 RETVAL->rc = rc_alloc ();
1035 1152
1036 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); 1153 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR);
1037 layout_update_font (RETVAL); 1154 layout_update_font (RETVAL);
1038 OUTPUT: 1155 OUTPUT:
1039 RETVAL 1156 RETVAL
1040 1157
1041void 1158void
1042DESTROY (CFPlus::Layout self) 1159DESTROY (DC::Layout self)
1043 CODE: 1160 CODE:
1044 g_object_unref (self->pl); 1161 g_object_unref (self->pl);
1162 rc_free (self->rc);
1045 Safefree (self); 1163 Safefree (self);
1046 1164
1047void 1165void
1048set_text (CFPlus::Layout self, SV *text_) 1166set_text (DC::Layout self, SV *text_)
1049 CODE: 1167 CODE:
1050{ 1168{
1051 STRLEN textlen; 1169 STRLEN textlen;
1052 char *text = SvPVutf8 (text_, textlen); 1170 char *text = SvPVutf8 (text_, textlen);
1053 1171
1054 pango_layout_set_text (self->pl, text, textlen); 1172 pango_layout_set_text (self->pl, text, textlen);
1055} 1173}
1056 1174
1057void 1175void
1058set_markup (CFPlus::Layout self, SV *text_) 1176set_markup (DC::Layout self, SV *text_)
1059 CODE: 1177 CODE:
1060{ 1178{
1061 STRLEN textlen; 1179 STRLEN textlen;
1062 char *text = SvPVutf8 (text_, textlen); 1180 char *text = SvPVutf8 (text_, textlen);
1063 1181
1064 pango_layout_set_markup (self->pl, text, textlen); 1182 pango_layout_set_markup (self->pl, text, textlen);
1065} 1183}
1066 1184
1067void 1185void
1068set_shapes (CFPlus::Layout self, ...) 1186set_shapes (DC::Layout self, ...)
1069 CODE: 1187 CODE:
1070{ 1188{
1071 PangoAttrList *attrs = 0; 1189 PangoAttrList *attrs = 0;
1072 const char *text = pango_layout_get_text (self->pl); 1190 const char *text = pango_layout_get_text (self->pl);
1073 const char *pos = text; 1191 const char *pos = text;
1108 if (attrs) 1226 if (attrs)
1109 pango_layout_set_attributes (self->pl, attrs); 1227 pango_layout_set_attributes (self->pl, attrs);
1110} 1228}
1111 1229
1112void 1230void
1113get_shapes (CFPlus::Layout self) 1231get_shapes (DC::Layout self)
1114 PPCODE: 1232 PPCODE:
1115{ 1233{
1116 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 1234 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
1117 1235
1118 do 1236 do
1119 { 1237 {
1120 PangoLayoutRun *run = pango_layout_iter_get_run (iter); 1238 PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter);
1121 1239
1122 if (run && shape_attr_p (run)) 1240 if (run && shape_attr_p (run))
1123 { 1241 {
1124 PangoRectangle extents; 1242 PangoRectangle extents;
1125 pango_layout_iter_get_run_extents (iter, 0, &extents); 1243 pango_layout_iter_get_run_extents (iter, 0, &extents);
1133 1251
1134 pango_layout_iter_free (iter); 1252 pango_layout_iter_free (iter);
1135} 1253}
1136 1254
1137int 1255int
1138has_wrapped (CFPlus::Layout self) 1256has_wrapped (DC::Layout self)
1139 CODE: 1257 CODE:
1140{ 1258{
1141 int lines = 1; 1259 int lines = 1;
1142 const char *text = pango_layout_get_text (self->pl); 1260 const char *text = pango_layout_get_text (self->pl);
1143 1261
1148} 1266}
1149 OUTPUT: 1267 OUTPUT:
1150 RETVAL 1268 RETVAL
1151 1269
1152SV * 1270SV *
1153get_text (CFPlus::Layout self) 1271get_text (DC::Layout self)
1154 CODE: 1272 CODE:
1155 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 1273 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
1156 sv_utf8_decode (RETVAL); 1274 sv_utf8_decode (RETVAL);
1157 OUTPUT: 1275 OUTPUT:
1158 RETVAL 1276 RETVAL
1159 1277
1160void 1278void
1161set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) 1279set_foreground (DC::Layout self, float r, float g, float b, float a = 1.)
1162 CODE: 1280 CODE:
1163 self->r = r; 1281 self->r = r;
1164 self->g = g; 1282 self->g = g;
1165 self->b = b; 1283 self->b = b;
1166 self->a = a; 1284 self->a = a;
1167 1285
1168void 1286void
1169set_font (CFPlus::Layout self, CFPlus::Font font = 0) 1287set_font (DC::Layout self, DC::Font font = 0)
1170 CODE: 1288 CODE:
1171 if (self->font != font) 1289 if (self->font != font)
1172 { 1290 {
1173 self->font = font; 1291 self->font = font;
1174 layout_update_font (self); 1292 layout_update_font (self);
1175 } 1293 }
1176 1294
1177void 1295void
1178set_height (CFPlus::Layout self, int base_height) 1296set_height (DC::Layout self, int base_height)
1179 CODE: 1297 CODE:
1180 if (self->base_height != base_height) 1298 if (self->base_height != base_height)
1181 { 1299 {
1182 self->base_height = base_height; 1300 self->base_height = base_height;
1183 layout_update_font (self); 1301 layout_update_font (self);
1184 } 1302 }
1185 1303
1186void 1304void
1187set_width (CFPlus::Layout self, int max_width = -1) 1305set_width (DC::Layout self, int max_width = -1)
1188 CODE: 1306 CODE:
1189 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 1307 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
1190 1308
1191void 1309void
1192set_indent (CFPlus::Layout self, int indent) 1310set_indent (DC::Layout self, int indent)
1193 CODE: 1311 CODE:
1194 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 1312 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
1195 1313
1196void 1314void
1197set_spacing (CFPlus::Layout self, int spacing) 1315set_spacing (DC::Layout self, int spacing)
1198 CODE: 1316 CODE:
1199 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 1317 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
1200 1318
1201void 1319void
1202set_ellipsise (CFPlus::Layout self, int ellipsise) 1320set_ellipsise (DC::Layout self, int ellipsise)
1203 CODE: 1321 CODE:
1204 pango_layout_set_ellipsize (self->pl, 1322 pango_layout_set_ellipsize (self->pl,
1205 ellipsise == 1 ? PANGO_ELLIPSIZE_START 1323 ellipsise == 1 ? PANGO_ELLIPSIZE_START
1206 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 1324 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
1207 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 1325 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
1208 : PANGO_ELLIPSIZE_NONE 1326 : PANGO_ELLIPSIZE_NONE
1209 ); 1327 );
1210 1328
1211void 1329void
1212set_single_paragraph_mode (CFPlus::Layout self, int spm) 1330set_single_paragraph_mode (DC::Layout self, int spm)
1213 CODE: 1331 CODE:
1214 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 1332 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
1215 1333
1216void 1334void
1217size (CFPlus::Layout self) 1335size (DC::Layout self)
1218 PPCODE: 1336 PPCODE:
1219{ 1337{
1220 int w, h; 1338 int w, h;
1221 1339
1222 layout_get_pixel_size (self, &w, &h); 1340 layout_get_pixel_size (self, &w, &h);
1225 PUSHs (sv_2mortal (newSViv (w))); 1343 PUSHs (sv_2mortal (newSViv (w)));
1226 PUSHs (sv_2mortal (newSViv (h))); 1344 PUSHs (sv_2mortal (newSViv (h)));
1227} 1345}
1228 1346
1229int 1347int
1230descent (CFPlus::Layout self) 1348descent (DC::Layout self)
1231 CODE: 1349 CODE:
1232{ 1350{
1233 PangoRectangle rect; 1351 PangoRectangle rect;
1234 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1352 PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0);
1235 pango_layout_line_get_pixel_extents (line, 0, &rect); 1353 pango_layout_line_get_pixel_extents (line, 0, &rect);
1236 RETVAL = PANGO_DESCENT (rect); 1354 RETVAL = PANGO_DESCENT (rect);
1237} 1355}
1238 OUTPUT: 1356 OUTPUT:
1239 RETVAL 1357 RETVAL
1240 1358
1241int 1359int
1242xy_to_index (CFPlus::Layout self, int x, int y) 1360xy_to_index (DC::Layout self, int x, int y)
1243 CODE: 1361 CODE:
1244{ 1362{
1245 int index, trailing; 1363 int index, trailing;
1246 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1364 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1247 RETVAL = index + trailing; 1365 RETVAL = index + trailing;
1248} 1366}
1249 OUTPUT: 1367 OUTPUT:
1250 RETVAL 1368 RETVAL
1251 1369
1252void 1370void
1253cursor_pos (CFPlus::Layout self, int index) 1371cursor_pos (DC::Layout self, int index)
1254 PPCODE: 1372 PPCODE:
1255{ 1373{
1256 PangoRectangle strong_pos; 1374 PangoRectangle pos;
1257 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1375 pango_layout_get_cursor_pos (self->pl, index, &pos, 0);
1258 1376
1259 EXTEND (SP, 3); 1377 EXTEND (SP, 3);
1260 PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); 1378 PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE)));
1261 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1379 PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE)));
1262 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1380 PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE)));
1263} 1381}
1264 1382
1265void 1383void
1266index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) 1384index_to_line_x (DC::Layout self, int index, int trailing = 0)
1267 PPCODE: 1385 PPCODE:
1268{ 1386{
1269 int line, x; 1387 int line, x;
1270 1388
1271 pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); 1389 pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x);
1390#if !PANGO_VERSION_CHECK (1, 17, 3)
1272 /* pango bug: line is between 1..numlines, not 0..numlines-1 */ 1391 /* pango bug: line is between 1..numlines, not 0..numlines-1 */
1273 1392 --line;
1393#endif
1274 EXTEND (SP, 2); 1394 EXTEND (SP, 2);
1275 PUSHs (sv_2mortal (newSViv (line - 1))); 1395 PUSHs (sv_2mortal (newSViv (line)));
1276 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); 1396 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE)));
1277} 1397}
1278 1398
1279void 1399void
1280line_x_to_index (CFPlus::Layout self, int line, int x) 1400line_x_to_index (DC::Layout self, int line, int x)
1281 PPCODE: 1401 PPCODE:
1282{ 1402{
1283 PangoLayoutLine *lp; 1403 PangoLayoutLine *lp;
1284 int index, trailing; 1404 int index, trailing;
1285 1405
1286 if (line < 0) 1406 if (line < 0)
1287 XSRETURN_EMPTY; 1407 XSRETURN_EMPTY;
1288 1408
1289 if (!(lp = pango_layout_get_line (self->pl, line))) 1409 if (!(lp = pango_layout_get_line_readonly (self->pl, line)))
1290 XSRETURN_EMPTY; /* do better */ 1410 XSRETURN_EMPTY; /* do better */
1291 1411
1292 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); 1412 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing);
1293 1413
1294 EXTEND (SP, 2); 1414 EXTEND (SP, 2);
1300 PUSHs (sv_2mortal (newSViv (trailing))); 1420 PUSHs (sv_2mortal (newSViv (trailing)));
1301 } 1421 }
1302} 1422}
1303 1423
1304void 1424void
1305render (CFPlus::Layout self, float x, float y, int flags = 0) 1425render (DC::Layout self, float x, float y, int flags = 0)
1306 PPCODE: 1426 CODE:
1427 rc_clear (self->rc);
1307 pango_opengl_render_layout_subpixel ( 1428 pango_opengl_render_layout_subpixel (
1308 self->pl, 1429 self->pl,
1430 self->rc,
1309 x * PANGO_SCALE, y * PANGO_SCALE, 1431 x * PANGO_SCALE, y * PANGO_SCALE,
1310 self->r, self->g, self->b, self->a, 1432 self->r, self->g, self->b, self->a,
1311 flags 1433 flags
1312 ); 1434 );
1435 // we assume that context_change actually clears/frees stuff
1436 // and does not do any recomputation...
1437 pango_layout_context_changed (self->pl);
1313 1438
1314MODULE = CFPlus PACKAGE = CFPlus::Texture 1439void
1440draw (DC::Layout self)
1441 CODE:
1442{
1443 glEnable (GL_TEXTURE_2D);
1444 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1445 glEnable (GL_BLEND);
1446 gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
1447 GL_ONE , GL_ONE_MINUS_SRC_ALPHA);
1448 glEnable (GL_ALPHA_TEST);
1449 glAlphaFunc (GL_GREATER, 7.f / 255.f);
1450
1451 rc_draw (self->rc);
1452
1453 glDisable (GL_ALPHA_TEST);
1454 glDisable (GL_BLEND);
1455 glDisable (GL_TEXTURE_2D);
1456}
1457
1458MODULE = Deliantra::Client PACKAGE = DC::Texture
1315 1459
1316PROTOTYPES: ENABLE 1460PROTOTYPES: ENABLE
1317
1318int minpot (int n)
1319 1461
1320void 1462void
1321pad (SV *data_, int ow, int oh, int nw, int nh) 1463pad (SV *data_, int ow, int oh, int nw, int nh)
1322 CODE: 1464 CODE:
1323{ 1465{
1400 RETVAL = width > 0; 1542 RETVAL = width > 0;
1401} 1543}
1402 OUTPUT: 1544 OUTPUT:
1403 RETVAL 1545 RETVAL
1404 1546
1405MODULE = CFPlus PACKAGE = CFPlus::Map 1547MODULE = Deliantra::Client PACKAGE = DC::Map
1406 1548
1407PROTOTYPES: DISABLE 1549PROTOTYPES: DISABLE
1408 1550
1409CFPlus::Map 1551DC::Map
1410new (SV *class) 1552new (SV *class)
1411 CODE: 1553 CODE:
1412 New (0, RETVAL, 1, struct map); 1554 New (0, RETVAL, 1, struct map);
1413 RETVAL->x = 0; 1555 RETVAL->x = 0;
1414 RETVAL->y = 0; 1556 RETVAL->y = 0;
1422 RETVAL->row = 0; 1564 RETVAL->row = 0;
1423 OUTPUT: 1565 OUTPUT:
1424 RETVAL 1566 RETVAL
1425 1567
1426void 1568void
1427DESTROY (CFPlus::Map self) 1569DESTROY (DC::Map self)
1428 CODE: 1570 CODE:
1429{ 1571{
1430 map_clear (self); 1572 map_clear (self);
1431 Safefree (self->face2tile); 1573 Safefree (self->face2tile);
1432 Safefree (self->tex); 1574 Safefree (self->tex);
1433 Safefree (self); 1575 Safefree (self);
1434} 1576}
1435 1577
1436void 1578void
1437resize (CFPlus::Map self, int map_width, int map_height) 1579resize (DC::Map self, int map_width, int map_height)
1438 CODE: 1580 CODE:
1439 self->w = map_width; 1581 self->w = map_width;
1440 self->h = map_height; 1582 self->h = map_height;
1441 1583
1442void 1584void
1443clear (CFPlus::Map self) 1585clear (DC::Map self)
1444 CODE: 1586 CODE:
1445 map_clear (self); 1587 map_clear (self);
1446 1588
1447void 1589void
1448set_tileid (CFPlus::Map self, int face, int tile) 1590set_tileid (DC::Map self, int face, int tile)
1449 CODE: 1591 CODE:
1450{ 1592{
1451 need_facenum (self, face); self->face2tile [face] = tile; 1593 need_facenum (self, face); self->face2tile [face] = tile;
1452 need_texid (self, tile); 1594 need_texid (self, tile);
1453} 1595}
1454 1596
1455void 1597void
1456set_smooth (CFPlus::Map self, int face, int smooth, int level) 1598set_smooth (DC::Map self, int face, int smooth, int level)
1457 CODE: 1599 CODE:
1458{ 1600{
1459 tileid texid; 1601 tileid texid;
1460 maptex *tex; 1602 maptex *tex;
1461 1603
1474 tex->smoothtile = self->face2tile [smooth]; 1616 tex->smoothtile = self->face2tile [smooth];
1475 tex->smoothlevel = level; 1617 tex->smoothlevel = level;
1476} 1618}
1477 1619
1478void 1620void
1479set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1621set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a)
1480 CODE: 1622 CODE:
1481{ 1623{
1482 need_texid (self, texid); 1624 need_texid (self, texid);
1483 1625
1484 { 1626 {
1504 // from transparent color bleeding and ugly wrapping effects. 1646 // from transparent color bleeding and ugly wrapping effects.
1505 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1647 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1506} 1648}
1507 1649
1508int 1650int
1509ox (CFPlus::Map self) 1651ox (DC::Map self)
1510 ALIAS: 1652 ALIAS:
1511 oy = 1 1653 oy = 1
1512 x = 2 1654 x = 2
1513 y = 3 1655 y = 3
1514 w = 4 1656 w = 4
1525 } 1667 }
1526 OUTPUT: 1668 OUTPUT:
1527 RETVAL 1669 RETVAL
1528 1670
1529void 1671void
1530scroll (CFPlus::Map self, int dx, int dy) 1672scroll (DC::Map self, int dx, int dy)
1531 CODE: 1673 CODE:
1532{ 1674{
1533 if (dx > 0) 1675 if (dx > 0)
1534 map_blank (self, self->x, self->y, dx, self->h); 1676 map_blank (self, self->x, self->y, dx, self->h);
1535 else if (dx < 0) 1677 else if (dx < 0)
1550 self->rows += MAP_EXTEND_Y; 1692 self->rows += MAP_EXTEND_Y;
1551 self->y += MAP_EXTEND_Y; 1693 self->y += MAP_EXTEND_Y;
1552 } 1694 }
1553} 1695}
1554 1696
1555void 1697SV *
1556map1a_update (CFPlus::Map self, SV *data_, int extmap) 1698map1a_update (DC::Map self, SV *data_, int extmap)
1557 CODE: 1699 CODE:
1558{ 1700{
1559 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1701 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1560 uint8_t *data_end = (uint8_t *)SvEND (data_); 1702 uint8_t *data_end = (uint8_t *)SvEND (data_);
1561 mapcell *cell; 1703 mapcell *cell;
1562 int x, y, flags; 1704 int x, y, z, flags;
1705 AV *missing = newAV ();
1706 RETVAL = newRV_noinc ((SV *)missing);
1563 1707
1564 while (data < data_end - 1) 1708 while (data < data_end - 1)
1565 { 1709 {
1566 flags = (data [0] << 8) + data [1]; data += 2; 1710 flags = (data [0] << 8) + data [1]; data += 2;
1567 1711
1587 uint8_t ext, cmd; 1731 uint8_t ext, cmd;
1588 1732
1589 do 1733 do
1590 { 1734 {
1591 ext = *data++; 1735 ext = *data++;
1592 cmd = ext & 0x3f; 1736 cmd = ext & 0x7f;
1593 1737
1594 if (cmd < 4) 1738 if (cmd < 4)
1595 cell->darkness = 255 - ext * 64 + 1; 1739 cell->darkness = 255 - ext * 64 + 1;
1596 else if (cmd == 5) // health 1740 else if (cmd == 5) // health
1597 { 1741 {
1600 } 1744 }
1601 else if (cmd == 6) // monster width 1745 else if (cmd == 6) // monster width
1602 cell->stat_width = *data++ + 1; 1746 cell->stat_width = *data++ + 1;
1603 else if (cmd == 0x47) 1747 else if (cmd == 0x47)
1604 { 1748 {
1605 if (*data == 4) 1749 if (*data == 1) cell->player = data [1];
1606 ; // decode player count 1750 else if (*data == 2) cell->player = data [2] + (data [1] << 8);
1751 else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16);
1752 else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24);
1607 1753
1608 data += *data + 1; 1754 data += *data + 1;
1609 } 1755 }
1610 else if (cmd == 8) // cell flags 1756 else if (cmd == 8) // cell flags
1611 cell->flags = *data++; 1757 cell->flags = *data++;
1618 } 1764 }
1619 else 1765 else
1620 cell->darkness = *data++ + 1; 1766 cell->darkness = *data++ + 1;
1621 } 1767 }
1622 1768
1769 for (z = 0; z <= 2; ++z)
1623 if (flags & 4) 1770 if (flags & (4 >> z))
1624 { 1771 {
1625 faceid face = (data [0] << 8) + data [1]; data += 2; 1772 faceid face = (data [0] << 8) + data [1]; data += 2;
1626 need_facenum (self, face); 1773 need_facenum (self, face);
1627 cell->tile [0] = self->face2tile [face]; 1774 cell->tile [z] = self->face2tile [face];
1775
1776 if (cell->tile [z])
1777 {
1778 maptex *tex = self->tex + cell->tile [z];
1779 if (!tex->name)
1780 av_push (missing, newSViv (cell->tile [z]));
1781
1782 if (tex->smoothtile)
1783 {
1784 maptex *smooth = self->tex + tex->smoothtile;
1785 if (!smooth->name)
1786 av_push (missing, newSViv (tex->smoothtile));
1787 }
1788 }
1628 } 1789 }
1629
1630 if (flags & 2)
1631 {
1632 faceid face = (data [0] << 8) + data [1]; data += 2;
1633 need_facenum (self, face);
1634 cell->tile [1] = self->face2tile [face];
1635 }
1636
1637 if (flags & 1)
1638 {
1639 faceid face = (data [0] << 8) + data [1]; data += 2;
1640 need_facenum (self, face);
1641 cell->tile [2] = self->face2tile [face];
1642 }
1643 } 1790 }
1644 else 1791 else
1645 cell->darkness = 0; 1792 CELL_CLEAR (cell);
1646 } 1793 }
1647} 1794}
1795 OUTPUT:
1796 RETVAL
1648 1797
1649SV * 1798SV *
1650mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1799mapmap (DC::Map self, int x0, int y0, int w, int h)
1651 CODE: 1800 CODE:
1652{ 1801{
1653 int x1, x; 1802 int x1, x;
1654 int y1, y; 1803 int y1, y;
1655 int z; 1804 int z;
1699 RETVAL = map_sv; 1848 RETVAL = map_sv;
1700} 1849}
1701 OUTPUT: 1850 OUTPUT:
1702 RETVAL 1851 RETVAL
1703 1852
1704SV * 1853void
1705draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) 1854draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0)
1706 CODE: 1855 CODE:
1707{ 1856{
1857 int x, y, z;
1858
1708 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1859 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1709 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 1860 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
1710 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) 1861 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k)
1711 smooth_key skey; 1862 smooth_key skey;
1712 int x, y, z; 1863 int pl_x, pl_y;
1713 int last_name; 1864 maptex pl_tex;
1714 AV *missing = newAV (); 1865 rc_t *rc = rc_alloc ();
1715 RETVAL = newRV_noinc ((SV *)missing); 1866 rc_key_t key;
1867 rc_array_t *arr;
1868
1869 pl_tex.name = 0;
1716 1870
1717 // thats current max. sorry. 1871 // thats current max. sorry.
1718 if (sw > 255) sw = 255; 1872 if (sw > 255) sw = 255;
1719 if (sh > 255) sh = 255; 1873 if (sh > 255) sh = 255;
1720 1874
1721 // clear key, in case of extra padding 1875 // clear key, in case of extra padding
1722 memset (&skey, 0, sizeof (skey)); 1876 memset (&skey, 0, sizeof (skey));
1723 1877
1724 glColor4ub (255, 255, 255, 255); 1878 memset (&key, 0, sizeof (key));
1725 1879 key.r = 255;
1726 glEnable (GL_BLEND); 1880 key.g = 255;
1727 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1881 key.b = 255;
1728 glEnable (GL_TEXTURE_2D); 1882 key.a = 255;
1729 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 1883 key.mode = GL_QUADS;
1730 1884 key.format = GL_T2F_V3F;
1731 glBegin (GL_QUADS);
1732
1733 last_name = -1; 1885 key.texname = -1;
1734 1886
1735 mx += self->x; 1887 mx += self->x;
1736 my += self->y; 1888 my += self->y;
1737 1889
1738 // first pass: determine smooth_max 1890 // first pass: determine smooth_max
1754 MAX (self->tex [cell->tile [0]].smoothlevel, 1906 MAX (self->tex [cell->tile [0]].smoothlevel,
1755 MAX (self->tex [cell->tile [1]].smoothlevel, 1907 MAX (self->tex [cell->tile [1]].smoothlevel,
1756 self->tex [cell->tile [2]].smoothlevel)); 1908 self->tex [cell->tile [2]].smoothlevel));
1757 } 1909 }
1758 } 1910 }
1911
1912 glEnable (GL_BLEND);
1913 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1914 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1759 1915
1760 for (z = 0; z <= 2; z++) 1916 for (z = 0; z <= 2; z++)
1761 { 1917 {
1762 memset (smooth_level, 0, sizeof (smooth_level)); 1918 memset (smooth_level, 0, sizeof (smooth_level));
1763 1919
1773 tileid tile = cell->tile [z]; 1929 tileid tile = cell->tile [z];
1774 1930
1775 if (tile) 1931 if (tile)
1776 { 1932 {
1777 maptex tex = self->tex [tile]; 1933 maptex tex = self->tex [tile];
1778 int px, py; 1934 int px = (x + 1) * T - tex.w;
1935 int py = (y + 1) * T - tex.h;
1779 1936
1780 // suppressing texture state switches here
1781 // is only moderately effective, but worth the extra effort
1782 if (last_name != tex.name) 1937 if (key.texname != tex.name)
1783 { 1938 {
1784 if (!tex.name) 1939 if (!tex.name)
1785 {
1786 av_push (missing, newSViv (tile));
1787 tex = self->tex [2]; /* missing, replace by noface */ 1940 tex = self->tex [2]; /* missing, replace by noface */
1788 }
1789 1941
1790 glEnd (); 1942 key.texname = tex.name;
1791 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1943 arr = rc_array (rc, &key);
1792 glBegin (GL_QUADS);
1793 } 1944 }
1794 1945
1795 px = (x + 1) * T - tex.w; 1946 if (expect_false (cell->player == player) && expect_false (z == 2))
1796 py = (y + 1) * T - tex.h;
1797
1798 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1799 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1800 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1801 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1802
1803 if (cell->flags && z == 2)
1804 { 1947 {
1948 pl_x = px;
1949 pl_y = py;
1950 pl_tex = tex;
1951 continue;
1952 }
1953
1954 rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
1955 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0);
1956 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0);
1957 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0);
1958
1959 if (expect_false (cell->flags) && expect_false (z == 2))
1960 {
1961 // overlays such as the speech bubble, probably more to come
1805 if (cell->flags & 1) 1962 if (cell->flags & 1)
1806 { 1963 {
1807 maptex tex = self->tex [1]; 1964 maptex tex = self->tex [1];
1808 int px = x * T + T * 2 / 32; 1965 int px = x * T + T * 2 / 32;
1809 int py = y * T - T * 6 / 32; 1966 int py = y * T - T * 6 / 32;
1810 1967
1968 if (tex.name)
1811 glEnd (); 1969 {
1812 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1970 if (key.texname != tex.name)
1971 {
1972 key.texname = tex.name;
1973 arr = rc_array (rc, &key);
1974 }
1975
1976 rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
1977 rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0);
1978 rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0);
1979 rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0);
1813 glBegin (GL_QUADS); 1980 }
1814
1815 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1816 glTexCoord2f (0 , tex.t); glVertex2f (px , py + T);
1817 glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T);
1818 glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py );
1819 } 1981 }
1820 } 1982 }
1821 1983
1822 // update smooth hash 1984 // update smooth hash
1823 if (tex.smoothtile) 1985 if (tex.smoothtile)
1859 } 2021 }
1860 } 2022 }
1861 } 2023 }
1862 } 2024 }
1863 2025
2026 rc_draw (rc);
2027 rc_clear (rc);
2028
1864 // go through all smoothlevels, lowest to highest, then draw. 2029 // go through all smoothlevels, lowest to highest, then draw.
1865 // this is basically counting sort 2030 // this is basically counting sort
1866 { 2031 {
1867 int w, b; 2032 int w, b;
1868 2033
2034 glEnable (GL_TEXTURE_2D);
2035 glBegin (GL_QUADS);
1869 for (w = 0; w < 256 / 32; ++w) 2036 for (w = 0; w < 256 / 32; ++w)
1870 { 2037 {
1871 uint32_t smask = smooth_level [w]; 2038 uint32_t smask = smooth_level [w];
1872 if (smask) 2039 if (smask)
1873 for (b = 0; b < 32; ++b) 2040 for (b = 0; b < 32; ++b)
1892 int border = bits & 15; 2059 int border = bits & 15;
1893 int corner = (bits >> 8) & ~(bits >> 4) & 15; 2060 int corner = (bits >> 8) & ~(bits >> 4) & 15;
1894 float dx = tex.s * .0625f; // 16 images/row 2061 float dx = tex.s * .0625f; // 16 images/row
1895 float dy = tex.t * .5f ; // 2 images/column 2062 float dy = tex.t * .5f ; // 2 images/column
1896 2063
1897 // this time naively avoiding texture state changes
1898 // save gobs of state changes.
1899 if (last_name != tex.name) 2064 if (tex.name)
1900 { 2065 {
2066 // this time avoiding texture state changes
2067 // save gobs of state changes.
1901 if (!tex.name) 2068 if (key.texname != tex.name)
1902 { 2069 {
1903 av_push (missing, newSViv (skey->tile)); 2070 glEnd ();
1904 continue; // smoothing not yet available 2071 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
2072 glBegin (GL_QUADS);
1905 } 2073 }
1906 2074
1907 glEnd ();
1908 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1909 glBegin (GL_QUADS);
1910 }
1911
1912 if (border) 2075 if (border)
1913 { 2076 {
1914 float ox = border * dx; 2077 float ox = border * dx;
1915 2078
1916 glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); 2079 glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
1917 glTexCoord2f (ox , dy ); glVertex2f (px , py + T); 2080 glTexCoord2f (ox , dy ); glVertex2i (px , py + T);
1918 glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); 2081 glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T);
1919 glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); 2082 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py );
1920 } 2083 }
1921 2084
1922 if (corner) 2085 if (corner)
1923 { 2086 {
1924 float ox = corner * dx; 2087 float ox = corner * dx;
1925 2088
1926 glTexCoord2f (ox , dy ); glVertex2f (px , py ); 2089 glTexCoord2f (ox , dy ); glVertex2i (px , py );
1927 glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); 2090 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T);
1928 glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); 2091 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T);
1929 glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); 2092 glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py );
2093 }
1930 } 2094 }
1931 } 2095 }
1932 } 2096 }
1933 } 2097 }
1934 } 2098 }
2099
2100 glEnd ();
2101 glDisable (GL_TEXTURE_2D);
2102 key.texname = -1;
1935 } 2103 }
1936 2104
1937 hv_clear (smooth); 2105 hv_clear (smooth);
1938 } 2106 }
1939 2107
1940 glEnd (); 2108 if (pl_tex.name)
2109 {
2110 maptex tex = pl_tex;
2111 int px = pl_x + sdx;
2112 int py = pl_y + sdy;
1941 2113
1942 glDisable (GL_TEXTURE_2D); 2114 key.texname = tex.name;
2115 arr = rc_array (rc, &key);
2116
2117 rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
2118 rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0);
2119 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0);
2120 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0);
2121
2122 rc_draw (rc);
2123 }
2124
1943 glDisable (GL_BLEND); 2125 glDisable (GL_BLEND);
2126 rc_free (rc);
1944 2127
1945 // top layer: overlays such as the health bar 2128 // top layer: overlays such as the health bar
1946 for (y = 0; y < sh; y++) 2129 for (y = 0; y < sh; y++)
1947 if (0 <= y + my && y + my < self->rows) 2130 if (0 <= y + my && y + my < self->rows)
1948 { 2131 {
1971 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); 2154 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1972 } 2155 }
1973 } 2156 }
1974 } 2157 }
1975} 2158}
1976 OUTPUT:
1977 RETVAL
1978 2159
1979void 2160void
1980draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 2161draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data)
1981 CODE: 2162 CODE:
1982{ 2163{
1983 static float color[16][3] = { 2164 static float color[16][3] = {
1984 { 0.00F, 0.00F, 0.00F }, 2165 { 0.00F, 0.00F, 0.00F },
1985 { 1.00F, 1.00F, 1.00F }, 2166 { 1.00F, 1.00F, 1.00F },
2035 glDisable (GL_BLEND); 2216 glDisable (GL_BLEND);
2036 glDisable (GL_TEXTURE_2D); 2217 glDisable (GL_TEXTURE_2D);
2037} 2218}
2038 2219
2039void 2220void
2040fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) 2221fow_texture (DC::Map self, int mx, int my, int sw, int sh)
2041 PPCODE: 2222 PPCODE:
2042{ 2223{
2043 int x, y; 2224 int x, y;
2044 int sw1 = sw + 2; 2225 int sw1 = sw + 2;
2045 int sh1 = sh + 2; 2226 int sh1 = sh + 2;
2116 PUSHs (sv_2mortal (newSViv (sh3))); 2297 PUSHs (sv_2mortal (newSViv (sh3)));
2117 PUSHs (darkness3_sv); 2298 PUSHs (darkness3_sv);
2118} 2299}
2119 2300
2120SV * 2301SV *
2121get_rect (CFPlus::Map self, int x0, int y0, int w, int h) 2302get_rect (DC::Map self, int x0, int y0, int w, int h)
2122 CODE: 2303 CODE:
2123{ 2304{
2124 int x, y, x1, y1; 2305 int x, y, x1, y1;
2125 SV *data_sv = newSV (w * h * 7 + 5); 2306 SV *data_sv = newSV (w * h * 7 + 5);
2126 uint8_t *data = (uint8_t *)SvPVX (data_sv); 2307 uint8_t *data = (uint8_t *)SvPVX (data_sv);
2183 else 2364 else
2184 *data++ = 0; 2365 *data++ = 0;
2185 } 2366 }
2186 } 2367 }
2187 2368
2369 /* if size is w*h + 5 then no data has been found */
2370 if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5)
2371 {
2188 SvPOK_only (data_sv); 2372 SvPOK_only (data_sv);
2189 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); 2373 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv));
2374 }
2375
2190 RETVAL = data_sv; 2376 RETVAL = data_sv;
2191} 2377}
2192 OUTPUT: 2378 OUTPUT:
2193 RETVAL 2379 RETVAL
2194 2380
2195void 2381void
2196set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) 2382set_rect (DC::Map self, int x0, int y0, SV *data_sv)
2197 PPCODE: 2383 PPCODE:
2198{ 2384{
2199 int x, y, z; 2385 int x, y, z;
2200 int w, h; 2386 int w, h;
2201 int x1, y1; 2387 int x1, y1;
2388 STRLEN len;
2389 uint8_t *data, *end;
2390
2391 len = SvLEN (data_sv);
2392 SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more
2393 data = SvPVbyte_nolen (data_sv);
2394 end = data + len + 8;
2395
2396 if (len < 5)
2397 XSRETURN_EMPTY;
2202 2398
2203 if (*data++ != 0) 2399 if (*data++ != 0)
2204 return; /* version mismatch */ 2400 XSRETURN_EMPTY; /* version mismatch */
2205 2401
2206 w = *data++ << 8; w |= *data++; 2402 w = *data++ << 8; w |= *data++;
2207 h = *data++ << 8; h |= *data++; 2403 h = *data++ << 8; h |= *data++;
2208 2404
2209 // we need to do this 'cause we don't keep an absolute coord system for rows 2405 // we need to do this 'cause we don't keep an absolute coord system for rows
2221 { 2417 {
2222 maprow *row = map_get_row (self, y); 2418 maprow *row = map_get_row (self, y);
2223 2419
2224 for (x = x0; x < x1; x++) 2420 for (x = x0; x < x1; x++)
2225 { 2421 {
2422 uint8_t flags;
2423
2424 if (data + 7 >= end)
2425 XSRETURN_EMPTY;
2426
2226 uint8_t flags = *data++; 2427 flags = *data++;
2227 2428
2228 if (flags) 2429 if (flags)
2229 { 2430 {
2230 mapcell *cell = row_get_cell (row, x); 2431 mapcell *cell = row_get_cell (row, x);
2231 tileid tile[3] = { 0, 0, 0 }; 2432 tileid tile[3] = { 0, 0, 0 };
2234 if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } 2435 if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; }
2235 if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } 2436 if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; }
2236 2437
2237 if (cell->darkness == 0) 2438 if (cell->darkness == 0)
2238 { 2439 {
2239 cell->darkness = 0; 2440 /*cell->darkness = 0;*/
2441 EXTEND (SP, 3);
2240 2442
2241 for (z = 0; z <= 2; z++) 2443 for (z = 0; z <= 2; z++)
2242 { 2444 {
2243 tileid t = tile [z]; 2445 tileid t = tile [z];
2244 2446
2245 if (t >= self->texs || (t && !self->tex [t].name)) 2447 if (t >= self->texs || (t && !self->tex [t].name))
2246 { 2448 {
2247 XPUSHs (sv_2mortal (newSViv (t))); 2449 PUSHs (sv_2mortal (newSViv (t)));
2248 need_texid (self, t); 2450 need_texid (self, t);
2249 } 2451 }
2250 2452
2251 cell->tile [z] = t; 2453 cell->tile [z] = t;
2252 } 2454 }
2254 } 2456 }
2255 } 2457 }
2256 } 2458 }
2257} 2459}
2258 2460
2259MODULE = CFPlus PACKAGE = CFPlus::RW 2461MODULE = Deliantra::Client PACKAGE = DC::RW
2260 2462
2261CFPlus::RW 2463DC::RW
2262new (SV *class, SV *data_sv) 2464new (SV *class, SV *data_sv)
2263 CODE: 2465 CODE:
2264{ 2466{
2265 STRLEN datalen; 2467 STRLEN datalen;
2266 char *data = SvPVbyte (data_sv, datalen); 2468 char *data = SvPVbyte (data_sv, datalen);
2268 RETVAL = SDL_RWFromConstMem (data, datalen); 2470 RETVAL = SDL_RWFromConstMem (data, datalen);
2269} 2471}
2270 OUTPUT: 2472 OUTPUT:
2271 RETVAL 2473 RETVAL
2272 2474
2273CFPlus::RW 2475DC::RW
2274new_from_file (SV *class, const char *path, const char *mode = "rb") 2476new_from_file (SV *class, const char *path, const char *mode = "rb")
2275 CODE: 2477 CODE:
2276 RETVAL = SDL_RWFromFile (path, mode); 2478 RETVAL = SDL_RWFromFile (path, mode);
2277 OUTPUT: 2479 OUTPUT:
2278 RETVAL 2480 RETVAL
2279 2481
2280# fails on win32: 2482# fails on win32:
2281# CFPlus.xs(2268) : error C2059: syntax error : '(' 2483# dc.xs(2268) : error C2059: syntax error : '('
2282#void 2484#void
2283#close (CFPlus::RW self) 2485#close (DC::RW self)
2284# CODE: 2486# CODE:
2285# (self->(close)) (self); 2487# (self->(close)) (self);
2286 2488
2287MODULE = CFPlus PACKAGE = CFPlus::Channel 2489MODULE = Deliantra::Client PACKAGE = DC::Channel
2288 2490
2289PROTOTYPES: DISABLE 2491PROTOTYPES: DISABLE
2290 2492
2291CFPlus::Channel 2493DC::Channel
2292find () 2494find ()
2293 CODE: 2495 CODE:
2294{ 2496{
2295 RETVAL = Mix_GroupAvailable (-1); 2497 RETVAL = Mix_GroupAvailable (-1);
2296 2498
2309} 2511}
2310 OUTPUT: 2512 OUTPUT:
2311 RETVAL 2513 RETVAL
2312 2514
2313void 2515void
2314halt (CFPlus::Channel self) 2516halt (DC::Channel self)
2315 CODE: 2517 CODE:
2316 Mix_HaltChannel (self); 2518 Mix_HaltChannel (self);
2317 2519
2318void 2520void
2319expire (CFPlus::Channel self, int ticks = -1) 2521expire (DC::Channel self, int ticks = -1)
2320 CODE: 2522 CODE:
2321 Mix_ExpireChannel (self, ticks); 2523 Mix_ExpireChannel (self, ticks);
2322 2524
2323void 2525void
2324fade_out (CFPlus::Channel self, int ticks = -1) 2526fade_out (DC::Channel self, int ticks = -1)
2325 CODE: 2527 CODE:
2326 Mix_FadeOutChannel (self, ticks); 2528 Mix_FadeOutChannel (self, ticks);
2327 2529
2328int 2530int
2329volume (CFPlus::Channel self, int volume) 2531volume (DC::Channel self, int volume)
2330 CODE: 2532 CODE:
2331 RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); 2533 RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128));
2332 OUTPUT: 2534 OUTPUT:
2333 RETVAL 2535 RETVAL
2334 2536
2335void 2537void
2336unregister_all_effects (CFPlus::Channel self) 2538unregister_all_effects (DC::Channel self)
2337 CODE: 2539 CODE:
2338 Mix_UnregisterAllEffects (self); 2540 Mix_UnregisterAllEffects (self);
2339 2541
2340void 2542void
2341set_panning (CFPlus::Channel self, int left, int right) 2543set_panning (DC::Channel self, int left, int right)
2342 CODE: 2544 CODE:
2343 left = CLAMP (left , 0, 255); 2545 left = CLAMP (left , 0, 255);
2344 right = CLAMP (right, 0, 255); 2546 right = CLAMP (right, 0, 255);
2345 Mix_SetPanning (self, left, right); 2547 Mix_SetPanning (self, left, right);
2346 2548
2347void 2549void
2348set_distance (CFPlus::Channel self, int distance) 2550set_distance (DC::Channel self, int distance)
2349 CODE: 2551 CODE:
2350 Mix_SetDistance (self, CLAMP (distance, 0, 255)); 2552 Mix_SetDistance (self, CLAMP (distance, 0, 255));
2351 2553
2352void 2554void
2353set_position (CFPlus::Channel self, int angle, int distance) 2555set_position (DC::Channel self, int angle, int distance)
2354 CODE: 2556 CODE:
2557
2558void
2559set_position_r (DC::Channel self, int dx, int dy, int maxdistance)
2560 CODE:
2561{
2562 int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance));
2563 int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI);
2355 Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); 2564 Mix_SetPosition (self, angle, CLAMP (distance, 0, 255));
2565}
2356 2566
2357void 2567void
2358set_reverse_stereo (CFPlus::Channel self, int flip) 2568set_reverse_stereo (DC::Channel self, int flip)
2359 CODE: 2569 CODE:
2360 Mix_SetReverseStereo (self, flip); 2570 Mix_SetReverseStereo (self, flip);
2361 2571
2362MODULE = CFPlus PACKAGE = CFPlus::MixChunk 2572MODULE = Deliantra::Client PACKAGE = DC::MixChunk
2363 2573
2364PROTOTYPES: DISABLE 2574PROTOTYPES: DISABLE
2365 2575
2366CFPlus::MixChunk 2576DC::MixChunk
2367new (SV *class, CFPlus::RW rwops) 2577new (SV *class, DC::RW rwops)
2368 CODE: 2578 CODE:
2369 RETVAL = Mix_LoadWAV_RW (rwops, 1); 2579 RETVAL = Mix_LoadWAV_RW (rwops, 1);
2370 OUTPUT: 2580 OUTPUT:
2371 RETVAL 2581 RETVAL
2372 2582
2373void 2583void
2374DESTROY (CFPlus::MixChunk self) 2584DESTROY (DC::MixChunk self)
2375 CODE: 2585 CODE:
2376 Mix_FreeChunk (self); 2586 Mix_FreeChunk (self);
2377 2587
2378int 2588int
2379volume (CFPlus::MixChunk self, int volume = -1) 2589volume (DC::MixChunk self, int volume = -1)
2380 CODE: 2590 CODE:
2381 if (items > 1) 2591 if (items > 1)
2382 volume = CLAMP (volume, 0, 128); 2592 volume = CLAMP (volume, 0, 128);
2383 RETVAL = Mix_VolumeChunk (self, volume); 2593 RETVAL = Mix_VolumeChunk (self, volume);
2384 OUTPUT: 2594 OUTPUT:
2385 RETVAL 2595 RETVAL
2386 2596
2387CFPlus::Channel 2597DC::Channel
2388play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) 2598play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1)
2389 CODE: 2599 CODE:
2390{ 2600{
2391 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 2601 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
2392 2602
2393 if (RETVAL < 0) 2603 if (RETVAL < 0)
2400 } 2610 }
2401} 2611}
2402 OUTPUT: 2612 OUTPUT:
2403 RETVAL 2613 RETVAL
2404 2614
2405MODULE = CFPlus PACKAGE = CFPlus::MixMusic 2615MODULE = Deliantra::Client PACKAGE = DC::MixMusic
2406 2616
2407int 2617int
2408volume (int volume = -1) 2618volume (int volume = -1)
2409 PROTOTYPE: ;$ 2619 PROTOTYPE: ;$
2410 CODE: 2620 CODE:
2422void 2632void
2423halt () 2633halt ()
2424 CODE: 2634 CODE:
2425 Mix_HaltMusic (); 2635 Mix_HaltMusic ();
2426 2636
2427CFPlus::MixMusic 2637DC::MixMusic
2428new (SV *class, CFPlus::RW rwops) 2638new (SV *class, DC::RW rwops)
2429 CODE: 2639 CODE:
2430 RETVAL = Mix_LoadMUS_RW (rwops); 2640 RETVAL = Mix_LoadMUS_RW (rwops);
2431 OUTPUT: 2641 OUTPUT:
2432 RETVAL 2642 RETVAL
2433 2643
2434void 2644void
2435DESTROY (CFPlus::MixMusic self) 2645DESTROY (DC::MixMusic self)
2436 CODE: 2646 CODE:
2437 Mix_FreeMusic (self); 2647 Mix_FreeMusic (self);
2438 2648
2439int 2649int
2440play (CFPlus::MixMusic self, int loops = -1) 2650play (DC::MixMusic self, int loops = -1)
2441 CODE: 2651 CODE:
2442 RETVAL = Mix_PlayMusic (self, loops); 2652 RETVAL = Mix_PlayMusic (self, loops);
2443 OUTPUT: 2653 OUTPUT:
2444 RETVAL 2654 RETVAL
2445 2655
2446void 2656void
2447fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) 2657fade_in_pos (DC::MixMusic self, int loops, int ms, double position)
2448 CODE: 2658 CODE:
2449 Mix_FadeInMusicPos (self, loops, ms, position); 2659 Mix_FadeInMusicPos (self, loops, ms, position);
2450 2660
2451MODULE = CFPlus PACKAGE = CFPlus::OpenGL 2661MODULE = Deliantra::Client PACKAGE = DC::OpenGL
2452 2662
2453PROTOTYPES: ENABLE 2663PROTOTYPES: ENABLE
2454 2664
2455BOOT: 2665BOOT:
2456{ 2666{
2457 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); 2667 HV *stash = gv_stashpv ("DC::OpenGL", 1);
2458 static const struct { 2668 static const struct {
2459 const char *name; 2669 const char *name;
2460 IV iv; 2670 IV iv;
2461 } *civ, const_iv[] = { 2671 } *civ, const_iv[] = {
2462# define const_iv(name) { # name, (IV)name } 2672# define const_iv(name) { # name, (IV)name }
2497 const_iv (GL_INTENSITY), 2707 const_iv (GL_INTENSITY),
2498 const_iv (GL_LUMINANCE), 2708 const_iv (GL_LUMINANCE),
2499 const_iv (GL_LUMINANCE_ALPHA), 2709 const_iv (GL_LUMINANCE_ALPHA),
2500 const_iv (GL_FLOAT), 2710 const_iv (GL_FLOAT),
2501 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), 2711 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV),
2712 const_iv (GL_COMPRESSED_ALPHA_ARB),
2713 const_iv (GL_COMPRESSED_LUMINANCE_ARB),
2714 const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB),
2715 const_iv (GL_COMPRESSED_INTENSITY_ARB),
2716 const_iv (GL_COMPRESSED_RGB_ARB),
2717 const_iv (GL_COMPRESSED_RGBA_ARB),
2502 const_iv (GL_COMPILE), 2718 const_iv (GL_COMPILE),
2503 const_iv (GL_PROXY_TEXTURE_1D), 2719 const_iv (GL_PROXY_TEXTURE_1D),
2504 const_iv (GL_PROXY_TEXTURE_2D), 2720 const_iv (GL_PROXY_TEXTURE_2D),
2505 const_iv (GL_TEXTURE_1D), 2721 const_iv (GL_TEXTURE_1D),
2506 const_iv (GL_TEXTURE_2D), 2722 const_iv (GL_TEXTURE_2D),
2545 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 2761 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
2546 const_iv (GL_POINT_SMOOTH_HINT), 2762 const_iv (GL_POINT_SMOOTH_HINT),
2547 const_iv (GL_LINE_SMOOTH_HINT), 2763 const_iv (GL_LINE_SMOOTH_HINT),
2548 const_iv (GL_POLYGON_SMOOTH_HINT), 2764 const_iv (GL_POLYGON_SMOOTH_HINT),
2549 const_iv (GL_GENERATE_MIPMAP_HINT), 2765 const_iv (GL_GENERATE_MIPMAP_HINT),
2766 const_iv (GL_TEXTURE_COMPRESSION_HINT),
2550 const_iv (GL_FASTEST), 2767 const_iv (GL_FASTEST),
2551 const_iv (GL_DONT_CARE), 2768 const_iv (GL_DONT_CARE),
2552 const_iv (GL_NICEST), 2769 const_iv (GL_NICEST),
2553 const_iv (GL_V2F), 2770 const_iv (GL_V2F),
2554 const_iv (GL_V3F), 2771 const_iv (GL_V3F),
2562 2779
2563 texture_av = newAV (); 2780 texture_av = newAV ();
2564 AvREAL_off (texture_av); 2781 AvREAL_off (texture_av);
2565} 2782}
2566 2783
2784void
2785disable_GL_EXT_blend_func_separate ()
2786 CODE:
2787 gl.BlendFuncSeparate = 0;
2788 gl.BlendFuncSeparateEXT = 0;
2789
2567char * 2790char *
2568gl_vendor () 2791gl_vendor ()
2569 CODE: 2792 CODE:
2570 RETVAL = (char *)glGetString (GL_VENDOR); 2793 RETVAL = (char *)glGetString (GL_VENDOR);
2571 OUTPUT: 2794 OUTPUT:
2692 2915
2693void glRect (float x1, float y1, float x2, float y2) 2916void glRect (float x1, float y1, float x2, float y2)
2694 CODE: 2917 CODE:
2695 glRectf (x1, y1, x2, y2); 2918 glRectf (x1, y1, x2, y2);
2696 2919
2920void glRect_lineloop (float x1, float y1, float x2, float y2)
2921 CODE:
2922 glBegin (GL_LINE_LOOP);
2923 glVertex2f (x1, y1);
2924 glVertex2f (x2, y1);
2925 glVertex2f (x2, y2);
2926 glVertex2f (x1, y2);
2927 glEnd ();
2928
2697PROTOTYPES: ENABLE 2929PROTOTYPES: ENABLE
2698 2930
2699void glBegin (int mode) 2931void glBegin (int mode)
2700 2932
2701void glEnd () 2933void glEnd ()
2733void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) 2965void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column)
2734 CODE: 2966 CODE:
2735 if (gl.SeparableFilter2D) 2967 if (gl.SeparableFilter2D)
2736 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); 2968 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column);
2737 2969
2738void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) 2970void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0)
2739 2971
2740void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) 2972void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border)
2741 2973
2742void glDrawPixels (int width, int height, int format, int type, char *pixels) 2974void glDrawPixels (int width, int height, int format, int type, char *pixels)
2743 2975
2769 3001
2770void glEndList () 3002void glEndList ()
2771 3003
2772void glCallList (int list) 3004void glCallList (int list)
2773 3005
2774MODULE = CFPlus PACKAGE = CFPlus::UI::Base 3006MODULE = Deliantra::Client PACKAGE = DC::UI::Base
2775 3007
2776PROTOTYPES: DISABLE 3008PROTOTYPES: DISABLE
2777 3009
2778void 3010void
2779find_widget (SV *self, NV x, NV y) 3011find_widget (SV *self, NV x, NV y)
2783 XPUSHs (self); 3015 XPUSHs (self);
2784} 3016}
2785 3017
2786BOOT: 3018BOOT:
2787{ 3019{
2788 hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); 3020 hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV);
2789 3021
2790 draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); 3022 draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV);
2791 draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); 3023 draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV);
2792 draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); 3024 draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV);
2793 draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); 3025 draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV);
2794} 3026}
2795 3027
2796void 3028void
2797draw (SV *self) 3029draw (SV *self)
2798 CODE: 3030 CODE:
2802 NV x, y, w, h; 3034 NV x, y, w, h;
2803 SV *draw_x_sv = GvSV (draw_x_gv); 3035 SV *draw_x_sv = GvSV (draw_x_gv);
2804 SV *draw_y_sv = GvSV (draw_y_gv); 3036 SV *draw_y_sv = GvSV (draw_y_gv);
2805 SV *draw_w_sv = GvSV (draw_w_gv); 3037 SV *draw_w_sv = GvSV (draw_w_gv);
2806 SV *draw_h_sv = GvSV (draw_h_gv); 3038 SV *draw_h_sv = GvSV (draw_h_gv);
2807 SV *hover;
2808 double draw_x, draw_y, draw_w, draw_h; 3039 double draw_x, draw_y;
2809 3040
2810 if (!SvROK (self)) 3041 if (!SvROK (self))
2811 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); 3042 croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self));
2812 3043
2813 hv = (HV *)SvRV (self); 3044 hv = (HV *)SvRV (self);
2814 3045
2815 if (SvTYPE (hv) != SVt_PVHV) 3046 if (SvTYPE (hv) != SVt_PVHV)
2816 croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); 3047 croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self));
2817 3048
2818 svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; 3049 svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.;
2819 svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; 3050 svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.;
2820 3051
2821 if (!h || !w) 3052 if (!h || !w)
2841 { 3072 {
2842 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); 3073 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0);
2843 3074
2844 if (svp && SvTRUE (*svp)) 3075 if (svp && SvTRUE (*svp))
2845 { 3076 {
2846 glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); 3077 glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f);
2847 glEnable (GL_BLEND); 3078 glEnable (GL_BLEND);
2848 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 3079 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
2849 glBegin (GL_QUADS); 3080 glBegin (GL_QUADS);
2850 glVertex2f (0, 0); 3081 glVertex2f (0, 0);
2851 glVertex2f (w, 0); 3082 glVertex2f (w, 0);
2854 glEnd (); 3085 glEnd ();
2855 glDisable (GL_BLEND); 3086 glDisable (GL_BLEND);
2856 } 3087 }
2857 } 3088 }
2858#if 0 3089#if 0
2859 if ($ENV{CFPLUS_DEBUG} & 1) { 3090 // draw borders, for debugging
2860 glPushMatrix; 3091 glPushMatrix ();
2861 glColor 1, 1, 0, 1; 3092 glColor4f (1., 1., 0., 1.);
2862 glTranslate 0.375, 0.375; 3093 glTranslatef (.5, .5, 0.);
2863 glBegin GL_LINE_LOOP; 3094 glBegin (GL_LINE_LOOP);
2864 glVertex 0 , 0; 3095 glVertex2f (0 , 0);
2865 glVertex $self->{w} - 1, 0; 3096 glVertex2f (w - 1, 0);
2866 glVertex $self->{w} - 1, $self->{h} - 1; 3097 glVertex2f (w - 1, h - 1);
2867 glVertex 0 , $self->{h} - 1; 3098 glVertex2f (0 , h - 1);
2868 glEnd; 3099 glEnd ();
2869 glPopMatrix; 3100 glPopMatrix ();
2870 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
2871 }
2872#endif 3101#endif
2873 PUSHMARK (SP); 3102 PUSHMARK (SP);
2874 XPUSHs (self); 3103 XPUSHs (self);
2875 PUTBACK; 3104 PUTBACK;
2876 call_method ("_draw", G_VOID | G_DISCARD); 3105 call_method ("_draw", G_VOID | G_DISCARD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines