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.215 by root, Tue Jul 31 00:50:04 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 = 4096) 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{
1350 HV *hv = (HV *)SvRV (self); 1492 HV *hv = (HV *)SvRV (self);
1351 float s = SvNV (*hv_fetch (hv, "s", 1, 1)); 1493 float s = SvNV (*hv_fetch (hv, "s", 1, 1));
1352 float t = SvNV (*hv_fetch (hv, "t", 1, 1)); 1494 float t = SvNV (*hv_fetch (hv, "t", 1, 1));
1353 int name = SvIV (*hv_fetch (hv, "name", 4, 1)); 1495 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
1354 1496
1497 if (name <= 0)
1498 XSRETURN_EMPTY;
1499
1355 if (items < 5) 1500 if (items < 5)
1356 { 1501 {
1357 w = SvNV (*hv_fetch (hv, "w", 1, 1)); 1502 w = SvNV (*hv_fetch (hv, "w", 1, 1));
1358 h = SvNV (*hv_fetch (hv, "h", 1, 1)); 1503 h = SvNV (*hv_fetch (hv, "h", 1, 1));
1359 } 1504 }
1397 RETVAL = width > 0; 1542 RETVAL = width > 0;
1398} 1543}
1399 OUTPUT: 1544 OUTPUT:
1400 RETVAL 1545 RETVAL
1401 1546
1402MODULE = CFPlus PACKAGE = CFPlus::Map 1547MODULE = Deliantra::Client PACKAGE = DC::Map
1403 1548
1404PROTOTYPES: DISABLE 1549PROTOTYPES: DISABLE
1405 1550
1406CFPlus::Map 1551DC::Map
1407new (SV *class) 1552new (SV *class)
1408 CODE: 1553 CODE:
1409 New (0, RETVAL, 1, struct map); 1554 New (0, RETVAL, 1, struct map);
1410 RETVAL->x = 0; 1555 RETVAL->x = 0;
1411 RETVAL->y = 0; 1556 RETVAL->y = 0;
1419 RETVAL->row = 0; 1564 RETVAL->row = 0;
1420 OUTPUT: 1565 OUTPUT:
1421 RETVAL 1566 RETVAL
1422 1567
1423void 1568void
1424DESTROY (CFPlus::Map self) 1569DESTROY (DC::Map self)
1425 CODE: 1570 CODE:
1426{ 1571{
1427 map_clear (self); 1572 map_clear (self);
1428 Safefree (self->face2tile); 1573 Safefree (self->face2tile);
1429 Safefree (self->tex); 1574 Safefree (self->tex);
1430 Safefree (self); 1575 Safefree (self);
1431} 1576}
1432 1577
1433void 1578void
1434resize (CFPlus::Map self, int map_width, int map_height) 1579resize (DC::Map self, int map_width, int map_height)
1435 CODE: 1580 CODE:
1436 self->w = map_width; 1581 self->w = map_width;
1437 self->h = map_height; 1582 self->h = map_height;
1438 1583
1439void 1584void
1440clear (CFPlus::Map self) 1585clear (DC::Map self)
1441 CODE: 1586 CODE:
1442 map_clear (self); 1587 map_clear (self);
1443 1588
1444void 1589void
1445set_tileid (CFPlus::Map self, int face, int tile) 1590set_tileid (DC::Map self, int face, int tile)
1446 CODE: 1591 CODE:
1447{ 1592{
1448 need_facenum (self, face); self->face2tile [face] = tile; 1593 need_facenum (self, face); self->face2tile [face] = tile;
1449 need_texid (self, tile); 1594 need_texid (self, tile);
1450} 1595}
1451 1596
1452void 1597void
1453set_smooth (CFPlus::Map self, int face, int smooth, int level) 1598set_smooth (DC::Map self, int face, int smooth, int level)
1454 CODE: 1599 CODE:
1455{ 1600{
1456 tileid texid; 1601 tileid texid;
1457 maptex *tex; 1602 maptex *tex;
1458 1603
1471 tex->smoothtile = self->face2tile [smooth]; 1616 tex->smoothtile = self->face2tile [smooth];
1472 tex->smoothlevel = level; 1617 tex->smoothlevel = level;
1473} 1618}
1474 1619
1475void 1620void
1476set_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)
1477 CODE: 1622 CODE:
1478{ 1623{
1479 need_texid (self, texid); 1624 need_texid (self, texid);
1480 1625
1481 { 1626 {
1501 // from transparent color bleeding and ugly wrapping effects. 1646 // from transparent color bleeding and ugly wrapping effects.
1502 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1647 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1503} 1648}
1504 1649
1505int 1650int
1506ox (CFPlus::Map self) 1651ox (DC::Map self)
1507 ALIAS: 1652 ALIAS:
1508 oy = 1 1653 oy = 1
1509 x = 2 1654 x = 2
1510 y = 3 1655 y = 3
1511 w = 4 1656 w = 4
1522 } 1667 }
1523 OUTPUT: 1668 OUTPUT:
1524 RETVAL 1669 RETVAL
1525 1670
1526void 1671void
1527scroll (CFPlus::Map self, int dx, int dy) 1672scroll (DC::Map self, int dx, int dy)
1528 CODE: 1673 CODE:
1529{ 1674{
1530 if (dx > 0) 1675 if (dx > 0)
1531 map_blank (self, self->x, self->y, dx, self->h); 1676 map_blank (self, self->x, self->y, dx, self->h);
1532 else if (dx < 0) 1677 else if (dx < 0)
1547 self->rows += MAP_EXTEND_Y; 1692 self->rows += MAP_EXTEND_Y;
1548 self->y += MAP_EXTEND_Y; 1693 self->y += MAP_EXTEND_Y;
1549 } 1694 }
1550} 1695}
1551 1696
1552void 1697SV *
1553map1a_update (CFPlus::Map self, SV *data_, int extmap) 1698map1a_update (DC::Map self, SV *data_, int extmap)
1554 CODE: 1699 CODE:
1555{ 1700{
1556 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1701 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1557 uint8_t *data_end = (uint8_t *)SvEND (data_); 1702 uint8_t *data_end = (uint8_t *)SvEND (data_);
1558 mapcell *cell; 1703 mapcell *cell;
1559 int x, y, flags; 1704 int x, y, z, flags;
1705 AV *missing = newAV ();
1706 RETVAL = newRV_noinc ((SV *)missing);
1560 1707
1561 while (data < data_end - 1) 1708 while (data < data_end - 1)
1562 { 1709 {
1563 flags = (data [0] << 8) + data [1]; data += 2; 1710 flags = (data [0] << 8) + data [1]; data += 2;
1564 1711
1584 uint8_t ext, cmd; 1731 uint8_t ext, cmd;
1585 1732
1586 do 1733 do
1587 { 1734 {
1588 ext = *data++; 1735 ext = *data++;
1589 cmd = ext & 0x3f; 1736 cmd = ext & 0x7f;
1590 1737
1591 if (cmd < 4) 1738 if (cmd < 4)
1592 cell->darkness = 255 - ext * 64 + 1; 1739 cell->darkness = 255 - ext * 64 + 1;
1593 else if (cmd == 5) // health 1740 else if (cmd == 5) // health
1594 { 1741 {
1597 } 1744 }
1598 else if (cmd == 6) // monster width 1745 else if (cmd == 6) // monster width
1599 cell->stat_width = *data++ + 1; 1746 cell->stat_width = *data++ + 1;
1600 else if (cmd == 0x47) 1747 else if (cmd == 0x47)
1601 { 1748 {
1602 if (*data == 4) 1749 if (*data == 1) cell->player = data [1];
1603 ; // 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);
1604 1753
1605 data += *data + 1; 1754 data += *data + 1;
1606 } 1755 }
1607 else if (cmd == 8) // cell flags 1756 else if (cmd == 8) // cell flags
1608 cell->flags = *data++; 1757 cell->flags = *data++;
1615 } 1764 }
1616 else 1765 else
1617 cell->darkness = *data++ + 1; 1766 cell->darkness = *data++ + 1;
1618 } 1767 }
1619 1768
1769 for (z = 0; z <= 2; ++z)
1620 if (flags & 4) 1770 if (flags & (4 >> z))
1621 { 1771 {
1622 faceid face = (data [0] << 8) + data [1]; data += 2; 1772 faceid face = (data [0] << 8) + data [1]; data += 2;
1623 need_facenum (self, face); 1773 need_facenum (self, face);
1624 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 }
1625 } 1789 }
1626
1627 if (flags & 2)
1628 {
1629 faceid face = (data [0] << 8) + data [1]; data += 2;
1630 need_facenum (self, face);
1631 cell->tile [1] = self->face2tile [face];
1632 }
1633
1634 if (flags & 1)
1635 {
1636 faceid face = (data [0] << 8) + data [1]; data += 2;
1637 need_facenum (self, face);
1638 cell->tile [2] = self->face2tile [face];
1639 }
1640 } 1790 }
1641 else 1791 else
1642 cell->darkness = 0; 1792 CELL_CLEAR (cell);
1643 } 1793 }
1644} 1794}
1795 OUTPUT:
1796 RETVAL
1645 1797
1646SV * 1798SV *
1647mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1799mapmap (DC::Map self, int x0, int y0, int w, int h)
1648 CODE: 1800 CODE:
1649{ 1801{
1650 int x1, x; 1802 int x1, x;
1651 int y1, y; 1803 int y1, y;
1652 int z; 1804 int z;
1697} 1849}
1698 OUTPUT: 1850 OUTPUT:
1699 RETVAL 1851 RETVAL
1700 1852
1701void 1853void
1702draw (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)
1703 CODE: 1855 CODE:
1704{ 1856{
1857 int x, y, z;
1858
1705 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1859 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1706 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
1707 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)
1708 smooth_key skey; 1862 smooth_key skey;
1709 int x, y, z; 1863 int pl_x, pl_y;
1710 int last_name; 1864 maptex pl_tex;
1865 rc_t *rc = rc_alloc ();
1866 rc_key_t key;
1867 rc_array_t *arr;
1868
1869 pl_tex.name = 0;
1711 1870
1712 // thats current max. sorry. 1871 // thats current max. sorry.
1713 if (sw > 255) sw = 255; 1872 if (sw > 255) sw = 255;
1714 if (sh > 255) sh = 255; 1873 if (sh > 255) sh = 255;
1715 1874
1716 // clear key, in case of extra padding 1875 // clear key, in case of extra padding
1717 memset (&skey, 0, sizeof (skey)); 1876 memset (&skey, 0, sizeof (skey));
1718 1877
1719 glColor4ub (255, 255, 255, 255); 1878 memset (&key, 0, sizeof (key));
1720 1879 key.r = 255;
1721 glEnable (GL_BLEND); 1880 key.g = 255;
1722 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1881 key.b = 255;
1723 glEnable (GL_TEXTURE_2D); 1882 key.a = 255;
1724 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 1883 key.mode = GL_QUADS;
1725 1884 key.format = GL_T2F_V3F;
1726 glBegin (GL_QUADS); 1885 key.texname = -1;
1727
1728 last_name = 0;
1729 1886
1730 mx += self->x; 1887 mx += self->x;
1731 my += self->y; 1888 my += self->y;
1732 1889
1733 // first pass: determine smooth_max 1890 // first pass: determine smooth_max
1749 MAX (self->tex [cell->tile [0]].smoothlevel, 1906 MAX (self->tex [cell->tile [0]].smoothlevel,
1750 MAX (self->tex [cell->tile [1]].smoothlevel, 1907 MAX (self->tex [cell->tile [1]].smoothlevel,
1751 self->tex [cell->tile [2]].smoothlevel)); 1908 self->tex [cell->tile [2]].smoothlevel));
1752 } 1909 }
1753 } 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);
1754 1915
1755 for (z = 0; z <= 2; z++) 1916 for (z = 0; z <= 2; z++)
1756 { 1917 {
1757 memset (smooth_level, 0, sizeof (smooth_level)); 1918 memset (smooth_level, 0, sizeof (smooth_level));
1758 1919
1771 { 1932 {
1772 maptex tex = self->tex [tile]; 1933 maptex tex = self->tex [tile];
1773 int px = (x + 1) * T - tex.w; 1934 int px = (x + 1) * T - tex.w;
1774 int py = (y + 1) * T - tex.h; 1935 int py = (y + 1) * T - tex.h;
1775 1936
1776 // suppressing texture state switches here
1777 // is only moderately effective, but worth the extra effort
1778 if (last_name != tex.name) 1937 if (key.texname != tex.name)
1779 { 1938 {
1780 if (!tex.name) 1939 if (!tex.name)
1781 tex = self->tex [2]; /* missing, replace by noface */ 1940 tex = self->tex [2]; /* missing, replace by noface */
1782 1941
1783 glEnd (); 1942 key.texname = tex.name;
1784 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1943 arr = rc_array (rc, &key);
1785 glBegin (GL_QUADS);
1786 } 1944 }
1787 1945
1788 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1946 if (expect_false (cell->player == player) && expect_false (z == 2))
1789 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1790 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1791 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1792
1793 if (cell->flags && z == 2)
1794 { 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
1795 if (cell->flags & 1) 1962 if (cell->flags & 1)
1796 { 1963 {
1797 maptex tex = self->tex [1]; 1964 maptex tex = self->tex [1];
1798 int px = x * T + T * 2 / 32; 1965 int px = x * T + T * 2 / 32;
1799 int py = y * T - T * 6 / 32; 1966 int py = y * T - T * 6 / 32;
1800 1967
1968 if (tex.name)
1801 glEnd (); 1969 {
1802 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);
1803 glBegin (GL_QUADS); 1980 }
1804
1805 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1806 glTexCoord2f (0 , tex.t); glVertex2f (px , py + T);
1807 glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T);
1808 glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py );
1809 } 1981 }
1810 } 1982 }
1811 1983
1812 // update smooth hash 1984 // update smooth hash
1813 if (tex.smoothtile) 1985 if (tex.smoothtile)
1849 } 2021 }
1850 } 2022 }
1851 } 2023 }
1852 } 2024 }
1853 2025
2026 rc_draw (rc);
2027 rc_clear (rc);
2028
1854 // go through all smoothlevels, lowest to highest, then draw. 2029 // go through all smoothlevels, lowest to highest, then draw.
1855 // this is basically counting sort 2030 // this is basically counting sort
1856 { 2031 {
1857 int w, b; 2032 int w, b;
1858 2033
2034 glEnable (GL_TEXTURE_2D);
2035 glBegin (GL_QUADS);
1859 for (w = 0; w < 256 / 32; ++w) 2036 for (w = 0; w < 256 / 32; ++w)
1860 { 2037 {
1861 uint32_t smask = smooth_level [w]; 2038 uint32_t smask = smooth_level [w];
1862 if (smask) 2039 if (smask)
1863 for (b = 0; b < 32; ++b) 2040 for (b = 0; b < 32; ++b)
1882 int border = bits & 15; 2059 int border = bits & 15;
1883 int corner = (bits >> 8) & ~(bits >> 4) & 15; 2060 int corner = (bits >> 8) & ~(bits >> 4) & 15;
1884 float dx = tex.s * .0625f; // 16 images/row 2061 float dx = tex.s * .0625f; // 16 images/row
1885 float dy = tex.t * .5f ; // 2 images/column 2062 float dy = tex.t * .5f ; // 2 images/column
1886 2063
1887 // this time naively avoiding texture state changes
1888 // save gobs of state changes.
1889 if (last_name != tex.name) 2064 if (tex.name)
1890 { 2065 {
2066 // this time avoiding texture state changes
2067 // save gobs of state changes.
1891 if (!tex.name) 2068 if (key.texname != tex.name)
1892 continue; // smoothing not yet available 2069 {
1893
1894 glEnd (); 2070 glEnd ();
1895 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 2071 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
1896 glBegin (GL_QUADS); 2072 glBegin (GL_QUADS);
1897 } 2073 }
1898 2074
1899 if (border) 2075 if (border)
1900 { 2076 {
1901 float ox = border * dx; 2077 float ox = border * dx;
1902 2078
1903 glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); 2079 glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
1904 glTexCoord2f (ox , dy ); glVertex2f (px , py + T); 2080 glTexCoord2f (ox , dy ); glVertex2i (px , py + T);
1905 glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); 2081 glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T);
1906 glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); 2082 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py );
1907 } 2083 }
1908 2084
1909 if (corner) 2085 if (corner)
1910 { 2086 {
1911 float ox = corner * dx; 2087 float ox = corner * dx;
1912 2088
1913 glTexCoord2f (ox , dy ); glVertex2f (px , py ); 2089 glTexCoord2f (ox , dy ); glVertex2i (px , py );
1914 glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); 2090 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T);
1915 glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); 2091 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T);
1916 glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); 2092 glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py );
2093 }
1917 } 2094 }
1918 } 2095 }
1919 } 2096 }
1920 } 2097 }
1921 } 2098 }
2099
2100 glEnd ();
2101 glDisable (GL_TEXTURE_2D);
2102 key.texname = -1;
1922 } 2103 }
1923 2104
1924 hv_clear (smooth); 2105 hv_clear (smooth);
1925 } 2106 }
1926 2107
1927 glEnd (); 2108 if (pl_tex.name)
2109 {
2110 maptex tex = pl_tex;
2111 int px = pl_x + sdx;
2112 int py = pl_y + sdy;
1928 2113
1929 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
1930 glDisable (GL_BLEND); 2125 glDisable (GL_BLEND);
2126 rc_free (rc);
1931 2127
1932 // top layer: overlays such as the health bar 2128 // top layer: overlays such as the health bar
1933 for (y = 0; y < sh; y++) 2129 for (y = 0; y < sh; y++)
1934 if (0 <= y + my && y + my < self->rows) 2130 if (0 <= y + my && y + my < self->rows)
1935 { 2131 {
1960 } 2156 }
1961 } 2157 }
1962} 2158}
1963 2159
1964void 2160void
1965draw_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)
1966 CODE: 2162 CODE:
1967{ 2163{
1968 static float color[16][3] = { 2164 static float color[16][3] = {
1969 { 0.00F, 0.00F, 0.00F }, 2165 { 0.00F, 0.00F, 0.00F },
1970 { 1.00F, 1.00F, 1.00F }, 2166 { 1.00F, 1.00F, 1.00F },
2020 glDisable (GL_BLEND); 2216 glDisable (GL_BLEND);
2021 glDisable (GL_TEXTURE_2D); 2217 glDisable (GL_TEXTURE_2D);
2022} 2218}
2023 2219
2024void 2220void
2025fow_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)
2026 PPCODE: 2222 PPCODE:
2027{ 2223{
2028 int x, y; 2224 int x, y;
2029 int sw1 = sw + 2; 2225 int sw1 = sw + 2;
2030 int sh1 = sh + 2; 2226 int sh1 = sh + 2;
2101 PUSHs (sv_2mortal (newSViv (sh3))); 2297 PUSHs (sv_2mortal (newSViv (sh3)));
2102 PUSHs (darkness3_sv); 2298 PUSHs (darkness3_sv);
2103} 2299}
2104 2300
2105SV * 2301SV *
2106get_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)
2107 CODE: 2303 CODE:
2108{ 2304{
2109 int x, y, x1, y1; 2305 int x, y, x1, y1;
2110 SV *data_sv = newSV (w * h * 7 + 5); 2306 SV *data_sv = newSV (w * h * 7 + 5);
2111 uint8_t *data = (uint8_t *)SvPVX (data_sv); 2307 uint8_t *data = (uint8_t *)SvPVX (data_sv);
2168 else 2364 else
2169 *data++ = 0; 2365 *data++ = 0;
2170 } 2366 }
2171 } 2367 }
2172 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 {
2173 SvPOK_only (data_sv); 2372 SvPOK_only (data_sv);
2174 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); 2373 SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv));
2374 }
2375
2175 RETVAL = data_sv; 2376 RETVAL = data_sv;
2176} 2377}
2177 OUTPUT: 2378 OUTPUT:
2178 RETVAL 2379 RETVAL
2179 2380
2180void 2381void
2181set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) 2382set_rect (DC::Map self, int x0, int y0, SV *data_sv)
2182 PPCODE: 2383 PPCODE:
2183{ 2384{
2184 int x, y, z; 2385 int x, y, z;
2185 int w, h; 2386 int w, h;
2186 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;
2187 2398
2188 if (*data++ != 0) 2399 if (*data++ != 0)
2189 return; /* version mismatch */ 2400 XSRETURN_EMPTY; /* version mismatch */
2190 2401
2191 w = *data++ << 8; w |= *data++; 2402 w = *data++ << 8; w |= *data++;
2192 h = *data++ << 8; h |= *data++; 2403 h = *data++ << 8; h |= *data++;
2193 2404
2194 // 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
2206 { 2417 {
2207 maprow *row = map_get_row (self, y); 2418 maprow *row = map_get_row (self, y);
2208 2419
2209 for (x = x0; x < x1; x++) 2420 for (x = x0; x < x1; x++)
2210 { 2421 {
2422 uint8_t flags;
2423
2424 if (data + 7 >= end)
2425 XSRETURN_EMPTY;
2426
2211 uint8_t flags = *data++; 2427 flags = *data++;
2212 2428
2213 if (flags) 2429 if (flags)
2214 { 2430 {
2215 mapcell *cell = row_get_cell (row, x); 2431 mapcell *cell = row_get_cell (row, x);
2216 tileid tile[3] = { 0, 0, 0 }; 2432 tileid tile[3] = { 0, 0, 0 };
2219 if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } 2435 if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; }
2220 if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } 2436 if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; }
2221 2437
2222 if (cell->darkness == 0) 2438 if (cell->darkness == 0)
2223 { 2439 {
2224 cell->darkness = 0; 2440 /*cell->darkness = 0;*/
2441 EXTEND (SP, 3);
2225 2442
2226 for (z = 0; z <= 2; z++) 2443 for (z = 0; z <= 2; z++)
2227 { 2444 {
2228 tileid t = tile [z]; 2445 tileid t = tile [z];
2229 2446
2230 if (t >= self->texs || (t && !self->tex [t].name)) 2447 if (t >= self->texs || (t && !self->tex [t].name))
2231 { 2448 {
2232 XPUSHs (sv_2mortal (newSViv (t))); 2449 PUSHs (sv_2mortal (newSViv (t)));
2233 need_texid (self, t); 2450 need_texid (self, t);
2234 } 2451 }
2235 2452
2236 cell->tile [z] = t; 2453 cell->tile [z] = t;
2237 } 2454 }
2239 } 2456 }
2240 } 2457 }
2241 } 2458 }
2242} 2459}
2243 2460
2244MODULE = CFPlus PACKAGE = CFPlus::RW 2461MODULE = Deliantra::Client PACKAGE = DC::RW
2245 2462
2246CFPlus::RW 2463DC::RW
2247new (SV *class, SV *data_sv) 2464new (SV *class, SV *data_sv)
2248 CODE: 2465 CODE:
2249{ 2466{
2250 STRLEN datalen; 2467 STRLEN datalen;
2251 char *data = SvPVbyte (data_sv, datalen); 2468 char *data = SvPVbyte (data_sv, datalen);
2253 RETVAL = SDL_RWFromConstMem (data, datalen); 2470 RETVAL = SDL_RWFromConstMem (data, datalen);
2254} 2471}
2255 OUTPUT: 2472 OUTPUT:
2256 RETVAL 2473 RETVAL
2257 2474
2258CFPlus::RW 2475DC::RW
2259new_from_file (SV *class, const char *path, const char *mode = "rb") 2476new_from_file (SV *class, const char *path, const char *mode = "rb")
2260 CODE: 2477 CODE:
2261 RETVAL = SDL_RWFromFile (path, mode); 2478 RETVAL = SDL_RWFromFile (path, mode);
2262 OUTPUT: 2479 OUTPUT:
2263 RETVAL 2480 RETVAL
2264 2481
2482# fails on win32:
2483# dc.xs(2268) : error C2059: syntax error : '('
2265void 2484#void
2266close (CFPlus::RW self) 2485#close (DC::RW self)
2267 CODE: 2486# CODE:
2268 SDL_RWclose (self); 2487# (self->(close)) (self);
2269 2488
2270MODULE = CFPlus PACKAGE = CFPlus::Channel 2489MODULE = Deliantra::Client PACKAGE = DC::Channel
2271 2490
2272PROTOTYPES: DISABLE 2491PROTOTYPES: DISABLE
2273 2492
2274CFPlus::Channel 2493DC::Channel
2275find () 2494find ()
2276 CODE: 2495 CODE:
2277{ 2496{
2278 RETVAL = Mix_GroupAvailable (-1); 2497 RETVAL = Mix_GroupAvailable (-1);
2279 2498
2292} 2511}
2293 OUTPUT: 2512 OUTPUT:
2294 RETVAL 2513 RETVAL
2295 2514
2296void 2515void
2297halt (CFPlus::Channel self) 2516halt (DC::Channel self)
2298 CODE: 2517 CODE:
2299 Mix_HaltChannel (self); 2518 Mix_HaltChannel (self);
2300 2519
2301void 2520void
2302expire (CFPlus::Channel self, int ticks = -1) 2521expire (DC::Channel self, int ticks = -1)
2303 CODE: 2522 CODE:
2304 Mix_ExpireChannel (self, ticks); 2523 Mix_ExpireChannel (self, ticks);
2305 2524
2306void 2525void
2307fade_out (CFPlus::Channel self, int ticks = -1) 2526fade_out (DC::Channel self, int ticks = -1)
2308 CODE: 2527 CODE:
2309 Mix_FadeOutChannel (self, ticks); 2528 Mix_FadeOutChannel (self, ticks);
2310 2529
2311int 2530int
2312volume (CFPlus::Channel self, int volume) 2531volume (DC::Channel self, int volume)
2313 CODE: 2532 CODE:
2314 RETVAL = Mix_Volume (self, volume); 2533 RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128));
2315 OUTPUT: 2534 OUTPUT:
2316 RETVAL 2535 RETVAL
2317 2536
2318void 2537void
2319unregister_all_effects (CFPlus::Channel self) 2538unregister_all_effects (DC::Channel self)
2320 CODE: 2539 CODE:
2321 Mix_UnregisterAllEffects (self); 2540 Mix_UnregisterAllEffects (self);
2322 2541
2323void 2542void
2324set_panning (CFPlus::Channel self, int left, int right) 2543set_panning (DC::Channel self, int left, int right)
2325 CODE: 2544 CODE:
2545 left = CLAMP (left , 0, 255);
2546 right = CLAMP (right, 0, 255);
2326 Mix_SetPanning (self, left, right); 2547 Mix_SetPanning (self, left, right);
2327 2548
2328void 2549void
2329set_distance (CFPlus::Channel self, int distance) 2550set_distance (DC::Channel self, int distance)
2330 CODE: 2551 CODE:
2331 Mix_SetDistance (self, distance); 2552 Mix_SetDistance (self, CLAMP (distance, 0, 255));
2332 2553
2333void 2554void
2334set_position (CFPlus::Channel self, int angle, int distance) 2555set_position (DC::Channel self, int angle, int distance)
2335 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);
2336 Mix_SetPosition (self, angle, distance); 2564 Mix_SetPosition (self, angle, CLAMP (distance, 0, 255));
2565}
2337 2566
2338void 2567void
2339set_reverse_stereo (CFPlus::Channel self, int flip) 2568set_reverse_stereo (DC::Channel self, int flip)
2340 CODE: 2569 CODE:
2341 Mix_SetReverseStereo (self, flip); 2570 Mix_SetReverseStereo (self, flip);
2342 2571
2343MODULE = CFPlus PACKAGE = CFPlus::MixChunk 2572MODULE = Deliantra::Client PACKAGE = DC::MixChunk
2344 2573
2345PROTOTYPES: DISABLE 2574PROTOTYPES: DISABLE
2346 2575
2347CFPlus::MixChunk 2576DC::MixChunk
2348new (SV *class, CFPlus::RW rwops) 2577new (SV *class, DC::RW rwops)
2349 CODE: 2578 CODE:
2350 RETVAL = Mix_LoadWAV_RW (rwops, 1); 2579 RETVAL = Mix_LoadWAV_RW (rwops, 1);
2351 OUTPUT: 2580 OUTPUT:
2352 RETVAL 2581 RETVAL
2353 2582
2354void 2583void
2355DESTROY (CFPlus::MixChunk self) 2584DESTROY (DC::MixChunk self)
2356 CODE: 2585 CODE:
2357 Mix_FreeChunk (self); 2586 Mix_FreeChunk (self);
2358 2587
2359int 2588int
2360volume (CFPlus::MixChunk self, int volume = -1) 2589volume (DC::MixChunk self, int volume = -1)
2361 CODE: 2590 CODE:
2591 if (items > 1)
2592 volume = CLAMP (volume, 0, 128);
2362 RETVAL = Mix_VolumeChunk (self, volume); 2593 RETVAL = Mix_VolumeChunk (self, volume);
2363 OUTPUT: 2594 OUTPUT:
2364 RETVAL 2595 RETVAL
2365 2596
2366CFPlus::Channel 2597DC::Channel
2367play (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)
2368 CODE: 2599 CODE:
2369{ 2600{
2370 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 2601 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
2371 2602
2372 if (RETVAL < 0) 2603 if (RETVAL < 0)
2379 } 2610 }
2380} 2611}
2381 OUTPUT: 2612 OUTPUT:
2382 RETVAL 2613 RETVAL
2383 2614
2384MODULE = CFPlus PACKAGE = CFPlus::MixMusic 2615MODULE = Deliantra::Client PACKAGE = DC::MixMusic
2385 2616
2386int 2617int
2387volume (int volume = -1) 2618volume (int volume = -1)
2388 PROTOTYPE: ;$ 2619 PROTOTYPE: ;$
2389 CODE: 2620 CODE:
2621 if (items > 0)
2622 volume = CLAMP (volume, 0, 128);
2390 RETVAL = Mix_VolumeMusic (volume); 2623 RETVAL = Mix_VolumeMusic (volume);
2391 OUTPUT: 2624 OUTPUT:
2392 RETVAL 2625 RETVAL
2393 2626
2394void 2627void
2399void 2632void
2400halt () 2633halt ()
2401 CODE: 2634 CODE:
2402 Mix_HaltMusic (); 2635 Mix_HaltMusic ();
2403 2636
2404CFPlus::MixMusic 2637DC::MixMusic
2405new (SV *class, CFPlus::RW rwops) 2638new (SV *class, DC::RW rwops)
2406 CODE: 2639 CODE:
2407 RETVAL = Mix_LoadMUS_RW (rwops); 2640 RETVAL = Mix_LoadMUS_RW (rwops);
2408 OUTPUT: 2641 OUTPUT:
2409 RETVAL 2642 RETVAL
2410 2643
2411void 2644void
2412DESTROY (CFPlus::MixMusic self) 2645DESTROY (DC::MixMusic self)
2413 CODE: 2646 CODE:
2414 Mix_FreeMusic (self); 2647 Mix_FreeMusic (self);
2415 2648
2416int 2649int
2417play (CFPlus::MixMusic self, int loops = -1) 2650play (DC::MixMusic self, int loops = -1)
2418 CODE: 2651 CODE:
2419 RETVAL = Mix_PlayMusic (self, loops); 2652 RETVAL = Mix_PlayMusic (self, loops);
2420 OUTPUT: 2653 OUTPUT:
2421 RETVAL 2654 RETVAL
2422 2655
2423void 2656void
2424fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) 2657fade_in_pos (DC::MixMusic self, int loops, int ms, double position)
2425 CODE: 2658 CODE:
2426 Mix_FadeInMusicPos (self, loops, ms, position); 2659 Mix_FadeInMusicPos (self, loops, ms, position);
2427 2660
2428MODULE = CFPlus PACKAGE = CFPlus::OpenGL 2661MODULE = Deliantra::Client PACKAGE = DC::OpenGL
2429 2662
2430PROTOTYPES: ENABLE 2663PROTOTYPES: ENABLE
2431 2664
2432BOOT: 2665BOOT:
2433{ 2666{
2434 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); 2667 HV *stash = gv_stashpv ("DC::OpenGL", 1);
2435 static const struct { 2668 static const struct {
2436 const char *name; 2669 const char *name;
2437 IV iv; 2670 IV iv;
2438 } *civ, const_iv[] = { 2671 } *civ, const_iv[] = {
2439# define const_iv(name) { # name, (IV)name } 2672# define const_iv(name) { # name, (IV)name }
2474 const_iv (GL_INTENSITY), 2707 const_iv (GL_INTENSITY),
2475 const_iv (GL_LUMINANCE), 2708 const_iv (GL_LUMINANCE),
2476 const_iv (GL_LUMINANCE_ALPHA), 2709 const_iv (GL_LUMINANCE_ALPHA),
2477 const_iv (GL_FLOAT), 2710 const_iv (GL_FLOAT),
2478 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),
2479 const_iv (GL_COMPILE), 2718 const_iv (GL_COMPILE),
2480 const_iv (GL_PROXY_TEXTURE_1D), 2719 const_iv (GL_PROXY_TEXTURE_1D),
2481 const_iv (GL_PROXY_TEXTURE_2D), 2720 const_iv (GL_PROXY_TEXTURE_2D),
2482 const_iv (GL_TEXTURE_1D), 2721 const_iv (GL_TEXTURE_1D),
2483 const_iv (GL_TEXTURE_2D), 2722 const_iv (GL_TEXTURE_2D),
2522 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 2761 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
2523 const_iv (GL_POINT_SMOOTH_HINT), 2762 const_iv (GL_POINT_SMOOTH_HINT),
2524 const_iv (GL_LINE_SMOOTH_HINT), 2763 const_iv (GL_LINE_SMOOTH_HINT),
2525 const_iv (GL_POLYGON_SMOOTH_HINT), 2764 const_iv (GL_POLYGON_SMOOTH_HINT),
2526 const_iv (GL_GENERATE_MIPMAP_HINT), 2765 const_iv (GL_GENERATE_MIPMAP_HINT),
2766 const_iv (GL_TEXTURE_COMPRESSION_HINT),
2527 const_iv (GL_FASTEST), 2767 const_iv (GL_FASTEST),
2528 const_iv (GL_DONT_CARE), 2768 const_iv (GL_DONT_CARE),
2529 const_iv (GL_NICEST), 2769 const_iv (GL_NICEST),
2530 const_iv (GL_V2F), 2770 const_iv (GL_V2F),
2531 const_iv (GL_V3F), 2771 const_iv (GL_V3F),
2539 2779
2540 texture_av = newAV (); 2780 texture_av = newAV ();
2541 AvREAL_off (texture_av); 2781 AvREAL_off (texture_av);
2542} 2782}
2543 2783
2784void
2785disable_GL_EXT_blend_func_separate ()
2786 CODE:
2787 gl.BlendFuncSeparate = 0;
2788 gl.BlendFuncSeparateEXT = 0;
2789
2544char * 2790char *
2545gl_vendor () 2791gl_vendor ()
2546 CODE: 2792 CODE:
2547 RETVAL = (char *)glGetString (GL_VENDOR); 2793 RETVAL = (char *)glGetString (GL_VENDOR);
2548 OUTPUT: 2794 OUTPUT:
2669 2915
2670void glRect (float x1, float y1, float x2, float y2) 2916void glRect (float x1, float y1, float x2, float y2)
2671 CODE: 2917 CODE:
2672 glRectf (x1, y1, x2, y2); 2918 glRectf (x1, y1, x2, y2);
2673 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
2674PROTOTYPES: ENABLE 2929PROTOTYPES: ENABLE
2675 2930
2676void glBegin (int mode) 2931void glBegin (int mode)
2677 2932
2678void glEnd () 2933void glEnd ()
2710void 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)
2711 CODE: 2966 CODE:
2712 if (gl.SeparableFilter2D) 2967 if (gl.SeparableFilter2D)
2713 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); 2968 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column);
2714 2969
2715void 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)
2716 2971
2717void 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)
2718 2973
2719void glDrawPixels (int width, int height, int format, int type, char *pixels) 2974void glDrawPixels (int width, int height, int format, int type, char *pixels)
2720 2975
2746 3001
2747void glEndList () 3002void glEndList ()
2748 3003
2749void glCallList (int list) 3004void glCallList (int list)
2750 3005
2751MODULE = CFPlus PACKAGE = CFPlus::UI::Base 3006MODULE = Deliantra::Client PACKAGE = DC::UI::Base
2752 3007
2753PROTOTYPES: DISABLE 3008PROTOTYPES: DISABLE
2754 3009
2755void 3010void
2756find_widget (SV *self, NV x, NV y) 3011find_widget (SV *self, NV x, NV y)
2760 XPUSHs (self); 3015 XPUSHs (self);
2761} 3016}
2762 3017
2763BOOT: 3018BOOT:
2764{ 3019{
2765 hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); 3020 hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV);
2766 3021
2767 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);
2768 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);
2769 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);
2770 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);
2771} 3026}
2772 3027
2773void 3028void
2774draw (SV *self) 3029draw (SV *self)
2775 CODE: 3030 CODE:
2779 NV x, y, w, h; 3034 NV x, y, w, h;
2780 SV *draw_x_sv = GvSV (draw_x_gv); 3035 SV *draw_x_sv = GvSV (draw_x_gv);
2781 SV *draw_y_sv = GvSV (draw_y_gv); 3036 SV *draw_y_sv = GvSV (draw_y_gv);
2782 SV *draw_w_sv = GvSV (draw_w_gv); 3037 SV *draw_w_sv = GvSV (draw_w_gv);
2783 SV *draw_h_sv = GvSV (draw_h_gv); 3038 SV *draw_h_sv = GvSV (draw_h_gv);
2784 SV *hover;
2785 double draw_x, draw_y, draw_w, draw_h; 3039 double draw_x, draw_y;
2786 3040
2787 if (!SvROK (self)) 3041 if (!SvROK (self))
2788 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); 3042 croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self));
2789 3043
2790 hv = (HV *)SvRV (self); 3044 hv = (HV *)SvRV (self);
2791 3045
2792 if (SvTYPE (hv) != SVt_PVHV) 3046 if (SvTYPE (hv) != SVt_PVHV)
2793 croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); 3047 croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self));
2794 3048
2795 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.;
2796 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.;
2797 3051
2798 if (!h || !w) 3052 if (!h || !w)
2818 { 3072 {
2819 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); 3073 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0);
2820 3074
2821 if (svp && SvTRUE (*svp)) 3075 if (svp && SvTRUE (*svp))
2822 { 3076 {
2823 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);
2824 glEnable (GL_BLEND); 3078 glEnable (GL_BLEND);
2825 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 3079 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
2826 glBegin (GL_QUADS); 3080 glBegin (GL_QUADS);
2827 glVertex2f (0, 0); 3081 glVertex2f (0, 0);
2828 glVertex2f (w, 0); 3082 glVertex2f (w, 0);
2831 glEnd (); 3085 glEnd ();
2832 glDisable (GL_BLEND); 3086 glDisable (GL_BLEND);
2833 } 3087 }
2834 } 3088 }
2835#if 0 3089#if 0
2836 if ($ENV{CFPLUS_DEBUG} & 1) { 3090 // draw borders, for debugging
2837 glPushMatrix; 3091 glPushMatrix ();
2838 glColor 1, 1, 0, 1; 3092 glColor4f (1., 1., 0., 1.);
2839 glTranslate 0.375, 0.375; 3093 glTranslatef (.5, .5, 0.);
2840 glBegin GL_LINE_LOOP; 3094 glBegin (GL_LINE_LOOP);
2841 glVertex 0 , 0; 3095 glVertex2f (0 , 0);
2842 glVertex $self->{w} - 1, 0; 3096 glVertex2f (w - 1, 0);
2843 glVertex $self->{w} - 1, $self->{h} - 1; 3097 glVertex2f (w - 1, h - 1);
2844 glVertex 0 , $self->{h} - 1; 3098 glVertex2f (0 , h - 1);
2845 glEnd; 3099 glEnd ();
2846 glPopMatrix; 3100 glPopMatrix ();
2847 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
2848 }
2849#endif 3101#endif
2850 PUSHMARK (SP); 3102 PUSHMARK (SP);
2851 XPUSHs (self); 3103 XPUSHs (self);
2852 PUTBACK; 3104 PUTBACK;
2853 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