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.115 by root, Wed Jun 14 18:59:30 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
463 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5); 481 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 5);
464 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); 482 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5);
465 SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1); 483 SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1);
466 484
467 SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); 485 SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15);
468 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); 486 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0);
469 487
470 SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0); 488 SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0);
471 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 489 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
472 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 490 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
473 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 491 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
655 PUSHs (sv_2mortal (newSViv (surface2->w))); 673 PUSHs (sv_2mortal (newSViv (surface2->w)));
656 PUSHs (sv_2mortal (newSViv (surface2->h))); 674 PUSHs (sv_2mortal (newSViv (surface2->h)));
657 SDL_LockSurface (surface2); 675 SDL_LockSurface (surface2);
658 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 676 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
659 SDL_UnlockSurface (surface2); 677 SDL_UnlockSurface (surface2);
660 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 678 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA8 : GL_RGB8)));
661 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 679 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
662 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 680 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
663 681
664 SDL_FreeSurface (surface); 682 SDL_FreeSurface (surface);
665 SDL_FreeSurface (surface2); 683 SDL_FreeSurface (surface2);
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)
944 967
945 EXTEND (SP, 5); 968 EXTEND (SP, 5);
946 PUSHs (sv_2mortal (newSViv (w))); 969 PUSHs (sv_2mortal (newSViv (w)));
947 PUSHs (sv_2mortal (newSViv (h))); 970 PUSHs (sv_2mortal (newSViv (h)));
948 PUSHs (sv_2mortal (retval)); 971 PUSHs (sv_2mortal (retval));
949 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 972 PUSHs (sv_2mortal (newSViv (GL_RGBA8)));
950 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 973 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
951 } 974 }
952 else 975 else
953 { 976 {
954 FT_Bitmap bitmap; 977 FT_Bitmap bitmap;
978} 1001}
979 1002
980MODULE = CFClient PACKAGE = CFClient::Texture 1003MODULE = CFClient PACKAGE = CFClient::Texture
981 1004
982void 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}
1041
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:
986 draw_quad_alpha = 1 1046 draw_quad_alpha = 1
987 draw_quad_alpha_premultiplied = 2 1047 draw_quad_alpha_premultiplied = 2
988 CODE: 1048 CODE:
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)
1577 const_iv (GL_ONE_MINUS_SRC_ALPHA), 1638 const_iv (GL_ONE_MINUS_SRC_ALPHA),
1578 const_iv (GL_ONE_MINUS_DST_ALPHA), 1639 const_iv (GL_ONE_MINUS_DST_ALPHA),
1579 const_iv (GL_SRC_ALPHA_SATURATE), 1640 const_iv (GL_SRC_ALPHA_SATURATE),
1580 const_iv (GL_RGB), 1641 const_iv (GL_RGB),
1581 const_iv (GL_RGBA), 1642 const_iv (GL_RGBA),
1643 const_iv (GL_RGBA4),
1644 const_iv (GL_RGBA8),
1645 const_iv (GL_RGB5_A1),
1582 const_iv (GL_UNSIGNED_BYTE), 1646 const_iv (GL_UNSIGNED_BYTE),
1583 const_iv (GL_UNSIGNED_SHORT), 1647 const_iv (GL_UNSIGNED_SHORT),
1584 const_iv (GL_UNSIGNED_INT), 1648 const_iv (GL_UNSIGNED_INT),
1585 const_iv (GL_ALPHA), 1649 const_iv (GL_ALPHA),
1586 const_iv (GL_INTENSITY), 1650 const_iv (GL_INTENSITY),
1660 OUTPUT: 1724 OUTPUT:
1661 RETVAL 1725 RETVAL
1662 1726
1663int glGetError () 1727int glGetError ()
1664 1728
1729void glFinish ()
1730
1665void glClear (int mask) 1731void glClear (int mask)
1666 1732
1667void glClearColor (float r, float g, float b, float a = 1.0) 1733void glClearColor (float r, float g, float b, float a = 1.0)
1668 PROTOTYPE: @ 1734 PROTOTYPE: @
1669 1735

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines