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.134 by root, Fri Aug 4 16:49:58 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{
146 pango_layout_get_pixel_size (self->pl, w, h); 149 pango_layout_get_pixel_size (self->pl, w, h);
147 150
148 if (!*w) *w = 1; 151 if (!*w) *w = 1;
149 if (!*h) *h = 1; 152 if (!*h) *h = 1;
179 int texs; 182 int texs;
180 maptex *tex; 183 maptex *tex;
181 184
182 int32_t rows; 185 int32_t rows;
183 maprow *row; 186 maprow *row;
184} *CFClient__Map; 187} *CFPlus__Map;
185 188
186static char * 189static char *
187prepend (char *ptr, int sze, int inc) 190prepend (char *ptr, int sze, int inc)
188{ 191{
189 char *p; 192 char *p;
207 210
208#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))
209#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))
210 213
211static maprow * 214static maprow *
212map_get_row (CFClient__Map self, int y) 215map_get_row (CFPlus__Map self, int y)
213{ 216{
214 if (0 > y) 217 if (0 > y)
215 { 218 {
216 int extend = - y + MAP_EXTEND_Y; 219 int extend = - y + MAP_EXTEND_Y;
217 Prepend (maprow, self->row, self->rows, extend); 220 Prepend (maprow, self->row, self->rows, extend);
255 258
256 return row->col + (x - row->c0); 259 return row->col + (x - row->c0);
257} 260}
258 261
259static mapcell * 262static mapcell *
260map_get_cell (CFClient__Map self, int x, int y) 263map_get_cell (CFPlus__Map self, int x, int y)
261{ 264{
262 return row_get_cell (map_get_row (self, y), x); 265 return row_get_cell (map_get_row (self, y), x);
263} 266}
264 267
265static void 268static void
266map_clear (CFClient__Map self) 269map_clear (CFPlus__Map self)
267{ 270{
268 int r; 271 int r;
269 272
270 for (r = 0; r < self->rows; r++) 273 for (r = 0; r < self->rows; r++)
271 Safefree (self->row[r].col); 274 Safefree (self->row[r].col);
279 self->row = 0; 282 self->row = 0;
280 self->rows = 0; 283 self->rows = 0;
281} 284}
282 285
283static void 286static void
284map_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)
285{ 288{
286 int x, y; 289 int x, y;
287 maprow *row; 290 maprow *row;
288 291
289 for (y = y0; y < y0 + h; y++) 292 for (y = y0; y < y0 + h; y++)
346 n |= n >> 16; 349 n |= n >> 16;
347 350
348 return n + 1; 351 return n + 1;
349} 352}
350 353
351MODULE = CFClient PACKAGE = CFClient 354MODULE = CFPlus PACKAGE = CFPlus
352 355
353PROTOTYPES: ENABLE 356PROTOTYPES: ENABLE
354 357
355BOOT: 358BOOT:
356{ 359{
357 HV *stash = gv_stashpv ("CFClient", 1); 360 HV *stash = gv_stashpv ("CFPlus", 1);
358 static const struct { 361 static const struct {
359 const char *name; 362 const char *name;
360 IV iv; 363 IV iv;
361 } *civ, const_iv[] = { 364 } *civ, const_iv[] = {
362# define const_iv(name) { # name, (IV)name } 365# define const_iv(name) { # name, (IV)name }
463 466
464 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; )
465 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 468 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
466} 469}
467 470
471int
472in_destruct ()
473 CODE:
474 RETVAL = PL_main_cv == Nullcv;
475 OUTPUT:
476 RETVAL
477
468NV floor (NV x) 478NV floor (NV x)
469 479
470NV ceil (NV x) 480NV ceil (NV x)
471 481
472void 482void
502 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
503 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
504 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
505 515
506 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
507 521
508 SDL_EnableUNICODE (1); 522 SDL_EnableUNICODE (1);
509 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 523 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
510 524
511 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 525 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
598 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 612 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
599 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 613 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
600 break; 614 break;
601 } 615 }
602 616
603 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 617 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
604 } 618 }
605} 619}
606 620
607int 621int
608Mix_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)
624#endif 638#endif
625 639
626void 640void
627add_font (char *file) 641add_font (char *file)
628 CODE: 642 CODE:
629 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 643 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
630 644
631void 645void
632load_image_inline (SV *image_) 646load_image_inline (SV *image_)
633 ALIAS: 647 ALIAS:
634 load_image_file = 1 648 load_image_file = 1
676 690
677 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 691 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
678 692
679 assert (surface2->pitch == surface2->w * 4); 693 assert (surface2->pitch == surface2->w * 4);
680 694
695 SDL_LockSurface (surface2);
681 EXTEND (SP, 5); 696 EXTEND (SP, 6);
682 PUSHs (sv_2mortal (newSViv (surface2->w))); 697 PUSHs (sv_2mortal (newSViv (surface2->w)));
683 PUSHs (sv_2mortal (newSViv (surface2->h))); 698 PUSHs (sv_2mortal (newSViv (surface2->h)));
684 SDL_LockSurface (surface2);
685 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 699 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))); 700 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
688 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 701 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
689 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 702 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
703 SDL_UnlockSurface (surface2);
690 704
691 SDL_FreeSurface (surface); 705 SDL_FreeSurface (surface);
692 SDL_FreeSurface (surface2); 706 SDL_FreeSurface (surface2);
693} 707}
694 708
737void 751void
738_exit (int retval) 752_exit (int retval)
739 CODE: 753 CODE:
740 _exit (retval); 754 _exit (retval);
741 755
742MODULE = CFClient PACKAGE = CFClient::Font 756MODULE = CFPlus PACKAGE = CFPlus::Font
743 757
744CFClient::Font 758CFPlus::Font
745new_from_file (SV *class, char *path, int id = 0) 759new_from_file (SV *class, char *path, int id = 0)
746 CODE: 760 CODE:
747{ 761{
748 int count; 762 int count;
749 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 763 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
752} 766}
753 OUTPUT: 767 OUTPUT:
754 RETVAL 768 RETVAL
755 769
756void 770void
757DESTROY (CFClient::Font self) 771DESTROY (CFPlus::Font self)
758 CODE: 772 CODE:
759 pango_font_description_free (self); 773 pango_font_description_free (self);
760 774
761void 775void
762make_default (CFClient::Font self) 776make_default (CFPlus::Font self)
763 CODE: 777 CODE:
764 default_font = self; 778 default_font = self;
765 779
766MODULE = CFClient PACKAGE = CFClient::Layout 780MODULE = CFPlus PACKAGE = CFPlus::Layout
767 781
768void 782void
769clear_font_cache () 783reset_glyph_cache ()
770 CODE: 784 CODE:
771 pango_fc_font_map_cache_clear ((PangoFcFontMap *)opengl_fontmap);
772 tc_clear (); 785 tc_clear ();
773 786
774CFClient::Layout 787CFPlus::Layout
775new (SV *class, int type = 0) 788new (SV *class)
776 CODE: 789 CODE:
777 New (0, RETVAL, 1, struct cf_layout); 790 New (0, RETVAL, 1, struct cf_layout);
778 791
779 RETVAL->pl = pango_layout_new (opengl_context); 792 RETVAL->pl = pango_layout_new (opengl_context);
780 RETVAL->r = 1.; 793 RETVAL->r = 1.;
788 layout_update_font (RETVAL); 801 layout_update_font (RETVAL);
789 OUTPUT: 802 OUTPUT:
790 RETVAL 803 RETVAL
791 804
792void 805void
793DESTROY (CFClient::Layout self) 806DESTROY (CFPlus::Layout self)
794 CODE: 807 CODE:
795 g_object_unref (self->pl); 808 g_object_unref (self->pl);
796 Safefree (self); 809 Safefree (self);
797 810
798void 811void
799set_text (CFClient::Layout self, SV *text_) 812set_text (CFPlus::Layout self, SV *text_)
800 CODE: 813 CODE:
801{ 814{
802 STRLEN textlen; 815 STRLEN textlen;
803 char *text = SvPVutf8 (text_, textlen); 816 char *text = SvPVutf8 (text_, textlen);
804 817
805 pango_layout_set_text (self->pl, text, textlen); 818 pango_layout_set_text (self->pl, text, textlen);
806} 819}
807 820
808void 821void
809set_markup (CFClient::Layout self, SV *text_) 822set_markup (CFPlus::Layout self, SV *text_)
810 CODE: 823 CODE:
811{ 824{
812 STRLEN textlen; 825 STRLEN textlen;
813 char *text = SvPVutf8 (text_, textlen); 826 char *text = SvPVutf8 (text_, textlen);
814 827
815 pango_layout_set_markup (self->pl, text, textlen); 828 pango_layout_set_markup (self->pl, text, textlen);
816} 829}
817 830
818void 831void
819set_shapes (CFClient::Layout self, ...) 832set_shapes (CFPlus::Layout self, ...)
820 CODE: 833 CODE:
821{ 834{
822 PangoAttrList *attrs = 0; 835 PangoAttrList *attrs = 0;
823 const char *text = pango_layout_get_text (self->pl); 836 const char *text = pango_layout_get_text (self->pl);
824 const char *pos = text; 837 const char *pos = text;
859 if (attrs) 872 if (attrs)
860 pango_layout_set_attributes (self->pl, attrs); 873 pango_layout_set_attributes (self->pl, attrs);
861} 874}
862 875
863void 876void
864get_shapes (CFClient::Layout self) 877get_shapes (CFPlus::Layout self)
865 PPCODE: 878 PPCODE:
866{ 879{
867 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 880 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
868 881
869 do 882 do
873 if (run && shape_attr_p (run)) 886 if (run && shape_attr_p (run))
874 { 887 {
875 PangoRectangle extents; 888 PangoRectangle extents;
876 pango_layout_iter_get_run_extents (iter, 0, &extents); 889 pango_layout_iter_get_run_extents (iter, 0, &extents);
877 890
891 EXTEND (SP, 2);
878 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); 892 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x))));
879 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); 893 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y))));
880 } 894 }
881 } 895 }
882 while (pango_layout_iter_next_run (iter)); 896 while (pango_layout_iter_next_run (iter));
883 897
884 pango_layout_iter_free (iter); 898 pango_layout_iter_free (iter);
885} 899}
886 900
887int 901int
888has_wrapped (CFClient::Layout self) 902has_wrapped (CFPlus::Layout self)
889 CODE: 903 CODE:
890{ 904{
891 int lines = 1; 905 int lines = 1;
892 const char *text = pango_layout_get_text (self->pl); 906 const char *text = pango_layout_get_text (self->pl);
893 907
898} 912}
899 OUTPUT: 913 OUTPUT:
900 RETVAL 914 RETVAL
901 915
902SV * 916SV *
903get_text (CFClient::Layout self) 917get_text (CFPlus::Layout self)
904 CODE: 918 CODE:
905 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 919 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
906 sv_utf8_decode (RETVAL); 920 sv_utf8_decode (RETVAL);
907 OUTPUT: 921 OUTPUT:
908 RETVAL 922 RETVAL
909 923
910void 924void
911set_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.)
912 CODE: 926 CODE:
913 self->r = r; 927 self->r = r;
914 self->g = g; 928 self->g = g;
915 self->b = b; 929 self->b = b;
916 self->a = a; 930 self->a = a;
917 931
918void 932void
919set_font (CFClient::Layout self, CFClient::Font font = 0) 933set_font (CFPlus::Layout self, CFPlus::Font font = 0)
920 CODE: 934 CODE:
921 if (self->font != font) 935 if (self->font != font)
922 { 936 {
923 self->font = font; 937 self->font = font;
924 layout_update_font (self); 938 layout_update_font (self);
925 } 939 }
926 940
927void 941void
928set_height (CFClient::Layout self, int base_height) 942set_height (CFPlus::Layout self, int base_height)
929 CODE: 943 CODE:
930 if (self->base_height != base_height) 944 if (self->base_height != base_height)
931 { 945 {
932 self->base_height = base_height; 946 self->base_height = base_height;
933 layout_update_font (self); 947 layout_update_font (self);
934 } 948 }
935 949
936void 950void
937set_width (CFClient::Layout self, int max_width = -1) 951set_width (CFPlus::Layout self, int max_width = -1)
938 CODE: 952 CODE:
939 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);
940 954
941void 955void
942set_indent (CFClient::Layout self, int indent) 956set_indent (CFPlus::Layout self, int indent)
943 CODE: 957 CODE:
944 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 958 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
945 959
946void 960void
947set_spacing (CFClient::Layout self, int spacing) 961set_spacing (CFPlus::Layout self, int spacing)
948 CODE: 962 CODE:
949 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 963 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
950 964
951void 965void
952set_ellipsise (CFClient::Layout self, int ellipsise) 966set_ellipsise (CFPlus::Layout self, int ellipsise)
953 CODE: 967 CODE:
954 pango_layout_set_ellipsize (self->pl, 968 pango_layout_set_ellipsize (self->pl,
955 ellipsise == 1 ? PANGO_ELLIPSIZE_START 969 ellipsise == 1 ? PANGO_ELLIPSIZE_START
956 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 970 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
957 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 971 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
958 : PANGO_ELLIPSIZE_NONE 972 : PANGO_ELLIPSIZE_NONE
959 ); 973 );
960 974
961void 975void
962set_single_paragraph_mode (CFClient::Layout self, int spm) 976set_single_paragraph_mode (CFPlus::Layout self, int spm)
963 CODE: 977 CODE:
964 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 978 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
965 979
966void 980void
967size (CFClient::Layout self) 981size (CFPlus::Layout self)
968 PPCODE: 982 PPCODE:
969{ 983{
970 int w, h; 984 int w, h;
971 985
972 layout_get_pixel_size (self, &w, &h); 986 layout_get_pixel_size (self, &w, &h);
975 PUSHs (sv_2mortal (newSViv (w))); 989 PUSHs (sv_2mortal (newSViv (w)));
976 PUSHs (sv_2mortal (newSViv (h))); 990 PUSHs (sv_2mortal (newSViv (h)));
977} 991}
978 992
979int 993int
980descent (CFClient::Layout self) 994descent (CFPlus::Layout self)
981 CODE: 995 CODE:
982{ 996{
983 PangoRectangle rect; 997 PangoRectangle rect;
984 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 998 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
985 pango_layout_line_get_pixel_extents (line, 0, &rect); 999 pango_layout_line_get_pixel_extents (line, 0, &rect);
987} 1001}
988 OUTPUT: 1002 OUTPUT:
989 RETVAL 1003 RETVAL
990 1004
991int 1005int
992xy_to_index (CFClient::Layout self, int x, int y) 1006xy_to_index (CFPlus::Layout self, int x, int y)
993 CODE: 1007 CODE:
994{ 1008{
995 int index, trailing; 1009 int index, trailing;
996 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);
997 RETVAL = index; 1011 RETVAL = index;
998} 1012}
999 OUTPUT: 1013 OUTPUT:
1000 RETVAL 1014 RETVAL
1001 1015
1002void 1016void
1003cursor_pos (CFClient::Layout self, int index) 1017cursor_pos (CFPlus::Layout self, int index)
1004 PPCODE: 1018 PPCODE:
1005{ 1019{
1006 PangoRectangle strong_pos; 1020 PangoRectangle strong_pos;
1007 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1021 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1008 1022
1011 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1025 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1012 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1026 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1013} 1027}
1014 1028
1015void 1029void
1016render (CFClient::Layout self, float x, float y) 1030render (CFPlus::Layout self, float x, float y)
1017 PPCODE: 1031 PPCODE:
1018 pango_opengl_render_layout_subpixel ( 1032 pango_opengl_render_layout_subpixel (
1019 self->pl, 1033 self->pl,
1020 x * PANGO_SCALE, y * PANGO_SCALE, 1034 x * PANGO_SCALE, y * PANGO_SCALE,
1021 self->r, self->g, self->b, self->a 1035 self->r, self->g, self->b, self->a
1022 ); 1036 );
1023 1037
1024MODULE = CFClient PACKAGE = CFClient::Texture 1038MODULE = CFPlus PACKAGE = CFPlus::Texture
1025 1039
1026void 1040void
1027pad2pot (SV *data_, SV *w_, SV *h_) 1041pad2pot (SV *data_, SV *w_, SV *h_)
1028 CODE: 1042 CODE:
1029{ 1043{
1107 glDisable (GL_ALPHA_TEST); 1121 glDisable (GL_ALPHA_TEST);
1108 glDisable (GL_BLEND); 1122 glDisable (GL_BLEND);
1109 } 1123 }
1110} 1124}
1111 1125
1112MODULE = CFClient PACKAGE = CFClient::Map 1126MODULE = CFPlus PACKAGE = CFPlus::Map
1113 1127
1114CFClient::Map 1128CFPlus::Map
1115new (SV *class, int map_width, int map_height) 1129new (SV *class, int map_width, int map_height)
1116 CODE: 1130 CODE:
1117 New (0, RETVAL, 1, struct map); 1131 New (0, RETVAL, 1, struct map);
1118 RETVAL->x = 0; 1132 RETVAL->x = 0;
1119 RETVAL->y = 0; 1133 RETVAL->y = 0;
1129 RETVAL->row = 0; 1143 RETVAL->row = 0;
1130 OUTPUT: 1144 OUTPUT:
1131 RETVAL 1145 RETVAL
1132 1146
1133void 1147void
1134DESTROY (CFClient::Map self) 1148DESTROY (CFPlus::Map self)
1135 CODE: 1149 CODE:
1136{ 1150{
1137 map_clear (self); 1151 map_clear (self);
1138 Safefree (self->face); 1152 Safefree (self->face);
1139 Safefree (self->tex); 1153 Safefree (self->tex);
1140 Safefree (self); 1154 Safefree (self);
1141} 1155}
1142 1156
1143void 1157void
1144clear (CFClient::Map self) 1158clear (CFPlus::Map self)
1145 CODE: 1159 CODE:
1146 map_clear (self); 1160 map_clear (self);
1147 1161
1148void 1162void
1149set_face (CFClient::Map self, int face, int texid) 1163set_face (CFPlus::Map self, int face, int texid)
1150 CODE: 1164 CODE:
1151{ 1165{
1152 while (self->faces <= face) 1166 while (self->faces <= face)
1153 { 1167 {
1154 Append (mapface, self->face, self->faces, self->faces); 1168 Append (mapface, self->face, self->faces, self->faces);
1157 1171
1158 self->face [face] = texid; 1172 self->face [face] = texid;
1159} 1173}
1160 1174
1161void 1175void
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) 1176set_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: 1177 CODE:
1164{ 1178{
1165 while (self->texs <= texid) 1179 while (self->texs <= texid)
1166 { 1180 {
1167 Append (maptex, self->tex, self->texs, self->texs); 1181 Append (maptex, self->tex, self->texs, self->texs);
1191 // from transparent color bleeding and ugly wrapping effects. 1205 // from transparent color bleeding and ugly wrapping effects.
1192 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1206 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1193} 1207}
1194 1208
1195int 1209int
1196ox (CFClient::Map self) 1210ox (CFPlus::Map self)
1197 ALIAS: 1211 ALIAS:
1198 oy = 1 1212 oy = 1
1199 x = 2 1213 x = 2
1200 y = 3 1214 y = 3
1201 w = 4 1215 w = 4
1212 } 1226 }
1213 OUTPUT: 1227 OUTPUT:
1214 RETVAL 1228 RETVAL
1215 1229
1216void 1230void
1217scroll (CFClient::Map self, int dx, int dy) 1231scroll (CFPlus::Map self, int dx, int dy)
1218 CODE: 1232 CODE:
1219{ 1233{
1220 if (dx > 0) 1234 if (dx > 0)
1221 map_blank (self, self->x, self->y, dx - 1, self->h); 1235 map_blank (self, self->x, self->y, dx - 1, self->h);
1222 else if (dx < 0) 1236 else if (dx < 0)
1238 self->y += MAP_EXTEND_Y; 1252 self->y += MAP_EXTEND_Y;
1239 } 1253 }
1240} 1254}
1241 1255
1242void 1256void
1243map1a_update (CFClient::Map self, SV *data_) 1257map1a_update (CFPlus::Map self, SV *data_)
1244 CODE: 1258 CODE:
1245{ 1259{
1246 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1260 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1247 uint8_t *data_end = (uint8_t *)SvEND (data_); 1261 uint8_t *data_end = (uint8_t *)SvEND (data_);
1248 mapcell *cell; 1262 mapcell *cell;
1290 cell->darkness = -1; 1304 cell->darkness = -1;
1291 } 1305 }
1292} 1306}
1293 1307
1294SV * 1308SV *
1295mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1309mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1296 CODE: 1310 CODE:
1297{ 1311{
1298 int x1, x; 1312 int x1, x;
1299 int y1, y; 1313 int y1, y;
1300 int z; 1314 int z;
1350} 1364}
1351 OUTPUT: 1365 OUTPUT:
1352 RETVAL 1366 RETVAL
1353 1367
1354void 1368void
1355draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1369draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1356 CODE: 1370 CODE:
1357{ 1371{
1358 int vx, vy; 1372 int vx, vy;
1359 int x, y, z; 1373 int x, y, z;
1360 int last_name; 1374 int last_name;
1425 glDisable (GL_TEXTURE_2D); 1439 glDisable (GL_TEXTURE_2D);
1426 glDisable (GL_BLEND); 1440 glDisable (GL_BLEND);
1427} 1441}
1428 1442
1429void 1443void
1430draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1444draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1431 CODE: 1445 CODE:
1432{ 1446{
1433 static float color[16][3] = { 1447 static float color[16][3] = {
1434 { 0.00F, 0.00F, 0.00F }, 1448 { 0.00F, 0.00F, 0.00F },
1435 { 1.00F, 1.00F, 1.00F }, 1449 { 1.00F, 1.00F, 1.00F },
1485 glDisable (GL_BLEND); 1499 glDisable (GL_BLEND);
1486 glDisable (GL_TEXTURE_2D); 1500 glDisable (GL_TEXTURE_2D);
1487} 1501}
1488 1502
1489void 1503void
1490fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1504fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1491 PPCODE: 1505 PPCODE:
1492{ 1506{
1493 int vx, vy; 1507 int vx, vy;
1494 int x, y; 1508 int x, y;
1495 int sw4 = (sw + 3) & ~3; 1509 int sw4 = (sw + 3) & ~3;
1524 PUSHs (sv_2mortal (newSViv (sh))); 1538 PUSHs (sv_2mortal (newSViv (sh)));
1525 PUSHs (darkness_sv); 1539 PUSHs (darkness_sv);
1526} 1540}
1527 1541
1528SV * 1542SV *
1529get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1543get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1530 CODE: 1544 CODE:
1531{ 1545{
1532 int x, y, x1, y1; 1546 int x, y, x1, y1;
1533 SV *data_sv = newSV (w * h * 7 + 5); 1547 SV *data_sv = newSV (w * h * 7 + 5);
1534 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1548 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1596} 1610}
1597 OUTPUT: 1611 OUTPUT:
1598 RETVAL 1612 RETVAL
1599 1613
1600void 1614void
1601set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1615set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1602 PPCODE: 1616 PPCODE:
1603{ 1617{
1604 int x, y, z; 1618 int x, y, z;
1605 int w, h; 1619 int w, h;
1606 int x1, y1; 1620 int x1, y1;
1655 } 1669 }
1656 } 1670 }
1657 } 1671 }
1658} 1672}
1659 1673
1660MODULE = CFClient PACKAGE = CFClient::MixChunk 1674MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1661 1675
1662CFClient::MixChunk 1676CFPlus::MixChunk
1663new_from_file (SV *class, char *path) 1677new_from_file (SV *class, char *path)
1664 CODE: 1678 CODE:
1665 RETVAL = Mix_LoadWAV (path); 1679 RETVAL = Mix_LoadWAV (path);
1666 OUTPUT: 1680 OUTPUT:
1667 RETVAL 1681 RETVAL
1668 1682
1669void 1683void
1670DESTROY (CFClient::MixChunk self) 1684DESTROY (CFPlus::MixChunk self)
1671 CODE: 1685 CODE:
1672 Mix_FreeChunk (self); 1686 Mix_FreeChunk (self);
1673 1687
1674int 1688int
1675volume (CFClient::MixChunk self, int volume = -1) 1689volume (CFPlus::MixChunk self, int volume = -1)
1676 CODE: 1690 CODE:
1677 RETVAL = Mix_VolumeChunk (self, volume); 1691 RETVAL = Mix_VolumeChunk (self, volume);
1678 OUTPUT: 1692 OUTPUT:
1679 RETVAL 1693 RETVAL
1680 1694
1681int 1695int
1682play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1696play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1683 CODE: 1697 CODE:
1684 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1698 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1685 OUTPUT: 1699 OUTPUT:
1686 RETVAL 1700 RETVAL
1687 1701
1688MODULE = CFClient PACKAGE = CFClient::MixMusic 1702MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1689 1703
1690int 1704int
1691volume (int volume = -1) 1705volume (int volume = -1)
1692 CODE: 1706 CODE:
1693 RETVAL = Mix_VolumeMusic (volume); 1707 RETVAL = Mix_VolumeMusic (volume);
1694 OUTPUT: 1708 OUTPUT:
1695 RETVAL 1709 RETVAL
1696 1710
1697CFClient::MixMusic 1711CFPlus::MixMusic
1698new_from_file (SV *class, char *path) 1712new_from_file (SV *class, char *path)
1699 CODE: 1713 CODE:
1700 RETVAL = Mix_LoadMUS (path); 1714 RETVAL = Mix_LoadMUS (path);
1701 OUTPUT: 1715 OUTPUT:
1702 RETVAL 1716 RETVAL
1703 1717
1704void 1718void
1705DESTROY (CFClient::MixMusic self) 1719DESTROY (CFPlus::MixMusic self)
1706 CODE: 1720 CODE:
1707 Mix_FreeMusic (self); 1721 Mix_FreeMusic (self);
1708 1722
1709int 1723int
1710play (CFClient::MixMusic self, int loops = -1) 1724play (CFPlus::MixMusic self, int loops = -1)
1711 CODE: 1725 CODE:
1712 RETVAL = Mix_PlayMusic (self, loops); 1726 RETVAL = Mix_PlayMusic (self, loops);
1713 OUTPUT: 1727 OUTPUT:
1714 RETVAL 1728 RETVAL
1715 1729
1716MODULE = CFClient PACKAGE = CFClient::OpenGL 1730MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1717 1731
1718BOOT: 1732BOOT:
1719{ 1733{
1720 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1734 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1721 static const struct { 1735 static const struct {
1722 const char *name; 1736 const char *name;
1723 IV iv; 1737 IV iv;
1724 } *civ, const_iv[] = { 1738 } *civ, const_iv[] = {
1725# define const_iv(name) { # name, (IV)name } 1739# define const_iv(name) { # name, (IV)name }
1907 r *= a; 1921 r *= a;
1908 g *= a; 1922 g *= a;
1909 b *= a; 1923 b *= a;
1910 } 1924 }
1911 // microsoft visual "c" rounds instead of truncating... 1925 // microsoft visual "c" rounds instead of truncating...
1912 glColor4ub (MIN ((int)(r * 256.f), 255), 1926 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 1927
1917void glInterleavedArrays (int format, int stride, char *data) 1928void glInterleavedArrays (int format, int stride, char *data)
1918 1929
1919void glDrawElements (int mode, int count, int type, char *indices) 1930void glDrawElements (int mode, int count, int type, char *indices)
1920 1931

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines