… | |
… | |
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_readonly |
|
|
57 | # define pango_layout_get_lines_readonly pango_layout_get_lines_readonly |
|
|
58 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly |
|
|
59 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly |
|
|
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> |
… | |
… | |
63 | #define MAP_EXTEND_X 32 |
74 | #define MAP_EXTEND_X 32 |
64 | #define MAP_EXTEND_Y 512 |
75 | #define MAP_EXTEND_Y 512 |
65 | |
76 | |
66 | #define MIN_FONT_HEIGHT 10 |
77 | #define MIN_FONT_HEIGHT 10 |
67 | |
78 | |
|
|
79 | /* mask out modifiers we are not interested in */ |
|
|
80 | #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) |
|
|
81 | |
68 | #if 0 |
82 | #if 0 |
69 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
83 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
70 | #else |
84 | #else |
71 | # define PARACHUTE 0 |
85 | # define PARACHUTE 0 |
72 | #endif |
86 | #endif |
… | |
… | |
120 | |
134 | |
121 | #include "pango-font.c" |
135 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
136 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
137 | #include "pango-render.c" |
124 | |
138 | |
125 | typedef IV CFPlus__Channel; |
139 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
140 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
141 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
142 | typedef Mix_Music *DC__MixMusic; |
129 | |
143 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
144 | typedef PangoFontDescription *DC__Font; |
131 | |
145 | |
132 | static int |
146 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
147 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
148 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
149 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
163 | |
150 | typedef struct cf_layout { |
164 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
165 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
166 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
167 | int base_height; |
154 | CFPlus__Font font; |
168 | DC__Font font; |
155 | rc_t *rc; |
169 | rc_t *rc; |
156 | } *CFPlus__Layout; |
170 | } *DC__Layout; |
157 | |
171 | |
158 | static CFPlus__Font default_font; |
172 | static DC__Font default_font; |
159 | static PangoContext *opengl_context; |
173 | static PangoContext *opengl_context; |
160 | static PangoFontMap *opengl_fontmap; |
174 | static PangoFontMap *opengl_fontmap; |
161 | |
175 | |
162 | static void |
176 | static void |
163 | substitute_func (FcPattern *pattern, gpointer data) |
177 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
168 | #endif |
182 | #endif |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
183 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
170 | } |
184 | } |
171 | |
185 | |
172 | static void |
186 | static void |
173 | layout_update_font (CFPlus__Layout self) |
187 | layout_update_font (DC__Layout self) |
174 | { |
188 | { |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
189 | /* use a random scale factor to account for unknown descenders, 0.8 works |
176 | * reasonably well with bitstream vera |
190 | * reasonably well with bitstream vera |
177 | */ |
191 | */ |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
192 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
182 | |
196 | |
183 | pango_layout_set_font_description (self->pl, font); |
197 | pango_layout_set_font_description (self->pl, font); |
184 | } |
198 | } |
185 | |
199 | |
186 | static void |
200 | static void |
187 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
201 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
188 | { |
202 | { |
189 | PangoRectangle rect; |
203 | PangoRectangle rect; |
190 | |
204 | |
191 | // get_pixel_* wrongly rounds down |
205 | // get_pixel_* wrongly rounds down |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
206 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
203 | |
217 | |
204 | typedef uint16_t tileid; |
218 | typedef uint16_t tileid; |
205 | typedef uint16_t faceid; |
219 | typedef uint16_t faceid; |
206 | |
220 | |
207 | typedef struct { |
221 | typedef struct { |
208 | int name; |
222 | GLuint name; |
209 | int w, h; |
223 | int w, h; |
210 | float s, t; |
224 | float s, t; |
211 | uint8_t r, g, b, a; |
225 | uint8_t r, g, b, a; |
212 | tileid smoothtile; |
226 | tileid smoothtile; |
213 | uint8_t smoothlevel; |
227 | uint8_t smoothlevel; |
… | |
… | |
231 | int faces; tileid *face2tile; // [faceid] |
245 | int faces; tileid *face2tile; // [faceid] |
232 | int texs; maptex *tex; // [tileid] |
246 | int texs; maptex *tex; // [tileid] |
233 | |
247 | |
234 | int32_t rows; |
248 | int32_t rows; |
235 | maprow *row; |
249 | maprow *row; |
236 | } *CFPlus__Map; |
250 | } *DC__Map; |
237 | |
251 | |
238 | static char * |
252 | static char * |
239 | prepend (char *ptr, int sze, int inc) |
253 | prepend (char *ptr, int sze, int inc) |
240 | { |
254 | { |
241 | char *p; |
255 | char *p; |
… | |
… | |
279 | self->texs *= 2; |
293 | self->texs *= 2; |
280 | } |
294 | } |
281 | } |
295 | } |
282 | |
296 | |
283 | static maprow * |
297 | static maprow * |
284 | map_get_row (CFPlus__Map self, int y) |
298 | map_get_row (DC__Map self, int y) |
285 | { |
299 | { |
286 | if (0 > y) |
300 | if (0 > y) |
287 | { |
301 | { |
288 | int extend = - y + MAP_EXTEND_Y; |
302 | int extend = - y + MAP_EXTEND_Y; |
289 | Prepend (maprow, self->row, self->rows, extend); |
303 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
327 | |
341 | |
328 | return row->col + (x - row->c0); |
342 | return row->col + (x - row->c0); |
329 | } |
343 | } |
330 | |
344 | |
331 | static mapcell * |
345 | static mapcell * |
332 | map_get_cell (CFPlus__Map self, int x, int y) |
346 | map_get_cell (DC__Map self, int x, int y) |
333 | { |
347 | { |
334 | return row_get_cell (map_get_row (self, y), x); |
348 | return row_get_cell (map_get_row (self, y), x); |
335 | } |
349 | } |
336 | |
350 | |
337 | static void |
351 | static void |
338 | map_clear (CFPlus__Map self) |
352 | map_clear (DC__Map self) |
339 | { |
353 | { |
340 | int r; |
354 | int r; |
341 | |
355 | |
342 | for (r = 0; r < self->rows; r++) |
356 | for (r = 0; r < self->rows; r++) |
343 | Safefree (self->row[r].col); |
357 | Safefree (self->row[r].col); |
… | |
… | |
351 | self->row = 0; |
365 | self->row = 0; |
352 | self->rows = 0; |
366 | self->rows = 0; |
353 | } |
367 | } |
354 | |
368 | |
355 | static void |
369 | static void |
356 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
370 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
357 | { |
371 | { |
358 | int x, y; |
372 | int x, y; |
359 | maprow *row; |
373 | maprow *row; |
360 | mapcell *cell; |
374 | mapcell *cell; |
361 | |
375 | |
… | |
… | |
440 | n |= n >> 16; |
454 | n |= n >> 16; |
441 | |
455 | |
442 | return n + 1; |
456 | return n + 1; |
443 | } |
457 | } |
444 | |
458 | |
|
|
459 | static unsigned int |
|
|
460 | popcount (unsigned int n) |
|
|
461 | { |
|
|
462 | n -= (n >> 1) & 0x55555555U; |
|
|
463 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
464 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
465 | n *= 0x01010101U; |
|
|
466 | |
|
|
467 | return n >> 24; |
|
|
468 | } |
|
|
469 | |
445 | /* SDL should provide this, really. */ |
470 | /* SDL should provide this, really. */ |
446 | #define SDLK_MODIFIER_MIN 300 |
471 | #define SDLK_MODIFIER_MIN 300 |
447 | #define SDLK_MODIFIER_MAX 314 |
472 | #define SDLK_MODIFIER_MAX 314 |
448 | |
473 | |
449 | /******************************************************************************/ |
474 | /******************************************************************************/ |
… | |
… | |
487 | return 0; |
512 | return 0; |
488 | |
513 | |
489 | return 1; |
514 | return 1; |
490 | } |
515 | } |
491 | |
516 | |
492 | MODULE = CFPlus PACKAGE = CFPlus |
517 | MODULE = Deliantra::Client PACKAGE = DC |
493 | |
518 | |
494 | PROTOTYPES: ENABLE |
519 | PROTOTYPES: ENABLE |
495 | |
520 | |
496 | BOOT: |
521 | BOOT: |
497 | { |
522 | { |
498 | HV *stash = gv_stashpv ("CFPlus", 1); |
523 | HV *stash = gv_stashpv ("DC", 1); |
499 | static const struct { |
524 | static const struct { |
500 | const char *name; |
525 | const char *name; |
501 | IV iv; |
526 | IV iv; |
502 | } *civ, const_iv[] = { |
527 | } *civ, const_iv[] = { |
503 | # define const_iv(name) { # name, (IV)name } |
528 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
525 | |
550 | |
526 | const_iv (SDL_APPINPUTFOCUS), |
551 | const_iv (SDL_APPINPUTFOCUS), |
527 | const_iv (SDL_APPMOUSEFOCUS), |
552 | const_iv (SDL_APPMOUSEFOCUS), |
528 | const_iv (SDL_APPACTIVE), |
553 | const_iv (SDL_APPACTIVE), |
529 | |
554 | |
|
|
555 | const_iv (SDLK_FIRST), |
|
|
556 | const_iv (SDLK_LAST), |
530 | const_iv (SDLK_KP0), |
557 | const_iv (SDLK_KP0), |
531 | const_iv (SDLK_KP1), |
558 | const_iv (SDLK_KP1), |
532 | const_iv (SDLK_KP2), |
559 | const_iv (SDLK_KP2), |
533 | const_iv (SDLK_KP3), |
560 | const_iv (SDLK_KP3), |
534 | const_iv (SDLK_KP4), |
561 | const_iv (SDLK_KP4), |
… | |
… | |
606 | const_iv (KMOD_LMETA), |
633 | const_iv (KMOD_LMETA), |
607 | const_iv (KMOD_RMETA), |
634 | const_iv (KMOD_RMETA), |
608 | const_iv (KMOD_NUM), |
635 | const_iv (KMOD_NUM), |
609 | const_iv (KMOD_CAPS), |
636 | const_iv (KMOD_CAPS), |
610 | const_iv (KMOD_MODE), |
637 | const_iv (KMOD_MODE), |
|
|
638 | |
|
|
639 | const_iv (MIX_DEFAULT_FORMAT), |
611 | # undef const_iv |
640 | # undef const_iv |
612 | }; |
641 | }; |
613 | |
642 | |
614 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
643 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
615 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
644 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
633 | |
662 | |
634 | NV floor (NV x) |
663 | NV floor (NV x) |
635 | |
664 | |
636 | NV ceil (NV x) |
665 | NV ceil (NV x) |
637 | |
666 | |
|
|
667 | IV minpot (UV n) |
|
|
668 | |
|
|
669 | IV popcount (UV n) |
|
|
670 | |
638 | void |
671 | void |
639 | pango_init () |
672 | pango_init () |
640 | CODE: |
673 | CODE: |
641 | { |
674 | { |
642 | opengl_fontmap = pango_opengl_font_map_new (); |
675 | opengl_fontmap = pango_opengl_font_map_new (); |
643 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
676 | 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); |
677 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
678 | #if PANGO_VERSION_CHECK (1, 15, 2) |
|
|
679 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
680 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
681 | #endif |
645 | } |
682 | } |
646 | |
683 | |
647 | char * |
684 | char * |
648 | SDL_GetError () |
685 | SDL_GetError () |
649 | |
686 | |
… | |
… | |
681 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
718 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
682 | |
719 | |
683 | if (m && m != (SDL_Rect **)-1) |
720 | if (m && m != (SDL_Rect **)-1) |
684 | while (*m) |
721 | while (*m) |
685 | { |
722 | { |
686 | if ((*m)->w >= 640 && (*m)->h >= 480) |
723 | if ((*m)->w >= 800 && (*m)->h >= 480) |
687 | { |
724 | { |
688 | AV *av = newAV (); |
725 | AV *av = newAV (); |
689 | av_push (av, newSViv ((*m)->w)); |
726 | av_push (av, newSViv ((*m)->w)); |
690 | av_push (av, newSViv ((*m)->h)); |
727 | av_push (av, newSViv ((*m)->h)); |
691 | av_push (av, newSViv (rgb)); |
728 | av_push (av, newSViv (rgb)); |
… | |
… | |
715 | |
752 | |
716 | if (RETVAL) |
753 | if (RETVAL) |
717 | { |
754 | { |
718 | av_clear (texture_av); |
755 | av_clear (texture_av); |
719 | |
756 | |
720 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
757 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
721 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
758 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
722 | #include "glfunc.h" |
759 | #include "glfunc.h" |
723 | #undef GL_FUNC |
760 | #undef GL_FUNC |
724 | } |
761 | } |
725 | } |
762 | } |
… | |
… | |
751 | { |
788 | { |
752 | case SDL_KEYDOWN: |
789 | case SDL_KEYDOWN: |
753 | case SDL_KEYUP: |
790 | case SDL_KEYUP: |
754 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
791 | hv_store (hv, "state", 5, newSViv (ev.key.state), 0); |
755 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
792 | hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); |
756 | hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); |
793 | 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 */ |
794 | 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); |
795 | hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); |
759 | break; |
796 | break; |
760 | |
797 | |
761 | case SDL_ACTIVEEVENT: |
798 | case SDL_ACTIVEEVENT: |
762 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
799 | hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); |
… | |
… | |
780 | x = ev.motion.x; |
817 | x = ev.motion.x; |
781 | y = ev.motion.y; |
818 | y = ev.motion.y; |
782 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
819 | SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); |
783 | } |
820 | } |
784 | |
821 | |
785 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
822 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
786 | hv_store (hv, "state", 5, newSViv (state), 0); |
823 | hv_store (hv, "state", 5, newSViv (state), 0); |
787 | hv_store (hv, "x", 1, newSViv (x), 0); |
824 | hv_store (hv, "x", 1, newSViv (x), 0); |
788 | hv_store (hv, "y", 1, newSViv (y), 0); |
825 | hv_store (hv, "y", 1, newSViv (y), 0); |
789 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
826 | hv_store (hv, "xrel", 4, newSViv (xrel), 0); |
790 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
827 | hv_store (hv, "yrel", 4, newSViv (yrel), 0); |
791 | } |
828 | } |
792 | break; |
829 | break; |
793 | |
830 | |
794 | case SDL_MOUSEBUTTONDOWN: |
831 | case SDL_MOUSEBUTTONDOWN: |
795 | case SDL_MOUSEBUTTONUP: |
832 | case SDL_MOUSEBUTTONUP: |
796 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); |
833 | hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); |
797 | |
834 | |
798 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
835 | hv_store (hv, "button", 6, newSViv (ev.button.button), 0); |
799 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
836 | hv_store (hv, "state", 5, newSViv (ev.button.state), 0); |
800 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
837 | hv_store (hv, "x", 1, newSViv (ev.button.x), 0); |
801 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
838 | hv_store (hv, "y", 1, newSViv (ev.button.y), 0); |
… | |
… | |
806 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
843 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
807 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
844 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
808 | break; |
845 | break; |
809 | } |
846 | } |
810 | |
847 | |
811 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
848 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
812 | } |
849 | } |
813 | } |
850 | } |
814 | |
851 | |
815 | int |
852 | int |
816 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
853 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
817 | POSTCALL: |
854 | POSTCALL: |
818 | Mix_HookMusicFinished (music_finished); |
855 | Mix_HookMusicFinished (music_finished); |
819 | Mix_ChannelFinished (channel_finished); |
856 | Mix_ChannelFinished (channel_finished); |
|
|
857 | |
|
|
858 | void |
|
|
859 | Mix_QuerySpec () |
|
|
860 | PPCODE: |
|
|
861 | { |
|
|
862 | int freq, channels; |
|
|
863 | Uint16 format; |
|
|
864 | |
|
|
865 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
866 | { |
|
|
867 | EXTEND (SP, 3); |
|
|
868 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
869 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
870 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
871 | } |
|
|
872 | } |
820 | |
873 | |
821 | void |
874 | void |
822 | Mix_CloseAudio () |
875 | Mix_CloseAudio () |
823 | |
876 | |
824 | int |
877 | int |
… | |
… | |
958 | void |
1011 | void |
959 | error (char *message) |
1012 | error (char *message) |
960 | CODE: |
1013 | CODE: |
961 | fprintf (stderr, "ERROR: %s\n", message); |
1014 | fprintf (stderr, "ERROR: %s\n", message); |
962 | #ifdef _WIN32 |
1015 | #ifdef _WIN32 |
963 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1016 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
964 | #endif |
1017 | #endif |
965 | |
1018 | |
966 | void |
1019 | void |
967 | fatal (char *message) |
1020 | fatal (char *message) |
968 | CODE: |
1021 | CODE: |
969 | fprintf (stderr, "FATAL: %s\n", message); |
1022 | fprintf (stderr, "FATAL: %s\n", message); |
970 | #ifdef _WIN32 |
1023 | #ifdef _WIN32 |
971 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1024 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
972 | #endif |
1025 | #endif |
973 | _exit (1); |
1026 | _exit (1); |
974 | |
1027 | |
975 | void |
1028 | void |
976 | _exit (int retval = 0) |
1029 | _exit (int retval = 0) |
… | |
… | |
988 | #if DEBUG |
1041 | #if DEBUG |
989 | VALGRIND_DO_LEAK_CHECK; |
1042 | VALGRIND_DO_LEAK_CHECK; |
990 | #endif |
1043 | #endif |
991 | } |
1044 | } |
992 | |
1045 | |
993 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1046 | MODULE = Deliantra::Client PACKAGE = DC::Font |
994 | |
1047 | |
995 | PROTOTYPES: DISABLE |
1048 | PROTOTYPES: DISABLE |
996 | |
1049 | |
997 | CFPlus::Font |
1050 | DC::Font |
998 | new_from_file (SV *class, char *path, int id = 0) |
1051 | new_from_file (SV *class, char *path, int id = 0) |
999 | CODE: |
1052 | CODE: |
1000 | { |
1053 | { |
1001 | int count; |
1054 | int count; |
1002 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1055 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1005 | } |
1058 | } |
1006 | OUTPUT: |
1059 | OUTPUT: |
1007 | RETVAL |
1060 | RETVAL |
1008 | |
1061 | |
1009 | void |
1062 | void |
1010 | DESTROY (CFPlus::Font self) |
1063 | DESTROY (DC::Font self) |
1011 | CODE: |
1064 | CODE: |
1012 | pango_font_description_free (self); |
1065 | pango_font_description_free (self); |
1013 | |
1066 | |
1014 | void |
1067 | void |
1015 | make_default (CFPlus::Font self) |
1068 | make_default (DC::Font self) |
1016 | PROTOTYPE: $ |
1069 | PROTOTYPE: $ |
1017 | CODE: |
1070 | CODE: |
1018 | default_font = self; |
1071 | default_font = self; |
1019 | |
1072 | |
1020 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1073 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1021 | |
1074 | |
1022 | PROTOTYPES: DISABLE |
1075 | PROTOTYPES: DISABLE |
1023 | |
1076 | |
1024 | void |
1077 | void |
1025 | reset_glyph_cache () |
1078 | glyph_cache_backup () |
1026 | PROTOTYPE: |
1079 | PROTOTYPE: |
1027 | CODE: |
1080 | CODE: |
|
|
1081 | tc_backup (); |
|
|
1082 | |
|
|
1083 | void |
|
|
1084 | glyph_cache_restore () |
|
|
1085 | PROTOTYPE: |
|
|
1086 | CODE: |
1028 | tc_clear (); |
1087 | tc_restore (); |
1029 | |
1088 | |
1030 | CFPlus::Layout |
1089 | DC::Layout |
1031 | new (SV *class) |
1090 | new (SV *class) |
1032 | CODE: |
1091 | CODE: |
1033 | New (0, RETVAL, 1, struct cf_layout); |
1092 | New (0, RETVAL, 1, struct cf_layout); |
1034 | |
1093 | |
1035 | RETVAL->pl = pango_layout_new (opengl_context); |
1094 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1045 | layout_update_font (RETVAL); |
1104 | layout_update_font (RETVAL); |
1046 | OUTPUT: |
1105 | OUTPUT: |
1047 | RETVAL |
1106 | RETVAL |
1048 | |
1107 | |
1049 | void |
1108 | void |
1050 | DESTROY (CFPlus::Layout self) |
1109 | DESTROY (DC::Layout self) |
1051 | CODE: |
1110 | CODE: |
1052 | g_object_unref (self->pl); |
1111 | g_object_unref (self->pl); |
1053 | rc_free (self->rc); |
1112 | rc_free (self->rc); |
1054 | Safefree (self); |
1113 | Safefree (self); |
1055 | |
1114 | |
1056 | void |
1115 | void |
1057 | set_text (CFPlus::Layout self, SV *text_) |
1116 | set_text (DC::Layout self, SV *text_) |
1058 | CODE: |
1117 | CODE: |
1059 | { |
1118 | { |
1060 | STRLEN textlen; |
1119 | STRLEN textlen; |
1061 | char *text = SvPVutf8 (text_, textlen); |
1120 | char *text = SvPVutf8 (text_, textlen); |
1062 | |
1121 | |
1063 | pango_layout_set_text (self->pl, text, textlen); |
1122 | pango_layout_set_text (self->pl, text, textlen); |
1064 | } |
1123 | } |
1065 | |
1124 | |
1066 | void |
1125 | void |
1067 | set_markup (CFPlus::Layout self, SV *text_) |
1126 | set_markup (DC::Layout self, SV *text_) |
1068 | CODE: |
1127 | CODE: |
1069 | { |
1128 | { |
1070 | STRLEN textlen; |
1129 | STRLEN textlen; |
1071 | char *text = SvPVutf8 (text_, textlen); |
1130 | char *text = SvPVutf8 (text_, textlen); |
1072 | |
1131 | |
1073 | pango_layout_set_markup (self->pl, text, textlen); |
1132 | pango_layout_set_markup (self->pl, text, textlen); |
1074 | } |
1133 | } |
1075 | |
1134 | |
1076 | void |
1135 | void |
1077 | set_shapes (CFPlus::Layout self, ...) |
1136 | set_shapes (DC::Layout self, ...) |
1078 | CODE: |
1137 | CODE: |
1079 | { |
1138 | { |
1080 | PangoAttrList *attrs = 0; |
1139 | PangoAttrList *attrs = 0; |
1081 | const char *text = pango_layout_get_text (self->pl); |
1140 | const char *text = pango_layout_get_text (self->pl); |
1082 | const char *pos = text; |
1141 | const char *pos = text; |
… | |
… | |
1117 | if (attrs) |
1176 | if (attrs) |
1118 | pango_layout_set_attributes (self->pl, attrs); |
1177 | pango_layout_set_attributes (self->pl, attrs); |
1119 | } |
1178 | } |
1120 | |
1179 | |
1121 | void |
1180 | void |
1122 | get_shapes (CFPlus::Layout self) |
1181 | get_shapes (DC::Layout self) |
1123 | PPCODE: |
1182 | PPCODE: |
1124 | { |
1183 | { |
1125 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1184 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1126 | |
1185 | |
1127 | do |
1186 | do |
1128 | { |
1187 | { |
1129 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1188 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1130 | |
1189 | |
1131 | if (run && shape_attr_p (run)) |
1190 | if (run && shape_attr_p (run)) |
1132 | { |
1191 | { |
1133 | PangoRectangle extents; |
1192 | PangoRectangle extents; |
1134 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1193 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1142 | |
1201 | |
1143 | pango_layout_iter_free (iter); |
1202 | pango_layout_iter_free (iter); |
1144 | } |
1203 | } |
1145 | |
1204 | |
1146 | int |
1205 | int |
1147 | has_wrapped (CFPlus::Layout self) |
1206 | has_wrapped (DC::Layout self) |
1148 | CODE: |
1207 | CODE: |
1149 | { |
1208 | { |
1150 | int lines = 1; |
1209 | int lines = 1; |
1151 | const char *text = pango_layout_get_text (self->pl); |
1210 | const char *text = pango_layout_get_text (self->pl); |
1152 | |
1211 | |
… | |
… | |
1157 | } |
1216 | } |
1158 | OUTPUT: |
1217 | OUTPUT: |
1159 | RETVAL |
1218 | RETVAL |
1160 | |
1219 | |
1161 | SV * |
1220 | SV * |
1162 | get_text (CFPlus::Layout self) |
1221 | get_text (DC::Layout self) |
1163 | CODE: |
1222 | CODE: |
1164 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1223 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1165 | sv_utf8_decode (RETVAL); |
1224 | sv_utf8_decode (RETVAL); |
1166 | OUTPUT: |
1225 | OUTPUT: |
1167 | RETVAL |
1226 | RETVAL |
1168 | |
1227 | |
1169 | void |
1228 | void |
1170 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1229 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1171 | CODE: |
1230 | CODE: |
1172 | self->r = r; |
1231 | self->r = r; |
1173 | self->g = g; |
1232 | self->g = g; |
1174 | self->b = b; |
1233 | self->b = b; |
1175 | self->a = a; |
1234 | self->a = a; |
1176 | |
1235 | |
1177 | void |
1236 | void |
1178 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1237 | set_font (DC::Layout self, DC::Font font = 0) |
1179 | CODE: |
1238 | CODE: |
1180 | if (self->font != font) |
1239 | if (self->font != font) |
1181 | { |
1240 | { |
1182 | self->font = font; |
1241 | self->font = font; |
1183 | layout_update_font (self); |
1242 | layout_update_font (self); |
1184 | } |
1243 | } |
1185 | |
1244 | |
1186 | void |
1245 | void |
1187 | set_height (CFPlus::Layout self, int base_height) |
1246 | set_height (DC::Layout self, int base_height) |
1188 | CODE: |
1247 | CODE: |
1189 | if (self->base_height != base_height) |
1248 | if (self->base_height != base_height) |
1190 | { |
1249 | { |
1191 | self->base_height = base_height; |
1250 | self->base_height = base_height; |
1192 | layout_update_font (self); |
1251 | layout_update_font (self); |
1193 | } |
1252 | } |
1194 | |
1253 | |
1195 | void |
1254 | void |
1196 | set_width (CFPlus::Layout self, int max_width = -1) |
1255 | set_width (DC::Layout self, int max_width = -1) |
1197 | CODE: |
1256 | CODE: |
1198 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1257 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1199 | |
1258 | |
1200 | void |
1259 | void |
1201 | set_indent (CFPlus::Layout self, int indent) |
1260 | set_indent (DC::Layout self, int indent) |
1202 | CODE: |
1261 | CODE: |
1203 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1262 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1204 | |
1263 | |
1205 | void |
1264 | void |
1206 | set_spacing (CFPlus::Layout self, int spacing) |
1265 | set_spacing (DC::Layout self, int spacing) |
1207 | CODE: |
1266 | CODE: |
1208 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1267 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1209 | |
1268 | |
1210 | void |
1269 | void |
1211 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1270 | set_ellipsise (DC::Layout self, int ellipsise) |
1212 | CODE: |
1271 | CODE: |
1213 | pango_layout_set_ellipsize (self->pl, |
1272 | pango_layout_set_ellipsize (self->pl, |
1214 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1273 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1215 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1274 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1216 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1275 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1217 | : PANGO_ELLIPSIZE_NONE |
1276 | : PANGO_ELLIPSIZE_NONE |
1218 | ); |
1277 | ); |
1219 | |
1278 | |
1220 | void |
1279 | void |
1221 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1280 | set_single_paragraph_mode (DC::Layout self, int spm) |
1222 | CODE: |
1281 | CODE: |
1223 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1282 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1224 | |
1283 | |
1225 | void |
1284 | void |
1226 | size (CFPlus::Layout self) |
1285 | size (DC::Layout self) |
1227 | PPCODE: |
1286 | PPCODE: |
1228 | { |
1287 | { |
1229 | int w, h; |
1288 | int w, h; |
1230 | |
1289 | |
1231 | layout_get_pixel_size (self, &w, &h); |
1290 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1234 | PUSHs (sv_2mortal (newSViv (w))); |
1293 | PUSHs (sv_2mortal (newSViv (w))); |
1235 | PUSHs (sv_2mortal (newSViv (h))); |
1294 | PUSHs (sv_2mortal (newSViv (h))); |
1236 | } |
1295 | } |
1237 | |
1296 | |
1238 | int |
1297 | int |
1239 | descent (CFPlus::Layout self) |
1298 | descent (DC::Layout self) |
1240 | CODE: |
1299 | CODE: |
1241 | { |
1300 | { |
1242 | PangoRectangle rect; |
1301 | PangoRectangle rect; |
1243 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1302 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1244 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1303 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1245 | RETVAL = PANGO_DESCENT (rect); |
1304 | RETVAL = PANGO_DESCENT (rect); |
1246 | } |
1305 | } |
1247 | OUTPUT: |
1306 | OUTPUT: |
1248 | RETVAL |
1307 | RETVAL |
1249 | |
1308 | |
1250 | int |
1309 | int |
1251 | xy_to_index (CFPlus::Layout self, int x, int y) |
1310 | xy_to_index (DC::Layout self, int x, int y) |
1252 | CODE: |
1311 | CODE: |
1253 | { |
1312 | { |
1254 | int index, trailing; |
1313 | int index, trailing; |
1255 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1314 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1256 | RETVAL = index + trailing; |
1315 | RETVAL = index + trailing; |
1257 | } |
1316 | } |
1258 | OUTPUT: |
1317 | OUTPUT: |
1259 | RETVAL |
1318 | RETVAL |
1260 | |
1319 | |
1261 | void |
1320 | void |
1262 | cursor_pos (CFPlus::Layout self, int index) |
1321 | cursor_pos (DC::Layout self, int index) |
1263 | PPCODE: |
1322 | PPCODE: |
1264 | { |
1323 | { |
1265 | PangoRectangle strong_pos; |
1324 | PangoRectangle pos; |
1266 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1325 | pango_layout_get_cursor_pos (self->pl, index, &pos, 0); |
1267 | |
1326 | |
1268 | EXTEND (SP, 3); |
1327 | EXTEND (SP, 3); |
1269 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1328 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1270 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1329 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1271 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1330 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1272 | } |
1331 | } |
1273 | |
1332 | |
1274 | void |
1333 | void |
1275 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1334 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1276 | PPCODE: |
1335 | PPCODE: |
1277 | { |
1336 | { |
1278 | int line, x; |
1337 | int line, x; |
1279 | |
1338 | |
1280 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1339 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1340 | #if !PANGO_VERSION_CHECK (1, 17, 3) |
1281 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1341 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1282 | |
1342 | --line; |
|
|
1343 | #endif |
1283 | EXTEND (SP, 2); |
1344 | EXTEND (SP, 2); |
1284 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1345 | PUSHs (sv_2mortal (newSViv (line))); |
1285 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1346 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1286 | } |
1347 | } |
1287 | |
1348 | |
1288 | void |
1349 | void |
1289 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1350 | line_x_to_index (DC::Layout self, int line, int x) |
1290 | PPCODE: |
1351 | PPCODE: |
1291 | { |
1352 | { |
1292 | PangoLayoutLine *lp; |
1353 | PangoLayoutLine *lp; |
1293 | int index, trailing; |
1354 | int index, trailing; |
1294 | |
1355 | |
1295 | if (line < 0) |
1356 | if (line < 0) |
1296 | XSRETURN_EMPTY; |
1357 | XSRETURN_EMPTY; |
1297 | |
1358 | |
1298 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1359 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1299 | XSRETURN_EMPTY; /* do better */ |
1360 | XSRETURN_EMPTY; /* do better */ |
1300 | |
1361 | |
1301 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1362 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1302 | |
1363 | |
1303 | EXTEND (SP, 2); |
1364 | EXTEND (SP, 2); |
… | |
… | |
1309 | PUSHs (sv_2mortal (newSViv (trailing))); |
1370 | PUSHs (sv_2mortal (newSViv (trailing))); |
1310 | } |
1371 | } |
1311 | } |
1372 | } |
1312 | |
1373 | |
1313 | void |
1374 | void |
1314 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1375 | render (DC::Layout self, float x, float y, int flags = 0) |
1315 | CODE: |
1376 | CODE: |
1316 | rc_clear (self->rc); |
1377 | rc_clear (self->rc); |
1317 | pango_opengl_render_layout_subpixel ( |
1378 | pango_opengl_render_layout_subpixel ( |
1318 | self->pl, |
1379 | self->pl, |
1319 | self->rc, |
1380 | self->rc, |
… | |
… | |
1324 | // we assume that context_change actually clears/frees stuff |
1385 | // we assume that context_change actually clears/frees stuff |
1325 | // and does not do any recomputation... |
1386 | // and does not do any recomputation... |
1326 | pango_layout_context_changed (self->pl); |
1387 | pango_layout_context_changed (self->pl); |
1327 | |
1388 | |
1328 | void |
1389 | void |
1329 | draw (CFPlus::Layout self) |
1390 | draw (DC::Layout self) |
1330 | CODE: |
1391 | CODE: |
1331 | { |
1392 | { |
1332 | glEnable (GL_TEXTURE_2D); |
1393 | glEnable (GL_TEXTURE_2D); |
1333 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1394 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1334 | glEnable (GL_BLEND); |
1395 | glEnable (GL_BLEND); |
… | |
… | |
1342 | glDisable (GL_ALPHA_TEST); |
1403 | glDisable (GL_ALPHA_TEST); |
1343 | glDisable (GL_BLEND); |
1404 | glDisable (GL_BLEND); |
1344 | glDisable (GL_TEXTURE_2D); |
1405 | glDisable (GL_TEXTURE_2D); |
1345 | } |
1406 | } |
1346 | |
1407 | |
1347 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1408 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1348 | |
1409 | |
1349 | PROTOTYPES: ENABLE |
1410 | PROTOTYPES: ENABLE |
1350 | |
|
|
1351 | int minpot (int n) |
|
|
1352 | |
1411 | |
1353 | void |
1412 | void |
1354 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1413 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1355 | CODE: |
1414 | CODE: |
1356 | { |
1415 | { |
… | |
… | |
1433 | RETVAL = width > 0; |
1492 | RETVAL = width > 0; |
1434 | } |
1493 | } |
1435 | OUTPUT: |
1494 | OUTPUT: |
1436 | RETVAL |
1495 | RETVAL |
1437 | |
1496 | |
1438 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1497 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1439 | |
1498 | |
1440 | PROTOTYPES: DISABLE |
1499 | PROTOTYPES: DISABLE |
1441 | |
1500 | |
1442 | CFPlus::Map |
1501 | DC::Map |
1443 | new (SV *class) |
1502 | new (SV *class) |
1444 | CODE: |
1503 | CODE: |
1445 | New (0, RETVAL, 1, struct map); |
1504 | New (0, RETVAL, 1, struct map); |
1446 | RETVAL->x = 0; |
1505 | RETVAL->x = 0; |
1447 | RETVAL->y = 0; |
1506 | RETVAL->y = 0; |
… | |
… | |
1455 | RETVAL->row = 0; |
1514 | RETVAL->row = 0; |
1456 | OUTPUT: |
1515 | OUTPUT: |
1457 | RETVAL |
1516 | RETVAL |
1458 | |
1517 | |
1459 | void |
1518 | void |
1460 | DESTROY (CFPlus::Map self) |
1519 | DESTROY (DC::Map self) |
1461 | CODE: |
1520 | CODE: |
1462 | { |
1521 | { |
1463 | map_clear (self); |
1522 | map_clear (self); |
1464 | Safefree (self->face2tile); |
1523 | Safefree (self->face2tile); |
1465 | Safefree (self->tex); |
1524 | Safefree (self->tex); |
1466 | Safefree (self); |
1525 | Safefree (self); |
1467 | } |
1526 | } |
1468 | |
1527 | |
1469 | void |
1528 | void |
1470 | resize (CFPlus::Map self, int map_width, int map_height) |
1529 | resize (DC::Map self, int map_width, int map_height) |
1471 | CODE: |
1530 | CODE: |
1472 | self->w = map_width; |
1531 | self->w = map_width; |
1473 | self->h = map_height; |
1532 | self->h = map_height; |
1474 | |
1533 | |
1475 | void |
1534 | void |
1476 | clear (CFPlus::Map self) |
1535 | clear (DC::Map self) |
1477 | CODE: |
1536 | CODE: |
1478 | map_clear (self); |
1537 | map_clear (self); |
1479 | |
1538 | |
1480 | void |
1539 | void |
1481 | set_tileid (CFPlus::Map self, int face, int tile) |
1540 | set_tileid (DC::Map self, int face, int tile) |
1482 | CODE: |
1541 | CODE: |
1483 | { |
1542 | { |
1484 | need_facenum (self, face); self->face2tile [face] = tile; |
1543 | need_facenum (self, face); self->face2tile [face] = tile; |
1485 | need_texid (self, tile); |
1544 | need_texid (self, tile); |
1486 | } |
1545 | } |
1487 | |
1546 | |
1488 | void |
1547 | void |
1489 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1548 | set_smooth (DC::Map self, int face, int smooth, int level) |
1490 | CODE: |
1549 | CODE: |
1491 | { |
1550 | { |
1492 | tileid texid; |
1551 | tileid texid; |
1493 | maptex *tex; |
1552 | maptex *tex; |
1494 | |
1553 | |
… | |
… | |
1507 | tex->smoothtile = self->face2tile [smooth]; |
1566 | tex->smoothtile = self->face2tile [smooth]; |
1508 | tex->smoothlevel = level; |
1567 | tex->smoothlevel = level; |
1509 | } |
1568 | } |
1510 | |
1569 | |
1511 | void |
1570 | 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) |
1571 | 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: |
1572 | CODE: |
1514 | { |
1573 | { |
1515 | need_texid (self, texid); |
1574 | need_texid (self, texid); |
1516 | |
1575 | |
1517 | { |
1576 | { |
… | |
… | |
1537 | // from transparent color bleeding and ugly wrapping effects. |
1596 | // from transparent color bleeding and ugly wrapping effects. |
1538 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1597 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1539 | } |
1598 | } |
1540 | |
1599 | |
1541 | int |
1600 | int |
1542 | ox (CFPlus::Map self) |
1601 | ox (DC::Map self) |
1543 | ALIAS: |
1602 | ALIAS: |
1544 | oy = 1 |
1603 | oy = 1 |
1545 | x = 2 |
1604 | x = 2 |
1546 | y = 3 |
1605 | y = 3 |
1547 | w = 4 |
1606 | w = 4 |
… | |
… | |
1558 | } |
1617 | } |
1559 | OUTPUT: |
1618 | OUTPUT: |
1560 | RETVAL |
1619 | RETVAL |
1561 | |
1620 | |
1562 | void |
1621 | void |
1563 | scroll (CFPlus::Map self, int dx, int dy) |
1622 | scroll (DC::Map self, int dx, int dy) |
1564 | CODE: |
1623 | CODE: |
1565 | { |
1624 | { |
1566 | if (dx > 0) |
1625 | if (dx > 0) |
1567 | map_blank (self, self->x, self->y, dx, self->h); |
1626 | map_blank (self, self->x, self->y, dx, self->h); |
1568 | else if (dx < 0) |
1627 | else if (dx < 0) |
… | |
… | |
1584 | self->y += MAP_EXTEND_Y; |
1643 | self->y += MAP_EXTEND_Y; |
1585 | } |
1644 | } |
1586 | } |
1645 | } |
1587 | |
1646 | |
1588 | SV * |
1647 | SV * |
1589 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1648 | map1a_update (DC::Map self, SV *data_, int extmap) |
1590 | CODE: |
1649 | CODE: |
1591 | { |
1650 | { |
1592 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1651 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1593 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1652 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1594 | mapcell *cell; |
1653 | mapcell *cell; |
… | |
… | |
1683 | } |
1742 | } |
1684 | OUTPUT: |
1743 | OUTPUT: |
1685 | RETVAL |
1744 | RETVAL |
1686 | |
1745 | |
1687 | SV * |
1746 | SV * |
1688 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1747 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1689 | CODE: |
1748 | CODE: |
1690 | { |
1749 | { |
1691 | int x1, x; |
1750 | int x1, x; |
1692 | int y1, y; |
1751 | int y1, y; |
1693 | int z; |
1752 | int z; |
… | |
… | |
1738 | } |
1797 | } |
1739 | OUTPUT: |
1798 | OUTPUT: |
1740 | RETVAL |
1799 | RETVAL |
1741 | |
1800 | |
1742 | void |
1801 | void |
1743 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1802 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1744 | CODE: |
1803 | CODE: |
1745 | { |
1804 | { |
1746 | int x, y, z; |
1805 | int x, y, z; |
1747 | |
1806 | |
1748 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1807 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
… | |
… | |
2019 | } |
2078 | } |
2020 | } |
2079 | } |
2021 | } |
2080 | } |
2022 | |
2081 | |
2023 | void |
2082 | void |
2024 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2083 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2025 | CODE: |
2084 | CODE: |
2026 | { |
2085 | { |
2027 | static float color[16][3] = { |
2086 | static float color[16][3] = { |
2028 | { 0.00F, 0.00F, 0.00F }, |
2087 | { 0.00F, 0.00F, 0.00F }, |
2029 | { 1.00F, 1.00F, 1.00F }, |
2088 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2079 | glDisable (GL_BLEND); |
2138 | glDisable (GL_BLEND); |
2080 | glDisable (GL_TEXTURE_2D); |
2139 | glDisable (GL_TEXTURE_2D); |
2081 | } |
2140 | } |
2082 | |
2141 | |
2083 | void |
2142 | void |
2084 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2143 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2085 | PPCODE: |
2144 | PPCODE: |
2086 | { |
2145 | { |
2087 | int x, y; |
2146 | int x, y; |
2088 | int sw1 = sw + 2; |
2147 | int sw1 = sw + 2; |
2089 | int sh1 = sh + 2; |
2148 | int sh1 = sh + 2; |
… | |
… | |
2160 | PUSHs (sv_2mortal (newSViv (sh3))); |
2219 | PUSHs (sv_2mortal (newSViv (sh3))); |
2161 | PUSHs (darkness3_sv); |
2220 | PUSHs (darkness3_sv); |
2162 | } |
2221 | } |
2163 | |
2222 | |
2164 | SV * |
2223 | SV * |
2165 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2224 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2166 | CODE: |
2225 | CODE: |
2167 | { |
2226 | { |
2168 | int x, y, x1, y1; |
2227 | int x, y, x1, y1; |
2169 | SV *data_sv = newSV (w * h * 7 + 5); |
2228 | SV *data_sv = newSV (w * h * 7 + 5); |
2170 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2229 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2235 | } |
2294 | } |
2236 | OUTPUT: |
2295 | OUTPUT: |
2237 | RETVAL |
2296 | RETVAL |
2238 | |
2297 | |
2239 | void |
2298 | void |
2240 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2299 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2241 | PPCODE: |
2300 | PPCODE: |
2242 | { |
2301 | { |
2243 | int x, y, z; |
2302 | int x, y, z; |
2244 | int w, h; |
2303 | int w, h; |
2245 | int x1, y1; |
2304 | int x1, y1; |
… | |
… | |
2298 | } |
2357 | } |
2299 | } |
2358 | } |
2300 | } |
2359 | } |
2301 | } |
2360 | } |
2302 | |
2361 | |
2303 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2362 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2304 | |
2363 | |
2305 | CFPlus::RW |
2364 | DC::RW |
2306 | new (SV *class, SV *data_sv) |
2365 | new (SV *class, SV *data_sv) |
2307 | CODE: |
2366 | CODE: |
2308 | { |
2367 | { |
2309 | STRLEN datalen; |
2368 | STRLEN datalen; |
2310 | char *data = SvPVbyte (data_sv, datalen); |
2369 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2312 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2371 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2313 | } |
2372 | } |
2314 | OUTPUT: |
2373 | OUTPUT: |
2315 | RETVAL |
2374 | RETVAL |
2316 | |
2375 | |
2317 | CFPlus::RW |
2376 | DC::RW |
2318 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2377 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2319 | CODE: |
2378 | CODE: |
2320 | RETVAL = SDL_RWFromFile (path, mode); |
2379 | RETVAL = SDL_RWFromFile (path, mode); |
2321 | OUTPUT: |
2380 | OUTPUT: |
2322 | RETVAL |
2381 | RETVAL |
2323 | |
2382 | |
2324 | # fails on win32: |
2383 | # fails on win32: |
2325 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2384 | # dc.xs(2268) : error C2059: syntax error : '(' |
2326 | #void |
2385 | #void |
2327 | #close (CFPlus::RW self) |
2386 | #close (DC::RW self) |
2328 | # CODE: |
2387 | # CODE: |
2329 | # (self->(close)) (self); |
2388 | # (self->(close)) (self); |
2330 | |
2389 | |
2331 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2390 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2332 | |
2391 | |
2333 | PROTOTYPES: DISABLE |
2392 | PROTOTYPES: DISABLE |
2334 | |
2393 | |
2335 | CFPlus::Channel |
2394 | DC::Channel |
2336 | find () |
2395 | find () |
2337 | CODE: |
2396 | CODE: |
2338 | { |
2397 | { |
2339 | RETVAL = Mix_GroupAvailable (-1); |
2398 | RETVAL = Mix_GroupAvailable (-1); |
2340 | |
2399 | |
… | |
… | |
2353 | } |
2412 | } |
2354 | OUTPUT: |
2413 | OUTPUT: |
2355 | RETVAL |
2414 | RETVAL |
2356 | |
2415 | |
2357 | void |
2416 | void |
2358 | halt (CFPlus::Channel self) |
2417 | halt (DC::Channel self) |
2359 | CODE: |
2418 | CODE: |
2360 | Mix_HaltChannel (self); |
2419 | Mix_HaltChannel (self); |
2361 | |
2420 | |
2362 | void |
2421 | void |
2363 | expire (CFPlus::Channel self, int ticks = -1) |
2422 | expire (DC::Channel self, int ticks = -1) |
2364 | CODE: |
2423 | CODE: |
2365 | Mix_ExpireChannel (self, ticks); |
2424 | Mix_ExpireChannel (self, ticks); |
2366 | |
2425 | |
2367 | void |
2426 | void |
2368 | fade_out (CFPlus::Channel self, int ticks = -1) |
2427 | fade_out (DC::Channel self, int ticks = -1) |
2369 | CODE: |
2428 | CODE: |
2370 | Mix_FadeOutChannel (self, ticks); |
2429 | Mix_FadeOutChannel (self, ticks); |
2371 | |
2430 | |
2372 | int |
2431 | int |
2373 | volume (CFPlus::Channel self, int volume) |
2432 | volume (DC::Channel self, int volume) |
2374 | CODE: |
2433 | CODE: |
2375 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2434 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2376 | OUTPUT: |
2435 | OUTPUT: |
2377 | RETVAL |
2436 | RETVAL |
2378 | |
2437 | |
2379 | void |
2438 | void |
2380 | unregister_all_effects (CFPlus::Channel self) |
2439 | unregister_all_effects (DC::Channel self) |
2381 | CODE: |
2440 | CODE: |
2382 | Mix_UnregisterAllEffects (self); |
2441 | Mix_UnregisterAllEffects (self); |
2383 | |
2442 | |
2384 | void |
2443 | void |
2385 | set_panning (CFPlus::Channel self, int left, int right) |
2444 | set_panning (DC::Channel self, int left, int right) |
2386 | CODE: |
2445 | CODE: |
2387 | left = CLAMP (left , 0, 255); |
2446 | left = CLAMP (left , 0, 255); |
2388 | right = CLAMP (right, 0, 255); |
2447 | right = CLAMP (right, 0, 255); |
2389 | Mix_SetPanning (self, left, right); |
2448 | Mix_SetPanning (self, left, right); |
2390 | |
2449 | |
2391 | void |
2450 | void |
2392 | set_distance (CFPlus::Channel self, int distance) |
2451 | set_distance (DC::Channel self, int distance) |
2393 | CODE: |
2452 | CODE: |
2394 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2453 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2395 | |
2454 | |
2396 | void |
2455 | void |
2397 | set_position (CFPlus::Channel self, int angle, int distance) |
2456 | set_position (DC::Channel self, int angle, int distance) |
2398 | CODE: |
2457 | CODE: |
2399 | |
2458 | |
2400 | void |
2459 | void |
2401 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2460 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2402 | CODE: |
2461 | CODE: |
2403 | { |
2462 | { |
2404 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2463 | 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); |
2464 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2406 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2465 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2407 | } |
2466 | } |
2408 | |
2467 | |
2409 | void |
2468 | void |
2410 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2469 | set_reverse_stereo (DC::Channel self, int flip) |
2411 | CODE: |
2470 | CODE: |
2412 | Mix_SetReverseStereo (self, flip); |
2471 | Mix_SetReverseStereo (self, flip); |
2413 | |
2472 | |
2414 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2473 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2415 | |
2474 | |
2416 | PROTOTYPES: DISABLE |
2475 | PROTOTYPES: DISABLE |
2417 | |
2476 | |
2418 | CFPlus::MixChunk |
2477 | DC::MixChunk |
2419 | new (SV *class, CFPlus::RW rwops) |
2478 | new (SV *class, DC::RW rwops) |
2420 | CODE: |
2479 | CODE: |
2421 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2480 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2422 | OUTPUT: |
2481 | OUTPUT: |
2423 | RETVAL |
2482 | RETVAL |
2424 | |
2483 | |
2425 | void |
2484 | void |
2426 | DESTROY (CFPlus::MixChunk self) |
2485 | DESTROY (DC::MixChunk self) |
2427 | CODE: |
2486 | CODE: |
2428 | Mix_FreeChunk (self); |
2487 | Mix_FreeChunk (self); |
2429 | |
2488 | |
2430 | int |
2489 | int |
2431 | volume (CFPlus::MixChunk self, int volume = -1) |
2490 | volume (DC::MixChunk self, int volume = -1) |
2432 | CODE: |
2491 | CODE: |
2433 | if (items > 1) |
2492 | if (items > 1) |
2434 | volume = CLAMP (volume, 0, 128); |
2493 | volume = CLAMP (volume, 0, 128); |
2435 | RETVAL = Mix_VolumeChunk (self, volume); |
2494 | RETVAL = Mix_VolumeChunk (self, volume); |
2436 | OUTPUT: |
2495 | OUTPUT: |
2437 | RETVAL |
2496 | RETVAL |
2438 | |
2497 | |
2439 | CFPlus::Channel |
2498 | DC::Channel |
2440 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2499 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2441 | CODE: |
2500 | CODE: |
2442 | { |
2501 | { |
2443 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2502 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2444 | |
2503 | |
2445 | if (RETVAL < 0) |
2504 | if (RETVAL < 0) |
… | |
… | |
2452 | } |
2511 | } |
2453 | } |
2512 | } |
2454 | OUTPUT: |
2513 | OUTPUT: |
2455 | RETVAL |
2514 | RETVAL |
2456 | |
2515 | |
2457 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2516 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2458 | |
2517 | |
2459 | int |
2518 | int |
2460 | volume (int volume = -1) |
2519 | volume (int volume = -1) |
2461 | PROTOTYPE: ;$ |
2520 | PROTOTYPE: ;$ |
2462 | CODE: |
2521 | CODE: |
… | |
… | |
2474 | void |
2533 | void |
2475 | halt () |
2534 | halt () |
2476 | CODE: |
2535 | CODE: |
2477 | Mix_HaltMusic (); |
2536 | Mix_HaltMusic (); |
2478 | |
2537 | |
2479 | CFPlus::MixMusic |
2538 | DC::MixMusic |
2480 | new (SV *class, CFPlus::RW rwops) |
2539 | new (SV *class, DC::RW rwops) |
2481 | CODE: |
2540 | CODE: |
2482 | RETVAL = Mix_LoadMUS_RW (rwops); |
2541 | RETVAL = Mix_LoadMUS_RW (rwops); |
2483 | OUTPUT: |
2542 | OUTPUT: |
2484 | RETVAL |
2543 | RETVAL |
2485 | |
2544 | |
2486 | void |
2545 | void |
2487 | DESTROY (CFPlus::MixMusic self) |
2546 | DESTROY (DC::MixMusic self) |
2488 | CODE: |
2547 | CODE: |
2489 | Mix_FreeMusic (self); |
2548 | Mix_FreeMusic (self); |
2490 | |
2549 | |
2491 | int |
2550 | int |
2492 | play (CFPlus::MixMusic self, int loops = -1) |
2551 | play (DC::MixMusic self, int loops = -1) |
2493 | CODE: |
2552 | CODE: |
2494 | RETVAL = Mix_PlayMusic (self, loops); |
2553 | RETVAL = Mix_PlayMusic (self, loops); |
2495 | OUTPUT: |
2554 | OUTPUT: |
2496 | RETVAL |
2555 | RETVAL |
2497 | |
2556 | |
2498 | void |
2557 | void |
2499 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2558 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2500 | CODE: |
2559 | CODE: |
2501 | Mix_FadeInMusicPos (self, loops, ms, position); |
2560 | Mix_FadeInMusicPos (self, loops, ms, position); |
2502 | |
2561 | |
2503 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2562 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2504 | |
2563 | |
2505 | PROTOTYPES: ENABLE |
2564 | PROTOTYPES: ENABLE |
2506 | |
2565 | |
2507 | BOOT: |
2566 | BOOT: |
2508 | { |
2567 | { |
2509 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2568 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2510 | static const struct { |
2569 | static const struct { |
2511 | const char *name; |
2570 | const char *name; |
2512 | IV iv; |
2571 | IV iv; |
2513 | } *civ, const_iv[] = { |
2572 | } *civ, const_iv[] = { |
2514 | # define const_iv(name) { # name, (IV)name } |
2573 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2549 | const_iv (GL_INTENSITY), |
2608 | const_iv (GL_INTENSITY), |
2550 | const_iv (GL_LUMINANCE), |
2609 | const_iv (GL_LUMINANCE), |
2551 | const_iv (GL_LUMINANCE_ALPHA), |
2610 | const_iv (GL_LUMINANCE_ALPHA), |
2552 | const_iv (GL_FLOAT), |
2611 | const_iv (GL_FLOAT), |
2553 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2612 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2613 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2614 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2615 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2616 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2617 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2618 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2554 | const_iv (GL_COMPILE), |
2619 | const_iv (GL_COMPILE), |
2555 | const_iv (GL_PROXY_TEXTURE_1D), |
2620 | const_iv (GL_PROXY_TEXTURE_1D), |
2556 | const_iv (GL_PROXY_TEXTURE_2D), |
2621 | const_iv (GL_PROXY_TEXTURE_2D), |
2557 | const_iv (GL_TEXTURE_1D), |
2622 | const_iv (GL_TEXTURE_1D), |
2558 | const_iv (GL_TEXTURE_2D), |
2623 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2597 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2662 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2598 | const_iv (GL_POINT_SMOOTH_HINT), |
2663 | const_iv (GL_POINT_SMOOTH_HINT), |
2599 | const_iv (GL_LINE_SMOOTH_HINT), |
2664 | const_iv (GL_LINE_SMOOTH_HINT), |
2600 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2665 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2601 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2666 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2667 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2602 | const_iv (GL_FASTEST), |
2668 | const_iv (GL_FASTEST), |
2603 | const_iv (GL_DONT_CARE), |
2669 | const_iv (GL_DONT_CARE), |
2604 | const_iv (GL_NICEST), |
2670 | const_iv (GL_NICEST), |
2605 | const_iv (GL_V2F), |
2671 | const_iv (GL_V2F), |
2606 | const_iv (GL_V3F), |
2672 | const_iv (GL_V3F), |
… | |
… | |
2614 | |
2680 | |
2615 | texture_av = newAV (); |
2681 | texture_av = newAV (); |
2616 | AvREAL_off (texture_av); |
2682 | AvREAL_off (texture_av); |
2617 | } |
2683 | } |
2618 | |
2684 | |
|
|
2685 | void |
|
|
2686 | disable_GL_EXT_blend_func_separate () |
|
|
2687 | CODE: |
|
|
2688 | gl.BlendFuncSeparate = 0; |
|
|
2689 | gl.BlendFuncSeparateEXT = 0; |
|
|
2690 | |
2619 | char * |
2691 | char * |
2620 | gl_vendor () |
2692 | gl_vendor () |
2621 | CODE: |
2693 | CODE: |
2622 | RETVAL = (char *)glGetString (GL_VENDOR); |
2694 | RETVAL = (char *)glGetString (GL_VENDOR); |
2623 | OUTPUT: |
2695 | OUTPUT: |
… | |
… | |
2744 | |
2816 | |
2745 | void glRect (float x1, float y1, float x2, float y2) |
2817 | void glRect (float x1, float y1, float x2, float y2) |
2746 | CODE: |
2818 | CODE: |
2747 | glRectf (x1, y1, x2, y2); |
2819 | glRectf (x1, y1, x2, y2); |
2748 | |
2820 | |
|
|
2821 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2822 | CODE: |
|
|
2823 | glBegin (GL_LINE_LOOP); |
|
|
2824 | glVertex2f (x1, y1); |
|
|
2825 | glVertex2f (x2, y1); |
|
|
2826 | glVertex2f (x2, y2); |
|
|
2827 | glVertex2f (x1, y2); |
|
|
2828 | glEnd (); |
|
|
2829 | |
2749 | PROTOTYPES: ENABLE |
2830 | PROTOTYPES: ENABLE |
2750 | |
2831 | |
2751 | void glBegin (int mode) |
2832 | void glBegin (int mode) |
2752 | |
2833 | |
2753 | void glEnd () |
2834 | void glEnd () |
… | |
… | |
2785 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2866 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2786 | CODE: |
2867 | CODE: |
2787 | if (gl.SeparableFilter2D) |
2868 | if (gl.SeparableFilter2D) |
2788 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2869 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2789 | |
2870 | |
2790 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2871 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2791 | |
2872 | |
2792 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2873 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2793 | |
2874 | |
2794 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2875 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2795 | |
2876 | |
… | |
… | |
2821 | |
2902 | |
2822 | void glEndList () |
2903 | void glEndList () |
2823 | |
2904 | |
2824 | void glCallList (int list) |
2905 | void glCallList (int list) |
2825 | |
2906 | |
2826 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2907 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2827 | |
2908 | |
2828 | PROTOTYPES: DISABLE |
2909 | PROTOTYPES: DISABLE |
2829 | |
2910 | |
2830 | void |
2911 | void |
2831 | find_widget (SV *self, NV x, NV y) |
2912 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2835 | XPUSHs (self); |
2916 | XPUSHs (self); |
2836 | } |
2917 | } |
2837 | |
2918 | |
2838 | BOOT: |
2919 | BOOT: |
2839 | { |
2920 | { |
2840 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2921 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2841 | |
2922 | |
2842 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2923 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2843 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2924 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2844 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2925 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2845 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2926 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2846 | } |
2927 | } |
2847 | |
2928 | |
2848 | void |
2929 | void |
2849 | draw (SV *self) |
2930 | draw (SV *self) |
2850 | CODE: |
2931 | CODE: |
… | |
… | |
2854 | NV x, y, w, h; |
2935 | NV x, y, w, h; |
2855 | SV *draw_x_sv = GvSV (draw_x_gv); |
2936 | SV *draw_x_sv = GvSV (draw_x_gv); |
2856 | SV *draw_y_sv = GvSV (draw_y_gv); |
2937 | SV *draw_y_sv = GvSV (draw_y_gv); |
2857 | SV *draw_w_sv = GvSV (draw_w_gv); |
2938 | SV *draw_w_sv = GvSV (draw_w_gv); |
2858 | SV *draw_h_sv = GvSV (draw_h_gv); |
2939 | SV *draw_h_sv = GvSV (draw_h_gv); |
2859 | SV *hover; |
|
|
2860 | double draw_x, draw_y, draw_w, draw_h; |
2940 | double draw_x, draw_y; |
2861 | |
2941 | |
2862 | if (!SvROK (self)) |
2942 | if (!SvROK (self)) |
2863 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2943 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2864 | |
2944 | |
2865 | hv = (HV *)SvRV (self); |
2945 | hv = (HV *)SvRV (self); |
2866 | |
2946 | |
2867 | if (SvTYPE (hv) != SVt_PVHV) |
2947 | if (SvTYPE (hv) != SVt_PVHV) |
2868 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2948 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2869 | |
2949 | |
2870 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2950 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2871 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2951 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2872 | |
2952 | |
2873 | if (!h || !w) |
2953 | if (!h || !w) |
… | |
… | |
2893 | { |
2973 | { |
2894 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2974 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2895 | |
2975 | |
2896 | if (svp && SvTRUE (*svp)) |
2976 | if (svp && SvTRUE (*svp)) |
2897 | { |
2977 | { |
2898 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
2978 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2899 | glEnable (GL_BLEND); |
2979 | glEnable (GL_BLEND); |
2900 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2980 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2901 | glBegin (GL_QUADS); |
2981 | glBegin (GL_QUADS); |
2902 | glVertex2f (0, 0); |
2982 | glVertex2f (0, 0); |
2903 | glVertex2f (w, 0); |
2983 | glVertex2f (w, 0); |
… | |
… | |
2906 | glEnd (); |
2986 | glEnd (); |
2907 | glDisable (GL_BLEND); |
2987 | glDisable (GL_BLEND); |
2908 | } |
2988 | } |
2909 | } |
2989 | } |
2910 | #if 0 |
2990 | #if 0 |
2911 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2991 | // draw borders, for debugging |
2912 | glPushMatrix; |
2992 | glPushMatrix (); |
2913 | glColor 1, 1, 0, 1; |
2993 | glColor4f (1., 1., 0., 1.); |
2914 | glTranslate 0.375, 0.375; |
2994 | glTranslatef (.5, .5, 0.); |
2915 | glBegin GL_LINE_LOOP; |
2995 | glBegin (GL_LINE_LOOP); |
2916 | glVertex 0 , 0; |
2996 | glVertex2f (0 , 0); |
2917 | glVertex $self->{w} - 1, 0; |
2997 | glVertex2f (w - 1, 0); |
2918 | glVertex $self->{w} - 1, $self->{h} - 1; |
2998 | glVertex2f (w - 1, h - 1); |
2919 | glVertex 0 , $self->{h} - 1; |
2999 | glVertex2f (0 , h - 1); |
2920 | glEnd; |
3000 | glEnd (); |
2921 | glPopMatrix; |
3001 | glPopMatrix (); |
2922 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2923 | } |
|
|
2924 | #endif |
3002 | #endif |
2925 | PUSHMARK (SP); |
3003 | PUSHMARK (SP); |
2926 | XPUSHs (self); |
3004 | XPUSHs (self); |
2927 | PUTBACK; |
3005 | PUTBACK; |
2928 | call_method ("_draw", G_VOID | G_DISCARD); |
3006 | call_method ("_draw", G_VOID | G_DISCARD); |