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.110 by root, Sat Jun 10 02:22:33 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>
299 ev.code = 1; 300 ev.code = 1;
300 ev.data1 = (void *)(long)channel; 301 ev.data1 = (void *)(long)channel;
301 ev.data2 = 0; 302 ev.data2 = 0;
302 303
303 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;
304} 322}
305 323
306MODULE = CFClient PACKAGE = CFClient 324MODULE = CFClient PACKAGE = CFClient
307 325
308PROTOTYPES: ENABLE 326PROTOTYPES: ENABLE
703 CODE: 721 CODE:
704 fprintf (stderr, "FATAL: %s\n", message); 722 fprintf (stderr, "FATAL: %s\n", message);
705#ifdef _WIN32 723#ifdef _WIN32
706 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); 724 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR);
707#endif 725#endif
708 exit (1); 726 _exit (1);
727
728void
729_exit (int retval)
730 CODE:
731 _exit (retval);
709 732
710MODULE = CFClient PACKAGE = CFClient::Font 733MODULE = CFClient PACKAGE = CFClient::Font
711 734
712CFClient::Font 735CFClient::Font
713new_from_file (SV *class, char *path, int id = 0) 736new_from_file (SV *class, char *path, int id = 0)
976 PUSHs (sv_2mortal (newSViv (GL_ALPHA))); 999 PUSHs (sv_2mortal (newSViv (GL_ALPHA)));
977 } 1000 }
978} 1001}
979 1002
980MODULE = 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}
981 1041
982void 1042void
983draw_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)
984 PROTOTYPE: $$$;$$ 1044 PROTOTYPE: $$$;$$
985 ALIAS: 1045 ALIAS:
1053DESTROY (CFClient::Map self) 1113DESTROY (CFClient::Map self)
1054 CODE: 1114 CODE:
1055{ 1115{
1056 map_clear (self); 1116 map_clear (self);
1057 Safefree (self->face); 1117 Safefree (self->face);
1118 Safefree (self->tex);
1058 Safefree (self); 1119 Safefree (self);
1059} 1120}
1060 1121
1061void 1122void
1062clear (CFClient::Map self) 1123clear (CFClient::Map self)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines