… | |
… | |
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 = 1024) |
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, &pos, 0); |
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 | { |
… | |
… | |
1400 | RETVAL = width > 0; |
1485 | RETVAL = width > 0; |
1401 | } |
1486 | } |
1402 | OUTPUT: |
1487 | OUTPUT: |
1403 | RETVAL |
1488 | RETVAL |
1404 | |
1489 | |
1405 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1490 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1406 | |
1491 | |
1407 | PROTOTYPES: DISABLE |
1492 | PROTOTYPES: DISABLE |
1408 | |
1493 | |
1409 | CFPlus::Map |
1494 | DC::Map |
1410 | new (SV *class) |
1495 | new (SV *class) |
1411 | CODE: |
1496 | CODE: |
1412 | New (0, RETVAL, 1, struct map); |
1497 | New (0, RETVAL, 1, struct map); |
1413 | RETVAL->x = 0; |
1498 | RETVAL->x = 0; |
1414 | RETVAL->y = 0; |
1499 | RETVAL->y = 0; |
… | |
… | |
1422 | RETVAL->row = 0; |
1507 | RETVAL->row = 0; |
1423 | OUTPUT: |
1508 | OUTPUT: |
1424 | RETVAL |
1509 | RETVAL |
1425 | |
1510 | |
1426 | void |
1511 | void |
1427 | DESTROY (CFPlus::Map self) |
1512 | DESTROY (DC::Map self) |
1428 | CODE: |
1513 | CODE: |
1429 | { |
1514 | { |
1430 | map_clear (self); |
1515 | map_clear (self); |
1431 | Safefree (self->face2tile); |
1516 | Safefree (self->face2tile); |
1432 | Safefree (self->tex); |
1517 | Safefree (self->tex); |
1433 | Safefree (self); |
1518 | Safefree (self); |
1434 | } |
1519 | } |
1435 | |
1520 | |
1436 | void |
1521 | void |
1437 | resize (CFPlus::Map self, int map_width, int map_height) |
1522 | resize (DC::Map self, int map_width, int map_height) |
1438 | CODE: |
1523 | CODE: |
1439 | self->w = map_width; |
1524 | self->w = map_width; |
1440 | self->h = map_height; |
1525 | self->h = map_height; |
1441 | |
1526 | |
1442 | void |
1527 | void |
1443 | clear (CFPlus::Map self) |
1528 | clear (DC::Map self) |
1444 | CODE: |
1529 | CODE: |
1445 | map_clear (self); |
1530 | map_clear (self); |
1446 | |
1531 | |
1447 | void |
1532 | void |
1448 | set_tileid (CFPlus::Map self, int face, int tile) |
1533 | set_tileid (DC::Map self, int face, int tile) |
1449 | CODE: |
1534 | CODE: |
1450 | { |
1535 | { |
1451 | need_facenum (self, face); self->face2tile [face] = tile; |
1536 | need_facenum (self, face); self->face2tile [face] = tile; |
1452 | need_texid (self, tile); |
1537 | need_texid (self, tile); |
1453 | } |
1538 | } |
1454 | |
1539 | |
1455 | void |
1540 | void |
1456 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1541 | set_smooth (DC::Map self, int face, int smooth, int level) |
1457 | CODE: |
1542 | CODE: |
1458 | { |
1543 | { |
1459 | tileid texid; |
1544 | tileid texid; |
1460 | maptex *tex; |
1545 | maptex *tex; |
1461 | |
1546 | |
… | |
… | |
1474 | tex->smoothtile = self->face2tile [smooth]; |
1559 | tex->smoothtile = self->face2tile [smooth]; |
1475 | tex->smoothlevel = level; |
1560 | tex->smoothlevel = level; |
1476 | } |
1561 | } |
1477 | |
1562 | |
1478 | void |
1563 | void |
1479 | 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) |
1480 | CODE: |
1565 | CODE: |
1481 | { |
1566 | { |
1482 | need_texid (self, texid); |
1567 | need_texid (self, texid); |
1483 | |
1568 | |
1484 | { |
1569 | { |
… | |
… | |
1504 | // from transparent color bleeding and ugly wrapping effects. |
1589 | // from transparent color bleeding and ugly wrapping effects. |
1505 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1590 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1506 | } |
1591 | } |
1507 | |
1592 | |
1508 | int |
1593 | int |
1509 | ox (CFPlus::Map self) |
1594 | ox (DC::Map self) |
1510 | ALIAS: |
1595 | ALIAS: |
1511 | oy = 1 |
1596 | oy = 1 |
1512 | x = 2 |
1597 | x = 2 |
1513 | y = 3 |
1598 | y = 3 |
1514 | w = 4 |
1599 | w = 4 |
… | |
… | |
1525 | } |
1610 | } |
1526 | OUTPUT: |
1611 | OUTPUT: |
1527 | RETVAL |
1612 | RETVAL |
1528 | |
1613 | |
1529 | void |
1614 | void |
1530 | scroll (CFPlus::Map self, int dx, int dy) |
1615 | scroll (DC::Map self, int dx, int dy) |
1531 | CODE: |
1616 | CODE: |
1532 | { |
1617 | { |
1533 | if (dx > 0) |
1618 | if (dx > 0) |
1534 | map_blank (self, self->x, self->y, dx, self->h); |
1619 | map_blank (self, self->x, self->y, dx, self->h); |
1535 | else if (dx < 0) |
1620 | else if (dx < 0) |
… | |
… | |
1550 | self->rows += MAP_EXTEND_Y; |
1635 | self->rows += MAP_EXTEND_Y; |
1551 | self->y += MAP_EXTEND_Y; |
1636 | self->y += MAP_EXTEND_Y; |
1552 | } |
1637 | } |
1553 | } |
1638 | } |
1554 | |
1639 | |
1555 | void |
1640 | SV * |
1556 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1641 | map1a_update (DC::Map self, SV *data_, int extmap) |
1557 | CODE: |
1642 | CODE: |
1558 | { |
1643 | { |
1559 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1644 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1560 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1645 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1561 | mapcell *cell; |
1646 | mapcell *cell; |
1562 | int x, y, flags; |
1647 | int x, y, z, flags; |
|
|
1648 | AV *missing = newAV (); |
|
|
1649 | RETVAL = newRV_noinc ((SV *)missing); |
1563 | |
1650 | |
1564 | while (data < data_end - 1) |
1651 | while (data < data_end - 1) |
1565 | { |
1652 | { |
1566 | flags = (data [0] << 8) + data [1]; data += 2; |
1653 | flags = (data [0] << 8) + data [1]; data += 2; |
1567 | |
1654 | |
… | |
… | |
1618 | } |
1705 | } |
1619 | else |
1706 | else |
1620 | cell->darkness = *data++ + 1; |
1707 | cell->darkness = *data++ + 1; |
1621 | } |
1708 | } |
1622 | |
1709 | |
|
|
1710 | for (z = 0; z <= 2; ++z) |
1623 | if (flags & 4) |
1711 | if (flags & (4 >> z)) |
1624 | { |
1712 | { |
1625 | faceid face = (data [0] << 8) + data [1]; data += 2; |
1713 | faceid face = (data [0] << 8) + data [1]; data += 2; |
1626 | need_facenum (self, face); |
1714 | need_facenum (self, face); |
1627 | 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 | } |
1628 | } |
1730 | } |
1629 | |
|
|
1630 | if (flags & 2) |
|
|
1631 | { |
|
|
1632 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1633 | need_facenum (self, face); |
|
|
1634 | cell->tile [1] = self->face2tile [face]; |
|
|
1635 | } |
|
|
1636 | |
|
|
1637 | if (flags & 1) |
|
|
1638 | { |
|
|
1639 | faceid face = (data [0] << 8) + data [1]; data += 2; |
|
|
1640 | need_facenum (self, face); |
|
|
1641 | cell->tile [2] = self->face2tile [face]; |
|
|
1642 | } |
|
|
1643 | } |
1731 | } |
1644 | else |
1732 | else |
1645 | cell->darkness = 0; |
1733 | cell->darkness = 0; |
1646 | } |
1734 | } |
1647 | } |
1735 | } |
|
|
1736 | OUTPUT: |
|
|
1737 | RETVAL |
1648 | |
1738 | |
1649 | SV * |
1739 | SV * |
1650 | 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) |
1651 | CODE: |
1741 | CODE: |
1652 | { |
1742 | { |
1653 | int x1, x; |
1743 | int x1, x; |
1654 | int y1, y; |
1744 | int y1, y; |
1655 | int z; |
1745 | int z; |
… | |
… | |
1699 | RETVAL = map_sv; |
1789 | RETVAL = map_sv; |
1700 | } |
1790 | } |
1701 | OUTPUT: |
1791 | OUTPUT: |
1702 | RETVAL |
1792 | RETVAL |
1703 | |
1793 | |
1704 | SV * |
1794 | void |
1705 | 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) |
1706 | CODE: |
1796 | CODE: |
1707 | { |
1797 | { |
|
|
1798 | int x, y, z; |
|
|
1799 | |
1708 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1800 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1709 | 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 |
1710 | 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) |
1711 | smooth_key skey; |
1803 | smooth_key skey; |
1712 | int x, y, z; |
1804 | |
1713 | int last_name; |
1805 | rc_t *rc = rc_alloc (); |
1714 | AV *missing = newAV (); |
1806 | rc_key_t key; |
1715 | RETVAL = newRV_noinc ((SV *)missing); |
1807 | rc_array_t *arr; |
1716 | |
1808 | |
1717 | // thats current max. sorry. |
1809 | // thats current max. sorry. |
1718 | if (sw > 255) sw = 255; |
1810 | if (sw > 255) sw = 255; |
1719 | if (sh > 255) sh = 255; |
1811 | if (sh > 255) sh = 255; |
1720 | |
1812 | |
1721 | // clear key, in case of extra padding |
1813 | // clear key, in case of extra padding |
1722 | memset (&skey, 0, sizeof (skey)); |
1814 | memset (&skey, 0, sizeof (skey)); |
1723 | |
1815 | |
1724 | glColor4ub (255, 255, 255, 255); |
1816 | memset (&key, 0, sizeof (key)); |
1725 | |
1817 | key.r = 255; |
1726 | glEnable (GL_BLEND); |
1818 | key.g = 255; |
1727 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1819 | key.b = 255; |
1728 | glEnable (GL_TEXTURE_2D); |
1820 | key.a = 255; |
1729 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1821 | key.mode = GL_QUADS; |
1730 | |
1822 | key.format = GL_T2F_V3F; |
1731 | glBegin (GL_QUADS); |
|
|
1732 | |
|
|
1733 | last_name = -1; |
1823 | key.texname = -1; |
1734 | |
1824 | |
1735 | mx += self->x; |
1825 | mx += self->x; |
1736 | my += self->y; |
1826 | my += self->y; |
1737 | |
1827 | |
1738 | // first pass: determine smooth_max |
1828 | // first pass: determine smooth_max |
… | |
… | |
1754 | MAX (self->tex [cell->tile [0]].smoothlevel, |
1844 | MAX (self->tex [cell->tile [0]].smoothlevel, |
1755 | MAX (self->tex [cell->tile [1]].smoothlevel, |
1845 | MAX (self->tex [cell->tile [1]].smoothlevel, |
1756 | self->tex [cell->tile [2]].smoothlevel)); |
1846 | self->tex [cell->tile [2]].smoothlevel)); |
1757 | } |
1847 | } |
1758 | } |
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); |
1759 | |
1853 | |
1760 | for (z = 0; z <= 2; z++) |
1854 | for (z = 0; z <= 2; z++) |
1761 | { |
1855 | { |
1762 | memset (smooth_level, 0, sizeof (smooth_level)); |
1856 | memset (smooth_level, 0, sizeof (smooth_level)); |
1763 | |
1857 | |
… | |
… | |
1775 | if (tile) |
1869 | if (tile) |
1776 | { |
1870 | { |
1777 | maptex tex = self->tex [tile]; |
1871 | maptex tex = self->tex [tile]; |
1778 | int px, py; |
1872 | int px, py; |
1779 | |
1873 | |
1780 | // suppressing texture state switches here |
|
|
1781 | // is only moderately effective, but worth the extra effort |
|
|
1782 | if (last_name != tex.name) |
1874 | if (key.texname != tex.name) |
1783 | { |
1875 | { |
1784 | if (!tex.name) |
1876 | if (!tex.name) |
1785 | { |
|
|
1786 | av_push (missing, newSViv (tile)); |
|
|
1787 | tex = self->tex [2]; /* missing, replace by noface */ |
1877 | tex = self->tex [2]; /* missing, replace by noface */ |
1788 | } |
|
|
1789 | |
1878 | |
1790 | glEnd (); |
1879 | key.texname = tex.name; |
1791 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
1880 | arr = rc_array (rc, &key); |
1792 | glBegin (GL_QUADS); |
|
|
1793 | } |
1881 | } |
1794 | |
1882 | |
1795 | px = (x + 1) * T - tex.w; |
1883 | px = (x + 1) * T - tex.w; |
1796 | py = (y + 1) * T - tex.h; |
1884 | py = (y + 1) * T - tex.h; |
1797 | |
1885 | |
1798 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
1886 | rc_t2f_v3f (arr, 0 , 0 , px , py , 0); |
1799 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); |
1887 | rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); |
1800 | 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); |
1801 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); |
1889 | rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); |
1802 | |
1890 | |
1803 | if (cell->flags && z == 2) |
1891 | if (cell->flags && z == 2) |
1804 | { |
1892 | { |
|
|
1893 | // overlays such as the speech bubble, probably more to come |
1805 | if (cell->flags & 1) |
1894 | if (cell->flags & 1) |
1806 | { |
1895 | { |
1807 | maptex tex = self->tex [1]; |
1896 | maptex tex = self->tex [1]; |
1808 | int px = x * T + T * 2 / 32; |
1897 | int px = x * T + T * 2 / 32; |
1809 | int py = y * T - T * 6 / 32; |
1898 | int py = y * T - T * 6 / 32; |
1810 | |
1899 | |
|
|
1900 | if (tex.name) |
1811 | glEnd (); |
1901 | { |
1812 | 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); |
1813 | glBegin (GL_QUADS); |
1912 | } |
1814 | |
|
|
1815 | glTexCoord2f (0 , 0 ); glVertex2f (px , py ); |
|
|
1816 | glTexCoord2f (0 , tex.t); glVertex2f (px , py + T); |
|
|
1817 | glTexCoord2f (tex.s, tex.t); glVertex2f (px + T, py + T); |
|
|
1818 | glTexCoord2f (tex.s, 0 ); glVertex2f (px + T, py ); |
|
|
1819 | } |
1913 | } |
1820 | } |
1914 | } |
1821 | |
1915 | |
1822 | // update smooth hash |
1916 | // update smooth hash |
1823 | if (tex.smoothtile) |
1917 | if (tex.smoothtile) |
… | |
… | |
1859 | } |
1953 | } |
1860 | } |
1954 | } |
1861 | } |
1955 | } |
1862 | } |
1956 | } |
1863 | |
1957 | |
|
|
1958 | rc_draw (rc); |
|
|
1959 | rc_clear (rc); |
|
|
1960 | |
1864 | // go through all smoothlevels, lowest to highest, then draw. |
1961 | // go through all smoothlevels, lowest to highest, then draw. |
1865 | // this is basically counting sort |
1962 | // this is basically counting sort |
1866 | { |
1963 | { |
1867 | int w, b; |
1964 | int w, b; |
1868 | |
1965 | |
|
|
1966 | glEnable (GL_TEXTURE_2D); |
|
|
1967 | glBegin (GL_QUADS); |
1869 | for (w = 0; w < 256 / 32; ++w) |
1968 | for (w = 0; w < 256 / 32; ++w) |
1870 | { |
1969 | { |
1871 | uint32_t smask = smooth_level [w]; |
1970 | uint32_t smask = smooth_level [w]; |
1872 | if (smask) |
1971 | if (smask) |
1873 | for (b = 0; b < 32; ++b) |
1972 | for (b = 0; b < 32; ++b) |
… | |
… | |
1892 | int border = bits & 15; |
1991 | int border = bits & 15; |
1893 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1992 | int corner = (bits >> 8) & ~(bits >> 4) & 15; |
1894 | float dx = tex.s * .0625f; // 16 images/row |
1993 | float dx = tex.s * .0625f; // 16 images/row |
1895 | float dy = tex.t * .5f ; // 2 images/column |
1994 | float dy = tex.t * .5f ; // 2 images/column |
1896 | |
1995 | |
1897 | // this time naively avoiding texture state changes |
|
|
1898 | // save gobs of state changes. |
|
|
1899 | if (last_name != tex.name) |
1996 | if (tex.name) |
1900 | { |
1997 | { |
|
|
1998 | // this time avoiding texture state changes |
|
|
1999 | // save gobs of state changes. |
1901 | if (!tex.name) |
2000 | if (key.texname != tex.name) |
1902 | { |
2001 | { |
1903 | av_push (missing, newSViv (skey->tile)); |
2002 | glEnd (); |
1904 | continue; // smoothing not yet available |
2003 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
|
|
2004 | glBegin (GL_QUADS); |
1905 | } |
2005 | } |
1906 | |
2006 | |
1907 | glEnd (); |
|
|
1908 | glBindTexture (GL_TEXTURE_2D, last_name = tex.name); |
|
|
1909 | glBegin (GL_QUADS); |
|
|
1910 | } |
|
|
1911 | |
|
|
1912 | if (border) |
2007 | if (border) |
1913 | { |
2008 | { |
1914 | float ox = border * dx; |
2009 | float ox = border * dx; |
1915 | |
2010 | |
1916 | glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); |
2011 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1917 | glTexCoord2f (ox , dy ); glVertex2f (px , py + T); |
2012 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1918 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); |
2013 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1919 | glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); |
2014 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1920 | } |
2015 | } |
1921 | |
2016 | |
1922 | if (corner) |
2017 | if (corner) |
1923 | { |
2018 | { |
1924 | float ox = corner * dx; |
2019 | float ox = corner * dx; |
1925 | |
2020 | |
1926 | glTexCoord2f (ox , dy ); glVertex2f (px , py ); |
2021 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1927 | glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); |
2022 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1928 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); |
2023 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1929 | glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); |
2024 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
|
|
2025 | } |
1930 | } |
2026 | } |
1931 | } |
2027 | } |
1932 | } |
2028 | } |
1933 | } |
2029 | } |
1934 | } |
2030 | } |
|
|
2031 | |
|
|
2032 | glEnd (); |
|
|
2033 | glDisable (GL_TEXTURE_2D); |
|
|
2034 | key.texname = -1; |
1935 | } |
2035 | } |
1936 | |
2036 | |
1937 | hv_clear (smooth); |
2037 | hv_clear (smooth); |
1938 | } |
2038 | } |
1939 | |
2039 | |
1940 | glEnd (); |
|
|
1941 | |
|
|
1942 | glDisable (GL_TEXTURE_2D); |
|
|
1943 | glDisable (GL_BLEND); |
2040 | glDisable (GL_BLEND); |
|
|
2041 | rc_free (rc); |
1944 | |
2042 | |
1945 | // top layer: overlays such as the health bar |
2043 | // top layer: overlays such as the health bar |
1946 | for (y = 0; y < sh; y++) |
2044 | for (y = 0; y < sh; y++) |
1947 | if (0 <= y + my && y + my < self->rows) |
2045 | if (0 <= y + my && y + my < self->rows) |
1948 | { |
2046 | { |
… | |
… | |
1971 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
2069 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); |
1972 | } |
2070 | } |
1973 | } |
2071 | } |
1974 | } |
2072 | } |
1975 | } |
2073 | } |
1976 | OUTPUT: |
|
|
1977 | RETVAL |
|
|
1978 | |
2074 | |
1979 | void |
2075 | void |
1980 | 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) |
1981 | CODE: |
2077 | CODE: |
1982 | { |
2078 | { |
1983 | static float color[16][3] = { |
2079 | static float color[16][3] = { |
1984 | { 0.00F, 0.00F, 0.00F }, |
2080 | { 0.00F, 0.00F, 0.00F }, |
1985 | { 1.00F, 1.00F, 1.00F }, |
2081 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2035 | glDisable (GL_BLEND); |
2131 | glDisable (GL_BLEND); |
2036 | glDisable (GL_TEXTURE_2D); |
2132 | glDisable (GL_TEXTURE_2D); |
2037 | } |
2133 | } |
2038 | |
2134 | |
2039 | void |
2135 | void |
2040 | 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) |
2041 | PPCODE: |
2137 | PPCODE: |
2042 | { |
2138 | { |
2043 | int x, y; |
2139 | int x, y; |
2044 | int sw1 = sw + 2; |
2140 | int sw1 = sw + 2; |
2045 | int sh1 = sh + 2; |
2141 | int sh1 = sh + 2; |
… | |
… | |
2116 | PUSHs (sv_2mortal (newSViv (sh3))); |
2212 | PUSHs (sv_2mortal (newSViv (sh3))); |
2117 | PUSHs (darkness3_sv); |
2213 | PUSHs (darkness3_sv); |
2118 | } |
2214 | } |
2119 | |
2215 | |
2120 | SV * |
2216 | SV * |
2121 | 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) |
2122 | CODE: |
2218 | CODE: |
2123 | { |
2219 | { |
2124 | int x, y, x1, y1; |
2220 | int x, y, x1, y1; |
2125 | SV *data_sv = newSV (w * h * 7 + 5); |
2221 | SV *data_sv = newSV (w * h * 7 + 5); |
2126 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2222 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2191 | } |
2287 | } |
2192 | OUTPUT: |
2288 | OUTPUT: |
2193 | RETVAL |
2289 | RETVAL |
2194 | |
2290 | |
2195 | void |
2291 | void |
2196 | 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) |
2197 | PPCODE: |
2293 | PPCODE: |
2198 | { |
2294 | { |
2199 | int x, y, z; |
2295 | int x, y, z; |
2200 | int w, h; |
2296 | int w, h; |
2201 | int x1, y1; |
2297 | int x1, y1; |
2202 | |
2298 | |
2203 | if (*data++ != 0) |
2299 | if (*data++ != 0) |
2204 | return; /* version mismatch */ |
2300 | XSRETURN_EMPTY; /* version mismatch */ |
2205 | |
2301 | |
2206 | w = *data++ << 8; w |= *data++; |
2302 | w = *data++ << 8; w |= *data++; |
2207 | h = *data++ << 8; h |= *data++; |
2303 | h = *data++ << 8; h |= *data++; |
2208 | |
2304 | |
2209 | // 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 |
… | |
… | |
2254 | } |
2350 | } |
2255 | } |
2351 | } |
2256 | } |
2352 | } |
2257 | } |
2353 | } |
2258 | |
2354 | |
2259 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2355 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2260 | |
2356 | |
2261 | CFPlus::RW |
2357 | DC::RW |
2262 | new (SV *class, SV *data_sv) |
2358 | new (SV *class, SV *data_sv) |
2263 | CODE: |
2359 | CODE: |
2264 | { |
2360 | { |
2265 | STRLEN datalen; |
2361 | STRLEN datalen; |
2266 | char *data = SvPVbyte (data_sv, datalen); |
2362 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2268 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2364 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2269 | } |
2365 | } |
2270 | OUTPUT: |
2366 | OUTPUT: |
2271 | RETVAL |
2367 | RETVAL |
2272 | |
2368 | |
2273 | CFPlus::RW |
2369 | DC::RW |
2274 | 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") |
2275 | CODE: |
2371 | CODE: |
2276 | RETVAL = SDL_RWFromFile (path, mode); |
2372 | RETVAL = SDL_RWFromFile (path, mode); |
2277 | OUTPUT: |
2373 | OUTPUT: |
2278 | RETVAL |
2374 | RETVAL |
2279 | |
2375 | |
2280 | # fails on win32: |
2376 | # fails on win32: |
2281 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2377 | # dc.xs(2268) : error C2059: syntax error : '(' |
2282 | #void |
2378 | #void |
2283 | #close (CFPlus::RW self) |
2379 | #close (DC::RW self) |
2284 | # CODE: |
2380 | # CODE: |
2285 | # (self->(close)) (self); |
2381 | # (self->(close)) (self); |
2286 | |
2382 | |
2287 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2383 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2288 | |
2384 | |
2289 | PROTOTYPES: DISABLE |
2385 | PROTOTYPES: DISABLE |
2290 | |
2386 | |
2291 | CFPlus::Channel |
2387 | DC::Channel |
2292 | find () |
2388 | find () |
2293 | CODE: |
2389 | CODE: |
2294 | { |
2390 | { |
2295 | RETVAL = Mix_GroupAvailable (-1); |
2391 | RETVAL = Mix_GroupAvailable (-1); |
2296 | |
2392 | |
… | |
… | |
2309 | } |
2405 | } |
2310 | OUTPUT: |
2406 | OUTPUT: |
2311 | RETVAL |
2407 | RETVAL |
2312 | |
2408 | |
2313 | void |
2409 | void |
2314 | halt (CFPlus::Channel self) |
2410 | halt (DC::Channel self) |
2315 | CODE: |
2411 | CODE: |
2316 | Mix_HaltChannel (self); |
2412 | Mix_HaltChannel (self); |
2317 | |
2413 | |
2318 | void |
2414 | void |
2319 | expire (CFPlus::Channel self, int ticks = -1) |
2415 | expire (DC::Channel self, int ticks = -1) |
2320 | CODE: |
2416 | CODE: |
2321 | Mix_ExpireChannel (self, ticks); |
2417 | Mix_ExpireChannel (self, ticks); |
2322 | |
2418 | |
2323 | void |
2419 | void |
2324 | fade_out (CFPlus::Channel self, int ticks = -1) |
2420 | fade_out (DC::Channel self, int ticks = -1) |
2325 | CODE: |
2421 | CODE: |
2326 | Mix_FadeOutChannel (self, ticks); |
2422 | Mix_FadeOutChannel (self, ticks); |
2327 | |
2423 | |
2328 | int |
2424 | int |
2329 | volume (CFPlus::Channel self, int volume) |
2425 | volume (DC::Channel self, int volume) |
2330 | CODE: |
2426 | CODE: |
2331 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2427 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2332 | OUTPUT: |
2428 | OUTPUT: |
2333 | RETVAL |
2429 | RETVAL |
2334 | |
2430 | |
2335 | void |
2431 | void |
2336 | unregister_all_effects (CFPlus::Channel self) |
2432 | unregister_all_effects (DC::Channel self) |
2337 | CODE: |
2433 | CODE: |
2338 | Mix_UnregisterAllEffects (self); |
2434 | Mix_UnregisterAllEffects (self); |
2339 | |
2435 | |
2340 | void |
2436 | void |
2341 | set_panning (CFPlus::Channel self, int left, int right) |
2437 | set_panning (DC::Channel self, int left, int right) |
2342 | CODE: |
2438 | CODE: |
2343 | left = CLAMP (left , 0, 255); |
2439 | left = CLAMP (left , 0, 255); |
2344 | right = CLAMP (right, 0, 255); |
2440 | right = CLAMP (right, 0, 255); |
2345 | Mix_SetPanning (self, left, right); |
2441 | Mix_SetPanning (self, left, right); |
2346 | |
2442 | |
2347 | void |
2443 | void |
2348 | set_distance (CFPlus::Channel self, int distance) |
2444 | set_distance (DC::Channel self, int distance) |
2349 | CODE: |
2445 | CODE: |
2350 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2446 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2351 | |
2447 | |
2352 | void |
2448 | void |
2353 | set_position (CFPlus::Channel self, int angle, int distance) |
2449 | set_position (DC::Channel self, int angle, int distance) |
2354 | CODE: |
2450 | CODE: |
2355 | |
2451 | |
2356 | void |
2452 | void |
2357 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2453 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2358 | CODE: |
2454 | CODE: |
2359 | { |
2455 | { |
2360 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2456 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2361 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2457 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2362 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2458 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2363 | } |
2459 | } |
2364 | |
2460 | |
2365 | void |
2461 | void |
2366 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2462 | set_reverse_stereo (DC::Channel self, int flip) |
2367 | CODE: |
2463 | CODE: |
2368 | Mix_SetReverseStereo (self, flip); |
2464 | Mix_SetReverseStereo (self, flip); |
2369 | |
2465 | |
2370 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2466 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2371 | |
2467 | |
2372 | PROTOTYPES: DISABLE |
2468 | PROTOTYPES: DISABLE |
2373 | |
2469 | |
2374 | CFPlus::MixChunk |
2470 | DC::MixChunk |
2375 | new (SV *class, CFPlus::RW rwops) |
2471 | new (SV *class, DC::RW rwops) |
2376 | CODE: |
2472 | CODE: |
2377 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2473 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2378 | OUTPUT: |
2474 | OUTPUT: |
2379 | RETVAL |
2475 | RETVAL |
2380 | |
2476 | |
2381 | void |
2477 | void |
2382 | DESTROY (CFPlus::MixChunk self) |
2478 | DESTROY (DC::MixChunk self) |
2383 | CODE: |
2479 | CODE: |
2384 | Mix_FreeChunk (self); |
2480 | Mix_FreeChunk (self); |
2385 | |
2481 | |
2386 | int |
2482 | int |
2387 | volume (CFPlus::MixChunk self, int volume = -1) |
2483 | volume (DC::MixChunk self, int volume = -1) |
2388 | CODE: |
2484 | CODE: |
2389 | if (items > 1) |
2485 | if (items > 1) |
2390 | volume = CLAMP (volume, 0, 128); |
2486 | volume = CLAMP (volume, 0, 128); |
2391 | RETVAL = Mix_VolumeChunk (self, volume); |
2487 | RETVAL = Mix_VolumeChunk (self, volume); |
2392 | OUTPUT: |
2488 | OUTPUT: |
2393 | RETVAL |
2489 | RETVAL |
2394 | |
2490 | |
2395 | CFPlus::Channel |
2491 | DC::Channel |
2396 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2492 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2397 | CODE: |
2493 | CODE: |
2398 | { |
2494 | { |
2399 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2495 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2400 | |
2496 | |
2401 | if (RETVAL < 0) |
2497 | if (RETVAL < 0) |
… | |
… | |
2408 | } |
2504 | } |
2409 | } |
2505 | } |
2410 | OUTPUT: |
2506 | OUTPUT: |
2411 | RETVAL |
2507 | RETVAL |
2412 | |
2508 | |
2413 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2509 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2414 | |
2510 | |
2415 | int |
2511 | int |
2416 | volume (int volume = -1) |
2512 | volume (int volume = -1) |
2417 | PROTOTYPE: ;$ |
2513 | PROTOTYPE: ;$ |
2418 | CODE: |
2514 | CODE: |
… | |
… | |
2430 | void |
2526 | void |
2431 | halt () |
2527 | halt () |
2432 | CODE: |
2528 | CODE: |
2433 | Mix_HaltMusic (); |
2529 | Mix_HaltMusic (); |
2434 | |
2530 | |
2435 | CFPlus::MixMusic |
2531 | DC::MixMusic |
2436 | new (SV *class, CFPlus::RW rwops) |
2532 | new (SV *class, DC::RW rwops) |
2437 | CODE: |
2533 | CODE: |
2438 | RETVAL = Mix_LoadMUS_RW (rwops); |
2534 | RETVAL = Mix_LoadMUS_RW (rwops); |
2439 | OUTPUT: |
2535 | OUTPUT: |
2440 | RETVAL |
2536 | RETVAL |
2441 | |
2537 | |
2442 | void |
2538 | void |
2443 | DESTROY (CFPlus::MixMusic self) |
2539 | DESTROY (DC::MixMusic self) |
2444 | CODE: |
2540 | CODE: |
2445 | Mix_FreeMusic (self); |
2541 | Mix_FreeMusic (self); |
2446 | |
2542 | |
2447 | int |
2543 | int |
2448 | play (CFPlus::MixMusic self, int loops = -1) |
2544 | play (DC::MixMusic self, int loops = -1) |
2449 | CODE: |
2545 | CODE: |
2450 | RETVAL = Mix_PlayMusic (self, loops); |
2546 | RETVAL = Mix_PlayMusic (self, loops); |
2451 | OUTPUT: |
2547 | OUTPUT: |
2452 | RETVAL |
2548 | RETVAL |
2453 | |
2549 | |
2454 | void |
2550 | void |
2455 | 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) |
2456 | CODE: |
2552 | CODE: |
2457 | Mix_FadeInMusicPos (self, loops, ms, position); |
2553 | Mix_FadeInMusicPos (self, loops, ms, position); |
2458 | |
2554 | |
2459 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2555 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2460 | |
2556 | |
2461 | PROTOTYPES: ENABLE |
2557 | PROTOTYPES: ENABLE |
2462 | |
2558 | |
2463 | BOOT: |
2559 | BOOT: |
2464 | { |
2560 | { |
2465 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2561 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2466 | static const struct { |
2562 | static const struct { |
2467 | const char *name; |
2563 | const char *name; |
2468 | IV iv; |
2564 | IV iv; |
2469 | } *civ, const_iv[] = { |
2565 | } *civ, const_iv[] = { |
2470 | # define const_iv(name) { # name, (IV)name } |
2566 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2505 | const_iv (GL_INTENSITY), |
2601 | const_iv (GL_INTENSITY), |
2506 | const_iv (GL_LUMINANCE), |
2602 | const_iv (GL_LUMINANCE), |
2507 | const_iv (GL_LUMINANCE_ALPHA), |
2603 | const_iv (GL_LUMINANCE_ALPHA), |
2508 | const_iv (GL_FLOAT), |
2604 | const_iv (GL_FLOAT), |
2509 | 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), |
2510 | const_iv (GL_COMPILE), |
2612 | const_iv (GL_COMPILE), |
2511 | const_iv (GL_PROXY_TEXTURE_1D), |
2613 | const_iv (GL_PROXY_TEXTURE_1D), |
2512 | const_iv (GL_PROXY_TEXTURE_2D), |
2614 | const_iv (GL_PROXY_TEXTURE_2D), |
2513 | const_iv (GL_TEXTURE_1D), |
2615 | const_iv (GL_TEXTURE_1D), |
2514 | const_iv (GL_TEXTURE_2D), |
2616 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2553 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2655 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2554 | const_iv (GL_POINT_SMOOTH_HINT), |
2656 | const_iv (GL_POINT_SMOOTH_HINT), |
2555 | const_iv (GL_LINE_SMOOTH_HINT), |
2657 | const_iv (GL_LINE_SMOOTH_HINT), |
2556 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2658 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2557 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2659 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2660 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2558 | const_iv (GL_FASTEST), |
2661 | const_iv (GL_FASTEST), |
2559 | const_iv (GL_DONT_CARE), |
2662 | const_iv (GL_DONT_CARE), |
2560 | const_iv (GL_NICEST), |
2663 | const_iv (GL_NICEST), |
2561 | const_iv (GL_V2F), |
2664 | const_iv (GL_V2F), |
2562 | const_iv (GL_V3F), |
2665 | const_iv (GL_V3F), |
… | |
… | |
2570 | |
2673 | |
2571 | texture_av = newAV (); |
2674 | texture_av = newAV (); |
2572 | AvREAL_off (texture_av); |
2675 | AvREAL_off (texture_av); |
2573 | } |
2676 | } |
2574 | |
2677 | |
|
|
2678 | void |
|
|
2679 | disable_GL_EXT_blend_func_separate () |
|
|
2680 | CODE: |
|
|
2681 | gl.BlendFuncSeparate = 0; |
|
|
2682 | gl.BlendFuncSeparateEXT = 0; |
|
|
2683 | |
2575 | char * |
2684 | char * |
2576 | gl_vendor () |
2685 | gl_vendor () |
2577 | CODE: |
2686 | CODE: |
2578 | RETVAL = (char *)glGetString (GL_VENDOR); |
2687 | RETVAL = (char *)glGetString (GL_VENDOR); |
2579 | OUTPUT: |
2688 | OUTPUT: |
… | |
… | |
2700 | |
2809 | |
2701 | void glRect (float x1, float y1, float x2, float y2) |
2810 | void glRect (float x1, float y1, float x2, float y2) |
2702 | CODE: |
2811 | CODE: |
2703 | glRectf (x1, y1, x2, y2); |
2812 | glRectf (x1, y1, x2, y2); |
2704 | |
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 | |
2705 | PROTOTYPES: ENABLE |
2823 | PROTOTYPES: ENABLE |
2706 | |
2824 | |
2707 | void glBegin (int mode) |
2825 | void glBegin (int mode) |
2708 | |
2826 | |
2709 | void glEnd () |
2827 | void glEnd () |
… | |
… | |
2741 | 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) |
2742 | CODE: |
2860 | CODE: |
2743 | if (gl.SeparableFilter2D) |
2861 | if (gl.SeparableFilter2D) |
2744 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2862 | gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); |
2745 | |
2863 | |
2746 | 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) |
2747 | |
2865 | |
2748 | 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) |
2749 | |
2867 | |
2750 | 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) |
2751 | |
2869 | |
… | |
… | |
2777 | |
2895 | |
2778 | void glEndList () |
2896 | void glEndList () |
2779 | |
2897 | |
2780 | void glCallList (int list) |
2898 | void glCallList (int list) |
2781 | |
2899 | |
2782 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2900 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2783 | |
2901 | |
2784 | PROTOTYPES: DISABLE |
2902 | PROTOTYPES: DISABLE |
2785 | |
2903 | |
2786 | void |
2904 | void |
2787 | find_widget (SV *self, NV x, NV y) |
2905 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2791 | XPUSHs (self); |
2909 | XPUSHs (self); |
2792 | } |
2910 | } |
2793 | |
2911 | |
2794 | BOOT: |
2912 | BOOT: |
2795 | { |
2913 | { |
2796 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2914 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2797 | |
2915 | |
2798 | 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); |
2799 | 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); |
2800 | 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); |
2801 | 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); |
2802 | } |
2920 | } |
2803 | |
2921 | |
2804 | void |
2922 | void |
2805 | draw (SV *self) |
2923 | draw (SV *self) |
2806 | CODE: |
2924 | CODE: |
… | |
… | |
2810 | NV x, y, w, h; |
2928 | NV x, y, w, h; |
2811 | SV *draw_x_sv = GvSV (draw_x_gv); |
2929 | SV *draw_x_sv = GvSV (draw_x_gv); |
2812 | SV *draw_y_sv = GvSV (draw_y_gv); |
2930 | SV *draw_y_sv = GvSV (draw_y_gv); |
2813 | SV *draw_w_sv = GvSV (draw_w_gv); |
2931 | SV *draw_w_sv = GvSV (draw_w_gv); |
2814 | SV *draw_h_sv = GvSV (draw_h_gv); |
2932 | SV *draw_h_sv = GvSV (draw_h_gv); |
2815 | SV *hover; |
|
|
2816 | double draw_x, draw_y, draw_w, draw_h; |
2933 | double draw_x, draw_y; |
2817 | |
2934 | |
2818 | if (!SvROK (self)) |
2935 | if (!SvROK (self)) |
2819 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2936 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2820 | |
2937 | |
2821 | hv = (HV *)SvRV (self); |
2938 | hv = (HV *)SvRV (self); |
2822 | |
2939 | |
2823 | if (SvTYPE (hv) != SVt_PVHV) |
2940 | if (SvTYPE (hv) != SVt_PVHV) |
2824 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2941 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2825 | |
2942 | |
2826 | 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.; |
2827 | 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.; |
2828 | |
2945 | |
2829 | if (!h || !w) |
2946 | if (!h || !w) |
… | |
… | |
2849 | { |
2966 | { |
2850 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2967 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2851 | |
2968 | |
2852 | if (svp && SvTRUE (*svp)) |
2969 | if (svp && SvTRUE (*svp)) |
2853 | { |
2970 | { |
2854 | 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); |
2855 | glEnable (GL_BLEND); |
2972 | glEnable (GL_BLEND); |
2856 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2973 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2857 | glBegin (GL_QUADS); |
2974 | glBegin (GL_QUADS); |
2858 | glVertex2f (0, 0); |
2975 | glVertex2f (0, 0); |
2859 | glVertex2f (w, 0); |
2976 | glVertex2f (w, 0); |
… | |
… | |
2862 | glEnd (); |
2979 | glEnd (); |
2863 | glDisable (GL_BLEND); |
2980 | glDisable (GL_BLEND); |
2864 | } |
2981 | } |
2865 | } |
2982 | } |
2866 | #if 0 |
2983 | #if 0 |
2867 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2984 | // draw borders, for debugging |
2868 | glPushMatrix; |
2985 | glPushMatrix (); |
2869 | glColor 1, 1, 0, 1; |
2986 | glColor4f (1., 1., 0., 1.); |
2870 | glTranslate 0.375, 0.375; |
2987 | glTranslatef (.5, .5, 0.); |
2871 | glBegin GL_LINE_LOOP; |
2988 | glBegin (GL_LINE_LOOP); |
2872 | glVertex 0 , 0; |
2989 | glVertex2f (0 , 0); |
2873 | glVertex $self->{w} - 1, 0; |
2990 | glVertex2f (w - 1, 0); |
2874 | glVertex $self->{w} - 1, $self->{h} - 1; |
2991 | glVertex2f (w - 1, h - 1); |
2875 | glVertex 0 , $self->{h} - 1; |
2992 | glVertex2f (0 , h - 1); |
2876 | glEnd; |
2993 | glEnd (); |
2877 | glPopMatrix; |
2994 | glPopMatrix (); |
2878 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2879 | } |
|
|
2880 | #endif |
2995 | #endif |
2881 | PUSHMARK (SP); |
2996 | PUSHMARK (SP); |
2882 | XPUSHs (self); |
2997 | XPUSHs (self); |
2883 | PUTBACK; |
2998 | PUTBACK; |
2884 | call_method ("_draw", G_VOID | G_DISCARD); |
2999 | call_method ("_draw", G_VOID | G_DISCARD); |