… | |
… | |
17 | #include "perl.h" |
17 | #include "perl.h" |
18 | #include "XSUB.h" |
18 | #include "XSUB.h" |
19 | |
19 | |
20 | #ifdef _WIN32 |
20 | #ifdef _WIN32 |
21 | # undef pipe |
21 | # undef pipe |
|
|
22 | // microsoft vs. C |
|
|
23 | # define sqrtf(x) sqrt(x) |
|
|
24 | # define roundf(x) (int)(x) |
|
|
25 | # define atan2f(x,y) atan2(x,y) |
|
|
26 | # define M_PI 3.14159265f |
22 | #endif |
27 | #endif |
23 | |
28 | |
24 | #include <assert.h> |
29 | #include <assert.h> |
25 | #include <math.h> |
30 | #include <math.h> |
26 | #include <string.h> |
31 | #include <string.h> |
… | |
… | |
40 | #define G_DISABLE_CAST_CHECKS |
45 | #define G_DISABLE_CAST_CHECKS |
41 | |
46 | |
42 | #include <glib/gmacros.h> |
47 | #include <glib/gmacros.h> |
43 | |
48 | |
44 | #include <pango/pango.h> |
49 | #include <pango/pango.h> |
|
|
50 | |
|
|
51 | #if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2)) |
|
|
52 | # define pango_layout_get_line_readonly pango_layout_get_line_readonly |
|
|
53 | # define pango_layout_get_lines_readonly pango_layout_get_lines_readonly |
|
|
54 | # define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly |
|
|
55 | # define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly |
|
|
56 | #endif |
45 | |
57 | |
46 | #ifndef _WIN32 |
58 | #ifndef _WIN32 |
47 | # include <sys/types.h> |
59 | # include <sys/types.h> |
48 | # include <sys/socket.h> |
60 | # include <sys/socket.h> |
49 | # include <netinet/in.h> |
61 | # include <netinet/in.h> |
… | |
… | |
109 | av_push (texture_av, (SV *)(size_t)name); |
121 | av_push (texture_av, (SV *)(size_t)name); |
110 | glDeleteTextures (1, &name); |
122 | glDeleteTextures (1, &name); |
111 | } |
123 | } |
112 | |
124 | |
113 | #include "texcache.c" |
125 | #include "texcache.c" |
|
|
126 | #include "rendercache.c" |
114 | |
127 | |
115 | #include "pango-font.c" |
128 | #include "pango-font.c" |
116 | #include "pango-fontmap.c" |
129 | #include "pango-fontmap.c" |
117 | #include "pango-render.c" |
130 | #include "pango-render.c" |
118 | |
131 | |
119 | typedef IV CFPlus__Channel; |
132 | typedef IV DC__Channel; |
120 | typedef SDL_RWops *CFPlus__RW; |
133 | typedef SDL_RWops *DC__RW; |
121 | typedef Mix_Chunk *CFPlus__MixChunk; |
134 | typedef Mix_Chunk *DC__MixChunk; |
122 | typedef Mix_Music *CFPlus__MixMusic; |
135 | typedef Mix_Music *DC__MixMusic; |
123 | |
136 | |
124 | typedef PangoFontDescription *CFPlus__Font; |
137 | typedef PangoFontDescription *DC__Font; |
125 | |
138 | |
126 | static int |
139 | static int |
127 | shape_attr_p (PangoLayoutRun *run) |
140 | shape_attr_p (PangoLayoutRun *run) |
128 | { |
141 | { |
129 | GSList *attrs = run->item->analysis.extra_attrs; |
142 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
143 | |
156 | |
144 | typedef struct cf_layout { |
157 | typedef struct cf_layout { |
145 | PangoLayout *pl; |
158 | PangoLayout *pl; |
146 | float r, g, b, a; // default color for rgba mode |
159 | float r, g, b, a; // default color for rgba mode |
147 | int base_height; |
160 | int base_height; |
148 | CFPlus__Font font; |
161 | DC__Font font; |
|
|
162 | rc_t *rc; |
149 | } *CFPlus__Layout; |
163 | } *DC__Layout; |
150 | |
164 | |
151 | static CFPlus__Font default_font; |
165 | static DC__Font default_font; |
152 | static PangoContext *opengl_context; |
166 | static PangoContext *opengl_context; |
153 | static PangoFontMap *opengl_fontmap; |
167 | static PangoFontMap *opengl_fontmap; |
154 | |
168 | |
155 | static void |
169 | static void |
156 | substitute_func (FcPattern *pattern, gpointer data) |
170 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
161 | #endif |
175 | #endif |
162 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
176 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
163 | } |
177 | } |
164 | |
178 | |
165 | static void |
179 | static void |
166 | layout_update_font (CFPlus__Layout self) |
180 | layout_update_font (DC__Layout self) |
167 | { |
181 | { |
168 | /* use a random scale factor to account for unknown descenders, 0.8 works |
182 | /* use a random scale factor to account for unknown descenders, 0.8 works |
169 | * reasonably well with bitstream vera |
183 | * reasonably well with bitstream vera |
170 | */ |
184 | */ |
171 | PangoFontDescription *font = self->font ? self->font : default_font; |
185 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
175 | |
189 | |
176 | pango_layout_set_font_description (self->pl, font); |
190 | pango_layout_set_font_description (self->pl, font); |
177 | } |
191 | } |
178 | |
192 | |
179 | static void |
193 | static void |
180 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
194 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
181 | { |
195 | { |
182 | PangoRectangle rect; |
196 | PangoRectangle rect; |
183 | |
197 | |
184 | // get_pixel_* wrongly rounds down |
198 | // get_pixel_* wrongly rounds down |
185 | pango_layout_get_extents (self->pl, 0, &rect); |
199 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
196 | |
210 | |
197 | typedef uint16_t tileid; |
211 | typedef uint16_t tileid; |
198 | typedef uint16_t faceid; |
212 | typedef uint16_t faceid; |
199 | |
213 | |
200 | typedef struct { |
214 | typedef struct { |
201 | int name; |
215 | GLuint name; |
202 | int w, h; |
216 | int w, h; |
203 | float s, t; |
217 | float s, t; |
204 | uint8_t r, g, b, a; |
218 | uint8_t r, g, b, a; |
205 | tileid smoothtile; |
219 | tileid smoothtile; |
206 | uint8_t smoothlevel; |
220 | uint8_t smoothlevel; |
… | |
… | |
224 | int faces; tileid *face2tile; // [faceid] |
238 | int faces; tileid *face2tile; // [faceid] |
225 | int texs; maptex *tex; // [tileid] |
239 | int texs; maptex *tex; // [tileid] |
226 | |
240 | |
227 | int32_t rows; |
241 | int32_t rows; |
228 | maprow *row; |
242 | maprow *row; |
229 | } *CFPlus__Map; |
243 | } *DC__Map; |
230 | |
244 | |
231 | static char * |
245 | static char * |
232 | prepend (char *ptr, int sze, int inc) |
246 | prepend (char *ptr, int sze, int inc) |
233 | { |
247 | { |
234 | char *p; |
248 | char *p; |
… | |
… | |
272 | self->texs *= 2; |
286 | self->texs *= 2; |
273 | } |
287 | } |
274 | } |
288 | } |
275 | |
289 | |
276 | static maprow * |
290 | static maprow * |
277 | map_get_row (CFPlus__Map self, int y) |
291 | map_get_row (DC__Map self, int y) |
278 | { |
292 | { |
279 | if (0 > y) |
293 | if (0 > y) |
280 | { |
294 | { |
281 | int extend = - y + MAP_EXTEND_Y; |
295 | int extend = - y + MAP_EXTEND_Y; |
282 | Prepend (maprow, self->row, self->rows, extend); |
296 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
320 | |
334 | |
321 | return row->col + (x - row->c0); |
335 | return row->col + (x - row->c0); |
322 | } |
336 | } |
323 | |
337 | |
324 | static mapcell * |
338 | static mapcell * |
325 | map_get_cell (CFPlus__Map self, int x, int y) |
339 | map_get_cell (DC__Map self, int x, int y) |
326 | { |
340 | { |
327 | return row_get_cell (map_get_row (self, y), x); |
341 | return row_get_cell (map_get_row (self, y), x); |
328 | } |
342 | } |
329 | |
343 | |
330 | static void |
344 | static void |
331 | map_clear (CFPlus__Map self) |
345 | map_clear (DC__Map self) |
332 | { |
346 | { |
333 | int r; |
347 | int r; |
334 | |
348 | |
335 | for (r = 0; r < self->rows; r++) |
349 | for (r = 0; r < self->rows; r++) |
336 | Safefree (self->row[r].col); |
350 | Safefree (self->row[r].col); |
… | |
… | |
344 | self->row = 0; |
358 | self->row = 0; |
345 | self->rows = 0; |
359 | self->rows = 0; |
346 | } |
360 | } |
347 | |
361 | |
348 | static void |
362 | static void |
349 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
363 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
350 | { |
364 | { |
351 | int x, y; |
365 | int x, y; |
352 | maprow *row; |
366 | maprow *row; |
353 | mapcell *cell; |
367 | mapcell *cell; |
354 | |
368 | |
… | |
… | |
433 | n |= n >> 16; |
447 | n |= n >> 16; |
434 | |
448 | |
435 | return n + 1; |
449 | return n + 1; |
436 | } |
450 | } |
437 | |
451 | |
|
|
452 | static unsigned int |
|
|
453 | popcount (unsigned int n) |
|
|
454 | { |
|
|
455 | n -= (n >> 1) & 0x55555555U; |
|
|
456 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
457 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
458 | n *= 0x01010101U; |
|
|
459 | |
|
|
460 | return n >> 24; |
|
|
461 | } |
|
|
462 | |
438 | /* SDL should provide this, really. */ |
463 | /* SDL should provide this, really. */ |
439 | #define SDLK_MODIFIER_MIN 300 |
464 | #define SDLK_MODIFIER_MIN 300 |
440 | #define SDLK_MODIFIER_MAX 314 |
465 | #define SDLK_MODIFIER_MAX 314 |
441 | |
466 | |
442 | /******************************************************************************/ |
467 | /******************************************************************************/ |
… | |
… | |
480 | return 0; |
505 | return 0; |
481 | |
506 | |
482 | return 1; |
507 | return 1; |
483 | } |
508 | } |
484 | |
509 | |
485 | MODULE = CFPlus PACKAGE = CFPlus |
510 | MODULE = Deliantra::Client PACKAGE = DC |
486 | |
511 | |
487 | PROTOTYPES: ENABLE |
512 | PROTOTYPES: ENABLE |
488 | |
513 | |
489 | BOOT: |
514 | BOOT: |
490 | { |
515 | { |
491 | HV *stash = gv_stashpv ("CFPlus", 1); |
516 | HV *stash = gv_stashpv ("DC", 1); |
492 | static const struct { |
517 | static const struct { |
493 | const char *name; |
518 | const char *name; |
494 | IV iv; |
519 | IV iv; |
495 | } *civ, const_iv[] = { |
520 | } *civ, const_iv[] = { |
496 | # define const_iv(name) { # name, (IV)name } |
521 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
518 | |
543 | |
519 | const_iv (SDL_APPINPUTFOCUS), |
544 | const_iv (SDL_APPINPUTFOCUS), |
520 | const_iv (SDL_APPMOUSEFOCUS), |
545 | const_iv (SDL_APPMOUSEFOCUS), |
521 | const_iv (SDL_APPACTIVE), |
546 | const_iv (SDL_APPACTIVE), |
522 | |
547 | |
|
|
548 | const_iv (SDLK_FIRST), |
|
|
549 | const_iv (SDLK_LAST), |
523 | const_iv (SDLK_KP0), |
550 | const_iv (SDLK_KP0), |
524 | const_iv (SDLK_KP1), |
551 | const_iv (SDLK_KP1), |
525 | const_iv (SDLK_KP2), |
552 | const_iv (SDLK_KP2), |
526 | const_iv (SDLK_KP3), |
553 | const_iv (SDLK_KP3), |
527 | const_iv (SDLK_KP4), |
554 | const_iv (SDLK_KP4), |
… | |
… | |
599 | const_iv (KMOD_LMETA), |
626 | const_iv (KMOD_LMETA), |
600 | const_iv (KMOD_RMETA), |
627 | const_iv (KMOD_RMETA), |
601 | const_iv (KMOD_NUM), |
628 | const_iv (KMOD_NUM), |
602 | const_iv (KMOD_CAPS), |
629 | const_iv (KMOD_CAPS), |
603 | const_iv (KMOD_MODE), |
630 | const_iv (KMOD_MODE), |
|
|
631 | |
|
|
632 | const_iv (MIX_DEFAULT_FORMAT), |
604 | # undef const_iv |
633 | # undef const_iv |
605 | }; |
634 | }; |
606 | |
635 | |
607 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
636 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
608 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
637 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
626 | |
655 | |
627 | NV floor (NV x) |
656 | NV floor (NV x) |
628 | |
657 | |
629 | NV ceil (NV x) |
658 | NV ceil (NV x) |
630 | |
659 | |
|
|
660 | IV minpot (UV n) |
|
|
661 | |
|
|
662 | IV popcount (UV n) |
|
|
663 | |
631 | void |
664 | void |
632 | pango_init () |
665 | pango_init () |
633 | CODE: |
666 | CODE: |
634 | { |
667 | { |
635 | opengl_fontmap = pango_opengl_font_map_new (); |
668 | opengl_fontmap = pango_opengl_font_map_new (); |
636 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
669 | pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); |
637 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
670 | opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); |
|
|
671 | #if defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2) |
|
|
672 | pango_context_set_language (opengl_context, pango_language_from_string ("en")); |
|
|
673 | /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ |
|
|
674 | #endif |
638 | } |
675 | } |
639 | |
676 | |
640 | char * |
677 | char * |
641 | SDL_GetError () |
678 | SDL_GetError () |
642 | |
679 | |
… | |
… | |
674 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
711 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
675 | |
712 | |
676 | if (m && m != (SDL_Rect **)-1) |
713 | if (m && m != (SDL_Rect **)-1) |
677 | while (*m) |
714 | while (*m) |
678 | { |
715 | { |
679 | if ((*m)->w >= 640 && (*m)->h >= 480) |
716 | if ((*m)->w >= 800 && (*m)->h >= 480) |
680 | { |
717 | { |
681 | AV *av = newAV (); |
718 | AV *av = newAV (); |
682 | av_push (av, newSViv ((*m)->w)); |
719 | av_push (av, newSViv ((*m)->w)); |
683 | av_push (av, newSViv ((*m)->h)); |
720 | av_push (av, newSViv ((*m)->h)); |
684 | av_push (av, newSViv (rgb)); |
721 | av_push (av, newSViv (rgb)); |
… | |
… | |
708 | |
745 | |
709 | if (RETVAL) |
746 | if (RETVAL) |
710 | { |
747 | { |
711 | av_clear (texture_av); |
748 | av_clear (texture_av); |
712 | |
749 | |
713 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
750 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
714 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
751 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
715 | #include "glfunc.h" |
752 | #include "glfunc.h" |
716 | #undef GL_FUNC |
753 | #undef GL_FUNC |
717 | } |
754 | } |
718 | } |
755 | } |
… | |
… | |
799 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
836 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
800 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
837 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
801 | break; |
838 | break; |
802 | } |
839 | } |
803 | |
840 | |
804 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
841 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
805 | } |
842 | } |
806 | } |
843 | } |
807 | |
844 | |
808 | int |
845 | int |
809 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
846 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
810 | POSTCALL: |
847 | POSTCALL: |
811 | Mix_HookMusicFinished (music_finished); |
848 | Mix_HookMusicFinished (music_finished); |
812 | Mix_ChannelFinished (channel_finished); |
849 | Mix_ChannelFinished (channel_finished); |
|
|
850 | |
|
|
851 | void |
|
|
852 | Mix_QuerySpec () |
|
|
853 | PPCODE: |
|
|
854 | { |
|
|
855 | int freq, channels; |
|
|
856 | Uint16 format; |
|
|
857 | |
|
|
858 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
859 | { |
|
|
860 | EXTEND (SP, 3); |
|
|
861 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
862 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
863 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
864 | } |
|
|
865 | } |
813 | |
866 | |
814 | void |
867 | void |
815 | Mix_CloseAudio () |
868 | Mix_CloseAudio () |
816 | |
869 | |
817 | int |
870 | int |
… | |
… | |
951 | void |
1004 | void |
952 | error (char *message) |
1005 | error (char *message) |
953 | CODE: |
1006 | CODE: |
954 | fprintf (stderr, "ERROR: %s\n", message); |
1007 | fprintf (stderr, "ERROR: %s\n", message); |
955 | #ifdef _WIN32 |
1008 | #ifdef _WIN32 |
956 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
1009 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
957 | #endif |
1010 | #endif |
958 | |
1011 | |
959 | void |
1012 | void |
960 | fatal (char *message) |
1013 | fatal (char *message) |
961 | CODE: |
1014 | CODE: |
962 | fprintf (stderr, "FATAL: %s\n", message); |
1015 | fprintf (stderr, "FATAL: %s\n", message); |
963 | #ifdef _WIN32 |
1016 | #ifdef _WIN32 |
964 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1017 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
965 | #endif |
1018 | #endif |
966 | _exit (1); |
1019 | _exit (1); |
967 | |
1020 | |
968 | void |
1021 | void |
969 | _exit (int retval = 0) |
1022 | _exit (int retval = 0) |
… | |
… | |
981 | #if DEBUG |
1034 | #if DEBUG |
982 | VALGRIND_DO_LEAK_CHECK; |
1035 | VALGRIND_DO_LEAK_CHECK; |
983 | #endif |
1036 | #endif |
984 | } |
1037 | } |
985 | |
1038 | |
986 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1039 | MODULE = Deliantra::Client PACKAGE = DC::Font |
987 | |
1040 | |
988 | PROTOTYPES: DISABLE |
1041 | PROTOTYPES: DISABLE |
989 | |
1042 | |
990 | CFPlus::Font |
1043 | DC::Font |
991 | new_from_file (SV *class, char *path, int id = 0) |
1044 | new_from_file (SV *class, char *path, int id = 0) |
992 | CODE: |
1045 | CODE: |
993 | { |
1046 | { |
994 | int count; |
1047 | int count; |
995 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1048 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
998 | } |
1051 | } |
999 | OUTPUT: |
1052 | OUTPUT: |
1000 | RETVAL |
1053 | RETVAL |
1001 | |
1054 | |
1002 | void |
1055 | void |
1003 | DESTROY (CFPlus::Font self) |
1056 | DESTROY (DC::Font self) |
1004 | CODE: |
1057 | CODE: |
1005 | pango_font_description_free (self); |
1058 | pango_font_description_free (self); |
1006 | |
1059 | |
1007 | void |
1060 | void |
1008 | make_default (CFPlus::Font self) |
1061 | make_default (DC::Font self) |
1009 | PROTOTYPE: $ |
1062 | PROTOTYPE: $ |
1010 | CODE: |
1063 | CODE: |
1011 | default_font = self; |
1064 | default_font = self; |
1012 | |
1065 | |
1013 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1066 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1014 | |
1067 | |
1015 | PROTOTYPES: DISABLE |
1068 | PROTOTYPES: DISABLE |
1016 | |
1069 | |
1017 | void |
1070 | void |
1018 | reset_glyph_cache () |
1071 | glyph_cache_backup () |
1019 | PROTOTYPE: |
1072 | PROTOTYPE: |
1020 | CODE: |
1073 | CODE: |
|
|
1074 | tc_backup (); |
|
|
1075 | |
|
|
1076 | void |
|
|
1077 | glyph_cache_restore () |
|
|
1078 | PROTOTYPE: |
|
|
1079 | CODE: |
1021 | tc_clear (); |
1080 | tc_restore (); |
1022 | |
1081 | |
1023 | CFPlus::Layout |
1082 | DC::Layout |
1024 | new (SV *class) |
1083 | new (SV *class) |
1025 | CODE: |
1084 | CODE: |
1026 | New (0, RETVAL, 1, struct cf_layout); |
1085 | New (0, RETVAL, 1, struct cf_layout); |
1027 | |
1086 | |
1028 | RETVAL->pl = pango_layout_new (opengl_context); |
1087 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1030 | RETVAL->g = 1.; |
1089 | RETVAL->g = 1.; |
1031 | RETVAL->b = 1.; |
1090 | RETVAL->b = 1.; |
1032 | RETVAL->a = 1.; |
1091 | RETVAL->a = 1.; |
1033 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1092 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1034 | RETVAL->font = 0; |
1093 | RETVAL->font = 0; |
|
|
1094 | RETVAL->rc = rc_alloc (); |
1035 | |
1095 | |
1036 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1096 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1037 | layout_update_font (RETVAL); |
1097 | layout_update_font (RETVAL); |
1038 | OUTPUT: |
1098 | OUTPUT: |
1039 | RETVAL |
1099 | RETVAL |
1040 | |
1100 | |
1041 | void |
1101 | void |
1042 | DESTROY (CFPlus::Layout self) |
1102 | DESTROY (DC::Layout self) |
1043 | CODE: |
1103 | CODE: |
1044 | g_object_unref (self->pl); |
1104 | g_object_unref (self->pl); |
|
|
1105 | rc_free (self->rc); |
1045 | Safefree (self); |
1106 | Safefree (self); |
1046 | |
1107 | |
1047 | void |
1108 | void |
1048 | set_text (CFPlus::Layout self, SV *text_) |
1109 | set_text (DC::Layout self, SV *text_) |
1049 | CODE: |
1110 | CODE: |
1050 | { |
1111 | { |
1051 | STRLEN textlen; |
1112 | STRLEN textlen; |
1052 | char *text = SvPVutf8 (text_, textlen); |
1113 | char *text = SvPVutf8 (text_, textlen); |
1053 | |
1114 | |
1054 | pango_layout_set_text (self->pl, text, textlen); |
1115 | pango_layout_set_text (self->pl, text, textlen); |
1055 | } |
1116 | } |
1056 | |
1117 | |
1057 | void |
1118 | void |
1058 | set_markup (CFPlus::Layout self, SV *text_) |
1119 | set_markup (DC::Layout self, SV *text_) |
1059 | CODE: |
1120 | CODE: |
1060 | { |
1121 | { |
1061 | STRLEN textlen; |
1122 | STRLEN textlen; |
1062 | char *text = SvPVutf8 (text_, textlen); |
1123 | char *text = SvPVutf8 (text_, textlen); |
1063 | |
1124 | |
1064 | pango_layout_set_markup (self->pl, text, textlen); |
1125 | pango_layout_set_markup (self->pl, text, textlen); |
1065 | } |
1126 | } |
1066 | |
1127 | |
1067 | void |
1128 | void |
1068 | set_shapes (CFPlus::Layout self, ...) |
1129 | set_shapes (DC::Layout self, ...) |
1069 | CODE: |
1130 | CODE: |
1070 | { |
1131 | { |
1071 | PangoAttrList *attrs = 0; |
1132 | PangoAttrList *attrs = 0; |
1072 | const char *text = pango_layout_get_text (self->pl); |
1133 | const char *text = pango_layout_get_text (self->pl); |
1073 | const char *pos = text; |
1134 | const char *pos = text; |
… | |
… | |
1108 | if (attrs) |
1169 | if (attrs) |
1109 | pango_layout_set_attributes (self->pl, attrs); |
1170 | pango_layout_set_attributes (self->pl, attrs); |
1110 | } |
1171 | } |
1111 | |
1172 | |
1112 | void |
1173 | void |
1113 | get_shapes (CFPlus::Layout self) |
1174 | get_shapes (DC::Layout self) |
1114 | PPCODE: |
1175 | PPCODE: |
1115 | { |
1176 | { |
1116 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1177 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1117 | |
1178 | |
1118 | do |
1179 | do |
1119 | { |
1180 | { |
1120 | PangoLayoutRun *run = pango_layout_iter_get_run (iter); |
1181 | PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter); |
1121 | |
1182 | |
1122 | if (run && shape_attr_p (run)) |
1183 | if (run && shape_attr_p (run)) |
1123 | { |
1184 | { |
1124 | PangoRectangle extents; |
1185 | PangoRectangle extents; |
1125 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
1186 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
… | |
… | |
1133 | |
1194 | |
1134 | pango_layout_iter_free (iter); |
1195 | pango_layout_iter_free (iter); |
1135 | } |
1196 | } |
1136 | |
1197 | |
1137 | int |
1198 | int |
1138 | has_wrapped (CFPlus::Layout self) |
1199 | has_wrapped (DC::Layout self) |
1139 | CODE: |
1200 | CODE: |
1140 | { |
1201 | { |
1141 | int lines = 1; |
1202 | int lines = 1; |
1142 | const char *text = pango_layout_get_text (self->pl); |
1203 | const char *text = pango_layout_get_text (self->pl); |
1143 | |
1204 | |
… | |
… | |
1148 | } |
1209 | } |
1149 | OUTPUT: |
1210 | OUTPUT: |
1150 | RETVAL |
1211 | RETVAL |
1151 | |
1212 | |
1152 | SV * |
1213 | SV * |
1153 | get_text (CFPlus::Layout self) |
1214 | get_text (DC::Layout self) |
1154 | CODE: |
1215 | CODE: |
1155 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1216 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1156 | sv_utf8_decode (RETVAL); |
1217 | sv_utf8_decode (RETVAL); |
1157 | OUTPUT: |
1218 | OUTPUT: |
1158 | RETVAL |
1219 | RETVAL |
1159 | |
1220 | |
1160 | void |
1221 | void |
1161 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1222 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1162 | CODE: |
1223 | CODE: |
1163 | self->r = r; |
1224 | self->r = r; |
1164 | self->g = g; |
1225 | self->g = g; |
1165 | self->b = b; |
1226 | self->b = b; |
1166 | self->a = a; |
1227 | self->a = a; |
1167 | |
1228 | |
1168 | void |
1229 | void |
1169 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1230 | set_font (DC::Layout self, DC::Font font = 0) |
1170 | CODE: |
1231 | CODE: |
1171 | if (self->font != font) |
1232 | if (self->font != font) |
1172 | { |
1233 | { |
1173 | self->font = font; |
1234 | self->font = font; |
1174 | layout_update_font (self); |
1235 | layout_update_font (self); |
1175 | } |
1236 | } |
1176 | |
1237 | |
1177 | void |
1238 | void |
1178 | set_height (CFPlus::Layout self, int base_height) |
1239 | set_height (DC::Layout self, int base_height) |
1179 | CODE: |
1240 | CODE: |
1180 | if (self->base_height != base_height) |
1241 | if (self->base_height != base_height) |
1181 | { |
1242 | { |
1182 | self->base_height = base_height; |
1243 | self->base_height = base_height; |
1183 | layout_update_font (self); |
1244 | layout_update_font (self); |
1184 | } |
1245 | } |
1185 | |
1246 | |
1186 | void |
1247 | void |
1187 | set_width (CFPlus::Layout self, int max_width = -1) |
1248 | set_width (DC::Layout self, int max_width = -1) |
1188 | CODE: |
1249 | CODE: |
1189 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1250 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1190 | |
1251 | |
1191 | void |
1252 | void |
1192 | set_indent (CFPlus::Layout self, int indent) |
1253 | set_indent (DC::Layout self, int indent) |
1193 | CODE: |
1254 | CODE: |
1194 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1255 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1195 | |
1256 | |
1196 | void |
1257 | void |
1197 | set_spacing (CFPlus::Layout self, int spacing) |
1258 | set_spacing (DC::Layout self, int spacing) |
1198 | CODE: |
1259 | CODE: |
1199 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1260 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1200 | |
1261 | |
1201 | void |
1262 | void |
1202 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1263 | set_ellipsise (DC::Layout self, int ellipsise) |
1203 | CODE: |
1264 | CODE: |
1204 | pango_layout_set_ellipsize (self->pl, |
1265 | pango_layout_set_ellipsize (self->pl, |
1205 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1266 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1206 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1267 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1207 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1268 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1208 | : PANGO_ELLIPSIZE_NONE |
1269 | : PANGO_ELLIPSIZE_NONE |
1209 | ); |
1270 | ); |
1210 | |
1271 | |
1211 | void |
1272 | void |
1212 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1273 | set_single_paragraph_mode (DC::Layout self, int spm) |
1213 | CODE: |
1274 | CODE: |
1214 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1275 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1215 | |
1276 | |
1216 | void |
1277 | void |
1217 | size (CFPlus::Layout self) |
1278 | size (DC::Layout self) |
1218 | PPCODE: |
1279 | PPCODE: |
1219 | { |
1280 | { |
1220 | int w, h; |
1281 | int w, h; |
1221 | |
1282 | |
1222 | layout_get_pixel_size (self, &w, &h); |
1283 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1225 | PUSHs (sv_2mortal (newSViv (w))); |
1286 | PUSHs (sv_2mortal (newSViv (w))); |
1226 | PUSHs (sv_2mortal (newSViv (h))); |
1287 | PUSHs (sv_2mortal (newSViv (h))); |
1227 | } |
1288 | } |
1228 | |
1289 | |
1229 | int |
1290 | int |
1230 | descent (CFPlus::Layout self) |
1291 | descent (DC::Layout self) |
1231 | CODE: |
1292 | CODE: |
1232 | { |
1293 | { |
1233 | PangoRectangle rect; |
1294 | PangoRectangle rect; |
1234 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1295 | PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0); |
1235 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1296 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1236 | RETVAL = PANGO_DESCENT (rect); |
1297 | RETVAL = PANGO_DESCENT (rect); |
1237 | } |
1298 | } |
1238 | OUTPUT: |
1299 | OUTPUT: |
1239 | RETVAL |
1300 | RETVAL |
1240 | |
1301 | |
1241 | int |
1302 | int |
1242 | xy_to_index (CFPlus::Layout self, int x, int y) |
1303 | xy_to_index (DC::Layout self, int x, int y) |
1243 | CODE: |
1304 | CODE: |
1244 | { |
1305 | { |
1245 | int index, trailing; |
1306 | int index, trailing; |
1246 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1307 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1247 | RETVAL = index + trailing; |
1308 | RETVAL = index + trailing; |
1248 | } |
1309 | } |
1249 | OUTPUT: |
1310 | OUTPUT: |
1250 | RETVAL |
1311 | RETVAL |
1251 | |
1312 | |
1252 | void |
1313 | void |
1253 | cursor_pos (CFPlus::Layout self, int index) |
1314 | cursor_pos (DC::Layout self, int index) |
1254 | PPCODE: |
1315 | PPCODE: |
1255 | { |
1316 | { |
1256 | PangoRectangle strong_pos; |
1317 | PangoRectangle pos; |
1257 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1318 | pango_layout_get_cursor_pos (self->pl, index, 0, &pos); |
1258 | |
1319 | |
1259 | EXTEND (SP, 3); |
1320 | EXTEND (SP, 3); |
1260 | PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); |
1321 | PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); |
1261 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1322 | PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); |
1262 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1323 | PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); |
1263 | } |
1324 | } |
1264 | |
1325 | |
1265 | void |
1326 | void |
1266 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1327 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1267 | PPCODE: |
1328 | PPCODE: |
1268 | { |
1329 | { |
1269 | int line, x; |
1330 | int line, x; |
1270 | |
1331 | |
1271 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1332 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
|
|
1333 | #if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 17, 3)) |
1272 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1334 | /* pango bug: line is between 1..numlines, not 0..numlines-1 */ |
1273 | |
1335 | --line; |
|
|
1336 | #endif |
1274 | EXTEND (SP, 2); |
1337 | EXTEND (SP, 2); |
1275 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1338 | PUSHs (sv_2mortal (newSViv (line))); |
1276 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1339 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1277 | } |
1340 | } |
1278 | |
1341 | |
1279 | void |
1342 | void |
1280 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1343 | line_x_to_index (DC::Layout self, int line, int x) |
1281 | PPCODE: |
1344 | PPCODE: |
1282 | { |
1345 | { |
1283 | PangoLayoutLine *lp; |
1346 | PangoLayoutLine *lp; |
1284 | int index, trailing; |
1347 | int index, trailing; |
1285 | |
1348 | |
1286 | if (line < 0) |
1349 | if (line < 0) |
1287 | XSRETURN_EMPTY; |
1350 | XSRETURN_EMPTY; |
1288 | |
1351 | |
1289 | if (!(lp = pango_layout_get_line (self->pl, line))) |
1352 | if (!(lp = pango_layout_get_line_readonly (self->pl, line))) |
1290 | XSRETURN_EMPTY; /* do better */ |
1353 | XSRETURN_EMPTY; /* do better */ |
1291 | |
1354 | |
1292 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1355 | pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); |
1293 | |
1356 | |
1294 | EXTEND (SP, 2); |
1357 | EXTEND (SP, 2); |
… | |
… | |
1300 | PUSHs (sv_2mortal (newSViv (trailing))); |
1363 | PUSHs (sv_2mortal (newSViv (trailing))); |
1301 | } |
1364 | } |
1302 | } |
1365 | } |
1303 | |
1366 | |
1304 | void |
1367 | void |
1305 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1368 | render (DC::Layout self, float x, float y, int flags = 0) |
1306 | PPCODE: |
1369 | CODE: |
|
|
1370 | rc_clear (self->rc); |
1307 | pango_opengl_render_layout_subpixel ( |
1371 | pango_opengl_render_layout_subpixel ( |
1308 | self->pl, |
1372 | self->pl, |
|
|
1373 | self->rc, |
1309 | x * PANGO_SCALE, y * PANGO_SCALE, |
1374 | x * PANGO_SCALE, y * PANGO_SCALE, |
1310 | self->r, self->g, self->b, self->a, |
1375 | self->r, self->g, self->b, self->a, |
1311 | flags |
1376 | flags |
1312 | ); |
1377 | ); |
|
|
1378 | // we assume that context_change actually clears/frees stuff |
|
|
1379 | // and does not do any recomputation... |
|
|
1380 | pango_layout_context_changed (self->pl); |
1313 | |
1381 | |
1314 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1382 | void |
|
|
1383 | draw (DC::Layout self) |
|
|
1384 | CODE: |
|
|
1385 | { |
|
|
1386 | glEnable (GL_TEXTURE_2D); |
|
|
1387 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1388 | glEnable (GL_BLEND); |
|
|
1389 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
|
|
1390 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
|
|
1391 | glEnable (GL_ALPHA_TEST); |
|
|
1392 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
|
|
1393 | |
|
|
1394 | rc_draw (self->rc); |
|
|
1395 | |
|
|
1396 | glDisable (GL_ALPHA_TEST); |
|
|
1397 | glDisable (GL_BLEND); |
|
|
1398 | glDisable (GL_TEXTURE_2D); |
|
|
1399 | } |
|
|
1400 | |
|
|
1401 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1315 | |
1402 | |
1316 | PROTOTYPES: ENABLE |
1403 | PROTOTYPES: ENABLE |
1317 | |
|
|
1318 | int minpot (int n) |
|
|
1319 | |
1404 | |
1320 | void |
1405 | void |
1321 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1406 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1322 | CODE: |
1407 | CODE: |
1323 | { |
1408 | { |
… | |
… | |
1350 | HV *hv = (HV *)SvRV (self); |
1435 | HV *hv = (HV *)SvRV (self); |
1351 | float s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
1436 | float s = SvNV (*hv_fetch (hv, "s", 1, 1)); |
1352 | float t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
1437 | float t = SvNV (*hv_fetch (hv, "t", 1, 1)); |
1353 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
1438 | int name = SvIV (*hv_fetch (hv, "name", 4, 1)); |
1354 | |
1439 | |
|
|
1440 | if (name <= 0) |
|
|
1441 | XSRETURN_EMPTY; |
|
|
1442 | |
1355 | if (items < 5) |
1443 | if (items < 5) |
1356 | { |
1444 | { |
1357 | w = SvNV (*hv_fetch (hv, "w", 1, 1)); |
1445 | w = SvNV (*hv_fetch (hv, "w", 1, 1)); |
1358 | h = SvNV (*hv_fetch (hv, "h", 1, 1)); |
1446 | h = SvNV (*hv_fetch (hv, "h", 1, 1)); |
1359 | } |
1447 | } |
… | |
… | |
1397 | RETVAL = width > 0; |
1485 | RETVAL = width > 0; |
1398 | } |
1486 | } |
1399 | OUTPUT: |
1487 | OUTPUT: |
1400 | RETVAL |
1488 | RETVAL |
1401 | |
1489 | |
1402 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1490 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1403 | |
1491 | |
1404 | PROTOTYPES: DISABLE |
1492 | PROTOTYPES: DISABLE |
1405 | |
1493 | |
1406 | CFPlus::Map |
1494 | DC::Map |
1407 | new (SV *class) |
1495 | new (SV *class) |
1408 | CODE: |
1496 | CODE: |
1409 | New (0, RETVAL, 1, struct map); |
1497 | New (0, RETVAL, 1, struct map); |
1410 | RETVAL->x = 0; |
1498 | RETVAL->x = 0; |
1411 | RETVAL->y = 0; |
1499 | RETVAL->y = 0; |
… | |
… | |
1419 | RETVAL->row = 0; |
1507 | RETVAL->row = 0; |
1420 | OUTPUT: |
1508 | OUTPUT: |
1421 | RETVAL |
1509 | RETVAL |
1422 | |
1510 | |
1423 | void |
1511 | void |
1424 | DESTROY (CFPlus::Map self) |
1512 | DESTROY (DC::Map self) |
1425 | CODE: |
1513 | CODE: |
1426 | { |
1514 | { |
1427 | map_clear (self); |
1515 | map_clear (self); |
1428 | Safefree (self->face2tile); |
1516 | Safefree (self->face2tile); |
1429 | Safefree (self->tex); |
1517 | Safefree (self->tex); |
1430 | Safefree (self); |
1518 | Safefree (self); |
1431 | } |
1519 | } |
1432 | |
1520 | |
1433 | void |
1521 | void |
1434 | resize (CFPlus::Map self, int map_width, int map_height) |
1522 | resize (DC::Map self, int map_width, int map_height) |
1435 | CODE: |
1523 | CODE: |
1436 | self->w = map_width; |
1524 | self->w = map_width; |
1437 | self->h = map_height; |
1525 | self->h = map_height; |
1438 | |
1526 | |
1439 | void |
1527 | void |
1440 | clear (CFPlus::Map self) |
1528 | clear (DC::Map self) |
1441 | CODE: |
1529 | CODE: |
1442 | map_clear (self); |
1530 | map_clear (self); |
1443 | |
1531 | |
1444 | void |
1532 | void |
1445 | set_tileid (CFPlus::Map self, int face, int tile) |
1533 | set_tileid (DC::Map self, int face, int tile) |
1446 | CODE: |
1534 | CODE: |
1447 | { |
1535 | { |
1448 | need_facenum (self, face); self->face2tile [face] = tile; |
1536 | need_facenum (self, face); self->face2tile [face] = tile; |
1449 | need_texid (self, tile); |
1537 | need_texid (self, tile); |
1450 | } |
1538 | } |
1451 | |
1539 | |
1452 | void |
1540 | void |
1453 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1541 | set_smooth (DC::Map self, int face, int smooth, int level) |
1454 | CODE: |
1542 | CODE: |
1455 | { |
1543 | { |
1456 | tileid texid; |
1544 | tileid texid; |
1457 | maptex *tex; |
1545 | maptex *tex; |
1458 | |
1546 | |
… | |
… | |
1471 | tex->smoothtile = self->face2tile [smooth]; |
1559 | tex->smoothtile = self->face2tile [smooth]; |
1472 | tex->smoothlevel = level; |
1560 | tex->smoothlevel = level; |
1473 | } |
1561 | } |
1474 | |
1562 | |
1475 | void |
1563 | void |
1476 | 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) |
1564 | 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) |
1477 | CODE: |
1565 | CODE: |
1478 | { |
1566 | { |
1479 | need_texid (self, texid); |
1567 | need_texid (self, texid); |
1480 | |
1568 | |
1481 | { |
1569 | { |
… | |
… | |
1501 | // from transparent color bleeding and ugly wrapping effects. |
1589 | // from transparent color bleeding and ugly wrapping effects. |
1502 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1590 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1503 | } |
1591 | } |
1504 | |
1592 | |
1505 | int |
1593 | int |
1506 | ox (CFPlus::Map self) |
1594 | ox (DC::Map self) |
1507 | ALIAS: |
1595 | ALIAS: |
1508 | oy = 1 |
1596 | oy = 1 |
1509 | x = 2 |
1597 | x = 2 |
1510 | y = 3 |
1598 | y = 3 |
1511 | w = 4 |
1599 | w = 4 |
… | |
… | |
1522 | } |
1610 | } |
1523 | OUTPUT: |
1611 | OUTPUT: |
1524 | RETVAL |
1612 | RETVAL |
1525 | |
1613 | |
1526 | void |
1614 | void |
1527 | scroll (CFPlus::Map self, int dx, int dy) |
1615 | scroll (DC::Map self, int dx, int dy) |
1528 | CODE: |
1616 | CODE: |
1529 | { |
1617 | { |
1530 | if (dx > 0) |
1618 | if (dx > 0) |
1531 | map_blank (self, self->x, self->y, dx, self->h); |
1619 | map_blank (self, self->x, self->y, dx, self->h); |
1532 | else if (dx < 0) |
1620 | else if (dx < 0) |
… | |
… | |
1547 | self->rows += MAP_EXTEND_Y; |
1635 | self->rows += MAP_EXTEND_Y; |
1548 | self->y += MAP_EXTEND_Y; |
1636 | self->y += MAP_EXTEND_Y; |
1549 | } |
1637 | } |
1550 | } |
1638 | } |
1551 | |
1639 | |
1552 | void |
1640 | SV * |
1553 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1641 | map1a_update (DC::Map self, SV *data_, int extmap) |
1554 | CODE: |
1642 | CODE: |
1555 | { |
1643 | { |
1556 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1644 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1557 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1645 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1558 | mapcell *cell; |
1646 | mapcell *cell; |
1559 | int x, y, flags; |
1647 | int x, y, z, flags; |
|
|
1648 | AV *missing = newAV (); |
|
|
1649 | RETVAL = newRV_noinc ((SV *)missing); |
1560 | |
1650 | |
1561 | while (data < data_end - 1) |
1651 | while (data < data_end - 1) |
1562 | { |
1652 | { |
1563 | flags = (data [0] << 8) + data [1]; data += 2; |
1653 | flags = (data [0] << 8) + data [1]; data += 2; |
1564 | |
1654 | |
… | |
… | |
1615 | } |
1705 | } |
1616 | else |
1706 | else |
1617 | cell->darkness = *data++ + 1; |
1707 | cell->darkness = *data++ + 1; |
1618 | } |
1708 | } |
1619 | |
1709 | |
|
|
1710 | for (z = 0; z <= 2; ++z) |
1620 | if (flags & 4) |
1711 | if (flags & (4 >> z)) |
1621 | { |
1712 | { |
1622 | faceid face = (data [0] << 8) + data [1]; data += 2; |
1713 | faceid face = (data [0] << 8) + data [1]; data += 2; |
1623 | need_facenum (self, face); |
1714 | need_facenum (self, face); |
1624 | cell->tile [0] = self->face2tile [face]; |
1715 | cell->tile [z] = self->face2tile [face]; |
|
|
1716 | |
|
|
1717 | if (cell->tile [z]) |
|
|
1718 | { |
|
|
1719 | maptex *tex = self->tex + cell->tile [z]; |
|
|
1720 | if (!tex->name) |
|
|
1721 | av_push (missing, newSViv (cell->tile [z])); |
|
|
1722 | |
|
|
1723 | if (tex->smoothtile) |
|
|
1724 | { |
|
|
1725 | maptex *smooth = self->tex + tex->smoothtile; |
|
|
1726 | if (!smooth->name) |
|
|
1727 | av_push (missing, newSViv (tex->smoothtile)); |
|
|
1728 | } |
|
|
1729 | } |
1625 | } |
1730 | } |
1626 | |
|
|
1627 | if (flags & 2) |
|
|
1628 | { |
|
|
1629 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1630 | need_facenum (self, face); |
|
|
1631 | cell->tile [1] = self->face2tile [face]; |
|
|
1632 | } |
|
|
1633 | |
|
|
1634 | if (flags & 1) |
|
|
1635 | { |
|
|
1636 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1637 | need_facenum (self, face); |
|
|
1638 | cell->tile [2] = self->face2tile [face]; |
|
|
1639 | } |
|
|
1640 | } |
1731 | } |
1641 | else |
1732 | else |
1642 | cell->darkness = 0; |
1733 | cell->darkness = 0; |
1643 | } |
1734 | } |
1644 | } |
1735 | } |
|
|
1736 | OUTPUT: |
|
|
1737 | RETVAL |
1645 | |
1738 | |
1646 | SV * |
1739 | SV * |
1647 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1740 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1648 | CODE: |
1741 | CODE: |
1649 | { |
1742 | { |
1650 | int x1, x; |
1743 | int x1, x; |
1651 | int y1, y; |
1744 | int y1, y; |
1652 | int z; |
1745 | int z; |
… | |
… | |
1697 | } |
1790 | } |
1698 | OUTPUT: |
1791 | OUTPUT: |
1699 | RETVAL |
1792 | RETVAL |
1700 | |
1793 | |
1701 | void |
1794 | void |
1702 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1795 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1703 | CODE: |
1796 | CODE: |
1704 | { |
1797 | { |
|
|
1798 | int x, y, z; |
|
|
1799 | |
1705 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1800 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1706 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1801 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1707 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1802 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1708 | smooth_key skey; |
1803 | smooth_key skey; |
1709 | int x, y, z; |
1804 | |
1710 | int last_name; |
1805 | rc_t *rc = rc_alloc (); |
|
|
1806 | rc_key_t key; |
|
|
1807 | rc_array_t *arr; |
1711 | |
1808 | |
1712 | // thats current max. sorry. |
1809 | // thats current max. sorry. |
1713 | if (sw > 255) sw = 255; |
1810 | if (sw > 255) sw = 255; |
1714 | if (sh > 255) sh = 255; |
1811 | if (sh > 255) sh = 255; |
1715 | |
1812 | |
1716 | // clear key, in case of extra padding |
1813 | // clear key, in case of extra padding |
1717 | memset (&skey, 0, sizeof (skey)); |
1814 | memset (&skey, 0, sizeof (skey)); |
1718 | |
1815 | |
1719 | glColor4ub (255, 255, 255, 255); |
1816 | memset (&key, 0, sizeof (key)); |
1720 | |
1817 | key.r = 255; |
1721 | glEnable (GL_BLEND); |
1818 | key.g = 255; |
1722 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1819 | key.b = 255; |
1723 | glEnable (GL_TEXTURE_2D); |
1820 | key.a = 255; |
1724 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1821 | key.mode = GL_QUADS; |
1725 | |
1822 | key.format = GL_T2F_V3F; |
1726 | glBegin (GL_QUADS); |
1823 | key.texname = -1; |
1727 | |
|
|
1728 | last_name = 0; |
|
|
1729 | |
1824 | |
1730 | mx += self->x; |
1825 | mx += self->x; |
1731 | my += self->y; |
1826 | my += self->y; |
1732 | |
1827 | |
1733 | // first pass: determine smooth_max |
1828 | // first pass: determine smooth_max |
… | |
… | |
1749 | MAX (self->tex [cell->tile [0]].smoothlevel, |
1844 | MAX (self->tex [cell->tile [0]].smoothlevel, |
1750 | MAX (self->tex [cell->tile [1]].smoothlevel, |
1845 | MAX (self->tex [cell->tile [1]].smoothlevel, |
1751 | self->tex [cell->tile [2]].smoothlevel)); |
1846 | self->tex [cell->tile [2]].smoothlevel)); |
1752 | } |
1847 | } |
1753 | } |
1848 | } |
|
|
1849 | |
|
|
1850 | glEnable (GL_BLEND); |
|
|
1851 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
1852 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1754 | |
1853 | |
1755 | for (z = 0; z <= 2; z++) |
1854 | for (z = 0; z <= 2; z++) |
1756 | { |
1855 | { |
1757 | memset (smooth_level, 0, sizeof (smooth_level)); |
1856 | memset (smooth_level, 0, sizeof (smooth_level)); |
1758 | |
1857 | |
… | |
… | |
1768 | tileid tile = cell->tile [z]; |
1867 | tileid tile = cell->tile [z]; |
1769 | |
1868 | |
1770 | if (tile) |
1869 | if (tile) |
1771 | { |
1870 | { |
1772 | maptex tex = self->tex [tile]; |
1871 | maptex tex = self->tex [tile]; |
1773 | int px = (x + 1) * T - tex.w; |
1872 | int px, py; |
1774 | int py = (y + 1) * T - tex.h; |
|
|
1775 | |
1873 | |
1776 | // suppressing texture state switches here |
|
|
1777 | // is only moderately effective, but worth the extra effort |
|
|
1778 | if (last_name != tex.name) |
1874 | if (key.texname != tex.name) |
1779 | { |
1875 | { |
1780 | if (!tex.name) |
1876 | if (!tex.name) |
1781 | tex = self->tex [2]; /* missing, replace by noface */ |
1877 | tex = self->tex [2]; /* missing, replace by noface */ |
1782 | |
1878 | |
1783 | glEnd (); |
1879 | key.texname = tex.name; |
1784 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1880 | arr = rc_array (rc, &key); |
1785 | glBegin (GL_QUADS); |
|
|
1786 | } |
1881 | } |
1787 | |
1882 | |
1788 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1883 | px = (x + 1) * T - tex.w; |
|
|
1884 | py = (y + 1) * T - tex.h; |
|
|
1885 | |
|
|
1886 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1789 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1887 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1790 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); |
1888 | rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); |
1791 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1889 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1792 | |
1890 | |
1793 | if (cell->flags && z == 2) |
1891 | if (cell->flags && z == 2) |
1794 | { |
1892 | { |
|
|
1893 | // overlays such as the speech bubble, probably more to come |
1795 | if (cell->flags & 1) |
1894 | if (cell->flags & 1) |
1796 | { |
1895 | { |
1797 | maptex tex = self->tex [1]; |
1896 | maptex tex = self->tex [1]; |
1798 | int px = x * T + T * 2 / 32; |
1897 | int px = x * T + T * 2 / 32; |
1799 | int py = y * T - T * 6 / 32; |
1898 | int py = y * T - T * 6 / 32; |
1800 | |
1899 | |
|
|
1900 | if (tex.name) |
1801 | glEnd (); |
1901 | { |
1802 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1902 | if (key.texname != tex.name) |
|
|
1903 | { |
|
|
1904 | key.texname = tex.name; |
|
|
1905 | arr = rc_array (rc, &key); |
|
|
1906 | } |
|
|
1907 | |
|
|
1908 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
|
|
1909 | rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); |
|
|
1910 | rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); |
|
|
1911 | rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); |
1803 | glBegin (GL_QUADS); |
1912 | } |
1804 | |
|
|
1805 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1806 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + T); |
|
|
1807 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T); |
|
|
1808 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py ); |
|
|
1809 | } |
1913 | } |
1810 | } |
1914 | } |
1811 | |
1915 | |
1812 | // update smooth hash |
1916 | // update smooth hash |
1813 | if (tex.smoothtile) |
1917 | if (tex.smoothtile) |
… | |
… | |
1849 | } |
1953 | } |
1850 | } |
1954 | } |
1851 | } |
1955 | } |
1852 | } |
1956 | } |
1853 | |
1957 | |
|
|
1958 | rc_draw (rc); |
|
|
1959 | rc_clear (rc); |
|
|
1960 | |
1854 | // go through all smoothlevels, lowest to highest, then draw. |
1961 | // go through all smoothlevels, lowest to highest, then draw. |
1855 | // this is basically counting sort |
1962 | // this is basically counting sort |
1856 | { |
1963 | { |
1857 | int w, b; |
1964 | int w, b; |
1858 | |
1965 | |
|
|
1966 | glEnable (GL_TEXTURE_2D); |
|
|
1967 | glBegin (GL_QUADS); |
1859 | for (w = 0; w < 256 / 32; ++w) |
1968 | for (w = 0; w < 256 / 32; ++w) |
1860 | { |
1969 | { |
1861 | uint32_t smask = smooth_level [w]; |
1970 | uint32_t smask = smooth_level [w]; |
1862 | if (smask) |
1971 | if (smask) |
1863 | for (b = 0; b < 32; ++b) |
1972 | for (b = 0; b < 32; ++b) |
… | |
… | |
1882 | int border = bits & 15; |
1991 | int border = bits & 15; |
1883 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1992 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1884 | float dx = tex.s * .0625f; // 16 images/row |
1993 | float dx = tex.s * .0625f; // 16 images/row |
1885 | float dy = tex.t * .5f ; // 2 images/column |
1994 | float dy = tex.t * .5f ; // 2 images/column |
1886 | |
1995 | |
1887 | // this time naively avoiding texture state changes |
|
|
1888 | // save gobs of state changes. |
|
|
1889 | if (last_name != tex.name) |
1996 | if (tex.name) |
1890 | { |
1997 | { |
|
|
1998 | // this time avoiding texture state changes |
|
|
1999 | // save gobs of state changes. |
1891 | if (!tex.name) |
2000 | if (key.texname != tex.name) |
1892 | continue; // smoothing not yet available |
2001 | { |
1893 | |
|
|
1894 | glEnd (); |
2002 | glEnd (); |
1895 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
2003 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1896 | glBegin (GL_QUADS); |
2004 | glBegin (GL_QUADS); |
1897 | } |
2005 | } |
1898 | |
2006 | |
1899 | if (border) |
2007 | if (border) |
1900 | { |
2008 | { |
1901 | float ox = border * dx; |
2009 | float ox = border * dx; |
1902 | |
2010 | |
1903 | glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); |
2011 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1904 | glTexCoord2f (ox , dy ); glVertex2f (px , py + T); |
2012 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1905 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); |
2013 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1906 | glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); |
2014 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1907 | } |
2015 | } |
1908 | |
2016 | |
1909 | if (corner) |
2017 | if (corner) |
1910 | { |
2018 | { |
1911 | float ox = corner * dx; |
2019 | float ox = corner * dx; |
1912 | |
2020 | |
1913 | glTexCoord2f (ox , dy ); glVertex2f (px , py ); |
2021 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1914 | glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); |
2022 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1915 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); |
2023 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1916 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); |
2024 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
|
|
2025 | } |
1917 | } |
2026 | } |
1918 | } |
2027 | } |
1919 | } |
2028 | } |
1920 | } |
2029 | } |
1921 | } |
2030 | } |
|
|
2031 | |
|
|
2032 | glEnd (); |
|
|
2033 | glDisable (GL_TEXTURE_2D); |
|
|
2034 | key.texname = -1; |
1922 | } |
2035 | } |
1923 | |
2036 | |
1924 | hv_clear (smooth); |
2037 | hv_clear (smooth); |
1925 | } |
2038 | } |
1926 | |
2039 | |
1927 | glEnd (); |
|
|
1928 | |
|
|
1929 | glDisable (GL_TEXTURE_2D); |
|
|
1930 | glDisable (GL_BLEND); |
2040 | glDisable (GL_BLEND); |
|
|
2041 | rc_free (rc); |
1931 | |
2042 | |
1932 | // top layer: overlays such as the health bar |
2043 | // top layer: overlays such as the health bar |
1933 | for (y = 0; y < sh; y++) |
2044 | for (y = 0; y < sh; y++) |
1934 | if (0 <= y + my && y + my < self->rows) |
2045 | if (0 <= y + my && y + my < self->rows) |
1935 | { |
2046 | { |
… | |
… | |
1960 | } |
2071 | } |
1961 | } |
2072 | } |
1962 | } |
2073 | } |
1963 | |
2074 | |
1964 | void |
2075 | void |
1965 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2076 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1966 | CODE: |
2077 | CODE: |
1967 | { |
2078 | { |
1968 | static float color[16][3] = { |
2079 | static float color[16][3] = { |
1969 | { 0.00F, 0.00F, 0.00F }, |
2080 | { 0.00F, 0.00F, 0.00F }, |
1970 | { 1.00F, 1.00F, 1.00F }, |
2081 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2020 | glDisable (GL_BLEND); |
2131 | glDisable (GL_BLEND); |
2021 | glDisable (GL_TEXTURE_2D); |
2132 | glDisable (GL_TEXTURE_2D); |
2022 | } |
2133 | } |
2023 | |
2134 | |
2024 | void |
2135 | void |
2025 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2136 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2026 | PPCODE: |
2137 | PPCODE: |
2027 | { |
2138 | { |
2028 | int x, y; |
2139 | int x, y; |
2029 | int sw1 = sw + 2; |
2140 | int sw1 = sw + 2; |
2030 | int sh1 = sh + 2; |
2141 | int sh1 = sh + 2; |
… | |
… | |
2101 | PUSHs (sv_2mortal (newSViv (sh3))); |
2212 | PUSHs (sv_2mortal (newSViv (sh3))); |
2102 | PUSHs (darkness3_sv); |
2213 | PUSHs (darkness3_sv); |
2103 | } |
2214 | } |
2104 | |
2215 | |
2105 | SV * |
2216 | SV * |
2106 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2217 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2107 | CODE: |
2218 | CODE: |
2108 | { |
2219 | { |
2109 | int x, y, x1, y1; |
2220 | int x, y, x1, y1; |
2110 | SV *data_sv = newSV (w * h * 7 + 5); |
2221 | SV *data_sv = newSV (w * h * 7 + 5); |
2111 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2222 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2176 | } |
2287 | } |
2177 | OUTPUT: |
2288 | OUTPUT: |
2178 | RETVAL |
2289 | RETVAL |
2179 | |
2290 | |
2180 | void |
2291 | void |
2181 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2292 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2182 | PPCODE: |
2293 | PPCODE: |
2183 | { |
2294 | { |
2184 | int x, y, z; |
2295 | int x, y, z; |
2185 | int w, h; |
2296 | int w, h; |
2186 | int x1, y1; |
2297 | int x1, y1; |
2187 | |
2298 | |
2188 | if (*data++ != 0) |
2299 | if (*data++ != 0) |
2189 | return; /* version mismatch */ |
2300 | XSRETURN_EMPTY; /* version mismatch */ |
2190 | |
2301 | |
2191 | w = *data++ << 8; w |= *data++; |
2302 | w = *data++ << 8; w |= *data++; |
2192 | h = *data++ << 8; h |= *data++; |
2303 | h = *data++ << 8; h |= *data++; |
2193 | |
2304 | |
2194 | // we need to do this 'cause we don't keep an absolute coord system for rows |
2305 | // we need to do this 'cause we don't keep an absolute coord system for rows |
… | |
… | |
2239 | } |
2350 | } |
2240 | } |
2351 | } |
2241 | } |
2352 | } |
2242 | } |
2353 | } |
2243 | |
2354 | |
2244 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2355 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2245 | |
2356 | |
2246 | CFPlus::RW |
2357 | DC::RW |
2247 | new (SV *class, SV *data_sv) |
2358 | new (SV *class, SV *data_sv) |
2248 | CODE: |
2359 | CODE: |
2249 | { |
2360 | { |
2250 | STRLEN datalen; |
2361 | STRLEN datalen; |
2251 | char *data = SvPVbyte (data_sv, datalen); |
2362 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2253 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2364 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2254 | } |
2365 | } |
2255 | OUTPUT: |
2366 | OUTPUT: |
2256 | RETVAL |
2367 | RETVAL |
2257 | |
2368 | |
2258 | CFPlus::RW |
2369 | DC::RW |
2259 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2370 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2260 | CODE: |
2371 | CODE: |
2261 | RETVAL = SDL_RWFromFile (path, mode); |
2372 | RETVAL = SDL_RWFromFile (path, mode); |
2262 | OUTPUT: |
2373 | OUTPUT: |
2263 | RETVAL |
2374 | RETVAL |
2264 | |
2375 | |
|
|
2376 | # fails on win32: |
|
|
2377 | # dc.xs(2268) : error C2059: syntax error : '(' |
2265 | void |
2378 | #void |
2266 | close (CFPlus::RW self) |
2379 | #close (DC::RW self) |
2267 | CODE: |
2380 | # CODE: |
2268 | SDL_RWclose (self); |
2381 | # (self->(close)) (self); |
2269 | |
2382 | |
2270 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2383 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2271 | |
2384 | |
2272 | PROTOTYPES: DISABLE |
2385 | PROTOTYPES: DISABLE |
2273 | |
2386 | |
2274 | void |
2387 | DC::Channel |
2275 | halt (CFPlus::Channel self) |
2388 | find () |
2276 | CODE: |
2389 | CODE: |
|
|
2390 | { |
|
|
2391 | RETVAL = Mix_GroupAvailable (-1); |
|
|
2392 | |
|
|
2393 | if (RETVAL < 0) |
|
|
2394 | { |
|
|
2395 | RETVAL = Mix_GroupOldest (-1); |
|
|
2396 | |
|
|
2397 | if (RETVAL < 0) |
|
|
2398 | XSRETURN_UNDEF; |
|
|
2399 | |
2277 | Mix_HaltChannel (self); |
2400 | Mix_HaltChannel (RETVAL); |
|
|
2401 | } |
2278 | |
2402 | |
2279 | void |
2403 | Mix_UnregisterAllEffects (RETVAL); |
2280 | expire (CFPlus::Channel self, int ticks = -1) |
2404 | Mix_Volume (RETVAL, 128); |
2281 | CODE: |
2405 | } |
2282 | Mix_ExpireChannel (self, ticks); |
|
|
2283 | |
|
|
2284 | void |
|
|
2285 | fade_out (CFPlus::Channel self, int ticks = -1) |
|
|
2286 | CODE: |
|
|
2287 | Mix_FadeOutChannel (self, ticks); |
|
|
2288 | |
|
|
2289 | int |
|
|
2290 | volume (CFPlus::Channel self, int volume) |
|
|
2291 | CODE: |
|
|
2292 | RETVAL = Mix_Volume (self, volume); |
|
|
2293 | OUTPUT: |
2406 | OUTPUT: |
2294 | RETVAL |
2407 | RETVAL |
2295 | |
2408 | |
2296 | void |
2409 | void |
|
|
2410 | halt (DC::Channel self) |
|
|
2411 | CODE: |
|
|
2412 | Mix_HaltChannel (self); |
|
|
2413 | |
|
|
2414 | void |
|
|
2415 | expire (DC::Channel self, int ticks = -1) |
|
|
2416 | CODE: |
|
|
2417 | Mix_ExpireChannel (self, ticks); |
|
|
2418 | |
|
|
2419 | void |
|
|
2420 | fade_out (DC::Channel self, int ticks = -1) |
|
|
2421 | CODE: |
|
|
2422 | Mix_FadeOutChannel (self, ticks); |
|
|
2423 | |
|
|
2424 | int |
|
|
2425 | volume (DC::Channel self, int volume) |
|
|
2426 | CODE: |
|
|
2427 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
|
|
2428 | OUTPUT: |
|
|
2429 | RETVAL |
|
|
2430 | |
|
|
2431 | void |
2297 | unregister_all_effects (CFPlus::Channel self) |
2432 | unregister_all_effects (DC::Channel self) |
2298 | CODE: |
2433 | CODE: |
2299 | Mix_UnregisterAllEffects (self); |
2434 | Mix_UnregisterAllEffects (self); |
2300 | |
2435 | |
2301 | void |
2436 | void |
2302 | set_panning (CFPlus::Channel self, int left, int right) |
2437 | set_panning (DC::Channel self, int left, int right) |
2303 | CODE: |
2438 | CODE: |
|
|
2439 | left = CLAMP (left , 0, 255); |
|
|
2440 | right = CLAMP (right, 0, 255); |
2304 | Mix_SetPanning (self, left, right); |
2441 | Mix_SetPanning (self, left, right); |
2305 | |
2442 | |
2306 | void |
2443 | void |
2307 | set_distance (CFPlus::Channel self, int distance) |
2444 | set_distance (DC::Channel self, int distance) |
2308 | CODE: |
2445 | CODE: |
2309 | Mix_SetDistance (self, distance); |
2446 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2310 | |
2447 | |
2311 | void |
2448 | void |
2312 | set_position (CFPlus::Channel self, int angle, int distance) |
2449 | set_position (DC::Channel self, int angle, int distance) |
2313 | CODE: |
2450 | CODE: |
|
|
2451 | |
|
|
2452 | void |
|
|
2453 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
|
|
2454 | CODE: |
|
|
2455 | { |
|
|
2456 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
|
|
2457 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2314 | Mix_SetPosition (self, angle, distance); |
2458 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
|
|
2459 | } |
2315 | |
2460 | |
2316 | void |
2461 | void |
2317 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2462 | set_reverse_stereo (DC::Channel self, int flip) |
2318 | CODE: |
2463 | CODE: |
2319 | Mix_SetReverseStereo (self, flip); |
2464 | Mix_SetReverseStereo (self, flip); |
2320 | |
2465 | |
2321 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2466 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2322 | |
2467 | |
2323 | PROTOTYPES: DISABLE |
2468 | PROTOTYPES: DISABLE |
2324 | |
2469 | |
2325 | CFPlus::MixChunk |
2470 | DC::MixChunk |
2326 | new (SV *class, CFPlus::RW rwops) |
2471 | new (SV *class, DC::RW rwops) |
2327 | CODE: |
2472 | CODE: |
2328 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2473 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2329 | OUTPUT: |
2474 | OUTPUT: |
2330 | RETVAL |
2475 | RETVAL |
2331 | |
2476 | |
2332 | void |
2477 | void |
2333 | DESTROY (CFPlus::MixChunk self) |
2478 | DESTROY (DC::MixChunk self) |
2334 | CODE: |
2479 | CODE: |
2335 | Mix_FreeChunk (self); |
2480 | Mix_FreeChunk (self); |
2336 | |
2481 | |
2337 | int |
2482 | int |
2338 | volume (CFPlus::MixChunk self, int volume = -1) |
2483 | volume (DC::MixChunk self, int volume = -1) |
2339 | CODE: |
2484 | CODE: |
|
|
2485 | if (items > 1) |
|
|
2486 | volume = CLAMP (volume, 0, 128); |
2340 | RETVAL = Mix_VolumeChunk (self, volume); |
2487 | RETVAL = Mix_VolumeChunk (self, volume); |
2341 | OUTPUT: |
2488 | OUTPUT: |
2342 | RETVAL |
2489 | RETVAL |
2343 | |
2490 | |
2344 | CFPlus::Channel |
2491 | DC::Channel |
2345 | play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) |
2492 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2346 | CODE: |
2493 | CODE: |
|
|
2494 | { |
2347 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2495 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
|
|
2496 | |
|
|
2497 | if (RETVAL < 0) |
|
|
2498 | XSRETURN_UNDEF; |
|
|
2499 | |
|
|
2500 | if (channel < 0) |
|
|
2501 | { |
2348 | Mix_UnregisterAllEffects (RETVAL); |
2502 | Mix_UnregisterAllEffects (RETVAL); |
|
|
2503 | Mix_Volume (RETVAL, 128); |
|
|
2504 | } |
|
|
2505 | } |
2349 | OUTPUT: |
2506 | OUTPUT: |
2350 | RETVAL |
2507 | RETVAL |
2351 | |
2508 | |
2352 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2509 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2353 | |
2510 | |
2354 | int |
2511 | int |
2355 | volume (int volume = -1) |
2512 | volume (int volume = -1) |
2356 | PROTOTYPE: ;$ |
2513 | PROTOTYPE: ;$ |
2357 | CODE: |
2514 | CODE: |
|
|
2515 | if (items > 0) |
|
|
2516 | volume = CLAMP (volume, 0, 128); |
2358 | RETVAL = Mix_VolumeMusic (volume); |
2517 | RETVAL = Mix_VolumeMusic (volume); |
2359 | OUTPUT: |
2518 | OUTPUT: |
2360 | RETVAL |
2519 | RETVAL |
2361 | |
2520 | |
2362 | void |
2521 | void |
… | |
… | |
2367 | void |
2526 | void |
2368 | halt () |
2527 | halt () |
2369 | CODE: |
2528 | CODE: |
2370 | Mix_HaltMusic (); |
2529 | Mix_HaltMusic (); |
2371 | |
2530 | |
2372 | CFPlus::MixMusic |
2531 | DC::MixMusic |
2373 | new (SV *class, CFPlus::RW rwops) |
2532 | new (SV *class, DC::RW rwops) |
2374 | CODE: |
2533 | CODE: |
2375 | RETVAL = Mix_LoadMUS_RW (rwops); |
2534 | RETVAL = Mix_LoadMUS_RW (rwops); |
2376 | OUTPUT: |
2535 | OUTPUT: |
2377 | RETVAL |
2536 | RETVAL |
2378 | |
2537 | |
2379 | void |
2538 | void |
2380 | DESTROY (CFPlus::MixMusic self) |
2539 | DESTROY (DC::MixMusic self) |
2381 | CODE: |
2540 | CODE: |
2382 | Mix_FreeMusic (self); |
2541 | Mix_FreeMusic (self); |
2383 | |
2542 | |
2384 | int |
2543 | int |
2385 | play (CFPlus::MixMusic self, int loops = -1) |
2544 | play (DC::MixMusic self, int loops = -1) |
2386 | CODE: |
2545 | CODE: |
2387 | RETVAL = Mix_PlayMusic (self, loops); |
2546 | RETVAL = Mix_PlayMusic (self, loops); |
2388 | OUTPUT: |
2547 | OUTPUT: |
2389 | RETVAL |
2548 | RETVAL |
2390 | |
2549 | |
2391 | void |
2550 | void |
2392 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2551 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2393 | CODE: |
2552 | CODE: |
2394 | Mix_FadeInMusicPos (self, loops, ms, position); |
2553 | Mix_FadeInMusicPos (self, loops, ms, position); |
2395 | |
2554 | |
2396 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2555 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2397 | |
2556 | |
2398 | PROTOTYPES: ENABLE |
2557 | PROTOTYPES: ENABLE |
2399 | |
2558 | |
2400 | BOOT: |
2559 | BOOT: |
2401 | { |
2560 | { |
2402 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2561 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2403 | static const struct { |
2562 | static const struct { |
2404 | const char *name; |
2563 | const char *name; |
2405 | IV iv; |
2564 | IV iv; |
2406 | } *civ, const_iv[] = { |
2565 | } *civ, const_iv[] = { |
2407 | # define const_iv(name) { # name, (IV)name } |
2566 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2442 | const_iv (GL_INTENSITY), |
2601 | const_iv (GL_INTENSITY), |
2443 | const_iv (GL_LUMINANCE), |
2602 | const_iv (GL_LUMINANCE), |
2444 | const_iv (GL_LUMINANCE_ALPHA), |
2603 | const_iv (GL_LUMINANCE_ALPHA), |
2445 | const_iv (GL_FLOAT), |
2604 | const_iv (GL_FLOAT), |
2446 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2605 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2606 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2607 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2608 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2609 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2610 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2611 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2447 | const_iv (GL_COMPILE), |
2612 | const_iv (GL_COMPILE), |
2448 | const_iv (GL_PROXY_TEXTURE_1D), |
2613 | const_iv (GL_PROXY_TEXTURE_1D), |
2449 | const_iv (GL_PROXY_TEXTURE_2D), |
2614 | const_iv (GL_PROXY_TEXTURE_2D), |
2450 | const_iv (GL_TEXTURE_1D), |
2615 | const_iv (GL_TEXTURE_1D), |
2451 | const_iv (GL_TEXTURE_2D), |
2616 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2490 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2655 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2491 | const_iv (GL_POINT_SMOOTH_HINT), |
2656 | const_iv (GL_POINT_SMOOTH_HINT), |
2492 | const_iv (GL_LINE_SMOOTH_HINT), |
2657 | const_iv (GL_LINE_SMOOTH_HINT), |
2493 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2658 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2494 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2659 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2660 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2495 | const_iv (GL_FASTEST), |
2661 | const_iv (GL_FASTEST), |
2496 | const_iv (GL_DONT_CARE), |
2662 | const_iv (GL_DONT_CARE), |
2497 | const_iv (GL_NICEST), |
2663 | const_iv (GL_NICEST), |
2498 | const_iv (GL_V2F), |
2664 | const_iv (GL_V2F), |
2499 | const_iv (GL_V3F), |
2665 | const_iv (GL_V3F), |
… | |
… | |
2507 | |
2673 | |
2508 | texture_av = newAV (); |
2674 | texture_av = newAV (); |
2509 | AvREAL_off (texture_av); |
2675 | AvREAL_off (texture_av); |
2510 | } |
2676 | } |
2511 | |
2677 | |
|
|
2678 | void |
|
|
2679 | disable_GL_EXT_blend_func_separate () |
|
|
2680 | CODE: |
|
|
2681 | gl.BlendFuncSeparate = 0; |
|
|
2682 | gl.BlendFuncSeparateEXT = 0; |
|
|
2683 | |
2512 | char * |
2684 | char * |
2513 | gl_vendor () |
2685 | gl_vendor () |
2514 | CODE: |
2686 | CODE: |
2515 | RETVAL = (char *)glGetString (GL_VENDOR); |
2687 | RETVAL = (char *)glGetString (GL_VENDOR); |
2516 | OUTPUT: |
2688 | OUTPUT: |
… | |
… | |
2637 | |
2809 | |
2638 | void glRect (float x1, float y1, float x2, float y2) |
2810 | void glRect (float x1, float y1, float x2, float y2) |
2639 | CODE: |
2811 | CODE: |
2640 | glRectf (x1, y1, x2, y2); |
2812 | glRectf (x1, y1, x2, y2); |
2641 | |
2813 | |
|
|
2814 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2815 | CODE: |
|
|
2816 | glBegin (GL_LINE_LOOP); |
|
|
2817 | glVertex2f (x1, y1); |
|
|
2818 | glVertex2f (x2, y1); |
|
|
2819 | glVertex2f (x2, y2); |
|
|
2820 | glVertex2f (x1, y2); |
|
|
2821 | glEnd (); |
|
|
2822 | |
2642 | PROTOTYPES: ENABLE |
2823 | PROTOTYPES: ENABLE |
2643 | |
2824 | |
2644 | void glBegin (int mode) |
2825 | void glBegin (int mode) |
2645 | |
2826 | |
2646 | void glEnd () |
2827 | void glEnd () |
… | |
… | |
2678 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2859 | void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) |
2679 | CODE: |
2860 | CODE: |
2680 | if (gl.SeparableFilter2D) |
2861 | if (gl.SeparableFilter2D) |
2681 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2862 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2682 | |
2863 | |
2683 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) |
2864 | void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0) |
2684 | |
2865 | |
2685 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2866 | void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) |
2686 | |
2867 | |
2687 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2868 | void glDrawPixels (int width, int height, int format, int type, char *pixels) |
2688 | |
2869 | |
… | |
… | |
2714 | |
2895 | |
2715 | void glEndList () |
2896 | void glEndList () |
2716 | |
2897 | |
2717 | void glCallList (int list) |
2898 | void glCallList (int list) |
2718 | |
2899 | |
2719 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2900 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2720 | |
2901 | |
2721 | PROTOTYPES: DISABLE |
2902 | PROTOTYPES: DISABLE |
2722 | |
2903 | |
2723 | void |
2904 | void |
2724 | find_widget (SV *self, NV x, NV y) |
2905 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2728 | XPUSHs (self); |
2909 | XPUSHs (self); |
2729 | } |
2910 | } |
2730 | |
2911 | |
2731 | BOOT: |
2912 | BOOT: |
2732 | { |
2913 | { |
2733 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2914 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2734 | |
2915 | |
2735 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2916 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2736 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2917 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2737 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2918 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2738 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2919 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2739 | } |
2920 | } |
2740 | |
2921 | |
2741 | void |
2922 | void |
2742 | draw (SV *self) |
2923 | draw (SV *self) |
2743 | CODE: |
2924 | CODE: |
… | |
… | |
2747 | NV x, y, w, h; |
2928 | NV x, y, w, h; |
2748 | SV *draw_x_sv = GvSV (draw_x_gv); |
2929 | SV *draw_x_sv = GvSV (draw_x_gv); |
2749 | SV *draw_y_sv = GvSV (draw_y_gv); |
2930 | SV *draw_y_sv = GvSV (draw_y_gv); |
2750 | SV *draw_w_sv = GvSV (draw_w_gv); |
2931 | SV *draw_w_sv = GvSV (draw_w_gv); |
2751 | SV *draw_h_sv = GvSV (draw_h_gv); |
2932 | SV *draw_h_sv = GvSV (draw_h_gv); |
2752 | SV *hover; |
|
|
2753 | double draw_x, draw_y, draw_w, draw_h; |
2933 | double draw_x, draw_y; |
2754 | |
2934 | |
2755 | if (!SvROK (self)) |
2935 | if (!SvROK (self)) |
2756 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2936 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2757 | |
2937 | |
2758 | hv = (HV *)SvRV (self); |
2938 | hv = (HV *)SvRV (self); |
2759 | |
2939 | |
2760 | if (SvTYPE (hv) != SVt_PVHV) |
2940 | if (SvTYPE (hv) != SVt_PVHV) |
2761 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2941 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2762 | |
2942 | |
2763 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2943 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2764 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2944 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2765 | |
2945 | |
2766 | if (!h || !w) |
2946 | if (!h || !w) |
… | |
… | |
2786 | { |
2966 | { |
2787 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2967 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2788 | |
2968 | |
2789 | if (svp && SvTRUE (*svp)) |
2969 | if (svp && SvTRUE (*svp)) |
2790 | { |
2970 | { |
2791 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
2971 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2792 | glEnable (GL_BLEND); |
2972 | glEnable (GL_BLEND); |
2793 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2973 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2794 | glBegin (GL_QUADS); |
2974 | glBegin (GL_QUADS); |
2795 | glVertex2f (0, 0); |
2975 | glVertex2f (0, 0); |
2796 | glVertex2f (w, 0); |
2976 | glVertex2f (w, 0); |
… | |
… | |
2799 | glEnd (); |
2979 | glEnd (); |
2800 | glDisable (GL_BLEND); |
2980 | glDisable (GL_BLEND); |
2801 | } |
2981 | } |
2802 | } |
2982 | } |
2803 | #if 0 |
2983 | #if 0 |
2804 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2984 | // draw borders, for debugging |
2805 | glPushMatrix; |
2985 | glPushMatrix (); |
2806 | glColor 1, 1, 0, 1; |
2986 | glColor4f (1., 1., 0., 1.); |
2807 | glTranslate 0.375, 0.375; |
2987 | glTranslatef (.5, .5, 0.); |
2808 | glBegin GL_LINE_LOOP; |
2988 | glBegin (GL_LINE_LOOP); |
2809 | glVertex 0 , 0; |
2989 | glVertex2f (0 , 0); |
2810 | glVertex $self->{w} - 1, 0; |
2990 | glVertex2f (w - 1, 0); |
2811 | glVertex $self->{w} - 1, $self->{h} - 1; |
2991 | glVertex2f (w - 1, h - 1); |
2812 | glVertex 0 , $self->{h} - 1; |
2992 | glVertex2f (0 , h - 1); |
2813 | glEnd; |
2993 | glEnd (); |
2814 | glPopMatrix; |
2994 | glPopMatrix (); |
2815 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2816 | } |
|
|
2817 | #endif |
2995 | #endif |
2818 | PUSHMARK (SP); |
2996 | PUSHMARK (SP); |
2819 | XPUSHs (self); |
2997 | XPUSHs (self); |
2820 | PUTBACK; |
2998 | PUTBACK; |
2821 | call_method ("_draw", G_VOID | G_DISCARD); |
2999 | call_method ("_draw", G_VOID | G_DISCARD); |