… | |
… | |
120 | |
120 | |
121 | #include "pango-font.c" |
121 | #include "pango-font.c" |
122 | #include "pango-fontmap.c" |
122 | #include "pango-fontmap.c" |
123 | #include "pango-render.c" |
123 | #include "pango-render.c" |
124 | |
124 | |
125 | typedef IV CFPlus__Channel; |
125 | typedef IV DC__Channel; |
126 | typedef SDL_RWops *CFPlus__RW; |
126 | typedef SDL_RWops *DC__RW; |
127 | typedef Mix_Chunk *CFPlus__MixChunk; |
127 | typedef Mix_Chunk *DC__MixChunk; |
128 | typedef Mix_Music *CFPlus__MixMusic; |
128 | typedef Mix_Music *DC__MixMusic; |
129 | |
129 | |
130 | typedef PangoFontDescription *CFPlus__Font; |
130 | typedef PangoFontDescription *DC__Font; |
131 | |
131 | |
132 | static int |
132 | static int |
133 | shape_attr_p (PangoLayoutRun *run) |
133 | shape_attr_p (PangoLayoutRun *run) |
134 | { |
134 | { |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
135 | GSList *attrs = run->item->analysis.extra_attrs; |
… | |
… | |
149 | |
149 | |
150 | typedef struct cf_layout { |
150 | typedef struct cf_layout { |
151 | PangoLayout *pl; |
151 | PangoLayout *pl; |
152 | float r, g, b, a; // default color for rgba mode |
152 | float r, g, b, a; // default color for rgba mode |
153 | int base_height; |
153 | int base_height; |
154 | CFPlus__Font font; |
154 | DC__Font font; |
|
|
155 | rc_t *rc; |
155 | } *CFPlus__Layout; |
156 | } *DC__Layout; |
156 | |
157 | |
157 | static CFPlus__Font default_font; |
158 | static DC__Font default_font; |
158 | static PangoContext *opengl_context; |
159 | static PangoContext *opengl_context; |
159 | static PangoFontMap *opengl_fontmap; |
160 | static PangoFontMap *opengl_fontmap; |
160 | |
161 | |
161 | static void |
162 | static void |
162 | substitute_func (FcPattern *pattern, gpointer data) |
163 | substitute_func (FcPattern *pattern, gpointer data) |
… | |
… | |
167 | #endif |
168 | #endif |
168 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
169 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
169 | } |
170 | } |
170 | |
171 | |
171 | static void |
172 | static void |
172 | layout_update_font (CFPlus__Layout self) |
173 | layout_update_font (DC__Layout self) |
173 | { |
174 | { |
174 | /* use a random scale factor to account for unknown descenders, 0.8 works |
175 | /* use a random scale factor to account for unknown descenders, 0.8 works |
175 | * reasonably well with bitstream vera |
176 | * reasonably well with bitstream vera |
176 | */ |
177 | */ |
177 | PangoFontDescription *font = self->font ? self->font : default_font; |
178 | PangoFontDescription *font = self->font ? self->font : default_font; |
… | |
… | |
181 | |
182 | |
182 | pango_layout_set_font_description (self->pl, font); |
183 | pango_layout_set_font_description (self->pl, font); |
183 | } |
184 | } |
184 | |
185 | |
185 | static void |
186 | static void |
186 | layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) |
187 | layout_get_pixel_size (DC__Layout self, int *w, int *h) |
187 | { |
188 | { |
188 | PangoRectangle rect; |
189 | PangoRectangle rect; |
189 | |
190 | |
190 | // get_pixel_* wrongly rounds down |
191 | // get_pixel_* wrongly rounds down |
191 | pango_layout_get_extents (self->pl, 0, &rect); |
192 | pango_layout_get_extents (self->pl, 0, &rect); |
… | |
… | |
202 | |
203 | |
203 | typedef uint16_t tileid; |
204 | typedef uint16_t tileid; |
204 | typedef uint16_t faceid; |
205 | typedef uint16_t faceid; |
205 | |
206 | |
206 | typedef struct { |
207 | typedef struct { |
207 | int name; |
208 | GLuint name; |
208 | int w, h; |
209 | int w, h; |
209 | float s, t; |
210 | float s, t; |
210 | uint8_t r, g, b, a; |
211 | uint8_t r, g, b, a; |
211 | tileid smoothtile; |
212 | tileid smoothtile; |
212 | uint8_t smoothlevel; |
213 | uint8_t smoothlevel; |
… | |
… | |
230 | int faces; tileid *face2tile; // [faceid] |
231 | int faces; tileid *face2tile; // [faceid] |
231 | int texs; maptex *tex; // [tileid] |
232 | int texs; maptex *tex; // [tileid] |
232 | |
233 | |
233 | int32_t rows; |
234 | int32_t rows; |
234 | maprow *row; |
235 | maprow *row; |
235 | } *CFPlus__Map; |
236 | } *DC__Map; |
236 | |
237 | |
237 | static char * |
238 | static char * |
238 | prepend (char *ptr, int sze, int inc) |
239 | prepend (char *ptr, int sze, int inc) |
239 | { |
240 | { |
240 | char *p; |
241 | char *p; |
… | |
… | |
278 | self->texs *= 2; |
279 | self->texs *= 2; |
279 | } |
280 | } |
280 | } |
281 | } |
281 | |
282 | |
282 | static maprow * |
283 | static maprow * |
283 | map_get_row (CFPlus__Map self, int y) |
284 | map_get_row (DC__Map self, int y) |
284 | { |
285 | { |
285 | if (0 > y) |
286 | if (0 > y) |
286 | { |
287 | { |
287 | int extend = - y + MAP_EXTEND_Y; |
288 | int extend = - y + MAP_EXTEND_Y; |
288 | Prepend (maprow, self->row, self->rows, extend); |
289 | Prepend (maprow, self->row, self->rows, extend); |
… | |
… | |
326 | |
327 | |
327 | return row->col + (x - row->c0); |
328 | return row->col + (x - row->c0); |
328 | } |
329 | } |
329 | |
330 | |
330 | static mapcell * |
331 | static mapcell * |
331 | map_get_cell (CFPlus__Map self, int x, int y) |
332 | map_get_cell (DC__Map self, int x, int y) |
332 | { |
333 | { |
333 | return row_get_cell (map_get_row (self, y), x); |
334 | return row_get_cell (map_get_row (self, y), x); |
334 | } |
335 | } |
335 | |
336 | |
336 | static void |
337 | static void |
337 | map_clear (CFPlus__Map self) |
338 | map_clear (DC__Map self) |
338 | { |
339 | { |
339 | int r; |
340 | int r; |
340 | |
341 | |
341 | for (r = 0; r < self->rows; r++) |
342 | for (r = 0; r < self->rows; r++) |
342 | Safefree (self->row[r].col); |
343 | Safefree (self->row[r].col); |
… | |
… | |
350 | self->row = 0; |
351 | self->row = 0; |
351 | self->rows = 0; |
352 | self->rows = 0; |
352 | } |
353 | } |
353 | |
354 | |
354 | static void |
355 | static void |
355 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
356 | map_blank (DC__Map self, int x0, int y0, int w, int h) |
356 | { |
357 | { |
357 | int x, y; |
358 | int x, y; |
358 | maprow *row; |
359 | maprow *row; |
359 | mapcell *cell; |
360 | mapcell *cell; |
360 | |
361 | |
… | |
… | |
439 | n |= n >> 16; |
440 | n |= n >> 16; |
440 | |
441 | |
441 | return n + 1; |
442 | return n + 1; |
442 | } |
443 | } |
443 | |
444 | |
|
|
445 | static unsigned int |
|
|
446 | popcount (unsigned int n) |
|
|
447 | { |
|
|
448 | n -= (n >> 1) & 0x55555555U; |
|
|
449 | n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); |
|
|
450 | n = ((n >> 4) + n) & 0x0f0f0f0fU; |
|
|
451 | n *= 0x01010101U; |
|
|
452 | |
|
|
453 | return n >> 24; |
|
|
454 | } |
|
|
455 | |
444 | /* SDL should provide this, really. */ |
456 | /* SDL should provide this, really. */ |
445 | #define SDLK_MODIFIER_MIN 300 |
457 | #define SDLK_MODIFIER_MIN 300 |
446 | #define SDLK_MODIFIER_MAX 314 |
458 | #define SDLK_MODIFIER_MAX 314 |
447 | |
459 | |
448 | /******************************************************************************/ |
460 | /******************************************************************************/ |
… | |
… | |
486 | return 0; |
498 | return 0; |
487 | |
499 | |
488 | return 1; |
500 | return 1; |
489 | } |
501 | } |
490 | |
502 | |
491 | MODULE = CFPlus PACKAGE = CFPlus |
503 | MODULE = Deliantra::Client PACKAGE = DC |
492 | |
504 | |
493 | PROTOTYPES: ENABLE |
505 | PROTOTYPES: ENABLE |
494 | |
506 | |
495 | BOOT: |
507 | BOOT: |
496 | { |
508 | { |
497 | HV *stash = gv_stashpv ("CFPlus", 1); |
509 | HV *stash = gv_stashpv ("DC", 1); |
498 | static const struct { |
510 | static const struct { |
499 | const char *name; |
511 | const char *name; |
500 | IV iv; |
512 | IV iv; |
501 | } *civ, const_iv[] = { |
513 | } *civ, const_iv[] = { |
502 | # define const_iv(name) { # name, (IV)name } |
514 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
524 | |
536 | |
525 | const_iv (SDL_APPINPUTFOCUS), |
537 | const_iv (SDL_APPINPUTFOCUS), |
526 | const_iv (SDL_APPMOUSEFOCUS), |
538 | const_iv (SDL_APPMOUSEFOCUS), |
527 | const_iv (SDL_APPACTIVE), |
539 | const_iv (SDL_APPACTIVE), |
528 | |
540 | |
|
|
541 | const_iv (SDLK_FIRST), |
|
|
542 | const_iv (SDLK_LAST), |
529 | const_iv (SDLK_KP0), |
543 | const_iv (SDLK_KP0), |
530 | const_iv (SDLK_KP1), |
544 | const_iv (SDLK_KP1), |
531 | const_iv (SDLK_KP2), |
545 | const_iv (SDLK_KP2), |
532 | const_iv (SDLK_KP3), |
546 | const_iv (SDLK_KP3), |
533 | const_iv (SDLK_KP4), |
547 | const_iv (SDLK_KP4), |
… | |
… | |
605 | const_iv (KMOD_LMETA), |
619 | const_iv (KMOD_LMETA), |
606 | const_iv (KMOD_RMETA), |
620 | const_iv (KMOD_RMETA), |
607 | const_iv (KMOD_NUM), |
621 | const_iv (KMOD_NUM), |
608 | const_iv (KMOD_CAPS), |
622 | const_iv (KMOD_CAPS), |
609 | const_iv (KMOD_MODE), |
623 | const_iv (KMOD_MODE), |
|
|
624 | |
|
|
625 | const_iv (MIX_DEFAULT_FORMAT), |
610 | # undef const_iv |
626 | # undef const_iv |
611 | }; |
627 | }; |
612 | |
628 | |
613 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
629 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
614 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
630 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
… | |
… | |
631 | RETVAL |
647 | RETVAL |
632 | |
648 | |
633 | NV floor (NV x) |
649 | NV floor (NV x) |
634 | |
650 | |
635 | NV ceil (NV x) |
651 | NV ceil (NV x) |
|
|
652 | |
|
|
653 | IV minpot (UV n) |
|
|
654 | |
|
|
655 | IV popcount (UV n) |
636 | |
656 | |
637 | void |
657 | void |
638 | pango_init () |
658 | pango_init () |
639 | CODE: |
659 | CODE: |
640 | { |
660 | { |
… | |
… | |
680 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
700 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
681 | |
701 | |
682 | if (m && m != (SDL_Rect **)-1) |
702 | if (m && m != (SDL_Rect **)-1) |
683 | while (*m) |
703 | while (*m) |
684 | { |
704 | { |
685 | if ((*m)->w >= 640 && (*m)->h >= 480) |
705 | if ((*m)->w >= 800 && (*m)->h >= 480) |
686 | { |
706 | { |
687 | AV *av = newAV (); |
707 | AV *av = newAV (); |
688 | av_push (av, newSViv ((*m)->w)); |
708 | av_push (av, newSViv ((*m)->w)); |
689 | av_push (av, newSViv ((*m)->h)); |
709 | av_push (av, newSViv ((*m)->h)); |
690 | av_push (av, newSViv (rgb)); |
710 | av_push (av, newSViv (rgb)); |
… | |
… | |
714 | |
734 | |
715 | if (RETVAL) |
735 | if (RETVAL) |
716 | { |
736 | { |
717 | av_clear (texture_av); |
737 | av_clear (texture_av); |
718 | |
738 | |
719 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
739 | SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); |
720 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
740 | #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
721 | #include "glfunc.h" |
741 | #include "glfunc.h" |
722 | #undef GL_FUNC |
742 | #undef GL_FUNC |
723 | } |
743 | } |
724 | } |
744 | } |
… | |
… | |
805 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
825 | hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); |
806 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
826 | hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); |
807 | break; |
827 | break; |
808 | } |
828 | } |
809 | |
829 | |
810 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); |
830 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("DC::UI::Event", 1)))); |
811 | } |
831 | } |
812 | } |
832 | } |
813 | |
833 | |
814 | int |
834 | int |
815 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) |
835 | Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) |
816 | POSTCALL: |
836 | POSTCALL: |
817 | Mix_HookMusicFinished (music_finished); |
837 | Mix_HookMusicFinished (music_finished); |
818 | Mix_ChannelFinished (channel_finished); |
838 | Mix_ChannelFinished (channel_finished); |
|
|
839 | |
|
|
840 | void |
|
|
841 | Mix_QuerySpec () |
|
|
842 | PPCODE: |
|
|
843 | { |
|
|
844 | int freq, channels; |
|
|
845 | Uint16 format; |
|
|
846 | |
|
|
847 | if (Mix_QuerySpec (&freq, &format, &channels)) |
|
|
848 | { |
|
|
849 | EXTEND (SP, 3); |
|
|
850 | PUSHs (sv_2mortal (newSViv (freq))); |
|
|
851 | PUSHs (sv_2mortal (newSViv (format))); |
|
|
852 | PUSHs (sv_2mortal (newSViv (channels))); |
|
|
853 | } |
|
|
854 | } |
819 | |
855 | |
820 | void |
856 | void |
821 | Mix_CloseAudio () |
857 | Mix_CloseAudio () |
822 | |
858 | |
823 | int |
859 | int |
… | |
… | |
957 | void |
993 | void |
958 | error (char *message) |
994 | error (char *message) |
959 | CODE: |
995 | CODE: |
960 | fprintf (stderr, "ERROR: %s\n", message); |
996 | fprintf (stderr, "ERROR: %s\n", message); |
961 | #ifdef _WIN32 |
997 | #ifdef _WIN32 |
962 | MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); |
998 | MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); |
963 | #endif |
999 | #endif |
964 | |
1000 | |
965 | void |
1001 | void |
966 | fatal (char *message) |
1002 | fatal (char *message) |
967 | CODE: |
1003 | CODE: |
968 | fprintf (stderr, "FATAL: %s\n", message); |
1004 | fprintf (stderr, "FATAL: %s\n", message); |
969 | #ifdef _WIN32 |
1005 | #ifdef _WIN32 |
970 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); |
1006 | MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); |
971 | #endif |
1007 | #endif |
972 | _exit (1); |
1008 | _exit (1); |
973 | |
1009 | |
974 | void |
1010 | void |
975 | _exit (int retval = 0) |
1011 | _exit (int retval = 0) |
… | |
… | |
987 | #if DEBUG |
1023 | #if DEBUG |
988 | VALGRIND_DO_LEAK_CHECK; |
1024 | VALGRIND_DO_LEAK_CHECK; |
989 | #endif |
1025 | #endif |
990 | } |
1026 | } |
991 | |
1027 | |
992 | MODULE = CFPlus PACKAGE = CFPlus::Font |
1028 | MODULE = Deliantra::Client PACKAGE = DC::Font |
993 | |
1029 | |
994 | PROTOTYPES: DISABLE |
1030 | PROTOTYPES: DISABLE |
995 | |
1031 | |
996 | CFPlus::Font |
1032 | DC::Font |
997 | new_from_file (SV *class, char *path, int id = 0) |
1033 | new_from_file (SV *class, char *path, int id = 0) |
998 | CODE: |
1034 | CODE: |
999 | { |
1035 | { |
1000 | int count; |
1036 | int count; |
1001 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
1037 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); |
… | |
… | |
1004 | } |
1040 | } |
1005 | OUTPUT: |
1041 | OUTPUT: |
1006 | RETVAL |
1042 | RETVAL |
1007 | |
1043 | |
1008 | void |
1044 | void |
1009 | DESTROY (CFPlus::Font self) |
1045 | DESTROY (DC::Font self) |
1010 | CODE: |
1046 | CODE: |
1011 | pango_font_description_free (self); |
1047 | pango_font_description_free (self); |
1012 | |
1048 | |
1013 | void |
1049 | void |
1014 | make_default (CFPlus::Font self) |
1050 | make_default (DC::Font self) |
1015 | PROTOTYPE: $ |
1051 | PROTOTYPE: $ |
1016 | CODE: |
1052 | CODE: |
1017 | default_font = self; |
1053 | default_font = self; |
1018 | |
1054 | |
1019 | MODULE = CFPlus PACKAGE = CFPlus::Layout |
1055 | MODULE = Deliantra::Client PACKAGE = DC::Layout |
1020 | |
1056 | |
1021 | PROTOTYPES: DISABLE |
1057 | PROTOTYPES: DISABLE |
1022 | |
1058 | |
1023 | void |
1059 | void |
1024 | reset_glyph_cache () |
1060 | glyph_cache_backup () |
1025 | PROTOTYPE: |
1061 | PROTOTYPE: |
1026 | CODE: |
1062 | CODE: |
|
|
1063 | tc_backup (); |
|
|
1064 | |
|
|
1065 | void |
|
|
1066 | glyph_cache_restore () |
|
|
1067 | PROTOTYPE: |
|
|
1068 | CODE: |
1027 | tc_clear (); |
1069 | tc_restore (); |
1028 | |
1070 | |
1029 | CFPlus::Layout |
1071 | DC::Layout |
1030 | new (SV *class) |
1072 | new (SV *class) |
1031 | CODE: |
1073 | CODE: |
1032 | New (0, RETVAL, 1, struct cf_layout); |
1074 | New (0, RETVAL, 1, struct cf_layout); |
1033 | |
1075 | |
1034 | RETVAL->pl = pango_layout_new (opengl_context); |
1076 | RETVAL->pl = pango_layout_new (opengl_context); |
… | |
… | |
1036 | RETVAL->g = 1.; |
1078 | RETVAL->g = 1.; |
1037 | RETVAL->b = 1.; |
1079 | RETVAL->b = 1.; |
1038 | RETVAL->a = 1.; |
1080 | RETVAL->a = 1.; |
1039 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1081 | RETVAL->base_height = MIN_FONT_HEIGHT; |
1040 | RETVAL->font = 0; |
1082 | RETVAL->font = 0; |
|
|
1083 | RETVAL->rc = rc_alloc (); |
1041 | |
1084 | |
1042 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1085 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
1043 | layout_update_font (RETVAL); |
1086 | layout_update_font (RETVAL); |
1044 | OUTPUT: |
1087 | OUTPUT: |
1045 | RETVAL |
1088 | RETVAL |
1046 | |
1089 | |
1047 | void |
1090 | void |
1048 | DESTROY (CFPlus::Layout self) |
1091 | DESTROY (DC::Layout self) |
1049 | CODE: |
1092 | CODE: |
1050 | g_object_unref (self->pl); |
1093 | g_object_unref (self->pl); |
|
|
1094 | rc_free (self->rc); |
1051 | Safefree (self); |
1095 | Safefree (self); |
1052 | |
1096 | |
1053 | void |
1097 | void |
1054 | set_text (CFPlus::Layout self, SV *text_) |
1098 | set_text (DC::Layout self, SV *text_) |
1055 | CODE: |
1099 | CODE: |
1056 | { |
1100 | { |
1057 | STRLEN textlen; |
1101 | STRLEN textlen; |
1058 | char *text = SvPVutf8 (text_, textlen); |
1102 | char *text = SvPVutf8 (text_, textlen); |
1059 | |
1103 | |
1060 | pango_layout_set_text (self->pl, text, textlen); |
1104 | pango_layout_set_text (self->pl, text, textlen); |
1061 | } |
1105 | } |
1062 | |
1106 | |
1063 | void |
1107 | void |
1064 | set_markup (CFPlus::Layout self, SV *text_) |
1108 | set_markup (DC::Layout self, SV *text_) |
1065 | CODE: |
1109 | CODE: |
1066 | { |
1110 | { |
1067 | STRLEN textlen; |
1111 | STRLEN textlen; |
1068 | char *text = SvPVutf8 (text_, textlen); |
1112 | char *text = SvPVutf8 (text_, textlen); |
1069 | |
1113 | |
1070 | pango_layout_set_markup (self->pl, text, textlen); |
1114 | pango_layout_set_markup (self->pl, text, textlen); |
1071 | } |
1115 | } |
1072 | |
1116 | |
1073 | void |
1117 | void |
1074 | set_shapes (CFPlus::Layout self, ...) |
1118 | set_shapes (DC::Layout self, ...) |
1075 | CODE: |
1119 | CODE: |
1076 | { |
1120 | { |
1077 | PangoAttrList *attrs = 0; |
1121 | PangoAttrList *attrs = 0; |
1078 | const char *text = pango_layout_get_text (self->pl); |
1122 | const char *text = pango_layout_get_text (self->pl); |
1079 | const char *pos = text; |
1123 | const char *pos = text; |
… | |
… | |
1114 | if (attrs) |
1158 | if (attrs) |
1115 | pango_layout_set_attributes (self->pl, attrs); |
1159 | pango_layout_set_attributes (self->pl, attrs); |
1116 | } |
1160 | } |
1117 | |
1161 | |
1118 | void |
1162 | void |
1119 | get_shapes (CFPlus::Layout self) |
1163 | get_shapes (DC::Layout self) |
1120 | PPCODE: |
1164 | PPCODE: |
1121 | { |
1165 | { |
1122 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1166 | PangoLayoutIter *iter = pango_layout_get_iter (self->pl); |
1123 | |
1167 | |
1124 | do |
1168 | do |
… | |
… | |
1139 | |
1183 | |
1140 | pango_layout_iter_free (iter); |
1184 | pango_layout_iter_free (iter); |
1141 | } |
1185 | } |
1142 | |
1186 | |
1143 | int |
1187 | int |
1144 | has_wrapped (CFPlus::Layout self) |
1188 | has_wrapped (DC::Layout self) |
1145 | CODE: |
1189 | CODE: |
1146 | { |
1190 | { |
1147 | int lines = 1; |
1191 | int lines = 1; |
1148 | const char *text = pango_layout_get_text (self->pl); |
1192 | const char *text = pango_layout_get_text (self->pl); |
1149 | |
1193 | |
… | |
… | |
1154 | } |
1198 | } |
1155 | OUTPUT: |
1199 | OUTPUT: |
1156 | RETVAL |
1200 | RETVAL |
1157 | |
1201 | |
1158 | SV * |
1202 | SV * |
1159 | get_text (CFPlus::Layout self) |
1203 | get_text (DC::Layout self) |
1160 | CODE: |
1204 | CODE: |
1161 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1205 | RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); |
1162 | sv_utf8_decode (RETVAL); |
1206 | sv_utf8_decode (RETVAL); |
1163 | OUTPUT: |
1207 | OUTPUT: |
1164 | RETVAL |
1208 | RETVAL |
1165 | |
1209 | |
1166 | void |
1210 | void |
1167 | set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.) |
1211 | set_foreground (DC::Layout self, float r, float g, float b, float a = 1.) |
1168 | CODE: |
1212 | CODE: |
1169 | self->r = r; |
1213 | self->r = r; |
1170 | self->g = g; |
1214 | self->g = g; |
1171 | self->b = b; |
1215 | self->b = b; |
1172 | self->a = a; |
1216 | self->a = a; |
1173 | |
1217 | |
1174 | void |
1218 | void |
1175 | set_font (CFPlus::Layout self, CFPlus::Font font = 0) |
1219 | set_font (DC::Layout self, DC::Font font = 0) |
1176 | CODE: |
1220 | CODE: |
1177 | if (self->font != font) |
1221 | if (self->font != font) |
1178 | { |
1222 | { |
1179 | self->font = font; |
1223 | self->font = font; |
1180 | layout_update_font (self); |
1224 | layout_update_font (self); |
1181 | } |
1225 | } |
1182 | |
1226 | |
1183 | void |
1227 | void |
1184 | set_height (CFPlus::Layout self, int base_height) |
1228 | set_height (DC::Layout self, int base_height) |
1185 | CODE: |
1229 | CODE: |
1186 | if (self->base_height != base_height) |
1230 | if (self->base_height != base_height) |
1187 | { |
1231 | { |
1188 | self->base_height = base_height; |
1232 | self->base_height = base_height; |
1189 | layout_update_font (self); |
1233 | layout_update_font (self); |
1190 | } |
1234 | } |
1191 | |
1235 | |
1192 | void |
1236 | void |
1193 | set_width (CFPlus::Layout self, int max_width = -1) |
1237 | set_width (DC::Layout self, int max_width = -1) |
1194 | CODE: |
1238 | CODE: |
1195 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1239 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
1196 | |
1240 | |
1197 | void |
1241 | void |
1198 | set_indent (CFPlus::Layout self, int indent) |
1242 | set_indent (DC::Layout self, int indent) |
1199 | CODE: |
1243 | CODE: |
1200 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1244 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
1201 | |
1245 | |
1202 | void |
1246 | void |
1203 | set_spacing (CFPlus::Layout self, int spacing) |
1247 | set_spacing (DC::Layout self, int spacing) |
1204 | CODE: |
1248 | CODE: |
1205 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1249 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
1206 | |
1250 | |
1207 | void |
1251 | void |
1208 | set_ellipsise (CFPlus::Layout self, int ellipsise) |
1252 | set_ellipsise (DC::Layout self, int ellipsise) |
1209 | CODE: |
1253 | CODE: |
1210 | pango_layout_set_ellipsize (self->pl, |
1254 | pango_layout_set_ellipsize (self->pl, |
1211 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1255 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
1212 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1256 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
1213 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1257 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
1214 | : PANGO_ELLIPSIZE_NONE |
1258 | : PANGO_ELLIPSIZE_NONE |
1215 | ); |
1259 | ); |
1216 | |
1260 | |
1217 | void |
1261 | void |
1218 | set_single_paragraph_mode (CFPlus::Layout self, int spm) |
1262 | set_single_paragraph_mode (DC::Layout self, int spm) |
1219 | CODE: |
1263 | CODE: |
1220 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1264 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
1221 | |
1265 | |
1222 | void |
1266 | void |
1223 | size (CFPlus::Layout self) |
1267 | size (DC::Layout self) |
1224 | PPCODE: |
1268 | PPCODE: |
1225 | { |
1269 | { |
1226 | int w, h; |
1270 | int w, h; |
1227 | |
1271 | |
1228 | layout_get_pixel_size (self, &w, &h); |
1272 | layout_get_pixel_size (self, &w, &h); |
… | |
… | |
1231 | PUSHs (sv_2mortal (newSViv (w))); |
1275 | PUSHs (sv_2mortal (newSViv (w))); |
1232 | PUSHs (sv_2mortal (newSViv (h))); |
1276 | PUSHs (sv_2mortal (newSViv (h))); |
1233 | } |
1277 | } |
1234 | |
1278 | |
1235 | int |
1279 | int |
1236 | descent (CFPlus::Layout self) |
1280 | descent (DC::Layout self) |
1237 | CODE: |
1281 | CODE: |
1238 | { |
1282 | { |
1239 | PangoRectangle rect; |
1283 | PangoRectangle rect; |
1240 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1284 | PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); |
1241 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
1285 | pango_layout_line_get_pixel_extents (line, 0, &rect); |
… | |
… | |
1243 | } |
1287 | } |
1244 | OUTPUT: |
1288 | OUTPUT: |
1245 | RETVAL |
1289 | RETVAL |
1246 | |
1290 | |
1247 | int |
1291 | int |
1248 | xy_to_index (CFPlus::Layout self, int x, int y) |
1292 | xy_to_index (DC::Layout self, int x, int y) |
1249 | CODE: |
1293 | CODE: |
1250 | { |
1294 | { |
1251 | int index, trailing; |
1295 | int index, trailing; |
1252 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1296 | pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); |
1253 | RETVAL = index + trailing; |
1297 | RETVAL = index + trailing; |
1254 | } |
1298 | } |
1255 | OUTPUT: |
1299 | OUTPUT: |
1256 | RETVAL |
1300 | RETVAL |
1257 | |
1301 | |
1258 | void |
1302 | void |
1259 | cursor_pos (CFPlus::Layout self, int index) |
1303 | cursor_pos (DC::Layout self, int index) |
1260 | PPCODE: |
1304 | PPCODE: |
1261 | { |
1305 | { |
1262 | PangoRectangle strong_pos; |
1306 | PangoRectangle strong_pos; |
1263 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1307 | pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); |
1264 | |
1308 | |
… | |
… | |
1267 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1311 | PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); |
1268 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1312 | PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); |
1269 | } |
1313 | } |
1270 | |
1314 | |
1271 | void |
1315 | void |
1272 | index_to_line_x (CFPlus::Layout self, int index, int trailing = 0) |
1316 | index_to_line_x (DC::Layout self, int index, int trailing = 0) |
1273 | PPCODE: |
1317 | PPCODE: |
1274 | { |
1318 | { |
1275 | int line, x; |
1319 | int line, x; |
1276 | |
1320 | |
1277 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
1321 | pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); |
… | |
… | |
1281 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1325 | PUSHs (sv_2mortal (newSViv (line - 1))); |
1282 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1326 | PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); |
1283 | } |
1327 | } |
1284 | |
1328 | |
1285 | void |
1329 | void |
1286 | line_x_to_index (CFPlus::Layout self, int line, int x) |
1330 | line_x_to_index (DC::Layout self, int line, int x) |
1287 | PPCODE: |
1331 | PPCODE: |
1288 | { |
1332 | { |
1289 | PangoLayoutLine *lp; |
1333 | PangoLayoutLine *lp; |
1290 | int index, trailing; |
1334 | int index, trailing; |
1291 | |
1335 | |
… | |
… | |
1306 | PUSHs (sv_2mortal (newSViv (trailing))); |
1350 | PUSHs (sv_2mortal (newSViv (trailing))); |
1307 | } |
1351 | } |
1308 | } |
1352 | } |
1309 | |
1353 | |
1310 | void |
1354 | void |
1311 | render (CFPlus::Layout self, float x, float y, int flags = 0) |
1355 | render (DC::Layout self, float x, float y, int flags = 0) |
1312 | PPCODE: |
1356 | CODE: |
|
|
1357 | rc_clear (self->rc); |
1313 | pango_opengl_render_layout_subpixel ( |
1358 | pango_opengl_render_layout_subpixel ( |
1314 | self->pl, |
1359 | self->pl, |
|
|
1360 | self->rc, |
1315 | x * PANGO_SCALE, y * PANGO_SCALE, |
1361 | x * PANGO_SCALE, y * PANGO_SCALE, |
1316 | self->r, self->g, self->b, self->a, |
1362 | self->r, self->g, self->b, self->a, |
1317 | flags |
1363 | flags |
1318 | ); |
1364 | ); |
|
|
1365 | // we assume that context_change actually clears/frees stuff |
|
|
1366 | // and does not do any recomputation... |
|
|
1367 | pango_layout_context_changed (self->pl); |
1319 | |
1368 | |
1320 | MODULE = CFPlus PACKAGE = CFPlus::Texture |
1369 | void |
|
|
1370 | draw (DC::Layout self) |
|
|
1371 | CODE: |
|
|
1372 | { |
|
|
1373 | glEnable (GL_TEXTURE_2D); |
|
|
1374 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
|
|
1375 | glEnable (GL_BLEND); |
|
|
1376 | gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
|
|
1377 | GL_ONE , GL_ONE_MINUS_SRC_ALPHA); |
|
|
1378 | glEnable (GL_ALPHA_TEST); |
|
|
1379 | glAlphaFunc (GL_GREATER, 7.f / 255.f); |
|
|
1380 | |
|
|
1381 | rc_draw (self->rc); |
|
|
1382 | |
|
|
1383 | glDisable (GL_ALPHA_TEST); |
|
|
1384 | glDisable (GL_BLEND); |
|
|
1385 | glDisable (GL_TEXTURE_2D); |
|
|
1386 | } |
|
|
1387 | |
|
|
1388 | MODULE = Deliantra::Client PACKAGE = DC::Texture |
1321 | |
1389 | |
1322 | PROTOTYPES: ENABLE |
1390 | PROTOTYPES: ENABLE |
1323 | |
|
|
1324 | int minpot (int n) |
|
|
1325 | |
1391 | |
1326 | void |
1392 | void |
1327 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1393 | pad (SV *data_, int ow, int oh, int nw, int nh) |
1328 | CODE: |
1394 | CODE: |
1329 | { |
1395 | { |
… | |
… | |
1406 | RETVAL = width > 0; |
1472 | RETVAL = width > 0; |
1407 | } |
1473 | } |
1408 | OUTPUT: |
1474 | OUTPUT: |
1409 | RETVAL |
1475 | RETVAL |
1410 | |
1476 | |
1411 | MODULE = CFPlus PACKAGE = CFPlus::Map |
1477 | MODULE = Deliantra::Client PACKAGE = DC::Map |
1412 | |
1478 | |
1413 | PROTOTYPES: DISABLE |
1479 | PROTOTYPES: DISABLE |
1414 | |
1480 | |
1415 | CFPlus::Map |
1481 | DC::Map |
1416 | new (SV *class) |
1482 | new (SV *class) |
1417 | CODE: |
1483 | CODE: |
1418 | New (0, RETVAL, 1, struct map); |
1484 | New (0, RETVAL, 1, struct map); |
1419 | RETVAL->x = 0; |
1485 | RETVAL->x = 0; |
1420 | RETVAL->y = 0; |
1486 | RETVAL->y = 0; |
… | |
… | |
1428 | RETVAL->row = 0; |
1494 | RETVAL->row = 0; |
1429 | OUTPUT: |
1495 | OUTPUT: |
1430 | RETVAL |
1496 | RETVAL |
1431 | |
1497 | |
1432 | void |
1498 | void |
1433 | DESTROY (CFPlus::Map self) |
1499 | DESTROY (DC::Map self) |
1434 | CODE: |
1500 | CODE: |
1435 | { |
1501 | { |
1436 | map_clear (self); |
1502 | map_clear (self); |
1437 | Safefree (self->face2tile); |
1503 | Safefree (self->face2tile); |
1438 | Safefree (self->tex); |
1504 | Safefree (self->tex); |
1439 | Safefree (self); |
1505 | Safefree (self); |
1440 | } |
1506 | } |
1441 | |
1507 | |
1442 | void |
1508 | void |
1443 | resize (CFPlus::Map self, int map_width, int map_height) |
1509 | resize (DC::Map self, int map_width, int map_height) |
1444 | CODE: |
1510 | CODE: |
1445 | self->w = map_width; |
1511 | self->w = map_width; |
1446 | self->h = map_height; |
1512 | self->h = map_height; |
1447 | |
1513 | |
1448 | void |
1514 | void |
1449 | clear (CFPlus::Map self) |
1515 | clear (DC::Map self) |
1450 | CODE: |
1516 | CODE: |
1451 | map_clear (self); |
1517 | map_clear (self); |
1452 | |
1518 | |
1453 | void |
1519 | void |
1454 | set_tileid (CFPlus::Map self, int face, int tile) |
1520 | set_tileid (DC::Map self, int face, int tile) |
1455 | CODE: |
1521 | CODE: |
1456 | { |
1522 | { |
1457 | need_facenum (self, face); self->face2tile [face] = tile; |
1523 | need_facenum (self, face); self->face2tile [face] = tile; |
1458 | need_texid (self, tile); |
1524 | need_texid (self, tile); |
1459 | } |
1525 | } |
1460 | |
1526 | |
1461 | void |
1527 | void |
1462 | set_smooth (CFPlus::Map self, int face, int smooth, int level) |
1528 | set_smooth (DC::Map self, int face, int smooth, int level) |
1463 | CODE: |
1529 | CODE: |
1464 | { |
1530 | { |
1465 | tileid texid; |
1531 | tileid texid; |
1466 | maptex *tex; |
1532 | maptex *tex; |
1467 | |
1533 | |
… | |
… | |
1480 | tex->smoothtile = self->face2tile [smooth]; |
1546 | tex->smoothtile = self->face2tile [smooth]; |
1481 | tex->smoothlevel = level; |
1547 | tex->smoothlevel = level; |
1482 | } |
1548 | } |
1483 | |
1549 | |
1484 | void |
1550 | void |
1485 | 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) |
1551 | 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) |
1486 | CODE: |
1552 | CODE: |
1487 | { |
1553 | { |
1488 | need_texid (self, texid); |
1554 | need_texid (self, texid); |
1489 | |
1555 | |
1490 | { |
1556 | { |
… | |
… | |
1510 | // from transparent color bleeding and ugly wrapping effects. |
1576 | // from transparent color bleeding and ugly wrapping effects. |
1511 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1577 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1512 | } |
1578 | } |
1513 | |
1579 | |
1514 | int |
1580 | int |
1515 | ox (CFPlus::Map self) |
1581 | ox (DC::Map self) |
1516 | ALIAS: |
1582 | ALIAS: |
1517 | oy = 1 |
1583 | oy = 1 |
1518 | x = 2 |
1584 | x = 2 |
1519 | y = 3 |
1585 | y = 3 |
1520 | w = 4 |
1586 | w = 4 |
… | |
… | |
1531 | } |
1597 | } |
1532 | OUTPUT: |
1598 | OUTPUT: |
1533 | RETVAL |
1599 | RETVAL |
1534 | |
1600 | |
1535 | void |
1601 | void |
1536 | scroll (CFPlus::Map self, int dx, int dy) |
1602 | scroll (DC::Map self, int dx, int dy) |
1537 | CODE: |
1603 | CODE: |
1538 | { |
1604 | { |
1539 | if (dx > 0) |
1605 | if (dx > 0) |
1540 | map_blank (self, self->x, self->y, dx, self->h); |
1606 | map_blank (self, self->x, self->y, dx, self->h); |
1541 | else if (dx < 0) |
1607 | else if (dx < 0) |
… | |
… | |
1557 | self->y += MAP_EXTEND_Y; |
1623 | self->y += MAP_EXTEND_Y; |
1558 | } |
1624 | } |
1559 | } |
1625 | } |
1560 | |
1626 | |
1561 | SV * |
1627 | SV * |
1562 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1628 | map1a_update (DC::Map self, SV *data_, int extmap) |
1563 | CODE: |
1629 | CODE: |
1564 | { |
1630 | { |
1565 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1631 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1566 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1632 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1567 | mapcell *cell; |
1633 | mapcell *cell; |
… | |
… | |
1656 | } |
1722 | } |
1657 | OUTPUT: |
1723 | OUTPUT: |
1658 | RETVAL |
1724 | RETVAL |
1659 | |
1725 | |
1660 | SV * |
1726 | SV * |
1661 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1727 | mapmap (DC::Map self, int x0, int y0, int w, int h) |
1662 | CODE: |
1728 | CODE: |
1663 | { |
1729 | { |
1664 | int x1, x; |
1730 | int x1, x; |
1665 | int y1, y; |
1731 | int y1, y; |
1666 | int z; |
1732 | int z; |
… | |
… | |
1711 | } |
1777 | } |
1712 | OUTPUT: |
1778 | OUTPUT: |
1713 | RETVAL |
1779 | RETVAL |
1714 | |
1780 | |
1715 | void |
1781 | void |
1716 | draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) |
1782 | draw (DC::Map self, int mx, int my, int sw, int sh, int T) |
1717 | CODE: |
1783 | CODE: |
1718 | { |
1784 | { |
1719 | int x, y, z; |
1785 | int x, y, z; |
1720 | |
1786 | |
1721 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1787 | HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); |
1722 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1788 | uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level |
1723 | static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) |
1789 | static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) |
1724 | smooth_key skey; |
1790 | smooth_key skey; |
1725 | |
1791 | |
1726 | rc_t *rc = rc_alloc (); |
1792 | rc_t *rc = rc_alloc (); |
1727 | rc_key_t key; |
1793 | rc_key_t key; |
1728 | rc_array_t *arr; |
1794 | rc_array_t *arr; |
… | |
… | |
1790 | if (tile) |
1856 | if (tile) |
1791 | { |
1857 | { |
1792 | maptex tex = self->tex [tile]; |
1858 | maptex tex = self->tex [tile]; |
1793 | int px, py; |
1859 | int px, py; |
1794 | |
1860 | |
1795 | // suppressing texture state switches here |
|
|
1796 | // is only moderately effective, but worth the extra effort |
|
|
1797 | if (key.texname != tex.name) |
1861 | if (key.texname != tex.name) |
1798 | { |
1862 | { |
1799 | if (!tex.name) |
1863 | if (!tex.name) |
1800 | tex = self->tex [2]; /* missing, replace by noface */ |
1864 | tex = self->tex [2]; /* missing, replace by noface */ |
1801 | |
1865 | |
… | |
… | |
1884 | // go through all smoothlevels, lowest to highest, then draw. |
1948 | // go through all smoothlevels, lowest to highest, then draw. |
1885 | // this is basically counting sort |
1949 | // this is basically counting sort |
1886 | { |
1950 | { |
1887 | int w, b; |
1951 | int w, b; |
1888 | |
1952 | |
|
|
1953 | glEnable (GL_TEXTURE_2D); |
|
|
1954 | glBegin (GL_QUADS); |
1889 | for (w = 0; w < 256 / 32; ++w) |
1955 | for (w = 0; w < 256 / 32; ++w) |
1890 | { |
1956 | { |
1891 | uint32_t smask = smooth_level [w]; |
1957 | uint32_t smask = smooth_level [w]; |
1892 | if (smask) |
1958 | if (smask) |
1893 | for (b = 0; b < 32; ++b) |
1959 | for (b = 0; b < 32; ++b) |
… | |
… | |
1918 | { |
1984 | { |
1919 | // this time avoiding texture state changes |
1985 | // this time avoiding texture state changes |
1920 | // save gobs of state changes. |
1986 | // save gobs of state changes. |
1921 | if (key.texname != tex.name) |
1987 | if (key.texname != tex.name) |
1922 | { |
1988 | { |
|
|
1989 | glEnd (); |
1923 | key.texname = tex.name; |
1990 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
1924 | arr = rc_array (rc, &key); |
1991 | glBegin (GL_QUADS); |
1925 | } |
1992 | } |
1926 | |
1993 | |
1927 | if (border) |
1994 | if (border) |
1928 | { |
1995 | { |
1929 | float ox = border * dx; |
1996 | float ox = border * dx; |
1930 | |
1997 | |
1931 | rc_t2f_v3f (arr, ox , 0.f , px , py , 0); |
1998 | glTexCoord2f (ox , 0.f ); glVertex2i (px , py ); |
1932 | rc_t2f_v3f (arr, ox , dy , px , py + T, 0); |
1999 | glTexCoord2f (ox , dy ); glVertex2i (px , py + T); |
1933 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py + T, 0); |
2000 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T); |
1934 | rc_t2f_v3f (arr, ox + dx, 0.f , px + T, py , 0); |
2001 | glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py ); |
1935 | } |
2002 | } |
1936 | |
2003 | |
1937 | if (corner) |
2004 | if (corner) |
1938 | { |
2005 | { |
1939 | float ox = corner * dx; |
2006 | float ox = corner * dx; |
1940 | |
2007 | |
1941 | rc_t2f_v3f (arr, ox , dy , px , py , 0); |
2008 | glTexCoord2f (ox , dy ); glVertex2i (px , py ); |
1942 | rc_t2f_v3f (arr, ox , dy * 2.f, px , py + T, 0); |
2009 | glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T); |
1943 | rc_t2f_v3f (arr, ox + dx, dy * 2.f, px + T, py + T, 0); |
2010 | glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T); |
1944 | rc_t2f_v3f (arr, ox + dx, dy , px + T, py , 0); |
2011 | glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py ); |
1945 | } |
2012 | } |
1946 | } |
2013 | } |
1947 | } |
2014 | } |
1948 | } |
2015 | } |
1949 | } |
2016 | } |
1950 | } |
2017 | } |
|
|
2018 | |
|
|
2019 | glEnd (); |
|
|
2020 | glDisable (GL_TEXTURE_2D); |
|
|
2021 | key.texname = -1; |
1951 | } |
2022 | } |
1952 | |
2023 | |
1953 | hv_clear (smooth); |
2024 | hv_clear (smooth); |
1954 | rc_draw (rc); |
|
|
1955 | rc_clear (rc); |
|
|
1956 | } |
2025 | } |
1957 | |
2026 | |
1958 | glDisable (GL_BLEND); |
2027 | glDisable (GL_BLEND); |
1959 | rc_free (rc); |
2028 | rc_free (rc); |
1960 | |
2029 | |
… | |
… | |
1989 | } |
2058 | } |
1990 | } |
2059 | } |
1991 | } |
2060 | } |
1992 | |
2061 | |
1993 | void |
2062 | void |
1994 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
2063 | draw_magicmap (DC::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1995 | CODE: |
2064 | CODE: |
1996 | { |
2065 | { |
1997 | static float color[16][3] = { |
2066 | static float color[16][3] = { |
1998 | { 0.00F, 0.00F, 0.00F }, |
2067 | { 0.00F, 0.00F, 0.00F }, |
1999 | { 1.00F, 1.00F, 1.00F }, |
2068 | { 1.00F, 1.00F, 1.00F }, |
… | |
… | |
2049 | glDisable (GL_BLEND); |
2118 | glDisable (GL_BLEND); |
2050 | glDisable (GL_TEXTURE_2D); |
2119 | glDisable (GL_TEXTURE_2D); |
2051 | } |
2120 | } |
2052 | |
2121 | |
2053 | void |
2122 | void |
2054 | fow_texture (CFPlus::Map self, int mx, int my, int sw, int sh) |
2123 | fow_texture (DC::Map self, int mx, int my, int sw, int sh) |
2055 | PPCODE: |
2124 | PPCODE: |
2056 | { |
2125 | { |
2057 | int x, y; |
2126 | int x, y; |
2058 | int sw1 = sw + 2; |
2127 | int sw1 = sw + 2; |
2059 | int sh1 = sh + 2; |
2128 | int sh1 = sh + 2; |
… | |
… | |
2130 | PUSHs (sv_2mortal (newSViv (sh3))); |
2199 | PUSHs (sv_2mortal (newSViv (sh3))); |
2131 | PUSHs (darkness3_sv); |
2200 | PUSHs (darkness3_sv); |
2132 | } |
2201 | } |
2133 | |
2202 | |
2134 | SV * |
2203 | SV * |
2135 | get_rect (CFPlus::Map self, int x0, int y0, int w, int h) |
2204 | get_rect (DC::Map self, int x0, int y0, int w, int h) |
2136 | CODE: |
2205 | CODE: |
2137 | { |
2206 | { |
2138 | int x, y, x1, y1; |
2207 | int x, y, x1, y1; |
2139 | SV *data_sv = newSV (w * h * 7 + 5); |
2208 | SV *data_sv = newSV (w * h * 7 + 5); |
2140 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
2209 | uint8_t *data = (uint8_t *)SvPVX (data_sv); |
… | |
… | |
2205 | } |
2274 | } |
2206 | OUTPUT: |
2275 | OUTPUT: |
2207 | RETVAL |
2276 | RETVAL |
2208 | |
2277 | |
2209 | void |
2278 | void |
2210 | set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data) |
2279 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2211 | PPCODE: |
2280 | PPCODE: |
2212 | { |
2281 | { |
2213 | int x, y, z; |
2282 | int x, y, z; |
2214 | int w, h; |
2283 | int w, h; |
2215 | int x1, y1; |
2284 | int x1, y1; |
2216 | |
2285 | |
2217 | if (*data++ != 0) |
2286 | if (*data++ != 0) |
2218 | return; /* version mismatch */ |
2287 | XSRETURN_EMPTY; /* version mismatch */ |
2219 | |
2288 | |
2220 | w = *data++ << 8; w |= *data++; |
2289 | w = *data++ << 8; w |= *data++; |
2221 | h = *data++ << 8; h |= *data++; |
2290 | h = *data++ << 8; h |= *data++; |
2222 | |
2291 | |
2223 | // we need to do this 'cause we don't keep an absolute coord system for rows |
2292 | // we need to do this 'cause we don't keep an absolute coord system for rows |
… | |
… | |
2268 | } |
2337 | } |
2269 | } |
2338 | } |
2270 | } |
2339 | } |
2271 | } |
2340 | } |
2272 | |
2341 | |
2273 | MODULE = CFPlus PACKAGE = CFPlus::RW |
2342 | MODULE = Deliantra::Client PACKAGE = DC::RW |
2274 | |
2343 | |
2275 | CFPlus::RW |
2344 | DC::RW |
2276 | new (SV *class, SV *data_sv) |
2345 | new (SV *class, SV *data_sv) |
2277 | CODE: |
2346 | CODE: |
2278 | { |
2347 | { |
2279 | STRLEN datalen; |
2348 | STRLEN datalen; |
2280 | char *data = SvPVbyte (data_sv, datalen); |
2349 | char *data = SvPVbyte (data_sv, datalen); |
… | |
… | |
2282 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2351 | RETVAL = SDL_RWFromConstMem (data, datalen); |
2283 | } |
2352 | } |
2284 | OUTPUT: |
2353 | OUTPUT: |
2285 | RETVAL |
2354 | RETVAL |
2286 | |
2355 | |
2287 | CFPlus::RW |
2356 | DC::RW |
2288 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2357 | new_from_file (SV *class, const char *path, const char *mode = "rb") |
2289 | CODE: |
2358 | CODE: |
2290 | RETVAL = SDL_RWFromFile (path, mode); |
2359 | RETVAL = SDL_RWFromFile (path, mode); |
2291 | OUTPUT: |
2360 | OUTPUT: |
2292 | RETVAL |
2361 | RETVAL |
2293 | |
2362 | |
2294 | # fails on win32: |
2363 | # fails on win32: |
2295 | # CFPlus.xs(2268) : error C2059: syntax error : '(' |
2364 | # dc.xs(2268) : error C2059: syntax error : '(' |
2296 | #void |
2365 | #void |
2297 | #close (CFPlus::RW self) |
2366 | #close (DC::RW self) |
2298 | # CODE: |
2367 | # CODE: |
2299 | # (self->(close)) (self); |
2368 | # (self->(close)) (self); |
2300 | |
2369 | |
2301 | MODULE = CFPlus PACKAGE = CFPlus::Channel |
2370 | MODULE = Deliantra::Client PACKAGE = DC::Channel |
2302 | |
2371 | |
2303 | PROTOTYPES: DISABLE |
2372 | PROTOTYPES: DISABLE |
2304 | |
2373 | |
2305 | CFPlus::Channel |
2374 | DC::Channel |
2306 | find () |
2375 | find () |
2307 | CODE: |
2376 | CODE: |
2308 | { |
2377 | { |
2309 | RETVAL = Mix_GroupAvailable (-1); |
2378 | RETVAL = Mix_GroupAvailable (-1); |
2310 | |
2379 | |
… | |
… | |
2323 | } |
2392 | } |
2324 | OUTPUT: |
2393 | OUTPUT: |
2325 | RETVAL |
2394 | RETVAL |
2326 | |
2395 | |
2327 | void |
2396 | void |
2328 | halt (CFPlus::Channel self) |
2397 | halt (DC::Channel self) |
2329 | CODE: |
2398 | CODE: |
2330 | Mix_HaltChannel (self); |
2399 | Mix_HaltChannel (self); |
2331 | |
2400 | |
2332 | void |
2401 | void |
2333 | expire (CFPlus::Channel self, int ticks = -1) |
2402 | expire (DC::Channel self, int ticks = -1) |
2334 | CODE: |
2403 | CODE: |
2335 | Mix_ExpireChannel (self, ticks); |
2404 | Mix_ExpireChannel (self, ticks); |
2336 | |
2405 | |
2337 | void |
2406 | void |
2338 | fade_out (CFPlus::Channel self, int ticks = -1) |
2407 | fade_out (DC::Channel self, int ticks = -1) |
2339 | CODE: |
2408 | CODE: |
2340 | Mix_FadeOutChannel (self, ticks); |
2409 | Mix_FadeOutChannel (self, ticks); |
2341 | |
2410 | |
2342 | int |
2411 | int |
2343 | volume (CFPlus::Channel self, int volume) |
2412 | volume (DC::Channel self, int volume) |
2344 | CODE: |
2413 | CODE: |
2345 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2414 | RETVAL = Mix_Volume (self, CLAMP (volume, 0, 128)); |
2346 | OUTPUT: |
2415 | OUTPUT: |
2347 | RETVAL |
2416 | RETVAL |
2348 | |
2417 | |
2349 | void |
2418 | void |
2350 | unregister_all_effects (CFPlus::Channel self) |
2419 | unregister_all_effects (DC::Channel self) |
2351 | CODE: |
2420 | CODE: |
2352 | Mix_UnregisterAllEffects (self); |
2421 | Mix_UnregisterAllEffects (self); |
2353 | |
2422 | |
2354 | void |
2423 | void |
2355 | set_panning (CFPlus::Channel self, int left, int right) |
2424 | set_panning (DC::Channel self, int left, int right) |
2356 | CODE: |
2425 | CODE: |
2357 | left = CLAMP (left , 0, 255); |
2426 | left = CLAMP (left , 0, 255); |
2358 | right = CLAMP (right, 0, 255); |
2427 | right = CLAMP (right, 0, 255); |
2359 | Mix_SetPanning (self, left, right); |
2428 | Mix_SetPanning (self, left, right); |
2360 | |
2429 | |
2361 | void |
2430 | void |
2362 | set_distance (CFPlus::Channel self, int distance) |
2431 | set_distance (DC::Channel self, int distance) |
2363 | CODE: |
2432 | CODE: |
2364 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2433 | Mix_SetDistance (self, CLAMP (distance, 0, 255)); |
2365 | |
2434 | |
2366 | void |
2435 | void |
2367 | set_position (CFPlus::Channel self, int angle, int distance) |
2436 | set_position (DC::Channel self, int angle, int distance) |
2368 | CODE: |
2437 | CODE: |
2369 | |
2438 | |
2370 | void |
2439 | void |
2371 | set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) |
2440 | set_position_r (DC::Channel self, int dx, int dy, int maxdistance) |
2372 | CODE: |
2441 | CODE: |
2373 | { |
2442 | { |
2374 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2443 | int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); |
2375 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2444 | int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); |
2376 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2445 | Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); |
2377 | } |
2446 | } |
2378 | |
2447 | |
2379 | void |
2448 | void |
2380 | set_reverse_stereo (CFPlus::Channel self, int flip) |
2449 | set_reverse_stereo (DC::Channel self, int flip) |
2381 | CODE: |
2450 | CODE: |
2382 | Mix_SetReverseStereo (self, flip); |
2451 | Mix_SetReverseStereo (self, flip); |
2383 | |
2452 | |
2384 | MODULE = CFPlus PACKAGE = CFPlus::MixChunk |
2453 | MODULE = Deliantra::Client PACKAGE = DC::MixChunk |
2385 | |
2454 | |
2386 | PROTOTYPES: DISABLE |
2455 | PROTOTYPES: DISABLE |
2387 | |
2456 | |
2388 | CFPlus::MixChunk |
2457 | DC::MixChunk |
2389 | new (SV *class, CFPlus::RW rwops) |
2458 | new (SV *class, DC::RW rwops) |
2390 | CODE: |
2459 | CODE: |
2391 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2460 | RETVAL = Mix_LoadWAV_RW (rwops, 1); |
2392 | OUTPUT: |
2461 | OUTPUT: |
2393 | RETVAL |
2462 | RETVAL |
2394 | |
2463 | |
2395 | void |
2464 | void |
2396 | DESTROY (CFPlus::MixChunk self) |
2465 | DESTROY (DC::MixChunk self) |
2397 | CODE: |
2466 | CODE: |
2398 | Mix_FreeChunk (self); |
2467 | Mix_FreeChunk (self); |
2399 | |
2468 | |
2400 | int |
2469 | int |
2401 | volume (CFPlus::MixChunk self, int volume = -1) |
2470 | volume (DC::MixChunk self, int volume = -1) |
2402 | CODE: |
2471 | CODE: |
2403 | if (items > 1) |
2472 | if (items > 1) |
2404 | volume = CLAMP (volume, 0, 128); |
2473 | volume = CLAMP (volume, 0, 128); |
2405 | RETVAL = Mix_VolumeChunk (self, volume); |
2474 | RETVAL = Mix_VolumeChunk (self, volume); |
2406 | OUTPUT: |
2475 | OUTPUT: |
2407 | RETVAL |
2476 | RETVAL |
2408 | |
2477 | |
2409 | CFPlus::Channel |
2478 | DC::Channel |
2410 | play (CFPlus::MixChunk self, CFPlus::Channel channel = -1, int loops = 0, int ticks = -1) |
2479 | play (DC::MixChunk self, DC::Channel channel = -1, int loops = 0, int ticks = -1) |
2411 | CODE: |
2480 | CODE: |
2412 | { |
2481 | { |
2413 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2482 | RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); |
2414 | |
2483 | |
2415 | if (RETVAL < 0) |
2484 | if (RETVAL < 0) |
… | |
… | |
2422 | } |
2491 | } |
2423 | } |
2492 | } |
2424 | OUTPUT: |
2493 | OUTPUT: |
2425 | RETVAL |
2494 | RETVAL |
2426 | |
2495 | |
2427 | MODULE = CFPlus PACKAGE = CFPlus::MixMusic |
2496 | MODULE = Deliantra::Client PACKAGE = DC::MixMusic |
2428 | |
2497 | |
2429 | int |
2498 | int |
2430 | volume (int volume = -1) |
2499 | volume (int volume = -1) |
2431 | PROTOTYPE: ;$ |
2500 | PROTOTYPE: ;$ |
2432 | CODE: |
2501 | CODE: |
… | |
… | |
2444 | void |
2513 | void |
2445 | halt () |
2514 | halt () |
2446 | CODE: |
2515 | CODE: |
2447 | Mix_HaltMusic (); |
2516 | Mix_HaltMusic (); |
2448 | |
2517 | |
2449 | CFPlus::MixMusic |
2518 | DC::MixMusic |
2450 | new (SV *class, CFPlus::RW rwops) |
2519 | new (SV *class, DC::RW rwops) |
2451 | CODE: |
2520 | CODE: |
2452 | RETVAL = Mix_LoadMUS_RW (rwops); |
2521 | RETVAL = Mix_LoadMUS_RW (rwops); |
2453 | OUTPUT: |
2522 | OUTPUT: |
2454 | RETVAL |
2523 | RETVAL |
2455 | |
2524 | |
2456 | void |
2525 | void |
2457 | DESTROY (CFPlus::MixMusic self) |
2526 | DESTROY (DC::MixMusic self) |
2458 | CODE: |
2527 | CODE: |
2459 | Mix_FreeMusic (self); |
2528 | Mix_FreeMusic (self); |
2460 | |
2529 | |
2461 | int |
2530 | int |
2462 | play (CFPlus::MixMusic self, int loops = -1) |
2531 | play (DC::MixMusic self, int loops = -1) |
2463 | CODE: |
2532 | CODE: |
2464 | RETVAL = Mix_PlayMusic (self, loops); |
2533 | RETVAL = Mix_PlayMusic (self, loops); |
2465 | OUTPUT: |
2534 | OUTPUT: |
2466 | RETVAL |
2535 | RETVAL |
2467 | |
2536 | |
2468 | void |
2537 | void |
2469 | fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position) |
2538 | fade_in_pos (DC::MixMusic self, int loops, int ms, double position) |
2470 | CODE: |
2539 | CODE: |
2471 | Mix_FadeInMusicPos (self, loops, ms, position); |
2540 | Mix_FadeInMusicPos (self, loops, ms, position); |
2472 | |
2541 | |
2473 | MODULE = CFPlus PACKAGE = CFPlus::OpenGL |
2542 | MODULE = Deliantra::Client PACKAGE = DC::OpenGL |
2474 | |
2543 | |
2475 | PROTOTYPES: ENABLE |
2544 | PROTOTYPES: ENABLE |
2476 | |
2545 | |
2477 | BOOT: |
2546 | BOOT: |
2478 | { |
2547 | { |
2479 | HV *stash = gv_stashpv ("CFPlus::OpenGL", 1); |
2548 | HV *stash = gv_stashpv ("DC::OpenGL", 1); |
2480 | static const struct { |
2549 | static const struct { |
2481 | const char *name; |
2550 | const char *name; |
2482 | IV iv; |
2551 | IV iv; |
2483 | } *civ, const_iv[] = { |
2552 | } *civ, const_iv[] = { |
2484 | # define const_iv(name) { # name, (IV)name } |
2553 | # define const_iv(name) { # name, (IV)name } |
… | |
… | |
2519 | const_iv (GL_INTENSITY), |
2588 | const_iv (GL_INTENSITY), |
2520 | const_iv (GL_LUMINANCE), |
2589 | const_iv (GL_LUMINANCE), |
2521 | const_iv (GL_LUMINANCE_ALPHA), |
2590 | const_iv (GL_LUMINANCE_ALPHA), |
2522 | const_iv (GL_FLOAT), |
2591 | const_iv (GL_FLOAT), |
2523 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
2592 | const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), |
|
|
2593 | const_iv (GL_COMPRESSED_ALPHA_ARB), |
|
|
2594 | const_iv (GL_COMPRESSED_LUMINANCE_ARB), |
|
|
2595 | const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), |
|
|
2596 | const_iv (GL_COMPRESSED_INTENSITY_ARB), |
|
|
2597 | const_iv (GL_COMPRESSED_RGB_ARB), |
|
|
2598 | const_iv (GL_COMPRESSED_RGBA_ARB), |
2524 | const_iv (GL_COMPILE), |
2599 | const_iv (GL_COMPILE), |
2525 | const_iv (GL_PROXY_TEXTURE_1D), |
2600 | const_iv (GL_PROXY_TEXTURE_1D), |
2526 | const_iv (GL_PROXY_TEXTURE_2D), |
2601 | const_iv (GL_PROXY_TEXTURE_2D), |
2527 | const_iv (GL_TEXTURE_1D), |
2602 | const_iv (GL_TEXTURE_1D), |
2528 | const_iv (GL_TEXTURE_2D), |
2603 | const_iv (GL_TEXTURE_2D), |
… | |
… | |
2567 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2642 | const_iv (GL_PERSPECTIVE_CORRECTION_HINT), |
2568 | const_iv (GL_POINT_SMOOTH_HINT), |
2643 | const_iv (GL_POINT_SMOOTH_HINT), |
2569 | const_iv (GL_LINE_SMOOTH_HINT), |
2644 | const_iv (GL_LINE_SMOOTH_HINT), |
2570 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2645 | const_iv (GL_POLYGON_SMOOTH_HINT), |
2571 | const_iv (GL_GENERATE_MIPMAP_HINT), |
2646 | const_iv (GL_GENERATE_MIPMAP_HINT), |
|
|
2647 | const_iv (GL_TEXTURE_COMPRESSION_HINT), |
2572 | const_iv (GL_FASTEST), |
2648 | const_iv (GL_FASTEST), |
2573 | const_iv (GL_DONT_CARE), |
2649 | const_iv (GL_DONT_CARE), |
2574 | const_iv (GL_NICEST), |
2650 | const_iv (GL_NICEST), |
2575 | const_iv (GL_V2F), |
2651 | const_iv (GL_V2F), |
2576 | const_iv (GL_V3F), |
2652 | const_iv (GL_V3F), |
… | |
… | |
2584 | |
2660 | |
2585 | texture_av = newAV (); |
2661 | texture_av = newAV (); |
2586 | AvREAL_off (texture_av); |
2662 | AvREAL_off (texture_av); |
2587 | } |
2663 | } |
2588 | |
2664 | |
|
|
2665 | void |
|
|
2666 | disable_GL_EXT_blend_func_separate () |
|
|
2667 | CODE: |
|
|
2668 | gl.BlendFuncSeparate = 0; |
|
|
2669 | gl.BlendFuncSeparateEXT = 0; |
|
|
2670 | |
2589 | char * |
2671 | char * |
2590 | gl_vendor () |
2672 | gl_vendor () |
2591 | CODE: |
2673 | CODE: |
2592 | RETVAL = (char *)glGetString (GL_VENDOR); |
2674 | RETVAL = (char *)glGetString (GL_VENDOR); |
2593 | OUTPUT: |
2675 | OUTPUT: |
… | |
… | |
2714 | |
2796 | |
2715 | void glRect (float x1, float y1, float x2, float y2) |
2797 | void glRect (float x1, float y1, float x2, float y2) |
2716 | CODE: |
2798 | CODE: |
2717 | glRectf (x1, y1, x2, y2); |
2799 | glRectf (x1, y1, x2, y2); |
2718 | |
2800 | |
|
|
2801 | void glRect_lineloop (float x1, float y1, float x2, float y2) |
|
|
2802 | CODE: |
|
|
2803 | glBegin (GL_LINE_LOOP); |
|
|
2804 | glVertex2f (x1, y1); |
|
|
2805 | glVertex2f (x2, y1); |
|
|
2806 | glVertex2f (x2, y2); |
|
|
2807 | glVertex2f (x1, y2); |
|
|
2808 | glEnd (); |
|
|
2809 | |
2719 | PROTOTYPES: ENABLE |
2810 | PROTOTYPES: ENABLE |
2720 | |
2811 | |
2721 | void glBegin (int mode) |
2812 | void glBegin (int mode) |
2722 | |
2813 | |
2723 | void glEnd () |
2814 | void glEnd () |
… | |
… | |
2791 | |
2882 | |
2792 | void glEndList () |
2883 | void glEndList () |
2793 | |
2884 | |
2794 | void glCallList (int list) |
2885 | void glCallList (int list) |
2795 | |
2886 | |
2796 | MODULE = CFPlus PACKAGE = CFPlus::UI::Base |
2887 | MODULE = Deliantra::Client PACKAGE = DC::UI::Base |
2797 | |
2888 | |
2798 | PROTOTYPES: DISABLE |
2889 | PROTOTYPES: DISABLE |
2799 | |
2890 | |
2800 | void |
2891 | void |
2801 | find_widget (SV *self, NV x, NV y) |
2892 | find_widget (SV *self, NV x, NV y) |
… | |
… | |
2805 | XPUSHs (self); |
2896 | XPUSHs (self); |
2806 | } |
2897 | } |
2807 | |
2898 | |
2808 | BOOT: |
2899 | BOOT: |
2809 | { |
2900 | { |
2810 | hover_gv = gv_fetchpv ("CFPlus::UI::HOVER", 1, SVt_NV); |
2901 | hover_gv = gv_fetchpv ("DC::UI::HOVER", 1, SVt_NV); |
2811 | |
2902 | |
2812 | draw_x_gv = gv_fetchpv ("CFPlus::UI::Base::draw_x", 1, SVt_NV); |
2903 | draw_x_gv = gv_fetchpv ("DC::UI::Base::draw_x", 1, SVt_NV); |
2813 | draw_y_gv = gv_fetchpv ("CFPlus::UI::Base::draw_y", 1, SVt_NV); |
2904 | draw_y_gv = gv_fetchpv ("DC::UI::Base::draw_y", 1, SVt_NV); |
2814 | draw_w_gv = gv_fetchpv ("CFPlus::UI::Base::draw_w", 1, SVt_NV); |
2905 | draw_w_gv = gv_fetchpv ("DC::UI::Base::draw_w", 1, SVt_NV); |
2815 | draw_h_gv = gv_fetchpv ("CFPlus::UI::Base::draw_h", 1, SVt_NV); |
2906 | draw_h_gv = gv_fetchpv ("DC::UI::Base::draw_h", 1, SVt_NV); |
2816 | } |
2907 | } |
2817 | |
2908 | |
2818 | void |
2909 | void |
2819 | draw (SV *self) |
2910 | draw (SV *self) |
2820 | CODE: |
2911 | CODE: |
… | |
… | |
2824 | NV x, y, w, h; |
2915 | NV x, y, w, h; |
2825 | SV *draw_x_sv = GvSV (draw_x_gv); |
2916 | SV *draw_x_sv = GvSV (draw_x_gv); |
2826 | SV *draw_y_sv = GvSV (draw_y_gv); |
2917 | SV *draw_y_sv = GvSV (draw_y_gv); |
2827 | SV *draw_w_sv = GvSV (draw_w_gv); |
2918 | SV *draw_w_sv = GvSV (draw_w_gv); |
2828 | SV *draw_h_sv = GvSV (draw_h_gv); |
2919 | SV *draw_h_sv = GvSV (draw_h_gv); |
2829 | SV *hover; |
|
|
2830 | double draw_x, draw_y, draw_w, draw_h; |
2920 | double draw_x, draw_y; |
2831 | |
2921 | |
2832 | if (!SvROK (self)) |
2922 | if (!SvROK (self)) |
2833 | croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); |
2923 | croak ("DC::Base::draw: %s not a reference", SvPV_nolen (self)); |
2834 | |
2924 | |
2835 | hv = (HV *)SvRV (self); |
2925 | hv = (HV *)SvRV (self); |
2836 | |
2926 | |
2837 | if (SvTYPE (hv) != SVt_PVHV) |
2927 | if (SvTYPE (hv) != SVt_PVHV) |
2838 | croak ("CFPlus::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2928 | croak ("DC::Base::draw: %s not a hashref", SvPV_nolen (self)); |
2839 | |
2929 | |
2840 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2930 | svp = hv_fetch (hv, "w", 1, 0); w = svp ? SvNV (*svp) : 0.; |
2841 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2931 | svp = hv_fetch (hv, "h", 1, 0); h = svp ? SvNV (*svp) : 0.; |
2842 | |
2932 | |
2843 | if (!h || !w) |
2933 | if (!h || !w) |
… | |
… | |
2863 | { |
2953 | { |
2864 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2954 | svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); |
2865 | |
2955 | |
2866 | if (svp && SvTRUE (*svp)) |
2956 | if (svp && SvTRUE (*svp)) |
2867 | { |
2957 | { |
2868 | glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); |
2958 | glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); |
2869 | glEnable (GL_BLEND); |
2959 | glEnable (GL_BLEND); |
2870 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2960 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
2871 | glBegin (GL_QUADS); |
2961 | glBegin (GL_QUADS); |
2872 | glVertex2f (0, 0); |
2962 | glVertex2f (0, 0); |
2873 | glVertex2f (w, 0); |
2963 | glVertex2f (w, 0); |
… | |
… | |
2876 | glEnd (); |
2966 | glEnd (); |
2877 | glDisable (GL_BLEND); |
2967 | glDisable (GL_BLEND); |
2878 | } |
2968 | } |
2879 | } |
2969 | } |
2880 | #if 0 |
2970 | #if 0 |
2881 | if ($ENV{CFPLUS_DEBUG} & 1) { |
2971 | // draw borders, for debugging |
2882 | glPushMatrix; |
2972 | glPushMatrix (); |
2883 | glColor 1, 1, 0, 1; |
2973 | glColor4f (1., 1., 0., 1.); |
2884 | glTranslate 0.375, 0.375; |
2974 | glTranslatef (.5, .5, 0.); |
2885 | glBegin GL_LINE_LOOP; |
2975 | glBegin (GL_LINE_LOOP); |
2886 | glVertex 0 , 0; |
2976 | glVertex2f (0 , 0); |
2887 | glVertex $self->{w} - 1, 0; |
2977 | glVertex2f (w - 1, 0); |
2888 | glVertex $self->{w} - 1, $self->{h} - 1; |
2978 | glVertex2f (w - 1, h - 1); |
2889 | glVertex 0 , $self->{h} - 1; |
2979 | glVertex2f (0 , h - 1); |
2890 | glEnd; |
2980 | glEnd (); |
2891 | glPopMatrix; |
2981 | glPopMatrix (); |
2892 | #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
|
|
2893 | } |
|
|
2894 | #endif |
2982 | #endif |
2895 | PUSHMARK (SP); |
2983 | PUSHMARK (SP); |
2896 | XPUSHs (self); |
2984 | XPUSHs (self); |
2897 | PUTBACK; |
2985 | PUTBACK; |
2898 | call_method ("_draw", G_VOID | G_DISCARD); |
2986 | call_method ("_draw", G_VOID | G_DISCARD); |