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.192 by root, Fri Apr 27 21:27:51 2007 UTC vs.
Revision 1.199 by root, Tue Jul 17 13:53:02 2007 UTC

4# include <malloc.h> 4# include <malloc.h>
5# include <windows.h> 5# include <windows.h>
6# include <wininet.h> 6# include <wininet.h>
7# pragma warning(disable:4244) 7# pragma warning(disable:4244)
8# pragma warning(disable:4761) 8# pragma warning(disable:4761)
9#endif
10
11//#define DEBUG 1
12#if DEBUG
13# include <valgrind/memcheck.h>
9#endif 14#endif
10 15
11#include "EXTERN.h" 16#include "EXTERN.h"
12#include "perl.h" 17#include "perl.h"
13#include "XSUB.h" 18#include "XSUB.h"
658SDL_GL_SwapBuffers () 663SDL_GL_SwapBuffers ()
659 664
660char * 665char *
661SDL_GetKeyName (int sym) 666SDL_GetKeyName (int sym)
662 667
668int
669SDL_GetAppState ()
670
663void 671void
664SDL_PollEvent () 672poll_events ()
665 PPCODE: 673 PPCODE:
666{ 674{
667 SDL_Event ev; 675 SDL_Event ev;
668 676
669 while (SDL_PollEvent (&ev)) 677 SDL_PumpEvents ();
678 while (SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0)
670 { 679 {
671 HV *hv = newHV (); 680 HV *hv = newHV ();
672 hv_store (hv, "type", 4, newSViv (ev.type), 0); 681 hv_store (hv, "type", 4, newSViv (ev.type), 0);
673 682
674 switch (ev.type) 683 switch (ev.type)
686 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 695 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
687 hv_store (hv, "state", 5, newSViv (ev.active.state), 0); 696 hv_store (hv, "state", 5, newSViv (ev.active.state), 0);
688 break; 697 break;
689 698
690 case SDL_MOUSEMOTION: 699 case SDL_MOUSEMOTION:
700 {
701 int state = ev.motion.state;
702 int x = ev.motion.x;
703 int y = ev.motion.y;
704 int xrel = ev.motion.xrel;
705 int yrel = ev.motion.yrel;
706
707 /* do simplistic event compression */
708 while (SDL_PeepEvents (&ev, 1, SDL_PEEKEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)) > 0
709 && state == ev.motion.state)
710 {
711 xrel += ev.motion.xrel;
712 yrel += ev.motion.yrel;
713 x = ev.motion.x;
714 y = ev.motion.y;
715 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
716 }
717
691 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 718 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
692
693 hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); 719 hv_store (hv, "state", 5, newSViv (state), 0);
694 hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); 720 hv_store (hv, "x", 1, newSViv (x), 0);
695 hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); 721 hv_store (hv, "y", 1, newSViv (y), 0);
696 hv_store (hv, "xrel", 4, newSViv (ev.motion.xrel), 0); 722 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
697 hv_store (hv, "yrel", 4, newSViv (ev.motion.yrel), 0); 723 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
724 }
698 break; 725 break;
699 726
700 case SDL_MOUSEBUTTONDOWN: 727 case SDL_MOUSEBUTTONDOWN:
701 case SDL_MOUSEBUTTONUP: 728 case SDL_MOUSEBUTTONUP:
702 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 729 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0);
882 ExitThread (retval); // unclean, please beam me up 909 ExitThread (retval); // unclean, please beam me up
883#else 910#else
884 _exit (retval); 911 _exit (retval);
885#endif 912#endif
886 913
914void
915debug ()
916 CODE:
917{
918#if DEBUG
919 VALGRIND_DO_LEAK_CHECK;
920#endif
921}
922
887MODULE = CFPlus PACKAGE = CFPlus::Font 923MODULE = CFPlus PACKAGE = CFPlus::Font
888 924
889CFPlus::Font 925CFPlus::Font
890new_from_file (SV *class, char *path, int id = 0) 926new_from_file (SV *class, char *path, int id = 0)
891 CODE: 927 CODE:
1206 flags 1242 flags
1207 ); 1243 );
1208 1244
1209MODULE = CFPlus PACKAGE = CFPlus::Texture 1245MODULE = CFPlus PACKAGE = CFPlus::Texture
1210 1246
1247int minpot (int n)
1248
1211void 1249void
1212pad2pot (SV *data_, SV *w_, SV *h_) 1250pad2pot (SV *data_, SV *w_, SV *h_)
1213 CODE: 1251 CODE:
1214{ 1252{
1215 int ow = SvIV (w_); 1253 int ow = SvIV (w_);
1291 { 1329 {
1292 glDisable (GL_ALPHA_TEST); 1330 glDisable (GL_ALPHA_TEST);
1293 glDisable (GL_BLEND); 1331 glDisable (GL_BLEND);
1294 } 1332 }
1295} 1333}
1334
1335IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type)
1336 CODE:
1337{
1338 GLint width;
1339 glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0);
1340 glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
1341 RETVAL = width > 0;
1342}
1343 OUTPUT:
1344 RETVAL
1296 1345
1297MODULE = CFPlus PACKAGE = CFPlus::Map 1346MODULE = CFPlus PACKAGE = CFPlus::Map
1298 1347
1299CFPlus::Map 1348CFPlus::Map
1300new (SV *class) 1349new (SV *class)
2126 CODE: 2175 CODE:
2127 RETVAL = Mix_VolumeMusic (volume); 2176 RETVAL = Mix_VolumeMusic (volume);
2128 OUTPUT: 2177 OUTPUT:
2129 RETVAL 2178 RETVAL
2130 2179
2180int
2181fade_out (int ms)
2182 CODE:
2183 RETVAL = Mix_FadeOutMusic (ms);
2184 OUTPUT:
2185 RETVAL
2186
2131CFPlus::MixMusic 2187CFPlus::MixMusic
2132new_from_file (SV *class, char *path) 2188new_from_file (SV *class, char *path)
2133 CODE: 2189 CODE:
2134 RETVAL = Mix_LoadMUS (path); 2190 RETVAL = Mix_LoadMUS (path);
2135 OUTPUT: 2191 OUTPUT:
2142 2198
2143int 2199int
2144play (CFPlus::MixMusic self, int loops = -1) 2200play (CFPlus::MixMusic self, int loops = -1)
2145 CODE: 2201 CODE:
2146 RETVAL = Mix_PlayMusic (self, loops); 2202 RETVAL = Mix_PlayMusic (self, loops);
2203 OUTPUT:
2204 RETVAL
2205
2206int
2207fade_in_pos (CFPlus::MixMusic self, int loops, int ms, double position)
2208 CODE:
2209 RETVAL = Mix_FadeInMusicPos (self, loops, ms, position);
2147 OUTPUT: 2210 OUTPUT:
2148 RETVAL 2211 RETVAL
2149 2212
2150MODULE = CFPlus PACKAGE = CFPlus::OpenGL 2213MODULE = CFPlus PACKAGE = CFPlus::OpenGL
2151 2214
2155 static const struct { 2218 static const struct {
2156 const char *name; 2219 const char *name;
2157 IV iv; 2220 IV iv;
2158 } *civ, const_iv[] = { 2221 } *civ, const_iv[] = {
2159# define const_iv(name) { # name, (IV)name } 2222# define const_iv(name) { # name, (IV)name }
2223 const_iv (GL_VENDOR),
2224 const_iv (GL_VERSION),
2225 const_iv (GL_EXTENSIONS),
2160 const_iv (GL_COLOR_MATERIAL), 2226 const_iv (GL_COLOR_MATERIAL),
2161 const_iv (GL_SMOOTH), 2227 const_iv (GL_SMOOTH),
2162 const_iv (GL_FLAT), 2228 const_iv (GL_FLAT),
2163 const_iv (GL_DITHER), 2229 const_iv (GL_DITHER),
2164 const_iv (GL_BLEND), 2230 const_iv (GL_BLEND),
2191 const_iv (GL_LUMINANCE), 2257 const_iv (GL_LUMINANCE),
2192 const_iv (GL_LUMINANCE_ALPHA), 2258 const_iv (GL_LUMINANCE_ALPHA),
2193 const_iv (GL_FLOAT), 2259 const_iv (GL_FLOAT),
2194 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), 2260 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV),
2195 const_iv (GL_COMPILE), 2261 const_iv (GL_COMPILE),
2262 const_iv (GL_PROXY_TEXTURE_1D),
2263 const_iv (GL_PROXY_TEXTURE_2D),
2196 const_iv (GL_TEXTURE_1D), 2264 const_iv (GL_TEXTURE_1D),
2197 const_iv (GL_TEXTURE_2D), 2265 const_iv (GL_TEXTURE_2D),
2198 const_iv (GL_TEXTURE_ENV), 2266 const_iv (GL_TEXTURE_ENV),
2199 const_iv (GL_TEXTURE_MAG_FILTER), 2267 const_iv (GL_TEXTURE_MAG_FILTER),
2200 const_iv (GL_TEXTURE_MIN_FILTER), 2268 const_iv (GL_TEXTURE_MIN_FILTER),
2266 CODE: 2334 CODE:
2267 RETVAL = (char *)glGetString (GL_EXTENSIONS); 2335 RETVAL = (char *)glGetString (GL_EXTENSIONS);
2268 OUTPUT: 2336 OUTPUT:
2269 RETVAL 2337 RETVAL
2270 2338
2339char *glGetString (GLenum pname)
2340
2341GLint glGetInteger (GLenum pname)
2342 CODE:
2343 glGetIntegerv (pname, &RETVAL);
2344 OUTPUT:
2345 RETVAL
2346
2347GLdouble glGetDouble (GLenum pname)
2348 CODE:
2349 glGetDoublev (pname, &RETVAL);
2350 OUTPUT:
2351 RETVAL
2352
2271int glGetError () 2353int glGetError ()
2272 2354
2273void glFinish () 2355void glFinish ()
2274 2356
2275void glClear (int mask) 2357void glClear (int mask)
2397 2479
2398void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) 2480void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border)
2399 2481
2400void glDrawPixels (int width, int height, int format, int type, char *pixels) 2482void glDrawPixels (int width, int height, int format, int type, char *pixels)
2401 2483
2484void glPixelZoom (float x, float y)
2485
2402void glCopyPixels (int x, int y, int width, int height, int type = GL_COLOR) 2486void glCopyPixels (int x, int y, int width, int height, int type = GL_COLOR)
2403 2487
2404int glGenTexture () 2488int glGenTexture ()
2405 CODE: 2489 CODE:
2406 RETVAL = gen_texture (); 2490 RETVAL = gen_texture ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines