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.108 by root, Wed Jun 7 23:28:12 2006 UTC vs.
Revision 1.113 by root, Wed Jun 14 16:20:21 2006 UTC

10#include "XSUB.h" 10#include "XSUB.h"
11 11
12#include <math.h> 12#include <math.h>
13#include <string.h> 13#include <string.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <stdlib.h>
15 16
16#include <SDL.h> 17#include <SDL.h>
17#include <SDL_endian.h> 18#include <SDL_endian.h>
18#include <SDL_image.h> 19#include <SDL_image.h>
19#include <SDL_mixer.h> 20#include <SDL_mixer.h>
86 87
87static void 88static void
88substitute_func (FcPattern *pattern, gpointer data) 89substitute_func (FcPattern *pattern, gpointer data)
89{ 90{
90 FcPatternAddBool (pattern, FC_HINTING, 1); 91 FcPatternAddBool (pattern, FC_HINTING, 1);
92#ifdef FC_HINT_STYLE
91 FcPatternAddBool (pattern, FC_HINTSTYLE, FC_HINT_FULL); 93 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL);
94#endif
92#ifdef _WIN32 95#ifdef _WIN32
93 FcPatternAddBool (pattern, FC_AUTOHINT, 1); 96 FcPatternAddBool (pattern, FC_AUTOHINT, 1);
94#else 97#else
95 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 98 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
96#endif 99#endif
297 ev.code = 1; 300 ev.code = 1;
298 ev.data1 = (void *)(long)channel; 301 ev.data1 = (void *)(long)channel;
299 ev.data2 = 0; 302 ev.data2 = 0;
300 303
301 SDL_PushEvent ((SDL_Event *)&ev); 304 SDL_PushEvent ((SDL_Event *)&ev);
305}
306
307static unsigned int
308minpot (unsigned int n)
309{
310 if (!n)
311 return 0;
312
313 --n;
314
315 n |= n >> 1;
316 n |= n >> 2;
317 n |= n >> 4;
318 n |= n >> 8;
319 n |= n >> 16;
320
321 return n + 1;
302} 322}
303 323
304MODULE = CFClient PACKAGE = CFClient 324MODULE = CFClient PACKAGE = CFClient
305 325
306PROTOTYPES: ENABLE 326PROTOTYPES: ENABLE
701 CODE: 721 CODE:
702 fprintf (stderr, "FATAL: %s\n", message); 722 fprintf (stderr, "FATAL: %s\n", message);
703#ifdef _WIN32 723#ifdef _WIN32
704 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); 724 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR);
705#endif 725#endif
706 exit (1); 726 _exit (1);
727
728void
729_exit (int retval)
730 CODE:
731 _exit (retval);
707 732
708MODULE = CFClient PACKAGE = CFClient::Font 733MODULE = CFClient PACKAGE = CFClient::Font
709 734
710CFClient::Font 735CFClient::Font
711new_from_file (SV *class, char *path, int id = 0) 736new_from_file (SV *class, char *path, int id = 0)
974 PUSHs (sv_2mortal (newSViv (GL_ALPHA))); 999 PUSHs (sv_2mortal (newSViv (GL_ALPHA)));
975 } 1000 }
976} 1001}
977 1002
978MODULE = CFClient PACKAGE = CFClient::Texture 1003MODULE = CFClient PACKAGE = CFClient::Texture
1004
1005void
1006pad2pot (SV *data_, SV *w_, SV *h_)
1007 CODE:
1008{
1009 int ow = SvIV (w_);
1010 int oh = SvIV (h_);
1011
1012 if (ow && oh)
1013 {
1014 int nw = minpot (ow);
1015 int nh = minpot (oh);
1016
1017 if (nw != ow || nh != oh)
1018 {
1019 if (SvOK (data_))
1020 {
1021 STRLEN datalen;
1022 char *data = SvPVbyte (data_, datalen);
1023 int bpp = datalen / (ow * oh);
1024 SV *result_ = sv_2mortal (newSV (nw * nh * bpp));
1025
1026 SvPOK_only (result_);
1027 SvCUR_set (result_, nw * nh * bpp);
1028
1029 memset (SvPVX (result_), 0, nw * nh * bpp);
1030 while (oh--)
1031 memcpy (SvPVX (result_) + oh * nw * bpp, data + oh * ow * bpp, ow * bpp);
1032
1033 sv_setsv (data_, result_);
1034 }
1035
1036 sv_setiv (w_, nw);
1037 sv_setiv (h_, nh);
1038 }
1039 }
1040}
979 1041
980void 1042void
981draw_quad (SV *self, float x, float y, float w = 0, float h = 0) 1043draw_quad (SV *self, float x, float y, float w = 0, float h = 0)
982 PROTOTYPE: $$$;$$ 1044 PROTOTYPE: $$$;$$
983 ALIAS: 1045 ALIAS:
1051DESTROY (CFClient::Map self) 1113DESTROY (CFClient::Map self)
1052 CODE: 1114 CODE:
1053{ 1115{
1054 map_clear (self); 1116 map_clear (self);
1055 Safefree (self->face); 1117 Safefree (self->face);
1118 Safefree (self->tex);
1056 Safefree (self); 1119 Safefree (self);
1057} 1120}
1058 1121
1059void 1122void
1060clear (CFClient::Map self) 1123clear (CFClient::Map self)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines