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.139 by root, Mon Aug 14 03:04:17 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{
149 PangoRectangle rect;
150
151 // get_pixel_* wrongly rounds down
150 pango_layout_get_pixel_size (self->pl, w, h); 152 pango_layout_get_extents (self->pl, 0, &rect);
151 153
152 if (!*w) *w = 1; 154 rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE;
153 if (!*h) *h = 1; 155 rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE;
154 156
155 *w = (*w + 3) & ~3; 157 if (!rect.width) rect.width = 1;
158 if (!rect.height) rect.height = 1;
159
160 rect.width = (rect.width + 3) & ~3;
161
162 *w = rect.width;
163 *h = rect.height;
156} 164}
157 165
158typedef uint16_t mapface; 166typedef uint16_t mapface;
159 167
160typedef struct { 168typedef struct {
183 int texs; 191 int texs;
184 maptex *tex; 192 maptex *tex;
185 193
186 int32_t rows; 194 int32_t rows;
187 maprow *row; 195 maprow *row;
188} *CFClient__Map; 196} *CFPlus__Map;
189 197
190static char * 198static char *
191prepend (char *ptr, int sze, int inc) 199prepend (char *ptr, int sze, int inc)
192{ 200{
193 char *p; 201 char *p;
211 219
212#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 220#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)) 221#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
214 222
215static maprow * 223static maprow *
216map_get_row (CFClient__Map self, int y) 224map_get_row (CFPlus__Map self, int y)
217{ 225{
218 if (0 > y) 226 if (0 > y)
219 { 227 {
220 int extend = - y + MAP_EXTEND_Y; 228 int extend = - y + MAP_EXTEND_Y;
221 Prepend (maprow, self->row, self->rows, extend); 229 Prepend (maprow, self->row, self->rows, extend);
259 267
260 return row->col + (x - row->c0); 268 return row->col + (x - row->c0);
261} 269}
262 270
263static mapcell * 271static mapcell *
264map_get_cell (CFClient__Map self, int x, int y) 272map_get_cell (CFPlus__Map self, int x, int y)
265{ 273{
266 return row_get_cell (map_get_row (self, y), x); 274 return row_get_cell (map_get_row (self, y), x);
267} 275}
268 276
269static void 277static void
270map_clear (CFClient__Map self) 278map_clear (CFPlus__Map self)
271{ 279{
272 int r; 280 int r;
273 281
274 for (r = 0; r < self->rows; r++) 282 for (r = 0; r < self->rows; r++)
275 Safefree (self->row[r].col); 283 Safefree (self->row[r].col);
283 self->row = 0; 291 self->row = 0;
284 self->rows = 0; 292 self->rows = 0;
285} 293}
286 294
287static void 295static void
288map_blank (CFClient__Map self, int x0, int y0, int w, int h) 296map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
289{ 297{
290 int x, y; 298 int x, y;
291 maprow *row; 299 maprow *row;
292 300
293 for (y = y0; y < y0 + h; y++) 301 for (y = y0; y < y0 + h; y++)
350 n |= n >> 16; 358 n |= n >> 16;
351 359
352 return n + 1; 360 return n + 1;
353} 361}
354 362
355MODULE = CFClient PACKAGE = CFClient 363MODULE = CFPlus PACKAGE = CFPlus
356 364
357PROTOTYPES: ENABLE 365PROTOTYPES: ENABLE
358 366
359BOOT: 367BOOT:
360{ 368{
361 HV *stash = gv_stashpv ("CFClient", 1); 369 HV *stash = gv_stashpv ("CFPlus", 1);
362 static const struct { 370 static const struct {
363 const char *name; 371 const char *name;
364 IV iv; 372 IV iv;
365 } *civ, const_iv[] = { 373 } *civ, const_iv[] = {
366# define const_iv(name) { # name, (IV)name } 374# define const_iv(name) { # name, (IV)name }
467 475
468 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 476 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
469 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 477 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
470} 478}
471 479
480int
481in_destruct ()
482 CODE:
483 RETVAL = PL_main_cv == Nullcv;
484 OUTPUT:
485 RETVAL
486
472NV floor (NV x) 487NV floor (NV x)
473 488
474NV ceil (NV x) 489NV ceil (NV x)
475 490
476void 491void
506 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 521 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
507 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 522 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
508 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 523 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
509 524
510 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 525 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
526#if SDL_VERSION_ATLEAST(1,2,10)
527 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
528 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
529#endif
511 530
512 SDL_EnableUNICODE (1); 531 SDL_EnableUNICODE (1);
513 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 532 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
514 533
515 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 534 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
602 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 621 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
603 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 622 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
604 break; 623 break;
605 } 624 }
606 625
607 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 626 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
608 } 627 }
609} 628}
610 629
611int 630int
612Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 631Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
628#endif 647#endif
629 648
630void 649void
631add_font (char *file) 650add_font (char *file)
632 CODE: 651 CODE:
633 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 652 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
634 653
635void 654void
636load_image_inline (SV *image_) 655load_image_inline (SV *image_)
637 ALIAS: 656 ALIAS:
638 load_image_file = 1 657 load_image_file = 1
680 699
681 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 700 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
682 701
683 assert (surface2->pitch == surface2->w * 4); 702 assert (surface2->pitch == surface2->w * 4);
684 703
704 SDL_LockSurface (surface2);
685 EXTEND (SP, 5); 705 EXTEND (SP, 6);
686 PUSHs (sv_2mortal (newSViv (surface2->w))); 706 PUSHs (sv_2mortal (newSViv (surface2->w)));
687 PUSHs (sv_2mortal (newSViv (surface2->h))); 707 PUSHs (sv_2mortal (newSViv (surface2->h)));
688 SDL_LockSurface (surface2);
689 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 708 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))); 709 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
692 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 710 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
693 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 711 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
712 SDL_UnlockSurface (surface2);
694 713
695 SDL_FreeSurface (surface); 714 SDL_FreeSurface (surface);
696 SDL_FreeSurface (surface2); 715 SDL_FreeSurface (surface2);
697} 716}
698 717
741void 760void
742_exit (int retval) 761_exit (int retval)
743 CODE: 762 CODE:
744 _exit (retval); 763 _exit (retval);
745 764
746MODULE = CFClient PACKAGE = CFClient::Font 765MODULE = CFPlus PACKAGE = CFPlus::Font
747 766
748CFClient::Font 767CFPlus::Font
749new_from_file (SV *class, char *path, int id = 0) 768new_from_file (SV *class, char *path, int id = 0)
750 CODE: 769 CODE:
751{ 770{
752 int count; 771 int count;
753 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 772 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
756} 775}
757 OUTPUT: 776 OUTPUT:
758 RETVAL 777 RETVAL
759 778
760void 779void
761DESTROY (CFClient::Font self) 780DESTROY (CFPlus::Font self)
762 CODE: 781 CODE:
763 pango_font_description_free (self); 782 pango_font_description_free (self);
764 783
765void 784void
766make_default (CFClient::Font self) 785make_default (CFPlus::Font self)
767 CODE: 786 CODE:
768 default_font = self; 787 default_font = self;
769 788
770MODULE = CFClient PACKAGE = CFClient::Layout 789MODULE = CFPlus PACKAGE = CFPlus::Layout
771 790
772void 791void
773clear_font_cache () 792reset_glyph_cache ()
774 CODE: 793 CODE:
775 pango_fc_font_map_cache_clear ((PangoFcFontMap *)opengl_fontmap);
776 tc_clear (); 794 tc_clear ();
777 795
778CFClient::Layout 796CFPlus::Layout
779new (SV *class, int type = 0) 797new (SV *class)
780 CODE: 798 CODE:
781 New (0, RETVAL, 1, struct cf_layout); 799 New (0, RETVAL, 1, struct cf_layout);
782 800
783 RETVAL->pl = pango_layout_new (opengl_context); 801 RETVAL->pl = pango_layout_new (opengl_context);
784 RETVAL->r = 1.; 802 RETVAL->r = 1.;
792 layout_update_font (RETVAL); 810 layout_update_font (RETVAL);
793 OUTPUT: 811 OUTPUT:
794 RETVAL 812 RETVAL
795 813
796void 814void
797DESTROY (CFClient::Layout self) 815DESTROY (CFPlus::Layout self)
798 CODE: 816 CODE:
799 g_object_unref (self->pl); 817 g_object_unref (self->pl);
800 Safefree (self); 818 Safefree (self);
801 819
802void 820void
803set_text (CFClient::Layout self, SV *text_) 821set_text (CFPlus::Layout self, SV *text_)
804 CODE: 822 CODE:
805{ 823{
806 STRLEN textlen; 824 STRLEN textlen;
807 char *text = SvPVutf8 (text_, textlen); 825 char *text = SvPVutf8 (text_, textlen);
808 826
809 pango_layout_set_text (self->pl, text, textlen); 827 pango_layout_set_text (self->pl, text, textlen);
810} 828}
811 829
812void 830void
813set_markup (CFClient::Layout self, SV *text_) 831set_markup (CFPlus::Layout self, SV *text_)
814 CODE: 832 CODE:
815{ 833{
816 STRLEN textlen; 834 STRLEN textlen;
817 char *text = SvPVutf8 (text_, textlen); 835 char *text = SvPVutf8 (text_, textlen);
818 836
819 pango_layout_set_markup (self->pl, text, textlen); 837 pango_layout_set_markup (self->pl, text, textlen);
820} 838}
821 839
822void 840void
823set_shapes (CFClient::Layout self, ...) 841set_shapes (CFPlus::Layout self, ...)
824 CODE: 842 CODE:
825{ 843{
826 PangoAttrList *attrs = 0; 844 PangoAttrList *attrs = 0;
827 const char *text = pango_layout_get_text (self->pl); 845 const char *text = pango_layout_get_text (self->pl);
828 const char *pos = text; 846 const char *pos = text;
863 if (attrs) 881 if (attrs)
864 pango_layout_set_attributes (self->pl, attrs); 882 pango_layout_set_attributes (self->pl, attrs);
865} 883}
866 884
867void 885void
868get_shapes (CFClient::Layout self) 886get_shapes (CFPlus::Layout self)
869 PPCODE: 887 PPCODE:
870{ 888{
871 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 889 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
872 890
873 do 891 do
877 if (run && shape_attr_p (run)) 895 if (run && shape_attr_p (run))
878 { 896 {
879 PangoRectangle extents; 897 PangoRectangle extents;
880 pango_layout_iter_get_run_extents (iter, 0, &extents); 898 pango_layout_iter_get_run_extents (iter, 0, &extents);
881 899
900 EXTEND (SP, 2);
882 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); 901 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x))));
883 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); 902 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y))));
884 } 903 }
885 } 904 }
886 while (pango_layout_iter_next_run (iter)); 905 while (pango_layout_iter_next_run (iter));
887 906
888 pango_layout_iter_free (iter); 907 pango_layout_iter_free (iter);
889} 908}
890 909
891int 910int
892has_wrapped (CFClient::Layout self) 911has_wrapped (CFPlus::Layout self)
893 CODE: 912 CODE:
894{ 913{
895 int lines = 1; 914 int lines = 1;
896 const char *text = pango_layout_get_text (self->pl); 915 const char *text = pango_layout_get_text (self->pl);
897 916
902} 921}
903 OUTPUT: 922 OUTPUT:
904 RETVAL 923 RETVAL
905 924
906SV * 925SV *
907get_text (CFClient::Layout self) 926get_text (CFPlus::Layout self)
908 CODE: 927 CODE:
909 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 928 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
910 sv_utf8_decode (RETVAL); 929 sv_utf8_decode (RETVAL);
911 OUTPUT: 930 OUTPUT:
912 RETVAL 931 RETVAL
913 932
914void 933void
915set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 934set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
916 CODE: 935 CODE:
917 self->r = r; 936 self->r = r;
918 self->g = g; 937 self->g = g;
919 self->b = b; 938 self->b = b;
920 self->a = a; 939 self->a = a;
921 940
922void 941void
923set_font (CFClient::Layout self, CFClient::Font font = 0) 942set_font (CFPlus::Layout self, CFPlus::Font font = 0)
924 CODE: 943 CODE:
925 if (self->font != font) 944 if (self->font != font)
926 { 945 {
927 self->font = font; 946 self->font = font;
928 layout_update_font (self); 947 layout_update_font (self);
929 } 948 }
930 949
931void 950void
932set_height (CFClient::Layout self, int base_height) 951set_height (CFPlus::Layout self, int base_height)
933 CODE: 952 CODE:
934 if (self->base_height != base_height) 953 if (self->base_height != base_height)
935 { 954 {
936 self->base_height = base_height; 955 self->base_height = base_height;
937 layout_update_font (self); 956 layout_update_font (self);
938 } 957 }
939 958
940void 959void
941set_width (CFClient::Layout self, int max_width = -1) 960set_width (CFPlus::Layout self, int max_width = -1)
942 CODE: 961 CODE:
943 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 962 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
944 963
945void 964void
946set_indent (CFClient::Layout self, int indent) 965set_indent (CFPlus::Layout self, int indent)
947 CODE: 966 CODE:
948 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 967 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
949 968
950void 969void
951set_spacing (CFClient::Layout self, int spacing) 970set_spacing (CFPlus::Layout self, int spacing)
952 CODE: 971 CODE:
953 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 972 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
954 973
955void 974void
956set_ellipsise (CFClient::Layout self, int ellipsise) 975set_ellipsise (CFPlus::Layout self, int ellipsise)
957 CODE: 976 CODE:
958 pango_layout_set_ellipsize (self->pl, 977 pango_layout_set_ellipsize (self->pl,
959 ellipsise == 1 ? PANGO_ELLIPSIZE_START 978 ellipsise == 1 ? PANGO_ELLIPSIZE_START
960 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 979 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
961 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 980 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
962 : PANGO_ELLIPSIZE_NONE 981 : PANGO_ELLIPSIZE_NONE
963 ); 982 );
964 983
965void 984void
966set_single_paragraph_mode (CFClient::Layout self, int spm) 985set_single_paragraph_mode (CFPlus::Layout self, int spm)
967 CODE: 986 CODE:
968 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 987 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
969 988
970void 989void
971size (CFClient::Layout self) 990size (CFPlus::Layout self)
972 PPCODE: 991 PPCODE:
973{ 992{
974 int w, h; 993 int w, h;
975 994
976 layout_get_pixel_size (self, &w, &h); 995 layout_get_pixel_size (self, &w, &h);
979 PUSHs (sv_2mortal (newSViv (w))); 998 PUSHs (sv_2mortal (newSViv (w)));
980 PUSHs (sv_2mortal (newSViv (h))); 999 PUSHs (sv_2mortal (newSViv (h)));
981} 1000}
982 1001
983int 1002int
984descent (CFClient::Layout self) 1003descent (CFPlus::Layout self)
985 CODE: 1004 CODE:
986{ 1005{
987 PangoRectangle rect; 1006 PangoRectangle rect;
988 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1007 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
989 pango_layout_line_get_pixel_extents (line, 0, &rect); 1008 pango_layout_line_get_pixel_extents (line, 0, &rect);
991} 1010}
992 OUTPUT: 1011 OUTPUT:
993 RETVAL 1012 RETVAL
994 1013
995int 1014int
996xy_to_index (CFClient::Layout self, int x, int y) 1015xy_to_index (CFPlus::Layout self, int x, int y)
997 CODE: 1016 CODE:
998{ 1017{
999 int index, trailing; 1018 int index, trailing;
1000 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1019 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1001 RETVAL = index; 1020 RETVAL = index;
1002} 1021}
1003 OUTPUT: 1022 OUTPUT:
1004 RETVAL 1023 RETVAL
1005 1024
1006void 1025void
1007cursor_pos (CFClient::Layout self, int index) 1026cursor_pos (CFPlus::Layout self, int index)
1008 PPCODE: 1027 PPCODE:
1009{ 1028{
1010 PangoRectangle strong_pos; 1029 PangoRectangle strong_pos;
1011 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1030 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1012 1031
1015 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1034 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1016 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1035 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1017} 1036}
1018 1037
1019void 1038void
1020render (CFClient::Layout self, float x, float y) 1039render (CFPlus::Layout self, float x, float y, int flags = 0)
1021 PPCODE: 1040 PPCODE:
1022 pango_opengl_render_layout_subpixel ( 1041 pango_opengl_render_layout_subpixel (
1023 self->pl, 1042 self->pl,
1024 x * PANGO_SCALE, y * PANGO_SCALE, 1043 x * PANGO_SCALE, y * PANGO_SCALE,
1025 self->r, self->g, self->b, self->a 1044 self->r, self->g, self->b, self->a,
1045 flags
1026 ); 1046 );
1027 1047
1028MODULE = CFClient PACKAGE = CFClient::Texture 1048MODULE = CFPlus PACKAGE = CFPlus::Texture
1029 1049
1030void 1050void
1031pad2pot (SV *data_, SV *w_, SV *h_) 1051pad2pot (SV *data_, SV *w_, SV *h_)
1032 CODE: 1052 CODE:
1033{ 1053{
1111 glDisable (GL_ALPHA_TEST); 1131 glDisable (GL_ALPHA_TEST);
1112 glDisable (GL_BLEND); 1132 glDisable (GL_BLEND);
1113 } 1133 }
1114} 1134}
1115 1135
1116MODULE = CFClient PACKAGE = CFClient::Map 1136MODULE = CFPlus PACKAGE = CFPlus::Map
1117 1137
1118CFClient::Map 1138CFPlus::Map
1119new (SV *class, int map_width, int map_height) 1139new (SV *class, int map_width, int map_height)
1120 CODE: 1140 CODE:
1121 New (0, RETVAL, 1, struct map); 1141 New (0, RETVAL, 1, struct map);
1122 RETVAL->x = 0; 1142 RETVAL->x = 0;
1123 RETVAL->y = 0; 1143 RETVAL->y = 0;
1133 RETVAL->row = 0; 1153 RETVAL->row = 0;
1134 OUTPUT: 1154 OUTPUT:
1135 RETVAL 1155 RETVAL
1136 1156
1137void 1157void
1138DESTROY (CFClient::Map self) 1158DESTROY (CFPlus::Map self)
1139 CODE: 1159 CODE:
1140{ 1160{
1141 map_clear (self); 1161 map_clear (self);
1142 Safefree (self->face); 1162 Safefree (self->face);
1143 Safefree (self->tex); 1163 Safefree (self->tex);
1144 Safefree (self); 1164 Safefree (self);
1145} 1165}
1146 1166
1147void 1167void
1148clear (CFClient::Map self) 1168clear (CFPlus::Map self)
1149 CODE: 1169 CODE:
1150 map_clear (self); 1170 map_clear (self);
1151 1171
1152void 1172void
1153set_face (CFClient::Map self, int face, int texid) 1173set_face (CFPlus::Map self, int face, int texid)
1154 CODE: 1174 CODE:
1155{ 1175{
1156 while (self->faces <= face) 1176 while (self->faces <= face)
1157 { 1177 {
1158 Append (mapface, self->face, self->faces, self->faces); 1178 Append (mapface, self->face, self->faces, self->faces);
1161 1181
1162 self->face [face] = texid; 1182 self->face [face] = texid;
1163} 1183}
1164 1184
1165void 1185void
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) 1186set_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: 1187 CODE:
1168{ 1188{
1169 while (self->texs <= texid) 1189 while (self->texs <= texid)
1170 { 1190 {
1171 Append (maptex, self->tex, self->texs, self->texs); 1191 Append (maptex, self->tex, self->texs, self->texs);
1195 // from transparent color bleeding and ugly wrapping effects. 1215 // from transparent color bleeding and ugly wrapping effects.
1196 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1216 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1197} 1217}
1198 1218
1199int 1219int
1200ox (CFClient::Map self) 1220ox (CFPlus::Map self)
1201 ALIAS: 1221 ALIAS:
1202 oy = 1 1222 oy = 1
1203 x = 2 1223 x = 2
1204 y = 3 1224 y = 3
1205 w = 4 1225 w = 4
1216 } 1236 }
1217 OUTPUT: 1237 OUTPUT:
1218 RETVAL 1238 RETVAL
1219 1239
1220void 1240void
1221scroll (CFClient::Map self, int dx, int dy) 1241scroll (CFPlus::Map self, int dx, int dy)
1222 CODE: 1242 CODE:
1223{ 1243{
1224 if (dx > 0) 1244 if (dx > 0)
1225 map_blank (self, self->x, self->y, dx - 1, self->h); 1245 map_blank (self, self->x, self->y, dx - 1, self->h);
1226 else if (dx < 0) 1246 else if (dx < 0)
1242 self->y += MAP_EXTEND_Y; 1262 self->y += MAP_EXTEND_Y;
1243 } 1263 }
1244} 1264}
1245 1265
1246void 1266void
1247map1a_update (CFClient::Map self, SV *data_) 1267map1a_update (CFPlus::Map self, SV *data_)
1248 CODE: 1268 CODE:
1249{ 1269{
1250 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1270 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1251 uint8_t *data_end = (uint8_t *)SvEND (data_); 1271 uint8_t *data_end = (uint8_t *)SvEND (data_);
1252 mapcell *cell; 1272 mapcell *cell;
1294 cell->darkness = -1; 1314 cell->darkness = -1;
1295 } 1315 }
1296} 1316}
1297 1317
1298SV * 1318SV *
1299mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1319mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1300 CODE: 1320 CODE:
1301{ 1321{
1302 int x1, x; 1322 int x1, x;
1303 int y1, y; 1323 int y1, y;
1304 int z; 1324 int z;
1354} 1374}
1355 OUTPUT: 1375 OUTPUT:
1356 RETVAL 1376 RETVAL
1357 1377
1358void 1378void
1359draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1379draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1360 CODE: 1380 CODE:
1361{ 1381{
1362 int vx, vy; 1382 int vx, vy;
1363 int x, y, z; 1383 int x, y, z;
1364 int last_name; 1384 int last_name;
1429 glDisable (GL_TEXTURE_2D); 1449 glDisable (GL_TEXTURE_2D);
1430 glDisable (GL_BLEND); 1450 glDisable (GL_BLEND);
1431} 1451}
1432 1452
1433void 1453void
1434draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1454draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1435 CODE: 1455 CODE:
1436{ 1456{
1437 static float color[16][3] = { 1457 static float color[16][3] = {
1438 { 0.00F, 0.00F, 0.00F }, 1458 { 0.00F, 0.00F, 0.00F },
1439 { 1.00F, 1.00F, 1.00F }, 1459 { 1.00F, 1.00F, 1.00F },
1489 glDisable (GL_BLEND); 1509 glDisable (GL_BLEND);
1490 glDisable (GL_TEXTURE_2D); 1510 glDisable (GL_TEXTURE_2D);
1491} 1511}
1492 1512
1493void 1513void
1494fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1514fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1495 PPCODE: 1515 PPCODE:
1496{ 1516{
1497 int vx, vy; 1517 int vx, vy;
1498 int x, y; 1518 int x, y;
1499 int sw4 = (sw + 3) & ~3; 1519 int sw4 = (sw + 3) & ~3;
1528 PUSHs (sv_2mortal (newSViv (sh))); 1548 PUSHs (sv_2mortal (newSViv (sh)));
1529 PUSHs (darkness_sv); 1549 PUSHs (darkness_sv);
1530} 1550}
1531 1551
1532SV * 1552SV *
1533get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1553get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1534 CODE: 1554 CODE:
1535{ 1555{
1536 int x, y, x1, y1; 1556 int x, y, x1, y1;
1537 SV *data_sv = newSV (w * h * 7 + 5); 1557 SV *data_sv = newSV (w * h * 7 + 5);
1538 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1558 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1600} 1620}
1601 OUTPUT: 1621 OUTPUT:
1602 RETVAL 1622 RETVAL
1603 1623
1604void 1624void
1605set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1625set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1606 PPCODE: 1626 PPCODE:
1607{ 1627{
1608 int x, y, z; 1628 int x, y, z;
1609 int w, h; 1629 int w, h;
1610 int x1, y1; 1630 int x1, y1;
1659 } 1679 }
1660 } 1680 }
1661 } 1681 }
1662} 1682}
1663 1683
1664MODULE = CFClient PACKAGE = CFClient::MixChunk 1684MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1665 1685
1666CFClient::MixChunk 1686CFPlus::MixChunk
1667new_from_file (SV *class, char *path) 1687new_from_file (SV *class, char *path)
1668 CODE: 1688 CODE:
1669 RETVAL = Mix_LoadWAV (path); 1689 RETVAL = Mix_LoadWAV (path);
1670 OUTPUT: 1690 OUTPUT:
1671 RETVAL 1691 RETVAL
1672 1692
1673void 1693void
1674DESTROY (CFClient::MixChunk self) 1694DESTROY (CFPlus::MixChunk self)
1675 CODE: 1695 CODE:
1676 Mix_FreeChunk (self); 1696 Mix_FreeChunk (self);
1677 1697
1678int 1698int
1679volume (CFClient::MixChunk self, int volume = -1) 1699volume (CFPlus::MixChunk self, int volume = -1)
1680 CODE: 1700 CODE:
1681 RETVAL = Mix_VolumeChunk (self, volume); 1701 RETVAL = Mix_VolumeChunk (self, volume);
1682 OUTPUT: 1702 OUTPUT:
1683 RETVAL 1703 RETVAL
1684 1704
1685int 1705int
1686play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1706play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1687 CODE: 1707 CODE:
1688 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1708 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1689 OUTPUT: 1709 OUTPUT:
1690 RETVAL 1710 RETVAL
1691 1711
1692MODULE = CFClient PACKAGE = CFClient::MixMusic 1712MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1693 1713
1694int 1714int
1695volume (int volume = -1) 1715volume (int volume = -1)
1696 CODE: 1716 CODE:
1697 RETVAL = Mix_VolumeMusic (volume); 1717 RETVAL = Mix_VolumeMusic (volume);
1698 OUTPUT: 1718 OUTPUT:
1699 RETVAL 1719 RETVAL
1700 1720
1701CFClient::MixMusic 1721CFPlus::MixMusic
1702new_from_file (SV *class, char *path) 1722new_from_file (SV *class, char *path)
1703 CODE: 1723 CODE:
1704 RETVAL = Mix_LoadMUS (path); 1724 RETVAL = Mix_LoadMUS (path);
1705 OUTPUT: 1725 OUTPUT:
1706 RETVAL 1726 RETVAL
1707 1727
1708void 1728void
1709DESTROY (CFClient::MixMusic self) 1729DESTROY (CFPlus::MixMusic self)
1710 CODE: 1730 CODE:
1711 Mix_FreeMusic (self); 1731 Mix_FreeMusic (self);
1712 1732
1713int 1733int
1714play (CFClient::MixMusic self, int loops = -1) 1734play (CFPlus::MixMusic self, int loops = -1)
1715 CODE: 1735 CODE:
1716 RETVAL = Mix_PlayMusic (self, loops); 1736 RETVAL = Mix_PlayMusic (self, loops);
1717 OUTPUT: 1737 OUTPUT:
1718 RETVAL 1738 RETVAL
1719 1739
1720MODULE = CFClient PACKAGE = CFClient::OpenGL 1740MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1721 1741
1722BOOT: 1742BOOT:
1723{ 1743{
1724 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1744 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1725 static const struct { 1745 static const struct {
1726 const char *name; 1746 const char *name;
1727 IV iv; 1747 IV iv;
1728 } *civ, const_iv[] = { 1748 } *civ, const_iv[] = {
1729# define const_iv(name) { # name, (IV)name } 1749# define const_iv(name) { # name, (IV)name }
1792 const_iv (GL_SEPARABLE_2D), 1812 const_iv (GL_SEPARABLE_2D),
1793 const_iv (GL_CONVOLUTION_2D), 1813 const_iv (GL_CONVOLUTION_2D),
1794 const_iv (GL_CONVOLUTION_BORDER_MODE), 1814 const_iv (GL_CONVOLUTION_BORDER_MODE),
1795 const_iv (GL_CONSTANT_BORDER), 1815 const_iv (GL_CONSTANT_BORDER),
1796 const_iv (GL_LINES), 1816 const_iv (GL_LINES),
1817 const_iv (GL_LINE_STRIP),
1797 const_iv (GL_LINE_LOOP), 1818 const_iv (GL_LINE_LOOP),
1798 const_iv (GL_QUADS), 1819 const_iv (GL_QUADS),
1799 const_iv (GL_QUAD_STRIP), 1820 const_iv (GL_QUAD_STRIP),
1800 const_iv (GL_TRIANGLES), 1821 const_iv (GL_TRIANGLES),
1801 const_iv (GL_TRIANGLE_STRIP), 1822 const_iv (GL_TRIANGLE_STRIP),
1911 r *= a; 1932 r *= a;
1912 g *= a; 1933 g *= a;
1913 b *= a; 1934 b *= a;
1914 } 1935 }
1915 // microsoft visual "c" rounds instead of truncating... 1936 // microsoft visual "c" rounds instead of truncating...
1916 glColor4ub (MIN ((int)(r * 256.f), 255), 1937 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 1938
1921void glInterleavedArrays (int format, int stride, char *data) 1939void glInterleavedArrays (int format, int stride, char *data)
1922 1940
1923void glDrawElements (int mode, int count, int type, char *indices) 1941void glDrawElements (int mode, int count, int type, char *indices)
1924 1942
2001 2019
2002void glEndList () 2020void glEndList ()
2003 2021
2004void glCallList (int list) 2022void glCallList (int list)
2005 2023
2006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines