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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines