ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.124 by root, Tue Jul 4 23:23:31 2006 UTC vs.
Revision 1.137 by root, Sun Aug 13 19:47:05 2006 UTC

1#ifdef _WIN32 1#ifdef _WIN32
2# define WIN32_LEAN_AND_MEAN
2# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls 3# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls
3# include <malloc.h> 4# include <malloc.h>
4# include <windows.h> 5# include <windows.h>
5# pragma warning(disable:4244) 6# pragma warning(disable:4244)
6#endif 7#endif
7 8
8#include "EXTERN.h" 9#include "EXTERN.h"
9#include "perl.h" 10#include "perl.h"
10#include "XSUB.h" 11#include "XSUB.h"
12
13#ifdef _WIN32
14# undef pipe
15#endif
11 16
12#include <math.h> 17#include <math.h>
13#include <string.h> 18#include <string.h>
14#include <stdio.h> 19#include <stdio.h>
15#include <stdlib.h> 20#include <stdlib.h>
40 typedef signed char int8_t; 45 typedef signed char int8_t;
41 typedef signed short int16_t; 46 typedef signed short int16_t;
42 typedef signed int int32_t; 47 typedef signed int int32_t;
43#endif 48#endif
44 49
45#include "glext.h"
46
47#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ 50#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */
48 51
49#define FOW_DARKNESS 32 52#define FOW_DARKNESS 32
50 53
51#define MAP_EXTEND_X 32 54#define MAP_EXTEND_X 32
52#define MAP_EXTEND_Y 512 55#define MAP_EXTEND_Y 512
53 56
54#define MIN_FONT_HEIGHT 10 57#define MIN_FONT_HEIGHT 10
55 58
56#if 1 59#if 0
57# define PARACHUTE SDL_INIT_NOPARACHUTE 60# define PARACHUTE SDL_INIT_NOPARACHUTE
58#else 61#else
59# define PARACHUTE 0 62# define PARACHUTE 0
60#endif 63#endif
61 64
80 83
81#include "pango-font.c" 84#include "pango-font.c"
82#include "pango-fontmap.c" 85#include "pango-fontmap.c"
83#include "pango-render.c" 86#include "pango-render.c"
84 87
85typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
86typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
87 90
88typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
89 92
90static int 93static int
91shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
92{ 95{
93 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
107 110
108typedef struct cf_layout { 111typedef struct cf_layout {
109 PangoLayout *pl; 112 PangoLayout *pl;
110 float r, g, b, a; // default color for rgba mode 113 float r, g, b, a; // default color for rgba mode
111 int base_height; 114 int base_height;
112 CFClient__Font font; 115 CFPlus__Font font;
113} *CFClient__Layout; 116} *CFPlus__Layout;
114 117
115static CFClient__Font default_font; 118static CFPlus__Font default_font;
116static PangoContext *opengl_context; 119static PangoContext *opengl_context;
117static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
118 121
119static void 122static void
120substitute_func (FcPattern *pattern, gpointer data) 123substitute_func (FcPattern *pattern, gpointer data)
121{ 124{
122 FcPatternAddBool (pattern, FC_HINTING, 1); 125 FcPatternAddBool (pattern, FC_HINTING, 1);
123#ifdef FC_HINT_STYLE 126#ifdef FC_HINT_STYLE
124 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); 127 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL);
125#endif 128#endif
126#ifdef _WIN32
127 FcPatternAddBool (pattern, FC_AUTOHINT, 1);
128#else
129 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 129 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
130#endif
131} 130}
132 131
133static void 132static void
134layout_update_font (CFClient__Layout self) 133layout_update_font (CFPlus__Layout self)
135{ 134{
136 /* use a random scale factor to account for unknown descenders, 0.8 works 135 /* use a random scale factor to account for unknown descenders, 0.8 works
137 * reasonably well with bitstream vera 136 * reasonably well with bitstream vera
138 */ 137 */
139 PangoFontDescription *font = self->font ? self->font : default_font; 138 PangoFontDescription *font = self->font ? self->font : default_font;
143 142
144 pango_layout_set_font_description (self->pl, font); 143 pango_layout_set_font_description (self->pl, font);
145} 144}
146 145
147static void 146static void
148layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
149{ 148{
150 pango_layout_get_pixel_size (self->pl, w, h); 149 pango_layout_get_pixel_size (self->pl, w, h);
151 150
152 if (!*w) *w = 1; 151 if (!*w) *w = 1;
153 if (!*h) *h = 1; 152 if (!*h) *h = 1;
183 int texs; 182 int texs;
184 maptex *tex; 183 maptex *tex;
185 184
186 int32_t rows; 185 int32_t rows;
187 maprow *row; 186 maprow *row;
188} *CFClient__Map; 187} *CFPlus__Map;
189 188
190static char * 189static char *
191prepend (char *ptr, int sze, int inc) 190prepend (char *ptr, int sze, int inc)
192{ 191{
193 char *p; 192 char *p;
211 210
212#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 211#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
213#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 212#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
214 213
215static maprow * 214static maprow *
216map_get_row (CFClient__Map self, int y) 215map_get_row (CFPlus__Map self, int y)
217{ 216{
218 if (0 > y) 217 if (0 > y)
219 { 218 {
220 int extend = - y + MAP_EXTEND_Y; 219 int extend = - y + MAP_EXTEND_Y;
221 Prepend (maprow, self->row, self->rows, extend); 220 Prepend (maprow, self->row, self->rows, extend);
259 258
260 return row->col + (x - row->c0); 259 return row->col + (x - row->c0);
261} 260}
262 261
263static mapcell * 262static mapcell *
264map_get_cell (CFClient__Map self, int x, int y) 263map_get_cell (CFPlus__Map self, int x, int y)
265{ 264{
266 return row_get_cell (map_get_row (self, y), x); 265 return row_get_cell (map_get_row (self, y), x);
267} 266}
268 267
269static void 268static void
270map_clear (CFClient__Map self) 269map_clear (CFPlus__Map self)
271{ 270{
272 int r; 271 int r;
273 272
274 for (r = 0; r < self->rows; r++) 273 for (r = 0; r < self->rows; r++)
275 Safefree (self->row[r].col); 274 Safefree (self->row[r].col);
283 self->row = 0; 282 self->row = 0;
284 self->rows = 0; 283 self->rows = 0;
285} 284}
286 285
287static void 286static void
288map_blank (CFClient__Map self, int x0, int y0, int w, int h) 287map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
289{ 288{
290 int x, y; 289 int x, y;
291 maprow *row; 290 maprow *row;
292 291
293 for (y = y0; y < y0 + h; y++) 292 for (y = y0; y < y0 + h; y++)
350 n |= n >> 16; 349 n |= n >> 16;
351 350
352 return n + 1; 351 return n + 1;
353} 352}
354 353
355MODULE = CFClient PACKAGE = CFClient 354MODULE = CFPlus PACKAGE = CFPlus
356 355
357PROTOTYPES: ENABLE 356PROTOTYPES: ENABLE
358 357
359BOOT: 358BOOT:
360{ 359{
361 HV *stash = gv_stashpv ("CFClient", 1); 360 HV *stash = gv_stashpv ("CFPlus", 1);
362 static const struct { 361 static const struct {
363 const char *name; 362 const char *name;
364 IV iv; 363 IV iv;
365 } *civ, const_iv[] = { 364 } *civ, const_iv[] = {
366# define const_iv(name) { # name, (IV)name } 365# define const_iv(name) { # name, (IV)name }
467 466
468 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 467 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
469 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 468 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
470} 469}
471 470
471int
472in_destruct ()
473 CODE:
474 RETVAL = PL_main_cv == Nullcv;
475 OUTPUT:
476 RETVAL
477
472NV floor (NV x) 478NV floor (NV x)
473 479
474NV ceil (NV x) 480NV ceil (NV x)
475 481
476void 482void
506 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
507 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
508 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
509 515
510 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 516 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
517#if SDL_VERSION_ATLEAST(1,2,10)
518 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
519 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
520#endif
511 521
512 SDL_EnableUNICODE (1); 522 SDL_EnableUNICODE (1);
513 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 523 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
514 524
515 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 525 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
602 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 612 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
603 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 613 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
604 break; 614 break;
605 } 615 }
606 616
607 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 617 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
608 } 618 }
609} 619}
610 620
611int 621int
612Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 622Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
628#endif 638#endif
629 639
630void 640void
631add_font (char *file) 641add_font (char *file)
632 CODE: 642 CODE:
633 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 643 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
634 644
635void 645void
636load_image_inline (SV *image_) 646load_image_inline (SV *image_)
637 ALIAS: 647 ALIAS:
638 load_image_file = 1 648 load_image_file = 1
680 690
681 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 691 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
682 692
683 assert (surface2->pitch == surface2->w * 4); 693 assert (surface2->pitch == surface2->w * 4);
684 694
695 SDL_LockSurface (surface2);
685 EXTEND (SP, 5); 696 EXTEND (SP, 6);
686 PUSHs (sv_2mortal (newSViv (surface2->w))); 697 PUSHs (sv_2mortal (newSViv (surface2->w)));
687 PUSHs (sv_2mortal (newSViv (surface2->h))); 698 PUSHs (sv_2mortal (newSViv (surface2->h)));
688 SDL_LockSurface (surface2);
689 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 699 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
690 SDL_UnlockSurface (surface2);
691 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 700 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
692 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 701 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
693 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 702 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
703 SDL_UnlockSurface (surface2);
694 704
695 SDL_FreeSurface (surface); 705 SDL_FreeSurface (surface);
696 SDL_FreeSurface (surface2); 706 SDL_FreeSurface (surface2);
697} 707}
698 708
741void 751void
742_exit (int retval) 752_exit (int retval)
743 CODE: 753 CODE:
744 _exit (retval); 754 _exit (retval);
745 755
746MODULE = CFClient PACKAGE = CFClient::Font 756MODULE = CFPlus PACKAGE = CFPlus::Font
747 757
748CFClient::Font 758CFPlus::Font
749new_from_file (SV *class, char *path, int id = 0) 759new_from_file (SV *class, char *path, int id = 0)
750 CODE: 760 CODE:
751{ 761{
752 int count; 762 int count;
753 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 763 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
756} 766}
757 OUTPUT: 767 OUTPUT:
758 RETVAL 768 RETVAL
759 769
760void 770void
761DESTROY (CFClient::Font self) 771DESTROY (CFPlus::Font self)
762 CODE: 772 CODE:
763 pango_font_description_free (self); 773 pango_font_description_free (self);
764 774
765void 775void
766make_default (CFClient::Font self) 776make_default (CFPlus::Font self)
767 CODE: 777 CODE:
768 default_font = self; 778 default_font = self;
769 779
770MODULE = CFClient PACKAGE = CFClient::Layout 780MODULE = CFPlus PACKAGE = CFPlus::Layout
771 781
772void 782void
773clear_font_cache () 783reset_glyph_cache ()
774 CODE: 784 CODE:
775 pango_fc_font_map_cache_clear ((PangoFcFontMap *)opengl_fontmap);
776 tc_clear (); 785 tc_clear ();
777 786
778CFClient::Layout 787CFPlus::Layout
779new (SV *class, int type = 0) 788new (SV *class)
780 CODE: 789 CODE:
781 New (0, RETVAL, 1, struct cf_layout); 790 New (0, RETVAL, 1, struct cf_layout);
782 791
783 RETVAL->pl = pango_layout_new (opengl_context); 792 RETVAL->pl = pango_layout_new (opengl_context);
784 RETVAL->r = 1.; 793 RETVAL->r = 1.;
792 layout_update_font (RETVAL); 801 layout_update_font (RETVAL);
793 OUTPUT: 802 OUTPUT:
794 RETVAL 803 RETVAL
795 804
796void 805void
797DESTROY (CFClient::Layout self) 806DESTROY (CFPlus::Layout self)
798 CODE: 807 CODE:
799 g_object_unref (self->pl); 808 g_object_unref (self->pl);
800 Safefree (self); 809 Safefree (self);
801 810
802void 811void
803set_text (CFClient::Layout self, SV *text_) 812set_text (CFPlus::Layout self, SV *text_)
804 CODE: 813 CODE:
805{ 814{
806 STRLEN textlen; 815 STRLEN textlen;
807 char *text = SvPVutf8 (text_, textlen); 816 char *text = SvPVutf8 (text_, textlen);
808 817
809 pango_layout_set_text (self->pl, text, textlen); 818 pango_layout_set_text (self->pl, text, textlen);
810} 819}
811 820
812void 821void
813set_markup (CFClient::Layout self, SV *text_) 822set_markup (CFPlus::Layout self, SV *text_)
814 CODE: 823 CODE:
815{ 824{
816 STRLEN textlen; 825 STRLEN textlen;
817 char *text = SvPVutf8 (text_, textlen); 826 char *text = SvPVutf8 (text_, textlen);
818 827
819 pango_layout_set_markup (self->pl, text, textlen); 828 pango_layout_set_markup (self->pl, text, textlen);
820} 829}
821 830
822void 831void
823set_shapes (CFClient::Layout self, ...) 832set_shapes (CFPlus::Layout self, ...)
824 CODE: 833 CODE:
825{ 834{
826 PangoAttrList *attrs = 0; 835 PangoAttrList *attrs = 0;
827 const char *text = pango_layout_get_text (self->pl); 836 const char *text = pango_layout_get_text (self->pl);
828 const char *pos = text; 837 const char *pos = text;
863 if (attrs) 872 if (attrs)
864 pango_layout_set_attributes (self->pl, attrs); 873 pango_layout_set_attributes (self->pl, attrs);
865} 874}
866 875
867void 876void
868get_shapes (CFClient::Layout self) 877get_shapes (CFPlus::Layout self)
869 PPCODE: 878 PPCODE:
870{ 879{
871 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 880 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
872 881
873 do 882 do
877 if (run && shape_attr_p (run)) 886 if (run && shape_attr_p (run))
878 { 887 {
879 PangoRectangle extents; 888 PangoRectangle extents;
880 pango_layout_iter_get_run_extents (iter, 0, &extents); 889 pango_layout_iter_get_run_extents (iter, 0, &extents);
881 890
891 EXTEND (SP, 2);
882 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); 892 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x))));
883 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); 893 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y))));
884 } 894 }
885 } 895 }
886 while (pango_layout_iter_next_run (iter)); 896 while (pango_layout_iter_next_run (iter));
887 897
888 pango_layout_iter_free (iter); 898 pango_layout_iter_free (iter);
889} 899}
890 900
891int 901int
892has_wrapped (CFClient::Layout self) 902has_wrapped (CFPlus::Layout self)
893 CODE: 903 CODE:
894{ 904{
895 int lines = 1; 905 int lines = 1;
896 const char *text = pango_layout_get_text (self->pl); 906 const char *text = pango_layout_get_text (self->pl);
897 907
902} 912}
903 OUTPUT: 913 OUTPUT:
904 RETVAL 914 RETVAL
905 915
906SV * 916SV *
907get_text (CFClient::Layout self) 917get_text (CFPlus::Layout self)
908 CODE: 918 CODE:
909 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 919 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
910 sv_utf8_decode (RETVAL); 920 sv_utf8_decode (RETVAL);
911 OUTPUT: 921 OUTPUT:
912 RETVAL 922 RETVAL
913 923
914void 924void
915set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 925set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
916 CODE: 926 CODE:
917 self->r = r; 927 self->r = r;
918 self->g = g; 928 self->g = g;
919 self->b = b; 929 self->b = b;
920 self->a = a; 930 self->a = a;
921 931
922void 932void
923set_font (CFClient::Layout self, CFClient::Font font = 0) 933set_font (CFPlus::Layout self, CFPlus::Font font = 0)
924 CODE: 934 CODE:
925 if (self->font != font) 935 if (self->font != font)
926 { 936 {
927 self->font = font; 937 self->font = font;
928 layout_update_font (self); 938 layout_update_font (self);
929 } 939 }
930 940
931void 941void
932set_height (CFClient::Layout self, int base_height) 942set_height (CFPlus::Layout self, int base_height)
933 CODE: 943 CODE:
934 if (self->base_height != base_height) 944 if (self->base_height != base_height)
935 { 945 {
936 self->base_height = base_height; 946 self->base_height = base_height;
937 layout_update_font (self); 947 layout_update_font (self);
938 } 948 }
939 949
940void 950void
941set_width (CFClient::Layout self, int max_width = -1) 951set_width (CFPlus::Layout self, int max_width = -1)
942 CODE: 952 CODE:
943 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 953 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
944 954
945void 955void
946set_indent (CFClient::Layout self, int indent) 956set_indent (CFPlus::Layout self, int indent)
947 CODE: 957 CODE:
948 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 958 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
949 959
950void 960void
951set_spacing (CFClient::Layout self, int spacing) 961set_spacing (CFPlus::Layout self, int spacing)
952 CODE: 962 CODE:
953 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 963 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
954 964
955void 965void
956set_ellipsise (CFClient::Layout self, int ellipsise) 966set_ellipsise (CFPlus::Layout self, int ellipsise)
957 CODE: 967 CODE:
958 pango_layout_set_ellipsize (self->pl, 968 pango_layout_set_ellipsize (self->pl,
959 ellipsise == 1 ? PANGO_ELLIPSIZE_START 969 ellipsise == 1 ? PANGO_ELLIPSIZE_START
960 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 970 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
961 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 971 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
962 : PANGO_ELLIPSIZE_NONE 972 : PANGO_ELLIPSIZE_NONE
963 ); 973 );
964 974
965void 975void
966set_single_paragraph_mode (CFClient::Layout self, int spm) 976set_single_paragraph_mode (CFPlus::Layout self, int spm)
967 CODE: 977 CODE:
968 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 978 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
969 979
970void 980void
971size (CFClient::Layout self) 981size (CFPlus::Layout self)
972 PPCODE: 982 PPCODE:
973{ 983{
974 int w, h; 984 int w, h;
975 985
976 layout_get_pixel_size (self, &w, &h); 986 layout_get_pixel_size (self, &w, &h);
979 PUSHs (sv_2mortal (newSViv (w))); 989 PUSHs (sv_2mortal (newSViv (w)));
980 PUSHs (sv_2mortal (newSViv (h))); 990 PUSHs (sv_2mortal (newSViv (h)));
981} 991}
982 992
983int 993int
984descent (CFClient::Layout self) 994descent (CFPlus::Layout self)
985 CODE: 995 CODE:
986{ 996{
987 PangoRectangle rect; 997 PangoRectangle rect;
988 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 998 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
989 pango_layout_line_get_pixel_extents (line, 0, &rect); 999 pango_layout_line_get_pixel_extents (line, 0, &rect);
991} 1001}
992 OUTPUT: 1002 OUTPUT:
993 RETVAL 1003 RETVAL
994 1004
995int 1005int
996xy_to_index (CFClient::Layout self, int x, int y) 1006xy_to_index (CFPlus::Layout self, int x, int y)
997 CODE: 1007 CODE:
998{ 1008{
999 int index, trailing; 1009 int index, trailing;
1000 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1010 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1001 RETVAL = index; 1011 RETVAL = index;
1002} 1012}
1003 OUTPUT: 1013 OUTPUT:
1004 RETVAL 1014 RETVAL
1005 1015
1006void 1016void
1007cursor_pos (CFClient::Layout self, int index) 1017cursor_pos (CFPlus::Layout self, int index)
1008 PPCODE: 1018 PPCODE:
1009{ 1019{
1010 PangoRectangle strong_pos; 1020 PangoRectangle strong_pos;
1011 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1021 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1012 1022
1015 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1025 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1016 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1026 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1017} 1027}
1018 1028
1019void 1029void
1020render (CFClient::Layout self, float x, float y) 1030render (CFPlus::Layout self, float x, float y, int flags = 0)
1021 PPCODE: 1031 PPCODE:
1022 pango_opengl_render_layout_subpixel ( 1032 pango_opengl_render_layout_subpixel (
1023 self->pl, 1033 self->pl,
1024 x * PANGO_SCALE, y * PANGO_SCALE, 1034 x * PANGO_SCALE, y * PANGO_SCALE,
1025 self->r, self->g, self->b, self->a 1035 self->r, self->g, self->b, self->a,
1036 flags
1026 ); 1037 );
1027 1038
1028MODULE = CFClient PACKAGE = CFClient::Texture 1039MODULE = CFPlus PACKAGE = CFPlus::Texture
1029 1040
1030void 1041void
1031pad2pot (SV *data_, SV *w_, SV *h_) 1042pad2pot (SV *data_, SV *w_, SV *h_)
1032 CODE: 1043 CODE:
1033{ 1044{
1111 glDisable (GL_ALPHA_TEST); 1122 glDisable (GL_ALPHA_TEST);
1112 glDisable (GL_BLEND); 1123 glDisable (GL_BLEND);
1113 } 1124 }
1114} 1125}
1115 1126
1116MODULE = CFClient PACKAGE = CFClient::Map 1127MODULE = CFPlus PACKAGE = CFPlus::Map
1117 1128
1118CFClient::Map 1129CFPlus::Map
1119new (SV *class, int map_width, int map_height) 1130new (SV *class, int map_width, int map_height)
1120 CODE: 1131 CODE:
1121 New (0, RETVAL, 1, struct map); 1132 New (0, RETVAL, 1, struct map);
1122 RETVAL->x = 0; 1133 RETVAL->x = 0;
1123 RETVAL->y = 0; 1134 RETVAL->y = 0;
1133 RETVAL->row = 0; 1144 RETVAL->row = 0;
1134 OUTPUT: 1145 OUTPUT:
1135 RETVAL 1146 RETVAL
1136 1147
1137void 1148void
1138DESTROY (CFClient::Map self) 1149DESTROY (CFPlus::Map self)
1139 CODE: 1150 CODE:
1140{ 1151{
1141 map_clear (self); 1152 map_clear (self);
1142 Safefree (self->face); 1153 Safefree (self->face);
1143 Safefree (self->tex); 1154 Safefree (self->tex);
1144 Safefree (self); 1155 Safefree (self);
1145} 1156}
1146 1157
1147void 1158void
1148clear (CFClient::Map self) 1159clear (CFPlus::Map self)
1149 CODE: 1160 CODE:
1150 map_clear (self); 1161 map_clear (self);
1151 1162
1152void 1163void
1153set_face (CFClient::Map self, int face, int texid) 1164set_face (CFPlus::Map self, int face, int texid)
1154 CODE: 1165 CODE:
1155{ 1166{
1156 while (self->faces <= face) 1167 while (self->faces <= face)
1157 { 1168 {
1158 Append (mapface, self->face, self->faces, self->faces); 1169 Append (mapface, self->face, self->faces, self->faces);
1161 1172
1162 self->face [face] = texid; 1173 self->face [face] = texid;
1163} 1174}
1164 1175
1165void 1176void
1166set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1177set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a)
1167 CODE: 1178 CODE:
1168{ 1179{
1169 while (self->texs <= texid) 1180 while (self->texs <= texid)
1170 { 1181 {
1171 Append (maptex, self->tex, self->texs, self->texs); 1182 Append (maptex, self->tex, self->texs, self->texs);
1195 // from transparent color bleeding and ugly wrapping effects. 1206 // from transparent color bleeding and ugly wrapping effects.
1196 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1207 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1197} 1208}
1198 1209
1199int 1210int
1200ox (CFClient::Map self) 1211ox (CFPlus::Map self)
1201 ALIAS: 1212 ALIAS:
1202 oy = 1 1213 oy = 1
1203 x = 2 1214 x = 2
1204 y = 3 1215 y = 3
1205 w = 4 1216 w = 4
1216 } 1227 }
1217 OUTPUT: 1228 OUTPUT:
1218 RETVAL 1229 RETVAL
1219 1230
1220void 1231void
1221scroll (CFClient::Map self, int dx, int dy) 1232scroll (CFPlus::Map self, int dx, int dy)
1222 CODE: 1233 CODE:
1223{ 1234{
1224 if (dx > 0) 1235 if (dx > 0)
1225 map_blank (self, self->x, self->y, dx - 1, self->h); 1236 map_blank (self, self->x, self->y, dx - 1, self->h);
1226 else if (dx < 0) 1237 else if (dx < 0)
1242 self->y += MAP_EXTEND_Y; 1253 self->y += MAP_EXTEND_Y;
1243 } 1254 }
1244} 1255}
1245 1256
1246void 1257void
1247map1a_update (CFClient::Map self, SV *data_) 1258map1a_update (CFPlus::Map self, SV *data_)
1248 CODE: 1259 CODE:
1249{ 1260{
1250 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1261 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1251 uint8_t *data_end = (uint8_t *)SvEND (data_); 1262 uint8_t *data_end = (uint8_t *)SvEND (data_);
1252 mapcell *cell; 1263 mapcell *cell;
1294 cell->darkness = -1; 1305 cell->darkness = -1;
1295 } 1306 }
1296} 1307}
1297 1308
1298SV * 1309SV *
1299mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1310mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1300 CODE: 1311 CODE:
1301{ 1312{
1302 int x1, x; 1313 int x1, x;
1303 int y1, y; 1314 int y1, y;
1304 int z; 1315 int z;
1354} 1365}
1355 OUTPUT: 1366 OUTPUT:
1356 RETVAL 1367 RETVAL
1357 1368
1358void 1369void
1359draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1370draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1360 CODE: 1371 CODE:
1361{ 1372{
1362 int vx, vy; 1373 int vx, vy;
1363 int x, y, z; 1374 int x, y, z;
1364 int last_name; 1375 int last_name;
1429 glDisable (GL_TEXTURE_2D); 1440 glDisable (GL_TEXTURE_2D);
1430 glDisable (GL_BLEND); 1441 glDisable (GL_BLEND);
1431} 1442}
1432 1443
1433void 1444void
1434draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1445draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1435 CODE: 1446 CODE:
1436{ 1447{
1437 static float color[16][3] = { 1448 static float color[16][3] = {
1438 { 0.00F, 0.00F, 0.00F }, 1449 { 0.00F, 0.00F, 0.00F },
1439 { 1.00F, 1.00F, 1.00F }, 1450 { 1.00F, 1.00F, 1.00F },
1489 glDisable (GL_BLEND); 1500 glDisable (GL_BLEND);
1490 glDisable (GL_TEXTURE_2D); 1501 glDisable (GL_TEXTURE_2D);
1491} 1502}
1492 1503
1493void 1504void
1494fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1505fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1495 PPCODE: 1506 PPCODE:
1496{ 1507{
1497 int vx, vy; 1508 int vx, vy;
1498 int x, y; 1509 int x, y;
1499 int sw4 = (sw + 3) & ~3; 1510 int sw4 = (sw + 3) & ~3;
1528 PUSHs (sv_2mortal (newSViv (sh))); 1539 PUSHs (sv_2mortal (newSViv (sh)));
1529 PUSHs (darkness_sv); 1540 PUSHs (darkness_sv);
1530} 1541}
1531 1542
1532SV * 1543SV *
1533get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1544get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1534 CODE: 1545 CODE:
1535{ 1546{
1536 int x, y, x1, y1; 1547 int x, y, x1, y1;
1537 SV *data_sv = newSV (w * h * 7 + 5); 1548 SV *data_sv = newSV (w * h * 7 + 5);
1538 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1549 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1600} 1611}
1601 OUTPUT: 1612 OUTPUT:
1602 RETVAL 1613 RETVAL
1603 1614
1604void 1615void
1605set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1616set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1606 PPCODE: 1617 PPCODE:
1607{ 1618{
1608 int x, y, z; 1619 int x, y, z;
1609 int w, h; 1620 int w, h;
1610 int x1, y1; 1621 int x1, y1;
1659 } 1670 }
1660 } 1671 }
1661 } 1672 }
1662} 1673}
1663 1674
1664MODULE = CFClient PACKAGE = CFClient::MixChunk 1675MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1665 1676
1666CFClient::MixChunk 1677CFPlus::MixChunk
1667new_from_file (SV *class, char *path) 1678new_from_file (SV *class, char *path)
1668 CODE: 1679 CODE:
1669 RETVAL = Mix_LoadWAV (path); 1680 RETVAL = Mix_LoadWAV (path);
1670 OUTPUT: 1681 OUTPUT:
1671 RETVAL 1682 RETVAL
1672 1683
1673void 1684void
1674DESTROY (CFClient::MixChunk self) 1685DESTROY (CFPlus::MixChunk self)
1675 CODE: 1686 CODE:
1676 Mix_FreeChunk (self); 1687 Mix_FreeChunk (self);
1677 1688
1678int 1689int
1679volume (CFClient::MixChunk self, int volume = -1) 1690volume (CFPlus::MixChunk self, int volume = -1)
1680 CODE: 1691 CODE:
1681 RETVAL = Mix_VolumeChunk (self, volume); 1692 RETVAL = Mix_VolumeChunk (self, volume);
1682 OUTPUT: 1693 OUTPUT:
1683 RETVAL 1694 RETVAL
1684 1695
1685int 1696int
1686play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1697play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1687 CODE: 1698 CODE:
1688 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1699 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1689 OUTPUT: 1700 OUTPUT:
1690 RETVAL 1701 RETVAL
1691 1702
1692MODULE = CFClient PACKAGE = CFClient::MixMusic 1703MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1693 1704
1694int 1705int
1695volume (int volume = -1) 1706volume (int volume = -1)
1696 CODE: 1707 CODE:
1697 RETVAL = Mix_VolumeMusic (volume); 1708 RETVAL = Mix_VolumeMusic (volume);
1698 OUTPUT: 1709 OUTPUT:
1699 RETVAL 1710 RETVAL
1700 1711
1701CFClient::MixMusic 1712CFPlus::MixMusic
1702new_from_file (SV *class, char *path) 1713new_from_file (SV *class, char *path)
1703 CODE: 1714 CODE:
1704 RETVAL = Mix_LoadMUS (path); 1715 RETVAL = Mix_LoadMUS (path);
1705 OUTPUT: 1716 OUTPUT:
1706 RETVAL 1717 RETVAL
1707 1718
1708void 1719void
1709DESTROY (CFClient::MixMusic self) 1720DESTROY (CFPlus::MixMusic self)
1710 CODE: 1721 CODE:
1711 Mix_FreeMusic (self); 1722 Mix_FreeMusic (self);
1712 1723
1713int 1724int
1714play (CFClient::MixMusic self, int loops = -1) 1725play (CFPlus::MixMusic self, int loops = -1)
1715 CODE: 1726 CODE:
1716 RETVAL = Mix_PlayMusic (self, loops); 1727 RETVAL = Mix_PlayMusic (self, loops);
1717 OUTPUT: 1728 OUTPUT:
1718 RETVAL 1729 RETVAL
1719 1730
1720MODULE = CFClient PACKAGE = CFClient::OpenGL 1731MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1721 1732
1722BOOT: 1733BOOT:
1723{ 1734{
1724 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1735 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1725 static const struct { 1736 static const struct {
1726 const char *name; 1737 const char *name;
1727 IV iv; 1738 IV iv;
1728 } *civ, const_iv[] = { 1739 } *civ, const_iv[] = {
1729# define const_iv(name) { # name, (IV)name } 1740# define const_iv(name) { # name, (IV)name }
1911 r *= a; 1922 r *= a;
1912 g *= a; 1923 g *= a;
1913 b *= a; 1924 b *= a;
1914 } 1925 }
1915 // microsoft visual "c" rounds instead of truncating... 1926 // microsoft visual "c" rounds instead of truncating...
1916 glColor4ub (MIN ((int)(r * 256.f), 255), 1927 glColor4f (r, g, b, a);
1917 MIN ((int)(g * 256.f), 255),
1918 MIN ((int)(b * 256.f), 255),
1919 MIN ((int)(a * 256.f), 255));
1920 1928
1921void glInterleavedArrays (int format, int stride, char *data) 1929void glInterleavedArrays (int format, int stride, char *data)
1922 1930
1923void glDrawElements (int mode, int count, int type, char *indices) 1931void glDrawElements (int mode, int count, int type, char *indices)
1924 1932
2001 2009
2002void glEndList () 2010void glEndList ()
2003 2011
2004void glCallList (int list) 2012void glCallList (int list)
2005 2013
2006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines