… | |
… | |
46 | |
46 | |
47 | #include <glib/gmacros.h> |
47 | #include <glib/gmacros.h> |
48 | |
48 | |
49 | #include <pango/pango.h> |
49 | #include <pango/pango.h> |
50 | |
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 |
|
|
61 | |
51 | #ifndef _WIN32 |
62 | #ifndef _WIN32 |
52 | # include <sys/types.h> |
63 | # include <sys/types.h> |
53 | # include <sys/socket.h> |
64 | # include <sys/socket.h> |
54 | # include <netinet/in.h> |
65 | # include <netinet/in.h> |
55 | # include <netinet/tcp.h> |
66 | # include <netinet/tcp.h> |
56 | # include <inttypes.h> |
67 | # include <inttypes.h> |
57 | #endif |
68 | #endif |
58 | |
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 | |
59 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
79 | #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ |
60 | |
80 | |
61 | #define FOW_DARKNESS 32 |
81 | #define FOW_DARKNESS 32 |
62 | |
82 | |
63 | #define MAP_EXTEND_X 32 |
83 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
84 | #define MAP_EXTEND_Y 512 |
65 | |
85 | |
66 | #define MIN_FONT_HEIGHT 10 |
86 | #define MIN_FONT_HEIGHT 10 |
67 | |
87 | |
68 | #if 0 |
88 | /* mask out modifiers we are not interested in */ |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
89 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
70 | #else |
|
|
71 | # define PARACHUTE 0 |
|
|
72 | #endif |
|
|
73 | |
90 | |
74 | static AV *texture_av; |
91 | static AV *texture_av; |
75 | |
92 | |
76 | static struct |
93 | static struct |
77 | { |
94 | { |
… | |
… | |
120 | |
137 | |
121 | #include "pango-font.c" |
138 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
139 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
140 | #include "pango-render.c" |
124 | |
141 | |
125 | typedef IV CFPlus__Channel; |
142 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
143 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
144 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
145 | typedef Mix_Music *DC__MixMusic; |
129 | |
146 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
147 | typedef PangoFontDescription *DC__Font; |
131 | |
148 | |
132 | static int |
149 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
150 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
151 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
152 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
166 | |
150 | typedef struct cf_layout { |
167 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
168 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
169 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
170 | int base_height; |
154 | CFPlus__Font font; |
171 | DC__Font font; |
155 | rc_t *rc; |
172 | rc_t *rc; |
156 | } *CFPlus__Layout; |
173 | } *DC__Layout; |
157 | |
174 | |
158 | static CFPlus__Font default_font; |
175 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
176 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
177 | static PangoFontMap *opengl_fontmap; |
161 | |
178 | |
162 | static void |
179 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
180 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
185 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
186 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
187 | } |
171 | |
188 | |
172 | static void |
189 | static void |
173 | layout_update_font (CFPlus__Layout self) |
190 | layout_update_font (DC__Layout self) |
174 | { |
191 | { |
175 | /* 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 |
176 | * reasonably well with bitstream vera |
193 | * reasonably well with dejavu/bistream fonts |
177 | */ |
194 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
195 | PangoFontDescription *font = self->font ? self->font : default_font; |
179 | |
196 | |
180 | pango_font_description_set_absolute_size (font, |
197 | pango_font_description_set_absolute_size (font, |
181 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
198 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
182 | |
199 | |
183 | pango_layout_set_font_description (self->pl, font); |
200 | pango_layout_set_font_description (self->pl, font); |
184 | } |
201 | } |
185 | |
202 | |
186 | static void |
203 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
204 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
205 | { |
189 | PangoRectangle rect; |
206 | PangoRectangle rect; |
190 | |
207 | |
191 | // get_pixel_* wrongly rounds down |
208 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
209 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
248 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
249 | int texs; maptex *tex; // [tileid] |
233 | |
250 | |
234 | int32_t rows; |
251 | int32_t rows; |
235 | maprow *row; |
252 | maprow *row; |
236 | } *CFPlus__Map; |
253 | } *DC__Map; |
237 | |
254 | |
238 | static char * |
255 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
256 | prepend (char *ptr, int sze, int inc) |
240 | { |
257 | { |
241 | char *p; |
258 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
296 | self->texs *= 2; |
280 | } |
297 | } |
281 | } |
298 | } |
282 | |
299 | |
283 | static maprow * |
300 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
301 | map_get_row (DC__Map self, int y) |
285 | { |
302 | { |
286 | if (0 > y) |
303 | if (0 > y) |
287 | { |
304 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
305 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
306 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
344 | |
328 | return row->col + (x - row->c0); |
345 | return row->col + (x - row->c0); |
329 | } |
346 | } |
330 | |
347 | |
331 | static mapcell * |
348 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
349 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
350 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
351 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
352 | } |
336 | |
353 | |
337 | static void |
354 | static void |
338 | map_clear (CFPlus__Map self) |
355 | map_clear (DC__Map self) |
339 | { |
356 | { |
340 | int r; |
357 | int r; |
341 | |
358 | |
342 | for (r = 0; r < self->rows; r++) |
359 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
360 | Safefree (self->row[r].col); |
… | |
… | |
350 | self->oy = 0; |
367 | self->oy = 0; |
351 | self->row = 0; |
368 | self->row = 0; |
352 | self->rows = 0; |
369 | self->rows = 0; |
353 | } |
370 | } |
354 | |
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 | |
355 | static void |
382 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
383 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
384 | { |
358 | int x, y; |
385 | int x, y; |
359 | maprow *row; |
386 | maprow *row; |
360 | mapcell *cell; |
387 | mapcell *cell; |
361 | |
388 | |
… | |
… | |
373 | if (x >= row->c1) |
400 | if (x >= row->c1) |
374 | break; |
401 | break; |
375 | |
402 | |
376 | cell = row->col + x - row->c0; |
403 | cell = row->col + x - row->c0; |
377 | |
404 | |
378 | cell->darkness = 0; |
405 | CELL_CLEAR (cell); |
379 | cell->stat_hp = 0; |
|
|
380 | cell->flags = 0; |
|
|
381 | cell->player = 0; |
|
|
382 | } |
406 | } |
383 | } |
407 | } |
384 | } |
408 | } |
385 | |
409 | |
386 | typedef struct { |
410 | typedef struct { |
… | |
… | |
440 | n |= n >> 16; |
464 | n |= n >> 16; |
441 | |
465 | |
442 | return n + 1; |
466 | return n + 1; |
443 | } |
467 | } |
444 | |
468 | |
|
|
469 | static unsigned int |
|
|
470 | popcount (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 | |
445 | /* SDL should provide this, really. */ |
480 | /* SDL should provide this, really. */ |
446 | #define SDLK_MODIFIER_MIN 300 |
481 | #define SDLK_MODIFIER_MIN 300 |
447 | #define SDLK_MODIFIER_MAX 314 |
482 | #define SDLK_MODIFIER_MAX 314 |
448 | |
483 | |
449 | /******************************************************************************/ |
484 | /******************************************************************************/ |
… | |
… | |
487 | return 0; |
522 | return 0; |
488 | |
523 | |
489 | return 1; |
524 | return 1; |
490 | } |
525 | } |
491 | |
526 | |
492 | MODULE = CFPlus PACKAGE = CFPlus |
527 | MODULE = Deliantra::Client PACKAGE = DC |
493 | |
528 | |
494 | PROTOTYPES: ENABLE |
529 | PROTOTYPES: ENABLE |
495 | |
530 | |
496 | BOOT: |
531 | BOOT: |
497 | { |
532 | { |
498 | HV *stash = gv_stashpv ("CFPlus", 1); |
533 | HV *stash = gv_stashpv ("DC", 1); |
499 | static const struct { |
534 | static const struct { |
500 | const char *name; |
535 | const char *name; |
501 | IV iv; |
536 | IV iv; |
502 | } *civ, const_iv[] = { |
537 | } *civ, const_iv[] = { |
503 | # define const_iv(name) { # name, (IV)name } |
538 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
525 | |
560 | |
526 | const_iv (SDL_APPINPUTFOCUS), |
561 | const_iv (SDL_APPINPUTFOCUS), |
527 | const_iv (SDL_APPMOUSEFOCUS), |
562 | const_iv (SDL_APPMOUSEFOCUS), |
528 | const_iv (SDL_APPACTIVE), |
563 | const_iv (SDL_APPACTIVE), |
529 | |
564 | |
|
|
565 | const_iv (SDLK_FIRST), |
|
|
566 | const_iv (SDLK_LAST), |
530 | const_iv (SDLK_KP0), |
567 | const_iv (SDLK_KP0), |
531 | const_iv (SDLK_KP1), |
568 | const_iv (SDLK_KP1), |
532 | const_iv (SDLK_KP2), |
569 | const_iv (SDLK_KP2), |
533 | const_iv (SDLK_KP3), |
570 | const_iv (SDLK_KP3), |
534 | const_iv (SDLK_KP4), |
571 | const_iv (SDLK_KP4), |
… | |
… | |
606 | const_iv (KMOD_LMETA), |
643 | const_iv (KMOD_LMETA), |
607 | const_iv (KMOD_RMETA), |
644 | const_iv (KMOD_RMETA), |
608 | const_iv (KMOD_NUM), |
645 | const_iv (KMOD_NUM), |
609 | const_iv (KMOD_CAPS), |
646 | const_iv (KMOD_CAPS), |
610 | 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) |
611 | # undef const_iv |
677 | # undef const_iv |
612 | }; |
678 | }; |
613 | |
679 | |
614 | 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; ) |
615 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
681 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
633 | |
699 | |
634 | NV floor (NV x) |
700 | NV floor (NV x) |
635 | |
701 | |
636 | NV ceil (NV x) |
702 | NV ceil (NV x) |
637 | |
703 | |
|
|
704 | IV minpot (UV n) |
|
|
705 | |
|
|
706 | IV popcount (UV n) |
|
|
707 | |
638 | void |
708 | void |
639 | pango_init () |
709 | pango_init () |
640 | CODE: |
710 | CODE: |
641 | { |
711 | { |
642 | opengl_fontmap = pango_opengl_font_map_new (); |
712 | opengl_fontmap = pango_opengl_font_map_new (); |
643 | 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); |
644 | 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 |
645 | } |
720 | } |
646 | |
721 | |
647 | char * |
|
|
648 | SDL_GetError () |
722 | char *SDL_GetError () |
649 | |
723 | |
650 | int |
724 | int SDL_Init (U32 flags) |
651 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | PARACHUTE) |
|
|
652 | |
725 | |
653 | void |
726 | int SDL_InitSubSystem (U32 flags) |
|
|
727 | |
|
|
728 | void SDL_QuitSubSystem (U32 flags) |
|
|
729 | |
654 | SDL_Quit () |
730 | void SDL_Quit () |
|
|
731 | |
|
|
732 | int SDL_GL_SetAttribute (int attr, int value) |
|
|
733 | |
|
|
734 | int SDL_GL_GetAttribute (int attr) |
|
|
735 | CODE: |
|
|
736 | if (SDL_GL_GetAttribute (attr, &RETVAL)) |
|
|
737 | XSRETURN_UNDEF; |
|
|
738 | OUTPUT: |
|
|
739 | RETVAL |
655 | |
740 | |
656 | void |
741 | void |
657 | SDL_ListModes (int rgb, int alpha) |
742 | SDL_ListModes (int rgb, int alpha) |
658 | PPCODE: |
743 | PPCODE: |
659 | { |
744 | { |
… | |
… | |
671 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
756 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
672 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
757 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE , 0); |
673 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
758 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
674 | |
759 | |
675 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
760 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
676 | #if SDL_VERSION_ATLEAST(1,2,10) |
|
|
677 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
678 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
761 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
679 | #endif |
|
|
680 | |
762 | |
681 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
763 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
682 | |
764 | |
683 | if (m && m != (SDL_Rect **)-1) |
765 | if (m && m != (SDL_Rect **)-1) |
684 | while (*m) |
766 | while (*m) |
685 | { |
767 | { |
686 | if ((*m)->w >= 640 && (*m)->h >= 480) |
768 | if ((*m)->w >= 400 && (*m)->h >= 300) |
687 | { |
769 | { |
688 | AV *av = newAV (); |
770 | AV *av = newAV (); |
689 | av_push (av, newSViv ((*m)->w)); |
771 | av_push (av, newSViv ((*m)->w)); |
690 | av_push (av, newSViv ((*m)->h)); |
772 | av_push (av, newSViv ((*m)->h)); |
691 | av_push (av, newSViv (rgb)); |
773 | av_push (av, newSViv (rgb)); |
… | |
… | |
715 | |
797 | |
716 | if (RETVAL) |
798 | if (RETVAL) |
717 | { |
799 | { |
718 | av_clear (texture_av); |
800 | av_clear (texture_av); |
719 | |
801 | |
720 | SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT"); |
802 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
721 | #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); |
722 | #include "glfunc.h" |
804 | #include "glfunc.h" |
723 | #undef GL_FUNC |
805 | #undef GL_FUNC |
724 | } |
806 | } |
725 | } |
807 | } |
… | |
… | |
732 | char * |
814 | char * |
733 | SDL_GetKeyName (int sym) |
815 | SDL_GetKeyName (int sym) |
734 | |
816 | |
735 | int |
817 | int |
736 | SDL_GetAppState () |
818 | SDL_GetAppState () |
|
|
819 | |
|
|
820 | int |
|
|
821 | SDL_GetModState () |
737 | |
822 | |
738 | void |
823 | void |
739 | poll_events () |
824 | poll_events () |
740 | PPCODE: |
825 | PPCODE: |
741 | { |
826 | { |
… | |
… | |
751 | { |
836 | { |
752 | case SDL_KEYDOWN: |
837 | case SDL_KEYDOWN: |
753 | case SDL_KEYUP: |
838 | case SDL_KEYUP: |
754 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
839 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
755 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
840 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
756 | 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); |
757 | 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 */ |
758 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
843 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
759 | break; |
844 | break; |
760 | |
845 | |
761 | case SDL_ACTIVEEVENT: |
846 | case SDL_ACTIVEEVENT: |
762 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
847 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
780 | x = ev.motion.x; |
865 | x = ev.motion.x; |
781 | y = ev.motion.y; |
866 | y = ev.motion.y; |
782 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
867 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
783 | } |
868 | } |
784 | |
869 | |
785 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
870 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
786 | hv_store (hv, "state", 5, newSViv (state), 0); |
871 | hv_store (hv, "state", 5, newSViv (state), 0); |
787 | hv_store (hv, "x", 1, newSViv (x), 0); |
872 | hv_store (hv, "x", 1, newSViv (x), 0); |
788 | hv_store (hv, "y", 1, newSViv (y), 0); |
873 | hv_store (hv, "y", 1, newSViv (y), 0); |
789 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
874 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
790 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
875 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
791 | } |
876 | } |
792 | break; |
877 | break; |
793 | |
878 | |
794 | case SDL_MOUSEBUTTONDOWN: |
879 | case SDL_MOUSEBUTTONDOWN: |
795 | case SDL_MOUSEBUTTONUP: |
880 | case SDL_MOUSEBUTTONUP: |
796 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
881 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
797 | |
882 | |
798 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
883 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
799 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
884 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
800 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
885 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
801 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
886 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
806 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
891 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
807 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
892 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
808 | break; |
893 | break; |
809 | } |
894 | } |
810 | |
895 | |
811 | 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)))); |
812 | } |
897 | } |
813 | } |
898 | } |
814 | |
899 | |
815 | int |
900 | int |
816 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
901 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
817 | POSTCALL: |
902 | POSTCALL: |
818 | Mix_HookMusicFinished (music_finished); |
903 | Mix_HookMusicFinished (music_finished); |
819 | Mix_ChannelFinished (channel_finished); |
904 | Mix_ChannelFinished (channel_finished); |
|
|
905 | |
|
|
906 | void |
|
|
907 | Mix_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 | } |
820 | |
921 | |
821 | void |
922 | void |
822 | Mix_CloseAudio () |
923 | Mix_CloseAudio () |
823 | |
924 | |
824 | int |
925 | int |
… | |
… | |
859 | } |
960 | } |
860 | } |
961 | } |
861 | #endif |
962 | #endif |
862 | } |
963 | } |
863 | |
964 | |
864 | void |
965 | int |
865 | add_font (char *file) |
966 | add_font (char *file) |
866 | CODE: |
967 | CODE: |
867 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
968 | RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
|
|
969 | OUTPUT: |
|
|
970 | RETVAL |
868 | |
971 | |
869 | void |
972 | void |
870 | load_image_inline (SV *image_) |
973 | load_image_inline (SV *image_) |
871 | ALIAS: |
974 | ALIAS: |
872 | load_image_file = 1 |
975 | load_image_file = 1 |
… | |
… | |
958 | void |
1061 | void |
959 | error (char *message) |
1062 | error (char *message) |
960 | CODE: |
1063 | CODE: |
961 | fprintf (stderr, "ERROR: %s\n", message); |
1064 | fprintf (stderr, "ERROR: %s\n", message); |
962 | #ifdef _WIN32 |
1065 | #ifdef _WIN32 |
963 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1066 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
964 | #endif |
1067 | #endif |
965 | |
1068 | |
966 | void |
1069 | void |
967 | fatal (char *message) |
1070 | fatal (char *message) |
968 | CODE: |
1071 | CODE: |
969 | fprintf (stderr, "FATAL: %s\n", message); |
1072 | fprintf (stderr, "FATAL: %s\n", message); |
970 | #ifdef _WIN32 |
1073 | #ifdef _WIN32 |
971 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1074 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
972 | #endif |
1075 | #endif |
973 | _exit (1); |
1076 | _exit (1); |
974 | |
1077 | |
975 | void |
1078 | void |
976 | _exit (int retval = 0) |
1079 | _exit (int retval = 0) |
… | |
… | |
988 | #if DEBUG |
1091 | #if DEBUG |
989 | VALGRIND_DO_LEAK_CHECK; |
1092 | VALGRIND_DO_LEAK_CHECK; |
990 | #endif |
1093 | #endif |
991 | } |
1094 | } |
992 | |
1095 | |
993 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1096 | MODULE = Deliantra::Client PACKAGE = DC::Font |
994 | |
1097 | |
995 | PROTOTYPES: DISABLE |
1098 | PROTOTYPES: DISABLE |
996 | |
1099 | |
997 | CFPlus::Font |
1100 | DC::Font |
998 | new_from_file (SV *class, char *path, int id = 0) |
1101 | new_from_file (SV *class, char *path, int id = 0) |
999 | CODE: |
1102 | CODE: |
1000 | { |
1103 | { |
1001 | int count; |
1104 | int count; |
1002 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1105 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1005 | } |
1108 | } |
1006 | OUTPUT: |
1109 | OUTPUT: |
1007 | RETVAL |
1110 | RETVAL |
1008 | |
1111 | |
1009 | void |
1112 | void |
1010 | DESTROY (CFPlus::Font self) |
1113 | DESTROY (DC::Font self) |
1011 | CODE: |
1114 | CODE: |
1012 | pango_font_description_free (self); |
1115 | pango_font_description_free (self); |
1013 | |
1116 | |
1014 | void |
1117 | void |
1015 | make_default (CFPlus::Font self) |
1118 | make_default (DC::Font self) |
1016 | PROTOTYPE: $ |
1119 | PROTOTYPE: $ |
1017 | CODE: |
1120 | CODE: |
1018 | default_font = self; |
1121 | default_font = self; |
1019 | |
1122 | |
1020 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1123 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1021 | |
1124 | |
1022 | PROTOTYPES: DISABLE |
1125 | PROTOTYPES: DISABLE |
1023 | |
1126 | |
1024 | void |
1127 | void |
1025 | reset_glyph_cache () |
1128 | glyph_cache_backup () |
1026 | PROTOTYPE: |
1129 | PROTOTYPE: |
1027 | CODE: |
1130 | CODE: |
|
|
1131 | tc_backup (); |
|
|
1132 | |
|
|
1133 | void |
|
|
1134 | glyph_cache_restore () |
|
|
1135 | PROTOTYPE: |
|
|
1136 | CODE: |
1028 | tc_clear (); |
1137 | tc_restore (); |
1029 | |
1138 | |
1030 | CFPlus::Layout |
1139 | DC::Layout |
1031 | new (SV *class) |
1140 | new (SV *class) |
1032 | CODE: |
1141 | CODE: |
1033 | New (0, RETVAL, 1, struct cf_layout); |
1142 | New (0, RETVAL, 1, struct cf_layout); |
1034 | |
1143 | |
1035 | RETVAL->pl = pango_layout_new (opengl_context); |
1144 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1045 | layout_update_font (RETVAL); |
1154 | layout_update_font (RETVAL); |
1046 | OUTPUT: |
1155 | OUTPUT: |
1047 | RETVAL |
1156 | RETVAL |
1048 | |
1157 | |
1049 | void |
1158 | void |
1050 | DESTROY (CFPlus::Layout self) |
1159 | DESTROY (DC::Layout self) |
1051 | CODE: |
1160 | CODE: |
1052 | g_object_unref (self->pl); |
1161 | g_object_unref (self->pl); |
1053 | rc_free (self->rc); |
1162 | rc_free (self->rc); |
1054 | Safefree (self); |
1163 | Safefree (self); |
1055 | |
1164 | |
1056 | void |
1165 | void |
1057 | set_text (CFPlus::Layout self, SV *text_) |
1166 | set_text (DC::Layout self, SV *text_) |
1058 | CODE: |
1167 | CODE: |
1059 | { |
1168 | { |
1060 | STRLEN textlen; |
1169 | STRLEN textlen; |
1061 | char *text = SvPVutf8 (text_, textlen); |
1170 | char *text = SvPVutf8 (text_, textlen); |
1062 | |
1171 | |
1063 | pango_layout_set_text (self->pl, text, textlen); |
1172 | pango_layout_set_text (self->pl, text, textlen); |
1064 | } |
1173 | } |
1065 | |
1174 | |
1066 | void |
1175 | void |
1067 | set_markup (CFPlus::Layout self, SV *text_) |
1176 | set_markup (DC::Layout self, SV *text_) |
1068 | CODE: |
1177 | CODE: |
1069 | { |
1178 | { |
1070 | STRLEN textlen; |
1179 | STRLEN textlen; |
1071 | char *text = SvPVutf8 (text_, textlen); |
1180 | char *text = SvPVutf8 (text_, textlen); |
1072 | |
1181 | |
1073 | pango_layout_set_markup (self->pl, text, textlen); |
1182 | pango_layout_set_markup (self->pl, text, textlen); |
1074 | } |
1183 | } |
1075 | |
1184 | |
1076 | void |
1185 | void |
1077 | set_shapes (CFPlus::Layout self, ...) |
1186 | set_shapes (DC::Layout self, ...) |
1078 | CODE: |
1187 | CODE: |
1079 | { |
1188 | { |
1080 | PangoAttrList *attrs = 0; |
1189 | PangoAttrList *attrs = 0; |
1081 | const char *text = pango_layout_get_text (self->pl); |
1190 | const char *text = pango_layout_get_text (self->pl); |
1082 | const char *pos = text; |
1191 | const char *pos = text; |
… | |
… | |
1117 | if (attrs) |
1226 | if (attrs) |
1118 | pango_layout_set_attributes (self->pl, attrs); |
1227 | pango_layout_set_attributes (self->pl, attrs); |
1119 | } |
1228 | } |
1120 | |
1229 | |
1121 | void |
1230 | void |
1122 | get_shapes (CFPlus::Layout self) |
1231 | get_shapes (DC::Layout self) |
1123 | PPCODE: |
1232 | PPCODE: |
1124 | { |
1233 | { |
1125 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1234 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1126 | |
1235 | |
1127 | do |
1236 | do |
1128 | { |
1237 | { |
1129 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1238 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1130 | |
1239 | |
1131 | if (run && shape_attr_p (run)) |
1240 | if (run && shape_attr_p (run)) |
1132 | { |
1241 | { |
1133 | PangoRectangle extents; |
1242 | PangoRectangle extents; |
1134 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1243 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1142 | |
1251 | |
1143 | pango_layout_iter_free (iter); |
1252 | pango_layout_iter_free (iter); |
1144 | } |
1253 | } |
1145 | |
1254 | |
1146 | int |
1255 | int |
1147 | has_wrapped (CFPlus::Layout self) |
1256 | has_wrapped (DC::Layout self) |
1148 | CODE: |
1257 | CODE: |
1149 | { |
1258 | { |
1150 | int lines = 1; |
1259 | int lines = 1; |
1151 | const char *text = pango_layout_get_text (self->pl); |
1260 | const char *text = pango_layout_get_text (self->pl); |
1152 | |
1261 | |
… | |
… | |
1157 | } |
1266 | } |
1158 | OUTPUT: |
1267 | OUTPUT: |
1159 | RETVAL |
1268 | RETVAL |
1160 | |
1269 | |
1161 | SV * |
1270 | SV * |
1162 | get_text (CFPlus::Layout self) |
1271 | get_text (DC::Layout self) |
1163 | CODE: |
1272 | CODE: |
1164 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1273 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1165 | sv_utf8_decode (RETVAL); |
1274 | sv_utf8_decode (RETVAL); |
1166 | OUTPUT: |
1275 | OUTPUT: |
1167 | RETVAL |
1276 | RETVAL |
1168 | |
1277 | |
1169 | void |
1278 | void |
1170 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1279 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1171 | CODE: |
1280 | CODE: |
1172 | self->r = r; |
1281 | self->r = r; |
1173 | self->g = g; |
1282 | self->g = g; |
1174 | self->b = b; |
1283 | self->b = b; |
1175 | self->a = a; |
1284 | self->a = a; |
1176 | |
1285 | |
1177 | void |
1286 | void |
1178 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1287 | set_font (DC::Layout self, DC::Font font = 0) |
1179 | CODE: |
1288 | CODE: |
1180 | if (self->font != font) |
1289 | if (self->font != font) |
1181 | { |
1290 | { |
1182 | self->font = font; |
1291 | self->font = font; |
1183 | layout_update_font (self); |
1292 | layout_update_font (self); |
1184 | } |
1293 | } |
1185 | |
1294 | |
1186 | void |
1295 | void |
1187 | set_height (CFPlus::Layout self, int base_height) |
1296 | set_height (DC::Layout self, int base_height) |
1188 | CODE: |
1297 | CODE: |
1189 | if (self->base_height != base_height) |
1298 | if (self->base_height != base_height) |
1190 | { |
1299 | { |
1191 | self->base_height = base_height; |
1300 | self->base_height = base_height; |
1192 | layout_update_font (self); |
1301 | layout_update_font (self); |
1193 | } |
1302 | } |
1194 | |
1303 | |
1195 | void |
1304 | void |
1196 | set_width (CFPlus::Layout self, int max_width = -1) |
1305 | set_width (DC::Layout self, int max_width = -1) |
1197 | CODE: |
1306 | CODE: |
1198 | 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); |
1199 | |
1308 | |
1200 | void |
1309 | void |
1201 | set_indent (CFPlus::Layout self, int indent) |
1310 | set_indent (DC::Layout self, int indent) |
1202 | CODE: |
1311 | CODE: |
1203 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1312 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1204 | |
1313 | |
1205 | void |
1314 | void |
1206 | set_spacing (CFPlus::Layout self, int spacing) |
1315 | set_spacing (DC::Layout self, int spacing) |
1207 | CODE: |
1316 | CODE: |
1208 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1317 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1209 | |
1318 | |
1210 | void |
1319 | void |
1211 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1320 | set_ellipsise (DC::Layout self, int ellipsise) |
1212 | CODE: |
1321 | CODE: |
1213 | pango_layout_set_ellipsize (self->pl, |
1322 | pango_layout_set_ellipsize (self->pl, |
1214 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1323 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1215 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1324 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1216 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1325 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1217 | : PANGO_ELLIPSIZE_NONE |
1326 | : PANGO_ELLIPSIZE_NONE |
1218 | ); |
1327 | ); |
1219 | |
1328 | |
1220 | void |
1329 | void |
1221 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1330 | set_single_paragraph_mode (DC::Layout self, int spm) |
1222 | CODE: |
1331 | CODE: |
1223 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1332 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1224 | |
1333 | |
1225 | void |
1334 | void |
1226 | size (CFPlus::Layout self) |
1335 | size (DC::Layout self) |
1227 | PPCODE: |
1336 | PPCODE: |
1228 | { |
1337 | { |
1229 | int w, h; |
1338 | int w, h; |
1230 | |
1339 | |
1231 | layout_get_pixel_size (self, &w, &h); |
1340 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1234 | PUSHs (sv_2mortal (newSViv (w))); |
1343 | PUSHs (sv_2mortal (newSViv (w))); |
1235 | PUSHs (sv_2mortal (newSViv (h))); |
1344 | PUSHs (sv_2mortal (newSViv (h))); |
1236 | } |
1345 | } |
1237 | |
1346 | |
1238 | int |
1347 | int |
1239 | descent (CFPlus::Layout self) |
1348 | descent (DC::Layout self) |
1240 | CODE: |
1349 | CODE: |
1241 | { |
1350 | { |
1242 | PangoRectangle rect; |
1351 | PangoRectangle rect; |
1243 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1352 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1244 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1353 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1245 | RETVAL = PANGO_DESCENT (rect); |
1354 | RETVAL = PANGO_DESCENT (rect); |
1246 | } |
1355 | } |
1247 | OUTPUT: |
1356 | OUTPUT: |
1248 | RETVAL |
1357 | RETVAL |
1249 | |
1358 | |
1250 | int |
1359 | int |
1251 | xy_to_index (CFPlus::Layout self, int x, int y) |
1360 | xy_to_index (DC::Layout self, int x, int y) |
1252 | CODE: |
1361 | CODE: |
1253 | { |
1362 | { |
1254 | int index, trailing; |
1363 | int index, trailing; |
1255 | 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); |
1256 | RETVAL = index + trailing; |
1365 | RETVAL = index + trailing; |
1257 | } |
1366 | } |
1258 | OUTPUT: |
1367 | OUTPUT: |
1259 | RETVAL |
1368 | RETVAL |
1260 | |
1369 | |
1261 | void |
1370 | void |
1262 | cursor_pos (CFPlus::Layout self, int index) |
1371 | cursor_pos (DC::Layout self, int index) |
1263 | PPCODE: |
1372 | PPCODE: |
1264 | { |
1373 | { |
1265 | PangoRectangle strong_pos; |
1374 | PangoRectangle pos; |
1266 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1375 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1267 | |
1376 | |
1268 | EXTEND (SP, 3); |
1377 | EXTEND (SP, 3); |
1269 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1378 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1270 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1379 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1271 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1380 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1272 | } |
1381 | } |
1273 | |
1382 | |
1274 | void |
1383 | void |
1275 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1384 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1276 | PPCODE: |
1385 | PPCODE: |
1277 | { |
1386 | { |
1278 | int line, x; |
1387 | int line, x; |
1279 | |
1388 | |
1280 | 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) |
1281 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1391 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1282 | |
1392 | --line; |
|
|
1393 | #endif |
1283 | EXTEND (SP, 2); |
1394 | EXTEND (SP, 2); |
1284 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1395 | PUSHs (sv_2mortal (newSViv (line))); |
1285 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1396 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1286 | } |
1397 | } |
1287 | |
1398 | |
1288 | void |
1399 | void |
1289 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1400 | line_x_to_index (DC::Layout self, int line, int x) |
1290 | PPCODE: |
1401 | PPCODE: |
1291 | { |
1402 | { |
1292 | PangoLayoutLine *lp; |
1403 | PangoLayoutLine *lp; |
1293 | int index, trailing; |
1404 | int index, trailing; |
1294 | |
1405 | |
1295 | if (line < 0) |
1406 | if (line < 0) |
1296 | XSRETURN_EMPTY; |
1407 | XSRETURN_EMPTY; |
1297 | |
1408 | |
1298 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1409 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1299 | XSRETURN_EMPTY; /* do better */ |
1410 | XSRETURN_EMPTY; /* do better */ |
1300 | |
1411 | |
1301 | 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); |
1302 | |
1413 | |
1303 | EXTEND (SP, 2); |
1414 | EXTEND (SP, 2); |
… | |
… | |
1309 | PUSHs (sv_2mortal (newSViv (trailing))); |
1420 | PUSHs (sv_2mortal (newSViv (trailing))); |
1310 | } |
1421 | } |
1311 | } |
1422 | } |
1312 | |
1423 | |
1313 | void |
1424 | void |
1314 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1425 | render (DC::Layout self, float x, float y, int flags = 0) |
1315 | CODE: |
1426 | CODE: |
1316 | rc_clear (self->rc); |
1427 | rc_clear (self->rc); |
1317 | pango_opengl_render_layout_subpixel ( |
1428 | pango_opengl_render_layout_subpixel ( |
1318 | self->pl, |
1429 | self->pl, |
1319 | self->rc, |
1430 | self->rc, |
… | |
… | |
1324 | // we assume that context_change actually clears/frees stuff |
1435 | // we assume that context_change actually clears/frees stuff |
1325 | // and does not do any recomputation... |
1436 | // and does not do any recomputation... |
1326 | pango_layout_context_changed (self->pl); |
1437 | pango_layout_context_changed (self->pl); |
1327 | |
1438 | |
1328 | void |
1439 | void |
1329 | draw (CFPlus::Layout self) |
1440 | draw (DC::Layout self) |
1330 | CODE: |
1441 | CODE: |
1331 | { |
1442 | { |
1332 | glEnable (GL_TEXTURE_2D); |
1443 | glEnable (GL_TEXTURE_2D); |
1333 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1444 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1334 | glEnable (GL_BLEND); |
1445 | glEnable (GL_BLEND); |
… | |
… | |
1342 | glDisable (GL_ALPHA_TEST); |
1453 | glDisable (GL_ALPHA_TEST); |
1343 | glDisable (GL_BLEND); |
1454 | glDisable (GL_BLEND); |
1344 | glDisable (GL_TEXTURE_2D); |
1455 | glDisable (GL_TEXTURE_2D); |
1345 | } |
1456 | } |
1346 | |
1457 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1458 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1348 | |
1459 | |
1349 | PROTOTYPES: ENABLE |
1460 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1461 | |
1353 | void |
1462 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1463 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1464 | CODE: |
1356 | { |
1465 | { |
… | |
… | |
1433 | RETVAL = width > 0; |
1542 | RETVAL = width > 0; |
1434 | } |
1543 | } |
1435 | OUTPUT: |
1544 | OUTPUT: |
1436 | RETVAL |
1545 | RETVAL |
1437 | |
1546 | |
1438 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1547 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1439 | |
1548 | |
1440 | PROTOTYPES: DISABLE |
1549 | PROTOTYPES: DISABLE |
1441 | |
1550 | |
1442 | CFPlus::Map |
1551 | DC::Map |
1443 | new (SV *class) |
1552 | new (SV *class) |
1444 | CODE: |
1553 | CODE: |
1445 | New (0, RETVAL, 1, struct map); |
1554 | New (0, RETVAL, 1, struct map); |
1446 | RETVAL->x = 0; |
1555 | RETVAL->x = 0; |
1447 | RETVAL->y = 0; |
1556 | RETVAL->y = 0; |
… | |
… | |
1455 | RETVAL->row = 0; |
1564 | RETVAL->row = 0; |
1456 | OUTPUT: |
1565 | OUTPUT: |
1457 | RETVAL |
1566 | RETVAL |
1458 | |
1567 | |
1459 | void |
1568 | void |
1460 | DESTROY (CFPlus::Map self) |
1569 | DESTROY (DC::Map self) |
1461 | CODE: |
1570 | CODE: |
1462 | { |
1571 | { |
1463 | map_clear (self); |
1572 | map_clear (self); |
1464 | Safefree (self->face2tile); |
1573 | Safefree (self->face2tile); |
1465 | Safefree (self->tex); |
1574 | Safefree (self->tex); |
1466 | Safefree (self); |
1575 | Safefree (self); |
1467 | } |
1576 | } |
1468 | |
1577 | |
1469 | void |
1578 | void |
1470 | resize (CFPlus::Map self, int map_width, int map_height) |
1579 | resize (DC::Map self, int map_width, int map_height) |
1471 | CODE: |
1580 | CODE: |
1472 | self->w = map_width; |
1581 | self->w = map_width; |
1473 | self->h = map_height; |
1582 | self->h = map_height; |
1474 | |
1583 | |
1475 | void |
1584 | void |
1476 | clear (CFPlus::Map self) |
1585 | clear (DC::Map self) |
1477 | CODE: |
1586 | CODE: |
1478 | map_clear (self); |
1587 | map_clear (self); |
1479 | |
1588 | |
1480 | void |
1589 | void |
1481 | set_tileid (CFPlus::Map self, int face, int tile) |
1590 | set_tileid (DC::Map self, int face, int tile) |
1482 | CODE: |
1591 | CODE: |
1483 | { |
1592 | { |
1484 | need_facenum (self, face); self->face2tile [face] = tile; |
1593 | need_facenum (self, face); self->face2tile [face] = tile; |
1485 | need_texid (self, tile); |
1594 | need_texid (self, tile); |
1486 | } |
1595 | } |
1487 | |
1596 | |
1488 | void |
1597 | void |
1489 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1598 | set_smooth (DC::Map self, int face, int smooth, int level) |
1490 | CODE: |
1599 | CODE: |
1491 | { |
1600 | { |
1492 | tileid texid; |
1601 | tileid texid; |
1493 | maptex *tex; |
1602 | maptex *tex; |
1494 | |
1603 | |
… | |
… | |
1507 | tex->smoothtile = self->face2tile [smooth]; |
1616 | tex->smoothtile = self->face2tile [smooth]; |
1508 | tex->smoothlevel = level; |
1617 | tex->smoothlevel = level; |
1509 | } |
1618 | } |
1510 | |
1619 | |
1511 | void |
1620 | void |
1512 | set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1621 | set_texture (DC::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) |
1513 | CODE: |
1622 | CODE: |
1514 | { |
1623 | { |
1515 | need_texid (self, texid); |
1624 | need_texid (self, texid); |
1516 | |
1625 | |
1517 | { |
1626 | { |
… | |
… | |
1537 | // from transparent color bleeding and ugly wrapping effects. |
1646 | // from transparent color bleeding and ugly wrapping effects. |
1538 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1647 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1539 | } |
1648 | } |
1540 | |
1649 | |
1541 | int |
1650 | int |
1542 | ox (CFPlus::Map self) |
1651 | ox (DC::Map self) |
1543 | ALIAS: |
1652 | ALIAS: |
1544 | oy = 1 |
1653 | oy = 1 |
1545 | x = 2 |
1654 | x = 2 |
1546 | y = 3 |
1655 | y = 3 |
1547 | w = 4 |
1656 | w = 4 |
… | |
… | |
1558 | } |
1667 | } |
1559 | OUTPUT: |
1668 | OUTPUT: |
1560 | RETVAL |
1669 | RETVAL |
1561 | |
1670 | |
1562 | void |
1671 | void |
1563 | scroll (CFPlus::Map self, int dx, int dy) |
1672 | scroll (DC::Map self, int dx, int dy) |
1564 | CODE: |
1673 | CODE: |
1565 | { |
1674 | { |
1566 | if (dx > 0) |
1675 | if (dx > 0) |
1567 | map_blank (self, self->x, self->y, dx, self->h); |
1676 | map_blank (self, self->x, self->y, dx, self->h); |
1568 | else if (dx < 0) |
1677 | else if (dx < 0) |
… | |
… | |
1584 | self->y += MAP_EXTEND_Y; |
1693 | self->y += MAP_EXTEND_Y; |
1585 | } |
1694 | } |
1586 | } |
1695 | } |
1587 | |
1696 | |
1588 | SV * |
1697 | SV * |
1589 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1698 | map1a_update (DC::Map self, SV *data_, int extmap) |
1590 | CODE: |
1699 | CODE: |
1591 | { |
1700 | { |
1592 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1701 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1593 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1702 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1594 | mapcell *cell; |
1703 | mapcell *cell; |
… | |
… | |
1622 | uint8_t ext, cmd; |
1731 | uint8_t ext, cmd; |
1623 | |
1732 | |
1624 | do |
1733 | do |
1625 | { |
1734 | { |
1626 | ext = *data++; |
1735 | ext = *data++; |
1627 | cmd = ext & 0x3f; |
1736 | cmd = ext & 0x7f; |
1628 | |
1737 | |
1629 | if (cmd < 4) |
1738 | if (cmd < 4) |
1630 | cell->darkness = 255 - ext * 64 + 1; |
1739 | cell->darkness = 255 - ext * 64 + 1; |
1631 | else if (cmd == 5) // health |
1740 | else if (cmd == 5) // health |
1632 | { |
1741 | { |
… | |
… | |
1635 | } |
1744 | } |
1636 | else if (cmd == 6) // monster width |
1745 | else if (cmd == 6) // monster width |
1637 | cell->stat_width = *data++ + 1; |
1746 | cell->stat_width = *data++ + 1; |
1638 | else if (cmd == 0x47) |
1747 | else if (cmd == 0x47) |
1639 | { |
1748 | { |
1640 | if (*data == 4) |
1749 | if (*data == 1) cell->player = data [1]; |
1641 | ; // 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); |
1642 | |
1753 | |
1643 | data += *data + 1; |
1754 | data += *data + 1; |
1644 | } |
1755 | } |
1645 | else if (cmd == 8) // cell flags |
1756 | else if (cmd == 8) // cell flags |
1646 | cell->flags = *data++; |
1757 | cell->flags = *data++; |
… | |
… | |
1676 | } |
1787 | } |
1677 | } |
1788 | } |
1678 | } |
1789 | } |
1679 | } |
1790 | } |
1680 | else |
1791 | else |
1681 | cell->darkness = 0; |
1792 | CELL_CLEAR (cell); |
1682 | } |
1793 | } |
1683 | } |
1794 | } |
1684 | OUTPUT: |
1795 | OUTPUT: |
1685 | RETVAL |
1796 | RETVAL |
1686 | |
1797 | |
1687 | SV * |
1798 | SV * |
1688 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1799 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1689 | CODE: |
1800 | CODE: |
1690 | { |
1801 | { |
1691 | int x1, x; |
1802 | int x1, x; |
1692 | int y1, y; |
1803 | int y1, y; |
1693 | int z; |
1804 | int z; |
… | |
… | |
1738 | } |
1849 | } |
1739 | OUTPUT: |
1850 | OUTPUT: |
1740 | RETVAL |
1851 | RETVAL |
1741 | |
1852 | |
1742 | void |
1853 | void |
1743 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1854 | draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int sdx = 0, int sdy = 0) |
1744 | CODE: |
1855 | CODE: |
1745 | { |
1856 | { |
1746 | int x, y, z; |
1857 | int x, y, z; |
1747 | |
1858 | |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1859 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1749 | 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 |
1750 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1861 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1751 | smooth_key skey; |
1862 | smooth_key skey; |
1752 | |
1863 | int pl_x, pl_y; |
|
|
1864 | maptex pl_tex; |
1753 | rc_t *rc = rc_alloc (); |
1865 | rc_t *rc = rc_alloc (); |
1754 | rc_key_t key; |
1866 | rc_key_t key; |
1755 | rc_array_t *arr; |
1867 | rc_array_t *arr; |
|
|
1868 | |
|
|
1869 | pl_tex.name = 0; |
1756 | |
1870 | |
1757 | // thats current max. sorry. |
1871 | // thats current max. sorry. |
1758 | if (sw > 255) sw = 255; |
1872 | if (sw > 255) sw = 255; |
1759 | if (sh > 255) sh = 255; |
1873 | if (sh > 255) sh = 255; |
1760 | |
1874 | |
… | |
… | |
1815 | tileid tile = cell->tile [z]; |
1929 | tileid tile = cell->tile [z]; |
1816 | |
1930 | |
1817 | if (tile) |
1931 | if (tile) |
1818 | { |
1932 | { |
1819 | maptex tex = self->tex [tile]; |
1933 | maptex tex = self->tex [tile]; |
1820 | int px, py; |
1934 | int px = (x + 1) * T - tex.w; |
|
|
1935 | int py = (y + 1) * T - tex.h; |
1821 | |
1936 | |
1822 | if (key.texname != tex.name) |
1937 | if (key.texname != tex.name) |
1823 | { |
1938 | { |
1824 | if (!tex.name) |
1939 | if (!tex.name) |
1825 | tex = self->tex [2]; /* missing, replace by noface */ |
1940 | tex = self->tex [2]; /* missing, replace by noface */ |
1826 | |
1941 | |
1827 | key.texname = tex.name; |
1942 | key.texname = tex.name; |
1828 | arr = rc_array (rc, &key); |
1943 | arr = rc_array (rc, &key); |
1829 | } |
1944 | } |
1830 | |
1945 | |
1831 | px = (x + 1) * T - tex.w; |
1946 | if (expect_false (cell->player == player) && expect_false (z == 2)) |
1832 | py = (y + 1) * T - tex.h; |
1947 | { |
|
|
1948 | pl_x = px; |
|
|
1949 | pl_y = py; |
|
|
1950 | pl_tex = tex; |
|
|
1951 | continue; |
|
|
1952 | } |
1833 | |
1953 | |
1834 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1954 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1835 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1955 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1836 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1956 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1837 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1957 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1838 | |
1958 | |
1839 | if (cell->flags && z == 2) |
1959 | if (expect_false (cell->flags) && expect_false (z == 2)) |
1840 | { |
1960 | { |
1841 | // overlays such as the speech bubble, probably more to come |
1961 | // overlays such as the speech bubble, probably more to come |
1842 | if (cell->flags & 1) |
1962 | if (cell->flags & 1) |
1843 | { |
1963 | { |
1844 | maptex tex = self->tex [1]; |
1964 | maptex tex = self->tex [1]; |
… | |
… | |
1983 | } |
2103 | } |
1984 | |
2104 | |
1985 | hv_clear (smooth); |
2105 | hv_clear (smooth); |
1986 | } |
2106 | } |
1987 | |
2107 | |
|
|
2108 | if (pl_tex.name) |
|
|
2109 | { |
|
|
2110 | maptex tex = pl_tex; |
|
|
2111 | int px = pl_x + sdx; |
|
|
2112 | int py = pl_y + sdy; |
|
|
2113 | |
|
|
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 | |
1988 | glDisable (GL_BLEND); |
2125 | glDisable (GL_BLEND); |
1989 | rc_free (rc); |
2126 | rc_free (rc); |
1990 | |
2127 | |
1991 | // top layer: overlays such as the health bar |
2128 | // top layer: overlays such as the health bar |
1992 | for (y = 0; y < sh; y++) |
2129 | for (y = 0; y < sh; y++) |
… | |
… | |
2019 | } |
2156 | } |
2020 | } |
2157 | } |
2021 | } |
2158 | } |
2022 | |
2159 | |
2023 | void |
2160 | void |
2024 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2161 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2025 | CODE: |
2162 | CODE: |
2026 | { |
2163 | { |
2027 | static float color[16][3] = { |
2164 | static float color[16][3] = { |
2028 | { 0.00F, 0.00F, 0.00F }, |
2165 | { 0.00F, 0.00F, 0.00F }, |
2029 | { 1.00F, 1.00F, 1.00F }, |
2166 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2079 | glDisable (GL_BLEND); |
2216 | glDisable (GL_BLEND); |
2080 | glDisable (GL_TEXTURE_2D); |
2217 | glDisable (GL_TEXTURE_2D); |
2081 | } |
2218 | } |
2082 | |
2219 | |
2083 | void |
2220 | void |
2084 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2221 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2085 | PPCODE: |
2222 | PPCODE: |
2086 | { |
2223 | { |
2087 | int x, y; |
2224 | int x, y; |
2088 | int sw1 = sw + 2; |
2225 | int sw1 = sw + 2; |
2089 | int sh1 = sh + 2; |
2226 | int sh1 = sh + 2; |
… | |
… | |
2160 | PUSHs (sv_2mortal (newSViv (sh3))); |
2297 | PUSHs (sv_2mortal (newSViv (sh3))); |
2161 | PUSHs (darkness3_sv); |
2298 | PUSHs (darkness3_sv); |
2162 | } |
2299 | } |
2163 | |
2300 | |
2164 | SV * |
2301 | SV * |
2165 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2302 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2166 | CODE: |
2303 | CODE: |
2167 | { |
2304 | { |
2168 | int x, y, x1, y1; |
2305 | int x, y, x1, y1; |
2169 | SV *data_sv = newSV (w * h * 7 + 5); |
2306 | SV *data_sv = newSV (w * h * 7 + 5); |
2170 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2307 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2227 | else |
2364 | else |
2228 | *data++ = 0; |
2365 | *data++ = 0; |
2229 | } |
2366 | } |
2230 | } |
2367 | } |
2231 | |
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 | { |
2232 | SvPOK_only (data_sv); |
2372 | SvPOK_only (data_sv); |
2233 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2373 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2374 | } |
|
|
2375 | |
2234 | RETVAL = data_sv; |
2376 | RETVAL = data_sv; |
2235 | } |
2377 | } |
2236 | OUTPUT: |
2378 | OUTPUT: |
2237 | RETVAL |
2379 | RETVAL |
2238 | |
2380 | |
2239 | void |
2381 | void |
2240 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2382 | set_rect (DC::Map self, int x0, int y0, SV *data_sv) |
2241 | PPCODE: |
2383 | PPCODE: |
2242 | { |
2384 | { |
2243 | int x, y, z; |
2385 | int x, y, z; |
2244 | int w, h; |
2386 | int w, h; |
2245 | 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; |
2246 | |
2398 | |
2247 | if (*data++ != 0) |
2399 | if (*data++ != 0) |
2248 | XSRETURN_EMPTY; /* version mismatch */ |
2400 | XSRETURN_EMPTY; /* version mismatch */ |
2249 | |
2401 | |
2250 | w = *data++ << 8; w |= *data++; |
2402 | w = *data++ << 8; w |= *data++; |
… | |
… | |
2265 | { |
2417 | { |
2266 | maprow *row = map_get_row (self, y); |
2418 | maprow *row = map_get_row (self, y); |
2267 | |
2419 | |
2268 | for (x = x0; x < x1; x++) |
2420 | for (x = x0; x < x1; x++) |
2269 | { |
2421 | { |
|
|
2422 | uint8_t flags; |
|
|
2423 | |
|
|
2424 | if (data + 7 >= end) |
|
|
2425 | XSRETURN_EMPTY; |
|
|
2426 | |
2270 | uint8_t flags = *data++; |
2427 | flags = *data++; |
2271 | |
2428 | |
2272 | if (flags) |
2429 | if (flags) |
2273 | { |
2430 | { |
2274 | mapcell *cell = row_get_cell (row, x); |
2431 | mapcell *cell = row_get_cell (row, x); |
2275 | tileid tile[3] = { 0, 0, 0 }; |
2432 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2278 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2435 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2279 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2436 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2280 | |
2437 | |
2281 | if (cell->darkness == 0) |
2438 | if (cell->darkness == 0) |
2282 | { |
2439 | { |
2283 | cell->darkness = 0; |
2440 | /*cell->darkness = 0;*/ |
|
|
2441 | EXTEND (SP, 3); |
2284 | |
2442 | |
2285 | for (z = 0; z <= 2; z++) |
2443 | for (z = 0; z <= 2; z++) |
2286 | { |
2444 | { |
2287 | tileid t = tile [z]; |
2445 | tileid t = tile [z]; |
2288 | |
2446 | |
2289 | if (t >= self->texs || (t && !self->tex [t].name)) |
2447 | if (t >= self->texs || (t && !self->tex [t].name)) |
2290 | { |
2448 | { |
2291 | XPUSHs (sv_2mortal (newSViv (t))); |
2449 | PUSHs (sv_2mortal (newSViv (t))); |
2292 | need_texid (self, t); |
2450 | need_texid (self, t); |
2293 | } |
2451 | } |
2294 | |
2452 | |
2295 | cell->tile [z] = t; |
2453 | cell->tile [z] = t; |
2296 | } |
2454 | } |
… | |
… | |
2298 | } |
2456 | } |
2299 | } |
2457 | } |
2300 | } |
2458 | } |
2301 | } |
2459 | } |
2302 | |
2460 | |
2303 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2461 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2304 | |
2462 | |
2305 | CFPlus::RW |
2463 | DC::RW |
2306 | new (SV *class, SV *data_sv) |
2464 | new (SV *class, SV *data_sv) |
2307 | CODE: |
2465 | CODE: |
2308 | { |
2466 | { |
2309 | STRLEN datalen; |
2467 | STRLEN datalen; |
2310 | char *data = SvPVbyte (data_sv, datalen); |
2468 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2312 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2470 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2313 | } |
2471 | } |
2314 | OUTPUT: |
2472 | OUTPUT: |
2315 | RETVAL |
2473 | RETVAL |
2316 | |
2474 | |
2317 | CFPlus::RW |
2475 | DC::RW |
2318 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2476 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2319 | CODE: |
2477 | CODE: |
2320 | RETVAL = SDL_RWFromFile (path, mode); |
2478 | RETVAL = SDL_RWFromFile (path, mode); |
2321 | OUTPUT: |
2479 | OUTPUT: |
2322 | RETVAL |
2480 | RETVAL |
2323 | |
2481 | |
2324 | # fails on win32: |
2482 | # fails on win32: |
2325 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2483 | # dc.xs(2268) : error C2059: syntax error : '(' |
2326 | #void |
2484 | #void |
2327 | #close (CFPlus::RW self) |
2485 | #close (DC::RW self) |
2328 | # CODE: |
2486 | # CODE: |
2329 | # (self->(close)) (self); |
2487 | # (self->(close)) (self); |
2330 | |
2488 | |
2331 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2489 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2332 | |
2490 | |
2333 | PROTOTYPES: DISABLE |
2491 | PROTOTYPES: DISABLE |
2334 | |
2492 | |
2335 | CFPlus::Channel |
2493 | DC::Channel |
2336 | find () |
2494 | find () |
2337 | CODE: |
2495 | CODE: |
2338 | { |
2496 | { |
2339 | RETVAL = Mix_GroupAvailable (-1); |
2497 | RETVAL = Mix_GroupAvailable (-1); |
2340 | |
2498 | |
… | |
… | |
2353 | } |
2511 | } |
2354 | OUTPUT: |
2512 | OUTPUT: |
2355 | RETVAL |
2513 | RETVAL |
2356 | |
2514 | |
2357 | void |
2515 | void |
2358 | halt (CFPlus::Channel self) |
2516 | halt (DC::Channel self) |
2359 | CODE: |
2517 | CODE: |
2360 | Mix_HaltChannel (self); |
2518 | Mix_HaltChannel (self); |
2361 | |
2519 | |
2362 | void |
2520 | void |
2363 | expire (CFPlus::Channel self, int ticks = -1) |
2521 | expire (DC::Channel self, int ticks = -1) |
2364 | CODE: |
2522 | CODE: |
2365 | Mix_ExpireChannel (self, ticks); |
2523 | Mix_ExpireChannel (self, ticks); |
2366 | |
2524 | |
2367 | void |
2525 | void |
2368 | fade_out (CFPlus::Channel self, int ticks = -1) |
2526 | fade_out (DC::Channel self, int ticks = -1) |
2369 | CODE: |
2527 | CODE: |
2370 | Mix_FadeOutChannel (self, ticks); |
2528 | Mix_FadeOutChannel (self, ticks); |
2371 | |
2529 | |
2372 | int |
2530 | int |
2373 | volume (CFPlus::Channel self, int volume) |
2531 | volume (DC::Channel self, int volume) |
2374 | CODE: |
2532 | CODE: |
2375 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2533 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2376 | OUTPUT: |
2534 | OUTPUT: |
2377 | RETVAL |
2535 | RETVAL |
2378 | |
2536 | |
2379 | void |
2537 | void |
2380 | unregister_all_effects (CFPlus::Channel self) |
2538 | unregister_all_effects (DC::Channel self) |
2381 | CODE: |
2539 | CODE: |
2382 | Mix_UnregisterAllEffects (self); |
2540 | Mix_UnregisterAllEffects (self); |
2383 | |
2541 | |
2384 | void |
2542 | void |
2385 | set_panning (CFPlus::Channel self, int left, int right) |
2543 | set_panning (DC::Channel self, int left, int right) |
2386 | CODE: |
2544 | CODE: |
2387 | left = CLAMP (left , 0, 255); |
2545 | left = CLAMP (left , 0, 255); |
2388 | right = CLAMP (right, 0, 255); |
2546 | right = CLAMP (right, 0, 255); |
2389 | Mix_SetPanning (self, left, right); |
2547 | Mix_SetPanning (self, left, right); |
2390 | |
2548 | |
2391 | void |
2549 | void |
2392 | set_distance (CFPlus::Channel self, int distance) |
2550 | set_distance (DC::Channel self, int distance) |
2393 | CODE: |
2551 | CODE: |
2394 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2552 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2395 | |
2553 | |
2396 | void |
2554 | void |
2397 | set_position (CFPlus::Channel self, int angle, int distance) |
2555 | set_position (DC::Channel self, int angle, int distance) |
2398 | CODE: |
2556 | CODE: |
2399 | |
2557 | |
2400 | void |
2558 | void |
2401 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2559 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2402 | CODE: |
2560 | CODE: |
2403 | { |
2561 | { |
2404 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2562 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2405 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2563 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2406 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2564 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2407 | } |
2565 | } |
2408 | |
2566 | |
2409 | void |
2567 | void |
2410 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2568 | set_reverse_stereo (DC::Channel self, int flip) |
2411 | CODE: |
2569 | CODE: |
2412 | Mix_SetReverseStereo (self, flip); |
2570 | Mix_SetReverseStereo (self, flip); |
2413 | |
2571 | |
2414 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2572 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2415 | |
2573 | |
2416 | PROTOTYPES: DISABLE |
2574 | PROTOTYPES: DISABLE |
2417 | |
2575 | |
2418 | CFPlus::MixChunk |
2576 | DC::MixChunk |
2419 | new (SV *class, CFPlus::RW rwops) |
2577 | new (SV *class, DC::RW rwops) |
2420 | CODE: |
2578 | CODE: |
2421 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2579 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2422 | OUTPUT: |
2580 | OUTPUT: |
2423 | RETVAL |
2581 | RETVAL |
2424 | |
2582 | |
2425 | void |
2583 | void |
2426 | DESTROY (CFPlus::MixChunk self) |
2584 | DESTROY (DC::MixChunk self) |
2427 | CODE: |
2585 | CODE: |
2428 | Mix_FreeChunk (self); |
2586 | Mix_FreeChunk (self); |
2429 | |
2587 | |
2430 | int |
2588 | int |
2431 | volume (CFPlus::MixChunk self, int volume = -1) |
2589 | volume (DC::MixChunk self, int volume = -1) |
2432 | CODE: |
2590 | CODE: |
2433 | if (items > 1) |
2591 | if (items > 1) |
2434 | volume = CLAMP (volume, 0, 128); |
2592 | volume = CLAMP (volume, 0, 128); |
2435 | RETVAL = Mix_VolumeChunk (self, volume); |
2593 | RETVAL = Mix_VolumeChunk (self, volume); |
2436 | OUTPUT: |
2594 | OUTPUT: |
2437 | RETVAL |
2595 | RETVAL |
2438 | |
2596 | |
2439 | CFPlus::Channel |
2597 | DC::Channel |
2440 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2598 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2441 | CODE: |
2599 | CODE: |
2442 | { |
2600 | { |
2443 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2601 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2444 | |
2602 | |
2445 | if (RETVAL < 0) |
2603 | if (RETVAL < 0) |
… | |
… | |
2452 | } |
2610 | } |
2453 | } |
2611 | } |
2454 | OUTPUT: |
2612 | OUTPUT: |
2455 | RETVAL |
2613 | RETVAL |
2456 | |
2614 | |
2457 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2615 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2458 | |
2616 | |
2459 | int |
2617 | int |
2460 | volume (int volume = -1) |
2618 | volume (int volume = -1) |
2461 | PROTOTYPE: ;$ |
2619 | PROTOTYPE: ;$ |
2462 | CODE: |
2620 | CODE: |
… | |
… | |
2474 | void |
2632 | void |
2475 | halt () |
2633 | halt () |
2476 | CODE: |
2634 | CODE: |
2477 | Mix_HaltMusic (); |
2635 | Mix_HaltMusic (); |
2478 | |
2636 | |
2479 | CFPlus::MixMusic |
2637 | DC::MixMusic |
2480 | new (SV *class, CFPlus::RW rwops) |
2638 | new (SV *class, DC::RW rwops) |
2481 | CODE: |
2639 | CODE: |
2482 | RETVAL = Mix_LoadMUS_RW (rwops); |
2640 | RETVAL = Mix_LoadMUS_RW (rwops); |
2483 | OUTPUT: |
2641 | OUTPUT: |
2484 | RETVAL |
2642 | RETVAL |
2485 | |
2643 | |
2486 | void |
2644 | void |
2487 | DESTROY (CFPlus::MixMusic self) |
2645 | DESTROY (DC::MixMusic self) |
2488 | CODE: |
2646 | CODE: |
2489 | Mix_FreeMusic (self); |
2647 | Mix_FreeMusic (self); |
2490 | |
2648 | |
2491 | int |
2649 | int |
2492 | play (CFPlus::MixMusic self, int loops = -1) |
2650 | play (DC::MixMusic self, int loops = -1) |
2493 | CODE: |
2651 | CODE: |
2494 | RETVAL = Mix_PlayMusic (self, loops); |
2652 | RETVAL = Mix_PlayMusic (self, loops); |
2495 | OUTPUT: |
2653 | OUTPUT: |
2496 | RETVAL |
2654 | RETVAL |
2497 | |
2655 | |
2498 | void |
2656 | void |
2499 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2657 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2500 | CODE: |
2658 | CODE: |
2501 | Mix_FadeInMusicPos (self, loops, ms, position); |
2659 | Mix_FadeInMusicPos (self, loops, ms, position); |
2502 | |
2660 | |
2503 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2661 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2504 | |
2662 | |
2505 | PROTOTYPES: ENABLE |
2663 | PROTOTYPES: ENABLE |
2506 | |
2664 | |
2507 | BOOT: |
2665 | BOOT: |
2508 | { |
2666 | { |
2509 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2667 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2510 | static const struct { |
2668 | static const struct { |
2511 | const char *name; |
2669 | const char *name; |
2512 | IV iv; |
2670 | IV iv; |
2513 | } *civ, const_iv[] = { |
2671 | } *civ, const_iv[] = { |
2514 | # define const_iv(name) { # name, (IV)name } |
2672 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2807 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2965 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2808 | CODE: |
2966 | CODE: |
2809 | if (gl.SeparableFilter2D) |
2967 | if (gl.SeparableFilter2D) |
2810 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2968 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2811 | |
2969 | |
2812 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2970 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2813 | |
2971 | |
2814 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2972 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2815 | |
2973 | |
2816 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2974 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2817 | |
2975 | |
… | |
… | |
2843 | |
3001 | |
2844 | void glEndList () |
3002 | void glEndList () |
2845 | |
3003 | |
2846 | void glCallList (int list) |
3004 | void glCallList (int list) |
2847 | |
3005 | |
2848 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
3006 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2849 | |
3007 | |
2850 | PROTOTYPES: DISABLE |
3008 | PROTOTYPES: DISABLE |
2851 | |
3009 | |
2852 | void |
3010 | void |
2853 | find_widget (SV *self, NV x, NV y) |
3011 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2857 | XPUSHs (self); |
3015 | XPUSHs (self); |
2858 | } |
3016 | } |
2859 | |
3017 | |
2860 | BOOT: |
3018 | BOOT: |
2861 | { |
3019 | { |
2862 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
3020 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2863 | |
3021 | |
2864 | 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); |
2865 | 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); |
2866 | 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); |
2867 | 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); |
2868 | } |
3026 | } |
2869 | |
3027 | |
2870 | void |
3028 | void |
2871 | draw (SV *self) |
3029 | draw (SV *self) |
2872 | CODE: |
3030 | CODE: |
… | |
… | |
2879 | SV *draw_w_sv = GvSV (draw_w_gv); |
3037 | SV *draw_w_sv = GvSV (draw_w_gv); |
2880 | SV *draw_h_sv = GvSV (draw_h_gv); |
3038 | SV *draw_h_sv = GvSV (draw_h_gv); |
2881 | double draw_x, draw_y; |
3039 | double draw_x, draw_y; |
2882 | |
3040 | |
2883 | if (!SvROK (self)) |
3041 | if (!SvROK (self)) |
2884 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
3042 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2885 | |
3043 | |
2886 | hv = (HV *)SvRV (self); |
3044 | hv = (HV *)SvRV (self); |
2887 | |
3045 | |
2888 | if (SvTYPE (hv) != SVt_PVHV) |
3046 | if (SvTYPE (hv) != SVt_PVHV) |
2889 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
3047 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2890 | |
3048 | |
2891 | 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.; |
2892 | 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.; |
2893 | |
3051 | |
2894 | if (!h || !w) |
3052 | if (!h || !w) |
… | |
… | |
2927 | glEnd (); |
3085 | glEnd (); |
2928 | glDisable (GL_BLEND); |
3086 | glDisable (GL_BLEND); |
2929 | } |
3087 | } |
2930 | } |
3088 | } |
2931 | #if 0 |
3089 | #if 0 |
2932 | if ($ENV{CFPLUS_DEBUG} & 1) { |
3090 | // draw borders, for debugging |
2933 | glPushMatrix; |
3091 | glPushMatrix (); |
2934 | glColor 1, 1, 0, 1; |
3092 | glColor4f (1., 1., 0., 1.); |
2935 | glTranslate 0.375, 0.375; |
3093 | glTranslatef (.5, .5, 0.); |
2936 | glBegin GL_LINE_LOOP; |
3094 | glBegin (GL_LINE_LOOP); |
2937 | glVertex 0 , 0; |
3095 | glVertex2f (0 , 0); |
2938 | glVertex $self->{w} - 1, 0; |
3096 | glVertex2f (w - 1, 0); |
2939 | glVertex $self->{w} - 1, $self->{h} - 1; |
3097 | glVertex2f (w - 1, h - 1); |
2940 | glVertex 0 , $self->{h} - 1; |
3098 | glVertex2f (0 , h - 1); |
2941 | glEnd; |
3099 | glEnd (); |
2942 | glPopMatrix; |
3100 | glPopMatrix (); |
2943 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2944 | } |
|
|
2945 | #endif |
3101 | #endif |
2946 | PUSHMARK (SP); |
3102 | PUSHMARK (SP); |
2947 | XPUSHs (self); |
3103 | XPUSHs (self); |
2948 | PUTBACK; |
3104 | PUTBACK; |
2949 | call_method ("_draw", G_VOID | G_DISCARD); |
3105 | call_method ("_draw", G_VOID | G_DISCARD); |