Fix bug with TTFSizeText, it actually returns 0 on success
[sdlgit/SDL_perl.git] / src / SDL.xs
1 //
2 // SDL.xs
3 //
4 // Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
5 //
6 // ------------------------------------------------------------------------------
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // 
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Lesser General Public License for more details.
17 // 
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 //
22 // ------------------------------------------------------------------------------
23 //
24 // Please feel free to send questions, suggestions or improvements to:
25 //
26 //      David J. Goehrig
27 //      dgoehrig@cpan.org
28 //
29
30 #include "EXTERN.h"
31 #include "perl.h"
32 #include "XSUB.h"
33
34 #ifndef aTHX_
35 #define aTHX_
36 #endif
37
38 #include <SDL.h>
39
40 #ifdef HAVE_GL
41 #include <gl.h>
42 #endif
43
44 #ifdef HAVE_GLU
45 #include <glu.h>
46 #endif
47
48 #ifdef HAVE_SDL_IMAGE
49 #include <SDL_image.h>
50 #endif 
51
52 #ifdef HAVE_SDL_MIXER
53 #include <SDL_mixer.h>
54 void (*mix_music_finished_cv)();
55 #endif
56
57 #ifdef HAVE_SDL_SOUND
58 #include <SDL_sound.h>
59 #endif
60
61 #ifdef HAVE_SDL_NET
62 #include <SDL_net.h>
63 #endif
64
65 #ifdef HAVE_SDL_TTF
66 #include <SDL_ttf.h>
67 #define TEXT_SOLID      1
68 #define TEXT_SHADED     2
69 #define TEXT_BLENDED    4
70 #define UTF8_SOLID      8
71 #define UTF8_SHADED     16      
72 #define UTF8_BLENDED    32
73 #define UNICODE_SOLID   64
74 #define UNICODE_SHADED  128
75 #define UNICODE_BLENDED 256
76 #endif
77
78 #ifdef HAVE_SMPEG
79 #include <smpeg/smpeg.h>
80 #ifdef HAVE_SDL_MIXER
81 static int sdl_perl_use_smpeg_audio = 0;
82 #endif
83 #endif
84
85 #ifdef HAVE_SDL_GFX
86 #include <SDL_rotozoom.h>
87 #include <SDL_gfxPrimitives.h>
88 #include <SDL_framerate.h>
89 #include <SDL_imageFilter.h>
90 #endif
91
92 #ifdef HAVE_SDL_SVG
93 #include <SDL_svg.h>
94 #endif
95
96 #ifdef USE_THREADS
97 #define HAVE_TLS_CONTEXT
98 #endif
99
100 /* For windows  */
101 #ifndef SDL_PERL_DEFINES_H
102 #define SDL_PERL_DEFINES_H
103
104 #ifdef HAVE_TLS_CONTEXT
105 PerlInterpreter *parent_perl = NULL;
106 extern PerlInterpreter *parent_perl;
107 #define GET_TLS_CONTEXT parent_perl =  PERL_GET_CONTEXT;
108 #define ENTER_TLS_CONTEXT \
109         PerlInterpreter *current_perl = PERL_GET_CONTEXT; \
110                 PERL_SET_CONTEXT(parent_perl); { \
111                                         PerlInterpreter *my_perl = parent_perl;
112 #define LEAVE_TLS_CONTEXT \
113                                                 } PERL_SET_CONTEXT(current_perl);
114 #else
115 #define GET_TLS_CONTEXT         /* TLS context not enabled */
116 #define ENTER_TLS_CONTEXT       /* TLS context not enabled */
117 #define LEAVE_TLS_CONTEXT       /* TLS context not enabled */
118 #endif
119
120 #endif
121
122 Uint32 
123 sdl_perl_timer_callback ( Uint32 interval, void* param )
124 {
125         Uint32 retval;
126         int back;
127         SV* cmd;
128         ENTER_TLS_CONTEXT
129         dSP;
130
131         cmd = (SV*)param;
132
133         ENTER;
134         SAVETMPS;
135         PUSHMARK(SP);
136         XPUSHs(sv_2mortal(newSViv(interval)));
137         PUTBACK;
138
139         if (0 != (back = call_sv(cmd,G_SCALAR))) {
140                 SPAGAIN;
141                 if (back != 1 ) Perl_croak (aTHX_ "Timer Callback failed!");
142                 retval = POPi;  
143         } else {
144                 Perl_croak(aTHX_ "Timer Callback failed!");
145         }
146
147         FREETMPS;
148         LEAVE;
149
150         LEAVE_TLS_CONTEXT
151         
152         return retval;
153 }
154
155 void
156 sdl_perl_audio_callback ( void* data, Uint8 *stream, int len )
157 {
158         SV *cmd;
159         ENTER_TLS_CONTEXT
160         dSP;
161
162         cmd = (SV*)data;
163
164         ENTER;
165         SAVETMPS;
166         PUSHMARK(SP);
167         XPUSHs(sv_2mortal(newSViv(PTR2IV(stream))));
168         XPUSHs(sv_2mortal(newSViv(len)));
169         PUTBACK;
170
171         call_sv(cmd,G_VOID|G_DISCARD);
172         
173         PUTBACK;
174         FREETMPS;
175         LEAVE;
176
177         LEAVE_TLS_CONTEXT       
178 }
179
180 #ifdef HAVE_SDL_MIXER
181
182 void
183 sdl_perl_music_callback ( void ) 
184 {
185         SV *cmd;
186         ENTER_TLS_CONTEXT
187         dSP;
188
189         cmd = (SV*)Mix_GetMusicHookData();
190
191         ENTER;
192         SAVETMPS;
193         PUSHMARK(SP);
194         PUTBACK;
195         
196         call_sv(cmd,G_VOID|G_DISCARD);
197
198         PUTBACK;
199         FREETMPS;
200         LEAVE;
201
202         LEAVE_TLS_CONTEXT
203 }
204
205 void
206 sdl_perl_music_finished_callback ( void )
207 {
208         SV *cmd;
209         ENTER_TLS_CONTEXT
210         dSP;
211
212         cmd = (SV*)mix_music_finished_cv;
213         if ( cmd == NULL ) return;
214
215         ENTER;
216         SAVETMPS;
217         PUSHMARK(SP);
218         PUTBACK;
219         
220         call_sv(cmd,G_VOID|G_DISCARD);
221         
222         PUTBACK;
223         FREETMPS;
224         LEAVE;
225
226         LEAVE_TLS_CONTEXT
227 }
228
229 #endif
230
231 #define INIT_NS_APPLICATION
232 #define QUIT_NS_APPLICATION
233
234
235 void
236 sdl_perl_atexit (void)
237 {
238         QUIT_NS_APPLICATION     
239         SDL_Quit();
240 }
241
242 void boot_SDL();
243 void boot_SDL__OpenGL();
244
245 XS(boot_SDL_perl)
246 {
247         GET_TLS_CONTEXT
248         boot_SDL();
249 }
250
251 MODULE = SDL_perl       PACKAGE = SDL
252 PROTOTYPES : DISABLE
253
254 char *
255 GetError ()
256         CODE:
257                 RETVAL = SDL_GetError();
258         OUTPUT:
259                 RETVAL
260
261 int
262 Init ( flags )
263         Uint32 flags
264         CODE:
265                 INIT_NS_APPLICATION
266                 RETVAL = SDL_Init(flags);
267 #ifdef HAVE_TLS_CONTEXT
268                 Perl_call_atexit(PERL_GET_CONTEXT, (void*)sdl_perl_atexit,0);
269 #else
270                 atexit(sdl_perl_atexit);
271 #endif
272         OUTPUT:
273                 RETVAL
274
275 int
276 InitSubSystem ( flags )
277         Uint32 flags
278         CODE:
279                 RETVAL = SDL_InitSubSystem(flags);
280         OUTPUT:
281                 RETVAL
282
283 void
284 QuitSubSystem ( flags )
285         Uint32 flags
286         CODE:
287                 SDL_QuitSubSystem(flags);
288
289 void
290 Quit ()
291         CODE:
292                 QUIT_NS_APPLICATION
293                 SDL_Quit();
294
295 int
296 WasInit ( flags )
297         Uint32 flags
298         CODE:
299                 RETVAL = SDL_WasInit(flags);
300         OUTPUT:
301                 RETVAL
302
303 void
304 Delay ( ms )
305         int ms
306         CODE:
307                 SDL_Delay(ms);
308
309 Uint32
310 GetTicks ()
311         CODE:
312                 RETVAL = SDL_GetTicks();
313         OUTPUT:
314                 RETVAL
315
316 int
317 SetTimer ( interval, callback )
318         Uint32 interval
319         SDL_TimerCallback callback
320         CODE:
321                 RETVAL = SDL_SetTimer(interval,callback);
322         OUTPUT:
323                 RETVAL
324
325 SDL_TimerID
326 AddTimer ( interval, callback, param )
327         Uint32 interval
328         SDL_NewTimerCallback callback
329         void *param
330         CODE:
331                 RETVAL = SDL_AddTimer(interval,callback,param);
332         OUTPUT:
333                 RETVAL
334
335 SDL_NewTimerCallback
336 PerlTimerCallback ()
337         CODE:
338                 RETVAL = sdl_perl_timer_callback;
339         OUTPUT:
340                 RETVAL  
341
342 SDL_TimerID
343 NewTimer ( interval, cmd )
344         Uint32 interval
345         void *cmd
346         CODE:
347                 RETVAL = SDL_AddTimer(interval,sdl_perl_timer_callback,cmd);
348         OUTPUT:
349                 RETVAL
350
351 Uint32
352 RemoveTimer ( id )
353         SDL_TimerID id
354         CODE:
355                 RETVAL = SDL_RemoveTimer(id);
356         OUTPUT:
357                 RETVAL
358
359 SDL_RWops*
360 RWFromFile ( file, mode )
361         char* file
362         char * mode
363         CODE:
364                 RETVAL = SDL_RWFromFile(file,mode);
365         OUTPUT:
366                 RETVAL
367
368 SDL_RWops*
369 RWFromFP ( fp, autoclose )
370         FILE* fp
371         int autoclose
372         CODE:
373                 RETVAL = SDL_RWFromFP(fp,autoclose);
374         OUTPUT:
375                 RETVAL
376
377 SDL_RWops*
378 RWFromMem ( mem, size )
379         char* mem
380         int size
381         CODE:
382                 RETVAL = SDL_RWFromMem((void*)mem,size);
383         OUTPUT:
384                 RETVAL
385
386 SDL_RWops*
387 RWFromConstMem ( mem, size )
388         const char* mem
389         int size
390         CODE:
391                 RETVAL = SDL_RWFromConstMem((const void*)mem,size);
392         OUTPUT:
393                 RETVAL
394
395 SDL_RWops*
396 AllocRW ()
397         CODE:
398                 RETVAL = SDL_AllocRW();
399         OUTPUT:
400                 RETVAL
401
402 void
403 FreeRW ( rw )
404         SDL_RWops* rw
405         CODE:
406                 SDL_FreeRW(rw);
407
408 int
409 RWseek ( rw, off, whence )
410         SDL_RWops* rw
411         int off
412         int whence
413         CODE:
414                 RETVAL = SDL_RWseek(rw,off,whence);
415         OUTPUT:
416                 RETVAL
417
418 int
419 RWtell ( rw )
420         SDL_RWops* rw
421         CODE:
422                 RETVAL = SDL_RWtell(rw);
423         OUTPUT:
424                 RETVAL
425
426 int
427 RWread ( rw, mem, size, n )
428         SDL_RWops* rw
429         char* mem
430         int size
431         int n
432         CODE:
433                 RETVAL = SDL_RWread(rw,mem,size,n);
434         OUTPUT:
435                 RETVAL
436
437 int
438 RWwrite ( rw, mem, size, n )
439         SDL_RWops* rw
440         char* mem
441         int size
442         int n
443         CODE:
444                 RETVAL = SDL_RWwrite(rw,mem,size,n);
445         OUTPUT:
446                 RETVAL
447
448 int
449 RWclose ( rw )
450         SDL_RWops* rw
451         CODE:
452                 RETVAL = SDL_RWclose(rw);
453         OUTPUT:
454                 RETVAL
455
456 int
457 CDNumDrives ()
458         CODE:
459                 RETVAL = SDL_CDNumDrives();
460         OUTPUT:
461                 RETVAL
462
463 char *
464 CDName ( drive )
465         int drive
466         CODE:
467                 RETVAL = strdup(SDL_CDName(drive));
468         OUTPUT:
469                 RETVAL
470
471 SDL_CD *
472 CDOpen ( drive )
473         int drive
474         CODE:
475                 RETVAL = SDL_CDOpen(drive);
476         OUTPUT:
477                 RETVAL
478
479 Uint8
480 CDTrackId ( track )
481         SDL_CDtrack *track
482         CODE:
483                 RETVAL = track->id;
484         OUTPUT:
485                 RETVAL
486
487 Uint8
488 CDTrackType ( track )
489         SDL_CDtrack *track
490         CODE:
491                 RETVAL = track->type;
492         OUTPUT:
493                 RETVAL
494
495 Uint16
496 CDTrackLength ( track )
497         SDL_CDtrack *track
498         CODE:
499                 RETVAL = track->length;
500         OUTPUT:
501                 RETVAL
502
503 Uint32
504 CDTrackOffset ( track )
505         SDL_CDtrack *track
506         CODE:
507                 RETVAL = track->offset;
508         OUTPUT: 
509                 RETVAL
510
511 Uint32
512 CDStatus ( cd )
513         SDL_CD *cd 
514         CODE:
515                 RETVAL = SDL_CDStatus(cd);
516         OUTPUT:
517                 RETVAL
518
519 int
520 CDPlayTracks ( cd, start_track, ntracks, start_frame, nframes )
521         SDL_CD *cd
522         int start_track
523         int ntracks
524         int start_frame
525         int nframes
526         CODE:
527                 RETVAL = SDL_CDPlayTracks(cd,start_track,start_frame,ntracks,nframes);
528         OUTPUT:
529                 RETVAL
530
531 int
532 CDPlay ( cd, start, length )
533         SDL_CD *cd
534         int start
535         int length
536         CODE:
537                 RETVAL = SDL_CDPlay(cd,start,length);
538         OUTPUT:
539                 RETVAL
540
541 int
542 CDPause ( cd )
543         SDL_CD *cd
544         CODE:
545                 RETVAL = SDL_CDPause(cd);
546         OUTPUT:
547                 RETVAL
548
549 int
550 CDResume ( cd )
551         SDL_CD *cd
552         CODE:
553                 RETVAL = SDL_CDResume(cd);
554         OUTPUT:
555                 RETVAL
556
557 int
558 CDStop ( cd )
559         SDL_CD *cd
560         CODE:
561                 RETVAL = SDL_CDStop(cd);
562         OUTPUT:
563                 RETVAL
564
565 int
566 CDEject ( cd )
567         SDL_CD *cd
568         CODE:
569                 RETVAL = SDL_CDEject(cd);
570         OUTPUT:
571                 RETVAL
572
573 void
574 CDClose ( cd )
575         SDL_CD *cd
576         CODE:
577                 SDL_CDClose(cd);
578         
579 int
580 CDId ( cd )
581         SDL_CD *cd
582         CODE:
583                 RETVAL = cd->id;
584         OUTPUT: 
585                 RETVAL
586
587 int
588 CDNumTracks ( cd )
589         SDL_CD *cd
590         CODE:
591                 RETVAL = cd->numtracks;
592         OUTPUT:
593                 RETVAL
594
595 int
596 CDCurTrack ( cd )
597         SDL_CD *cd
598         CODE:
599                 RETVAL = cd->cur_track;
600         OUTPUT:
601                 RETVAL
602
603 int
604 CDCurFrame ( cd )
605         SDL_CD *cd
606         CODE:
607                 RETVAL = cd->cur_frame;
608         OUTPUT:
609                 RETVAL
610
611 SDL_CDtrack *
612 CDTrack ( cd, number )
613         SDL_CD *cd
614         int number
615         CODE:
616                 RETVAL = (SDL_CDtrack *)(cd->track + number);
617         OUTPUT:
618                 RETVAL
619
620 void
621 PumpEvents ()
622         CODE:
623                 SDL_PumpEvents();
624
625 int
626 PushEvent( e )
627         SDL_Event *e
628         CODE:
629                 RETVAL = SDL_PushEvent( e );
630         OUTPUT:
631                 RETVAL
632
633 SDL_Event *
634 NewEvent ()
635         CODE:   
636                 RETVAL = (SDL_Event *) safemalloc (sizeof(SDL_Event));
637         OUTPUT:
638                 RETVAL
639
640 void
641 FreeEvent ( e )
642         SDL_Event *e
643         CODE:
644                 safefree(e);
645
646 int
647 PollEvent ( e )
648         SDL_Event *e
649         CODE:
650                 RETVAL = SDL_PollEvent(e);
651         OUTPUT:
652                 RETVAL
653
654 int
655 WaitEvent ( e )
656         SDL_Event *e
657         CODE:
658                 RETVAL = SDL_WaitEvent(e);
659         OUTPUT:
660                 RETVAL
661
662 Uint8
663 EventState ( type, state )
664         Uint8 type
665         int state
666         CODE:
667                 RETVAL = SDL_EventState(type,state);
668         OUTPUT:
669                 RETVAL 
670
671 Uint8
672 EventType ( e )
673         SDL_Event *e
674         CODE:
675                 RETVAL = e->type;
676         OUTPUT:
677                 RETVAL
678
679 Uint8
680 SetEventType ( e, type )
681         SDL_Event *e
682         Uint8 type
683         CODE:
684                 RETVAL = e->type;
685                 e->type = type;
686         OUTPUT:
687                 RETVAL
688
689 Uint8
690 ActiveEventGain ( e )
691         SDL_Event *e
692         CODE:
693                 RETVAL = e->active.gain;
694         OUTPUT: 
695                 RETVAL
696
697 Uint8
698 ActiveEventState ( e )
699         SDL_Event *e
700         CODE:
701                 RETVAL = e->active.state;
702         OUTPUT:
703                 RETVAL
704
705 Uint8
706 KeyEventState( e )
707         SDL_Event *e
708         CODE:
709                 RETVAL = e->key.state;
710         OUTPUT:
711                 RETVAL
712
713 int
714 KeyEventSym ( e )
715         SDL_Event *e
716         CODE:
717                 RETVAL = e->key.keysym.sym;
718         OUTPUT:
719                 RETVAL
720
721 int 
722 KeyEventMod ( e )
723         SDL_Event *e
724         CODE:
725                 RETVAL = e->key.keysym.mod;
726         OUTPUT:
727                 RETVAL
728
729 Uint16
730 KeyEventUnicode ( e )
731         SDL_Event *e
732         CODE:
733                 RETVAL = e->key.keysym.unicode;
734         OUTPUT:
735                 RETVAL
736
737 Uint8
738 KeyEventScanCode ( e )
739         SDL_Event *e
740         CODE:
741                 RETVAL = e->key.keysym.scancode;
742         OUTPUT:
743                 RETVAL
744
745 Uint8
746 MouseMotionState ( e )
747         SDL_Event *e
748         CODE:
749                 RETVAL = e->motion.state;
750         OUTPUT: 
751                 RETVAL
752
753 Uint16
754 MouseMotionX ( e )
755         SDL_Event *e
756         CODE:
757                 RETVAL = e->motion.x;
758         OUTPUT:
759                 RETVAL
760
761 Uint16
762 MouseMotionY ( e )
763         SDL_Event *e
764         CODE:
765                 RETVAL = e->motion.y;
766         OUTPUT:
767                 RETVAL
768
769 Sint16
770 MouseMotionXrel( e )
771         SDL_Event *e
772         CODE:
773                 RETVAL = e->motion.xrel;
774         OUTPUT:
775                 RETVAL
776
777 Sint16
778 MouseMotionYrel ( e )
779         SDL_Event *e
780         CODE:
781                 RETVAL = e->motion.yrel;
782         OUTPUT:
783                 RETVAL
784
785 Uint8
786 MouseButtonState ( e )
787         SDL_Event *e
788         CODE:
789                 RETVAL = e->button.state;
790         OUTPUT:
791                 RETVAL
792
793 Uint8
794 MouseButton ( e )
795         SDL_Event *e
796         CODE:
797                 RETVAL = e->button.button;
798         OUTPUT:
799                 RETVAL
800
801 Uint16
802 MouseButtonX ( e )
803         SDL_Event *e
804         CODE:
805                 RETVAL = e->button.x;
806         OUTPUT:
807                 RETVAL
808
809 Uint16
810 MouseButtonY ( e )
811         SDL_Event *e
812         CODE:
813                 RETVAL = e->button.y;
814         OUTPUT:
815                 RETVAL
816
817 SDL_SysWMmsg *
818 SysWMEventMsg ( e )
819         SDL_Event *e
820         CODE:
821                 RETVAL = e->syswm.msg;
822         OUTPUT:
823                 RETVAL
824
825 int
826 EnableUnicode ( enable )
827         int enable
828         CODE:
829                 RETVAL = SDL_EnableUNICODE(enable);
830         OUTPUT:
831                 RETVAL
832
833 void
834 EnableKeyRepeat ( delay, interval )
835         int delay
836         int interval
837         CODE:
838                 SDL_EnableKeyRepeat(delay,interval);
839
840 Uint32
841 GetModState ()
842         CODE:
843                 RETVAL = SDL_GetModState();
844         OUTPUT:
845                 RETVAL
846
847 void
848 SetModState ( state )
849         Uint32 state
850         CODE:
851                 SDL_SetModState(state);
852
853 char *
854 GetKeyName ( sym )
855         int sym
856         CODE:
857                 RETVAL = SDL_GetKeyName(sym);
858         OUTPUT:
859                 RETVAL
860
861 SDL_Surface *
862 CreateRGBSurface (flags, width, height, depth, Rmask, Gmask, Bmask, Amask )
863         Uint32 flags
864         int width
865         int height
866         int depth
867         Uint32 Rmask
868         Uint32 Gmask
869         Uint32 Bmask
870         Uint32 Amask
871         CODE:
872                 RETVAL = SDL_CreateRGBSurface ( flags, width, height,
873                                 depth, Rmask, Gmask, Bmask, Amask );
874         OUTPUT: 
875                 RETVAL
876
877
878 SDL_Surface *
879 CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask )
880         char *pixels
881         int width
882         int height
883         int depth
884         int pitch
885         Uint32 Rmask
886         Uint32 Gmask
887         Uint32 Bmask
888         Uint32 Amask
889         CODE:
890                 Uint8* pixeldata;
891                 Uint32 len = pitch * height;
892                 New(0,pixeldata,len,Uint8);
893                 Copy(pixels,pixeldata,len,Uint8);
894                 RETVAL = SDL_CreateRGBSurfaceFrom ( pixeldata, width, height,
895                                 depth, pitch, Rmask, Gmask, Bmask, Amask );
896         OUTPUT: 
897                 RETVAL
898
899 #ifdef HAVE_SDL_IMAGE
900
901 SDL_Surface *
902 IMGLoad ( fname )
903         char *fname
904         CODE:
905                 RETVAL = IMG_Load(fname);
906         OUTPUT:
907                 RETVAL
908
909 #endif
910
911 SDL_Surface*
912 SurfaceCopy ( surface )
913         SDL_Surface *surface
914         CODE:
915                 Uint8* pixels;
916                 Uint32 size = surface->pitch * surface->h;
917                 New(0,pixels,size,Uint8);
918                 Copy(surface->pixels,pixels,size,Uint8);
919                 RETVAL = SDL_CreateRGBSurfaceFrom(pixels,surface->w,surface->h,
920                         surface->format->BitsPerPixel, surface->pitch,
921                         surface->format->Rmask, surface->format->Gmask,
922                         surface->format->Bmask, surface->format->Amask);
923         OUTPUT:
924                 RETVAL
925
926 void
927 FreeSurface ( surface )
928         SDL_Surface *surface
929         CODE:
930                 if (surface) {
931                         Uint8* pixels = surface->pixels;
932                         Uint32 flags = surface->flags;
933                         SDL_FreeSurface(surface);
934                         if (flags & SDL_PREALLOC)
935                                 Safefree(pixels);
936                 }
937         
938 Uint32
939 SurfaceFlags ( surface )
940         SDL_Surface *surface
941         CODE:
942                 RETVAL = surface->flags;
943         OUTPUT:
944                 RETVAL
945
946 SDL_Palette *
947 SurfacePalette ( surface )
948         SDL_Surface *surface
949         CODE:
950                 RETVAL = surface->format->palette;
951         OUTPUT:
952                 RETVAL
953
954 Uint8
955 SurfaceBitsPerPixel ( surface )
956         SDL_Surface *surface
957         CODE:
958                 RETVAL = surface->format->BitsPerPixel;
959         OUTPUT:
960                 RETVAL
961
962 Uint8
963 SurfaceBytesPerPixel ( surface )
964         SDL_Surface *surface
965         CODE:   
966                 RETVAL = surface->format->BytesPerPixel;
967         OUTPUT:
968                 RETVAL
969
970 Uint8
971 SurfaceRshift ( surface )
972         SDL_Surface *surface
973         CODE:
974                 RETVAL = surface->format->Rshift;
975         OUTPUT:
976                 RETVAL
977
978 Uint8
979 SurfaceGshift ( surface )
980         SDL_Surface *surface
981         CODE:
982                 RETVAL = surface->format->Gshift;
983         OUTPUT:
984                 RETVAL
985
986 Uint8
987 SurfaceBshift ( surface )
988         SDL_Surface *surface
989         CODE:
990                 RETVAL = surface->format->Bshift;
991         OUTPUT:
992                 RETVAL
993
994 Uint8
995 SurfaceAshift ( surface )
996         SDL_Surface *surface
997         CODE:
998                 RETVAL = surface->format->Ashift;
999         OUTPUT:
1000                 RETVAL
1001
1002 Uint32
1003 SurfaceRmask( surface )
1004         SDL_Surface *surface
1005         CODE:
1006                 RETVAL = surface->format->Rmask;
1007         OUTPUT:
1008                 RETVAL
1009
1010 Uint32
1011 SurfaceGmask ( surface )
1012         SDL_Surface *surface
1013         CODE:
1014                 RETVAL = surface->format->Gmask;
1015         OUTPUT:
1016                 RETVAL
1017
1018 Uint32
1019 SurfaceBmask ( surface )
1020         SDL_Surface *surface
1021         CODE:
1022                 RETVAL = surface->format->Bmask;
1023         OUTPUT:
1024                 RETVAL
1025
1026 Uint32
1027 SurfaceAmask ( surface )
1028         SDL_Surface *surface
1029         CODE:
1030                 RETVAL = surface->format->Amask;
1031         OUTPUT:
1032                 RETVAL
1033
1034 Uint32
1035 SurfaceColorKey ( surface )
1036         SDL_Surface *surface
1037         CODE:
1038                 RETVAL = surface->format->colorkey;
1039         OUTPUT:
1040                 RETVAL
1041
1042 Uint32
1043 SurfaceAlpha( surface )
1044         SDL_Surface *surface
1045         CODE:
1046                 RETVAL = surface->format->alpha;
1047         OUTPUT:
1048                 RETVAL
1049
1050 int
1051 SurfaceW ( surface )
1052         SDL_Surface *surface
1053         CODE:   
1054                 RETVAL = surface->w;
1055         OUTPUT:
1056                 RETVAL
1057
1058 int
1059 SurfaceH ( surface )
1060         SDL_Surface *surface
1061         CODE:   
1062                 RETVAL = surface->h;
1063         OUTPUT:
1064                 RETVAL
1065
1066 Uint16
1067 SurfacePitch ( surface )
1068         SDL_Surface *surface
1069         CODE:   
1070                 RETVAL = surface->pitch;
1071         OUTPUT:
1072                 RETVAL
1073
1074 SV*
1075 SurfacePixels ( surface )
1076         SDL_Surface *surface
1077         CODE:   
1078                 RETVAL = newSVpvn(surface->pixels,surface->pitch*surface->h);
1079         OUTPUT:
1080                 RETVAL
1081
1082 SDL_Color*
1083 SurfacePixel ( surface, x, y, ... )
1084         SDL_Surface *surface
1085         Sint32 x
1086         Sint32 y
1087         CODE:
1088                 SDL_Color* color;
1089                 int pix,index;
1090                 Uint8 r,g,b,a;
1091                 int bpp = surface->format->BytesPerPixel;
1092                 Uint8* p = (Uint8*)surface->pixels + bpp*x + surface->pitch*y;
1093                 if ( items < 3 || items > 4 ) 
1094                         Perl_croak(aTHX_ "usage: SDL::SurfacePixel(surface,x,y,[color])");
1095                 if ( items == 4) {
1096                         color = (SDL_Color*)SvIV(ST(3));
1097                         pix = SDL_MapRGB(surface->format,color->r,color->g,color->b);
1098                         switch(bpp) {
1099                                 case 1:
1100                                         *(Uint8*)p = pix;
1101                                         break;
1102                                 case 2:
1103                                         *(Uint16*)p = pix;
1104                                         break;
1105                                 case 3:
1106                                         if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
1107                                                 p[0] = (pix >> 16) & 0xff;
1108                                                 p[1] = (pix >> 8) & 0xff;
1109                                                 p[2] = pix & 0xff;
1110                                         } else {
1111                                                 p[0] = pix & 0xff;
1112                                                 p[1] = (pix >> 8) & 0xff;
1113                                                 p[2] = (pix >> 16) & 0xff;
1114                                         }
1115                                         break;
1116                                 case 4:
1117                                         *(Uint32*)p = pix;
1118                                         break;
1119                         }
1120                 }
1121                 RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color));
1122                 switch(bpp) {
1123                         case 1:
1124                                 index = *(Uint8*)p;
1125                                 memcpy(RETVAL,&surface->format->palette[index],sizeof(SDL_Color));
1126                                 break;
1127                         case 2:
1128                                 pix = *(Uint16*)p;
1129                                 SDL_GetRGB(pix,surface->format,&r,&g,&b);
1130                                 RETVAL->r = r;
1131                                 RETVAL->g = g;
1132                                 RETVAL->b = b;
1133                                 break;
1134                         case 3:
1135                         case 4:
1136                                 pix = *(Uint32*)p;
1137                                 SDL_GetRGB(pix,surface->format,&r,&g,&b);
1138                                 RETVAL->r = r;
1139                                 RETVAL->g = g;
1140                                 RETVAL->b = b;
1141                                 break;
1142                 }
1143         OUTPUT:
1144                 RETVAL
1145
1146 int
1147 MUSTLOCK ( surface )
1148         SDL_Surface *surface
1149         CODE:
1150                 RETVAL = SDL_MUSTLOCK(surface);
1151         OUTPUT:
1152                 RETVAL          
1153
1154 int
1155 SurfaceLock ( surface )
1156         SDL_Surface *surface
1157         CODE:
1158                 RETVAL = SDL_LockSurface(surface);
1159         OUTPUT:
1160                 RETVAL
1161
1162 void
1163 SurfaceUnlock ( surface )
1164         SDL_Surface *surface
1165         CODE:
1166                 SDL_UnlockSurface(surface);
1167
1168 SDL_Surface *
1169 GetVideoSurface ()
1170         CODE:
1171                 RETVAL = SDL_GetVideoSurface();
1172         OUTPUT:
1173                 RETVAL
1174
1175
1176 HV *
1177 VideoInfo ()
1178         CODE:
1179                 HV *hv;
1180                 SDL_VideoInfo *info;
1181                 info = (SDL_VideoInfo *) safemalloc ( sizeof(SDL_VideoInfo));
1182                 memcpy(info,SDL_GetVideoInfo(),sizeof(SDL_VideoInfo));
1183                 hv = newHV();
1184                 hv_store(hv,"hw_available",strlen("hw_available"),
1185                         newSViv(info->hw_available),0);
1186                 hv_store(hv,"wm_available",strlen("wm_available"),
1187                         newSViv(info->wm_available),0);
1188                 hv_store(hv,"blit_hw",strlen("blit_hw"),
1189                         newSViv(info->blit_hw),0);
1190                 hv_store(hv,"blit_hw_CC",strlen("blit_hw_CC"),
1191                         newSViv(info->blit_hw_CC),0);
1192                 hv_store(hv,"blit_hw_A",strlen("blit_hw_A"),
1193                         newSViv(info->blit_hw_A),0);
1194                 hv_store(hv,"blit_sw",strlen("blit_sw"),
1195                         newSViv(info->blit_sw),0);
1196                 hv_store(hv,"blit_sw_CC",strlen("blit_sw_CC"),
1197                         newSViv(info->blit_sw_CC),0);
1198                 hv_store(hv,"blit_sw_A",strlen("blit_sw_A"),
1199                         newSViv(info->blit_sw_A),0);
1200                 hv_store(hv,"blit_fill",strlen("blit_fill"),
1201                         newSViv(info->blit_fill),0);
1202                 hv_store(hv,"video_mem",strlen("video_mem"),
1203                         newSViv(info->video_mem),0);
1204                 RETVAL = hv;
1205         OUTPUT:
1206                 RETVAL
1207
1208 AV*
1209 ListModes ( format, flags )
1210         Uint32 flags
1211         SDL_PixelFormat *format
1212         CODE:
1213                 SDL_Rect **mode;
1214                 RETVAL = newAV();
1215                 mode = SDL_ListModes(format,flags);
1216                 if (mode == (SDL_Rect**)-1 ) {
1217                         av_push(RETVAL,newSVpv("all",0));
1218                 } else if (! mode ) {
1219                         av_push(RETVAL,newSVpv("none",0));
1220                 } else {
1221                         for (;*mode;mode++) {
1222                                 av_push(RETVAL,newSViv(PTR2IV(*mode)));
1223                         }
1224                 }
1225         OUTPUT:
1226                 RETVAL
1227
1228
1229 SDL_Color *
1230 NewColor ( r, g, b )
1231         Uint8 r
1232         Uint8 g
1233         Uint8 b
1234         CODE:
1235                 RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color));
1236                 RETVAL->r = r;
1237                 RETVAL->g = g;
1238                 RETVAL->b = b;
1239         OUTPUT:
1240                 RETVAL
1241
1242 Uint8
1243 ColorR ( color, ... )
1244         SDL_Color *color
1245         CODE:
1246                 if (items > 1 ) color->r = SvIV(ST(1)); 
1247                 RETVAL = color->r;
1248         OUTPUT:
1249                 RETVAL
1250
1251 Uint8
1252 ColorG ( color, ... )
1253         SDL_Color *color
1254         CODE:
1255                 if (items > 1 ) color->g = SvIV(ST(1)); 
1256                 RETVAL = color->g;
1257         OUTPUT:
1258                 RETVAL
1259
1260 Uint8
1261 ColorB ( color, ... )
1262         SDL_Color *color
1263         CODE:
1264                 if (items > 1 ) color->b = SvIV(ST(1)); 
1265                 RETVAL = color->b;
1266         OUTPUT:
1267                 RETVAL
1268
1269
1270 void
1271 ColorRGB ( color, ... )
1272  SDL_Color *color
1273  PPCODE:
1274  if (items > 1 ) {
1275  color->r = SvIV(ST(1));
1276  color->g = SvIV(ST(2));
1277  color->b = SvIV(ST(3));
1278  }
1279  mXPUSHi( color->r );
1280  mXPUSHi( color->g );
1281  mXPUSHi( color->b );
1282  XSRETURN(3);
1283
1284 void
1285 FreeColor ( color )
1286         SDL_Color *color
1287         CODE:
1288                 return; safefree(color);
1289
1290 SDL_Palette *
1291 NewPalette ( number )
1292         int number
1293         CODE:
1294                 RETVAL = (SDL_Palette *)safemalloc(sizeof(SDL_Palette));
1295                 RETVAL->colors = (SDL_Color *)safemalloc(number * 
1296                                                 sizeof(SDL_Color));
1297                 RETVAL->ncolors = number;
1298         OUTPUT:
1299                 RETVAL
1300
1301 int
1302 PaletteNColors ( palette, ... )
1303         SDL_Palette *palette
1304         CODE:
1305                 if ( items > 1 ) palette->ncolors = SvIV(ST(1));
1306                 RETVAL = palette->ncolors;
1307         OUTPUT:
1308                 RETVAL
1309
1310 SDL_Color *
1311 PaletteColors ( palette, index, ... )
1312         SDL_Palette *palette
1313         int index
1314         CODE:
1315                 if ( items > 2 ) {
1316                         palette->colors[index].r = SvUV(ST(2)); 
1317                         palette->colors[index].g = SvUV(ST(3)); 
1318                         palette->colors[index].b = SvUV(ST(4)); 
1319                 }
1320                 RETVAL = (SDL_Color *)(palette->colors + index);
1321         OUTPUT:
1322                 RETVAL
1323
1324 int
1325 VideoModeOK ( width, height, bpp, flags )
1326         int width
1327         int height
1328         int bpp
1329         Uint32 flags
1330         CODE:
1331                 RETVAL = SDL_VideoModeOK(width,height,bpp,flags);
1332         OUTPUT:
1333                 RETVAL
1334
1335 SDL_Surface *
1336 SetVideoMode ( width, height, bpp, flags )
1337         int width
1338         int height
1339         int bpp
1340         Uint32 flags
1341         CODE:
1342                 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
1343         OUTPUT:
1344                 RETVAL
1345
1346 void
1347 UpdateRect ( surface, x, y, w ,h )
1348         SDL_Surface *surface
1349         int x
1350         int y
1351         int w
1352         int h
1353         CODE:
1354                 SDL_UpdateRect(surface,x,y,w,h);
1355
1356 void
1357 UpdateRects ( surface, ... )
1358         SDL_Surface *surface
1359         CODE:
1360                 SDL_Rect *rects, *temp;
1361                 int num_rects,i;
1362                 if ( items < 2 ) return;
1363                 num_rects = items - 1;
1364                         
1365                 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
1366                 for(i=0;i<num_rects;i++) {
1367                         temp = (SDL_Rect *)SvIV(ST(i+1));
1368                         rects[i].x = temp->x;
1369                         rects[i].y = temp->y;
1370                         rects[i].w = temp->w;
1371                         rects[i].h = temp->h;
1372                 } 
1373                 SDL_UpdateRects(surface,num_rects,rects);
1374                 safefree(rects);
1375                 
1376
1377 int
1378 Flip ( surface )
1379         SDL_Surface *surface
1380         CODE:
1381                 RETVAL = SDL_Flip(surface);
1382         OUTPUT:
1383                 RETVAL
1384
1385 int
1386 SetColors ( surface, start, ... )
1387         SDL_Surface *surface
1388         int start
1389         CODE:
1390                 SDL_Color *colors,*temp;
1391                 int i, length;
1392                 if ( items < 3 ) { RETVAL = 0;  goto all_done; }
1393                 length = items - 2;
1394                 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
1395                 for ( i = 0; i < length ; i++ ) {
1396                         temp = (SDL_Color *)SvIV(ST(i+2));
1397                         colors[i].r = temp->r;
1398                         colors[i].g = temp->g;
1399                         colors[i].b = temp->b;
1400                 }
1401                 RETVAL = SDL_SetColors(surface, colors, start, length );
1402                 safefree(colors);
1403 all_done:
1404         OUTPUT: 
1405                 RETVAL
1406
1407 Uint32
1408 MapRGB ( surface, r, g, b )
1409         SDL_Surface *surface
1410         Uint8 r
1411         Uint8 g
1412         Uint8 b
1413         CODE:
1414                 RETVAL = SDL_MapRGB(surface->format,r,g,b);
1415         OUTPUT:
1416                 RETVAL
1417
1418 Uint32
1419 MapRGBA ( surface, r, g, b, a )
1420         SDL_Surface *surface
1421         Uint8 r
1422         Uint8 g
1423         Uint8 b
1424         Uint8 a
1425         CODE:
1426                 RETVAL = SDL_MapRGBA(surface->format,r,g,b,a);
1427         OUTPUT:
1428                 RETVAL
1429
1430 AV *
1431 GetRGB ( surface, pixel )
1432         SDL_Surface *surface
1433         Uint32 pixel
1434         CODE:
1435                 Uint8 r,g,b;
1436                 SDL_GetRGB(pixel,surface->format,&r,&g,&b);
1437                 RETVAL = newAV();
1438                 av_push(RETVAL,newSViv(r));
1439                 av_push(RETVAL,newSViv(g));
1440                 av_push(RETVAL,newSViv(b));
1441         OUTPUT:
1442                 RETVAL
1443
1444 AV *
1445 GetRGBA ( surface, pixel )
1446         SDL_Surface *surface
1447         Uint32 pixel
1448         CODE:
1449                 Uint8 r,g,b,a;
1450                 SDL_GetRGBA(pixel,surface->format,&r,&g,&b,&a);
1451                 RETVAL = newAV();
1452                 av_push(RETVAL,newSViv(r));
1453                 av_push(RETVAL,newSViv(g));
1454                 av_push(RETVAL,newSViv(b));
1455                 av_push(RETVAL,newSViv(a));
1456         OUTPUT:
1457                 RETVAL
1458
1459 int
1460 SaveBMP ( surface, filename )
1461         SDL_Surface *surface
1462         char *filename
1463         CODE:
1464                 RETVAL = SDL_SaveBMP(surface,filename);
1465         OUTPUT:
1466                 RETVAL  
1467
1468 int
1469 SetColorKey ( surface, flag, key )
1470         SDL_Surface *surface
1471         Uint32 flag
1472         SDL_Color *key
1473         CODE:
1474                 Uint32 pixel = SDL_MapRGB(surface->format,key->r,key->g,key->b);
1475                 RETVAL = SDL_SetColorKey(surface,flag,pixel);
1476         OUTPUT:
1477                 RETVAL
1478
1479 int
1480 SetAlpha ( surface, flag, alpha )
1481         SDL_Surface *surface
1482         Uint32 flag
1483         Uint8 alpha
1484         CODE:
1485                 RETVAL = SDL_SetAlpha(surface,flag,alpha);
1486         OUTPUT:
1487                 RETVAL
1488
1489 SDL_Surface *
1490 DisplayFormat ( surface )
1491         SDL_Surface *surface
1492         CODE:
1493                 RETVAL = SDL_DisplayFormat(surface);
1494         OUTPUT:
1495                 RETVAL
1496
1497 SDL_Surface*
1498 DisplayFormatAlpha ( surface )
1499         SDL_Surface *surface
1500         CODE:
1501                 RETVAL = SDL_DisplayFormatAlpha(surface);
1502         OUTPUT:
1503                 RETVAL
1504
1505 SDL_Surface*
1506 ConvertRGB ( surface )
1507         SDL_Surface * surface
1508         CODE:
1509                 SDL_PixelFormat fmt;
1510                 fmt.palette = NULL;
1511                 fmt.BitsPerPixel = 24;
1512                 fmt.BytesPerPixel = 3;
1513                 fmt.Rmask = 0x000000ff;
1514                 fmt.Gmask = 0x0000ff00;
1515                 fmt.Bmask = 0x00ff0000;
1516                 fmt.Amask = 0x00000000;
1517                 fmt.Rloss = 0;
1518                 fmt.Gloss = 0;
1519                 fmt.Bloss = 0;
1520                 fmt.Aloss = 0;
1521                 fmt.Rshift = 0;
1522                 fmt.Gshift = 8;
1523                 fmt.Bshift = 16;
1524                 fmt.Ashift = 24;
1525                 fmt.colorkey = 0;
1526                 fmt.alpha = 0;
1527                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1528         OUTPUT:
1529                 RETVAL
1530
1531 SDL_Surface* 
1532 ConvertRGBA ( surface )
1533         SDL_Surface * surface
1534         CODE:
1535                 SDL_PixelFormat fmt;
1536                 fmt.palette = NULL;
1537                 fmt.BitsPerPixel = 32;
1538                 fmt.BytesPerPixel = 4;
1539                 fmt.Rmask = 0x000000ff;
1540                 fmt.Gmask = 0x0000ff00;
1541                 fmt.Bmask = 0x00ff0000;
1542                 fmt.Amask = 0xff000000;
1543                 fmt.Rloss = 0;
1544                 fmt.Gloss = 0;
1545                 fmt.Bloss = 0;
1546                 fmt.Aloss = 0;
1547                 fmt.Rshift = 0;
1548                 fmt.Gshift = 8;
1549                 fmt.Bshift = 16;
1550                 fmt.Ashift = 24;
1551                 fmt.colorkey = 0;
1552                 fmt.alpha = 0;
1553                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1554         OUTPUT:
1555                 RETVAL
1556
1557 int
1558 BlitSurface ( src, src_rect, dest, dest_rect )
1559         SDL_Surface *src
1560
1561         SDL_Surface *dest
1562
1563         SDL_Rect *src_rect
1564
1565         SDL_Rect *dest_rect
1566         CODE:
1567                 RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
1568         OUTPUT:
1569                 RETVAL
1570
1571 int
1572 FillRect ( dest, dest_rect, color )
1573         SDL_Surface *dest
1574         
1575         SDL_Color *color
1576         
1577         SDL_Rect *dest_rect
1578
1579         CODE:
1580                 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
1581                 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
1582         OUTPUT:
1583                 RETVAL
1584
1585 Uint8
1586 GetAppState ()
1587         CODE:
1588                 RETVAL = SDL_GetAppState();
1589         OUTPUT:
1590                 RETVAL
1591
1592
1593 void
1594 WMSetCaption ( title, icon )
1595         char *title
1596         char *icon
1597         CODE:
1598                 SDL_WM_SetCaption(title,icon);
1599
1600 AV *
1601 WMGetCaption ()
1602         CODE:
1603                 char *title,*icon;
1604                 SDL_WM_GetCaption(&title,&icon);
1605                 RETVAL = newAV();
1606                 av_push(RETVAL,newSVpv(title,0));
1607                 av_push(RETVAL,newSVpv(icon,0));
1608         OUTPUT:
1609                 RETVAL
1610
1611 void
1612 WMSetIcon ( icon )
1613         SDL_Surface *icon
1614         CODE:
1615                 SDL_WM_SetIcon(icon,NULL);
1616
1617 void
1618 WarpMouse ( x, y )
1619         Uint16 x
1620         Uint16 y
1621         CODE:
1622                 SDL_WarpMouse(x,y);
1623
1624 AV*
1625 GetMouseState ()
1626         CODE:
1627                 Uint8 mask;
1628                 int x;
1629                 int y;
1630                 mask = SDL_GetMouseState(&x,&y);
1631                 RETVAL = newAV();
1632                 av_push(RETVAL,newSViv(mask));
1633                 av_push(RETVAL,newSViv(x));
1634                 av_push(RETVAL,newSViv(y));
1635         OUTPUT:
1636                 RETVAL  
1637
1638 AV*
1639 GetRelativeMouseState ()
1640         CODE:
1641                 Uint8 mask;
1642                 int x;
1643                 int y;
1644                 mask = SDL_GetRelativeMouseState(&x,&y);
1645                 RETVAL = newAV();
1646                 av_push(RETVAL,newSViv(mask));
1647                 av_push(RETVAL,newSViv(x));
1648                 av_push(RETVAL,newSViv(y));
1649         OUTPUT:
1650                 RETVAL  
1651
1652 SDL_Cursor *
1653 NewCursor ( data, mask, x ,y )
1654         SDL_Surface *data
1655         SDL_Surface *mask
1656         int x
1657         int y
1658         CODE:
1659                 RETVAL = SDL_CreateCursor((Uint8*)data->pixels,
1660                                 (Uint8*)mask->pixels,data->w,data->h,x,y);
1661         OUTPUT:
1662                 RETVAL
1663
1664 void
1665 FreeCursor ( cursor )
1666         SDL_Cursor *cursor
1667         CODE:
1668                 SDL_FreeCursor(cursor);
1669
1670 void
1671 SetCursor ( cursor )
1672         SDL_Cursor *cursor
1673         CODE:
1674                 SDL_SetCursor(cursor);
1675
1676 SDL_Cursor *
1677 GetCursor ()
1678         CODE:
1679                 RETVAL = SDL_GetCursor();
1680         OUTPUT:
1681                 RETVAL
1682
1683 int
1684 ShowCursor ( toggle )
1685         int toggle
1686         CODE:
1687                 RETVAL = SDL_ShowCursor(toggle);
1688         OUTPUT: 
1689                 RETVAL
1690
1691 SDL_AudioSpec *
1692 NewAudioSpec ( freq, format, channels, samples )
1693         int freq
1694         Uint16 format
1695         Uint8 channels
1696         Uint16 samples
1697         CODE:
1698                 RETVAL = (SDL_AudioSpec *)safemalloc(sizeof(SDL_AudioSpec));
1699                 RETVAL->freq = freq;
1700                 RETVAL->format = format;
1701                 RETVAL->channels = channels;
1702                 RETVAL->samples = samples;
1703         OUTPUT:
1704                 RETVAL
1705
1706 void
1707 FreeAudioSpec ( spec )
1708         SDL_AudioSpec *spec
1709         CODE:
1710                 safefree(spec);
1711
1712 SDL_AudioCVT *
1713 NewAudioCVT ( src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)
1714         Uint16 src_format
1715         Uint8 src_channels
1716         int src_rate
1717         Uint16 dst_format
1718         Uint8 dst_channels
1719         int dst_rate
1720         CODE:
1721                 RETVAL = (SDL_AudioCVT *)safemalloc(sizeof(SDL_AudioCVT));
1722                 if (SDL_BuildAudioCVT(RETVAL,src_format, src_channels, src_rate,
1723                         dst_format, dst_channels, dst_rate)) { 
1724                         safefree(RETVAL); RETVAL = NULL; }
1725         OUTPUT:
1726                 RETVAL
1727
1728 void
1729 FreeAudioCVT ( cvt )
1730         SDL_AudioCVT *cvt
1731         CODE:
1732                 safefree(cvt);
1733
1734 int
1735 ConvertAudioData ( cvt, data, len )
1736         SDL_AudioCVT *cvt
1737         Uint8 *data
1738         int len
1739         CODE:
1740                 cvt->len = len;
1741                 cvt->buf = (Uint8*) safemalloc(cvt->len*cvt->len_mult);
1742                 memcpy(cvt->buf,data,cvt->len);
1743                 RETVAL = SDL_ConvertAudio(cvt);
1744         OUTPUT:
1745                 RETVAL                  
1746
1747 int
1748 OpenAudio ( spec, callback )
1749         SDL_AudioSpec *spec
1750         SV* callback
1751         CODE:
1752                 spec->userdata = (void*)callback;
1753                 spec->callback = sdl_perl_audio_callback;
1754                 RETVAL = SDL_OpenAudio(spec,NULL);
1755         OUTPUT:
1756                 RETVAL
1757
1758 Uint32
1759 GetAudioStatus ()
1760         CODE:
1761                 RETVAL = SDL_GetAudioStatus ();
1762         OUTPUT:
1763                 RETVAL
1764
1765 void
1766 PauseAudio ( p_on )
1767         int p_on
1768         CODE:
1769                 SDL_PauseAudio(p_on);
1770         
1771 void
1772 LockAudio ()
1773         CODE:
1774                 SDL_LockAudio();
1775
1776 void
1777 UnlockAudio ()
1778         CODE:
1779                 SDL_UnlockAudio();
1780
1781 void
1782 CloseAudio ()
1783         CODE:
1784                 SDL_CloseAudio();
1785
1786 void
1787 FreeWAV ( buf )
1788         Uint8 *buf
1789         CODE:
1790                 SDL_FreeWAV(buf);
1791
1792 AV *
1793 LoadWAV ( filename, spec )
1794         char *filename
1795         SDL_AudioSpec *spec
1796         CODE:
1797                 SDL_AudioSpec *temp;
1798                 Uint8 *buf;
1799                 Uint32 len;
1800
1801                 RETVAL = newAV();
1802                 temp = SDL_LoadWAV(filename,spec,&buf,&len);
1803                 if ( ! temp ) goto error;
1804                 av_push(RETVAL,newSViv(PTR2IV(temp)));
1805                 av_push(RETVAL,newSViv(PTR2IV(buf)));
1806                 av_push(RETVAL,newSViv(len));
1807 error:
1808         OUTPUT:
1809                 RETVAL
1810         
1811 #ifdef HAVE_SDL_MIXER
1812
1813 void
1814 MixAudio ( dst, src, len, volume )
1815         Uint8 *dst
1816         Uint8 *src
1817         Uint32 len
1818         int volume
1819         CODE:
1820                 SDL_MixAudio(dst,src,len,volume);
1821
1822 int
1823 MixOpenAudio ( frequency, format, channels, chunksize )
1824         int frequency
1825         Uint16 format
1826         int channels
1827         int chunksize   
1828         CODE:
1829                 RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
1830         OUTPUT:
1831                 RETVAL
1832
1833 int
1834 MixAllocateChannels ( number )
1835         int number
1836         CODE:
1837                 RETVAL = Mix_AllocateChannels(number);
1838         OUTPUT:
1839                 RETVAL
1840
1841 AV *
1842 MixQuerySpec ()
1843         CODE:
1844                 int freq, channels, status;
1845                 Uint16 format;
1846                 status = Mix_QuerySpec(&freq,&format,&channels);
1847                 RETVAL = newAV();
1848                 av_push(RETVAL,newSViv(status));
1849                 av_push(RETVAL,newSViv(freq));
1850                 av_push(RETVAL,newSViv(format));
1851                 av_push(RETVAL,newSViv(channels));
1852         OUTPUT:
1853                 RETVAL
1854
1855 Mix_Chunk *
1856 MixLoadWAV ( filename )
1857         char *filename
1858         CODE:
1859                 RETVAL = Mix_LoadWAV(filename);
1860         OUTPUT:
1861                 RETVAL
1862
1863 Mix_Music *
1864 MixLoadMusic ( filename )
1865         char *filename
1866         CODE:
1867                 RETVAL = Mix_LoadMUS(filename);
1868         OUTPUT:
1869                 RETVAL
1870
1871 Mix_Chunk *
1872 MixQuickLoadWAV ( buf )
1873         Uint8 *buf
1874         CODE:
1875                 RETVAL = Mix_QuickLoad_WAV(buf);
1876         OUTPUT:
1877                 RETVAL
1878
1879 void
1880 MixFreeChunk( chunk )
1881         Mix_Chunk *chunk
1882         CODE:
1883                 Mix_FreeChunk(chunk);
1884
1885 void
1886 MixFreeMusic ( music )
1887         Mix_Music *music
1888         CODE:
1889                 Mix_FreeMusic(music);
1890
1891 void
1892 MixSetPostMixCallback ( func, arg )
1893         void *func
1894         void *arg
1895         CODE:
1896                 Mix_SetPostMix(func,arg);
1897
1898 void*
1899 PerlMixMusicHook ()
1900         CODE:
1901                 RETVAL = sdl_perl_music_callback;
1902         OUTPUT:
1903                 RETVAL
1904
1905 void
1906 MixSetMusicHook ( func, arg )
1907         void *func
1908         void *arg
1909         CODE:
1910                 Mix_HookMusic(func,arg);
1911
1912 void
1913 MixSetMusicFinishedHook ( func )
1914         void *func
1915         CODE:
1916                 mix_music_finished_cv = func;
1917                 Mix_HookMusicFinished(sdl_perl_music_finished_callback);
1918
1919 void *
1920 MixGetMusicHookData ()
1921         CODE:
1922                 RETVAL = Mix_GetMusicHookData();
1923         OUTPUT:
1924                 RETVAL
1925
1926 int
1927 MixReverseChannels ( number )
1928         int number
1929         CODE:
1930                 RETVAL = Mix_ReserveChannels ( number );
1931         OUTPUT:
1932                 RETVAL
1933
1934 int
1935 MixGroupChannel ( which, tag )
1936         int which
1937         int tag
1938         CODE:
1939                 RETVAL = Mix_GroupChannel(which,tag);
1940         OUTPUT:
1941                 RETVAL
1942
1943 int
1944 MixGroupChannels ( from, to, tag )
1945         int from
1946         int to
1947         int tag
1948         CODE:
1949                 RETVAL = Mix_GroupChannels(from,to,tag);
1950         OUTPUT:
1951                 RETVAL
1952
1953 int
1954 MixGroupAvailable ( tag )
1955         int tag
1956         CODE:
1957                 RETVAL = Mix_GroupAvailable(tag);
1958         OUTPUT:
1959                 RETVAL
1960
1961 int
1962 MixGroupCount ( tag )
1963         int tag
1964         CODE:
1965                 RETVAL = Mix_GroupCount(tag);
1966         OUTPUT:
1967                 RETVAL
1968
1969 int
1970 MixGroupOldest ( tag )
1971         int tag
1972         CODE:
1973                 RETVAL = Mix_GroupOldest(tag);
1974         OUTPUT:
1975                 RETVAL
1976
1977 int
1978 MixGroupNewer ( tag )
1979         int tag
1980         CODE:
1981                 RETVAL = Mix_GroupNewer(tag);
1982         OUTPUT:
1983                 RETVAL
1984
1985 int
1986 MixPlayChannel ( channel, chunk, loops )
1987         int channel
1988         Mix_Chunk *chunk
1989         int loops
1990         CODE:
1991                 RETVAL = Mix_PlayChannel(channel,chunk,loops);
1992         OUTPUT:
1993                 RETVAL
1994
1995 int
1996 MixPlayChannelTimed ( channel, chunk, loops, ticks )
1997         int channel
1998         Mix_Chunk *chunk
1999         int loops
2000         int ticks
2001         CODE:
2002                 RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
2003         OUTPUT:
2004                 RETVAL
2005
2006 int
2007 MixPlayMusic ( music, loops )
2008         Mix_Music *music
2009         int loops
2010         CODE:
2011                 RETVAL = Mix_PlayMusic(music,loops);
2012         OUTPUT:
2013                 RETVAL
2014
2015 int
2016 MixFadeInChannel ( channel, chunk, loops, ms )
2017         int channel
2018         Mix_Chunk *chunk
2019         int loops
2020         int ms
2021         CODE:
2022                 RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
2023         OUTPUT:
2024                 RETVAL
2025
2026 int
2027 MixFadeInChannelTimed ( channel, chunk, loops, ms, ticks )
2028         int channel
2029         Mix_Chunk *chunk
2030         int loops
2031         int ticks
2032         int ms
2033         CODE:
2034                 RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
2035         OUTPUT:
2036                 RETVAL
2037
2038 int
2039 MixFadeInMusic ( music, loops, ms )
2040         Mix_Music *music
2041         int loops
2042         int ms
2043         CODE:
2044                 RETVAL = Mix_FadeInMusic(music,loops,ms);
2045         OUTPUT:
2046                 RETVAL
2047
2048 int
2049 MixVolume ( channel, volume )
2050         int channel
2051         int volume
2052         CODE:   
2053                 RETVAL = Mix_Volume(channel,volume);
2054         OUTPUT:
2055                 RETVAL
2056
2057 int
2058 MixVolumeChunk ( chunk, volume )
2059         Mix_Chunk *chunk
2060         int volume
2061         CODE:
2062                 RETVAL = Mix_VolumeChunk(chunk,volume);
2063         OUTPUT:
2064                 RETVAL
2065
2066 int
2067 MixVolumeMusic ( volume )
2068         int volume
2069         CODE:
2070                 RETVAL = Mix_VolumeMusic(volume);
2071         OUTPUT:
2072                 RETVAL
2073
2074 int
2075 MixHaltChannel ( channel )
2076         int channel
2077         CODE:
2078                 RETVAL = Mix_HaltChannel(channel);
2079         OUTPUT:
2080                 RETVAL
2081
2082 int
2083 MixHaltGroup ( tag )
2084         int tag
2085         CODE:
2086                 RETVAL = Mix_HaltGroup(tag);
2087         OUTPUT:
2088                 RETVAL
2089
2090 int
2091 MixHaltMusic ()
2092         CODE:
2093                 RETVAL = Mix_HaltMusic();
2094         OUTPUT:
2095                 RETVAL
2096
2097 int
2098 MixExpireChannel ( channel, ticks )
2099         int channel
2100         int ticks
2101         CODE:
2102                 RETVAL = Mix_ExpireChannel ( channel,ticks);
2103         OUTPUT:
2104                 RETVAL
2105
2106 int
2107 MixFadeOutChannel ( which, ms )
2108         int which
2109         int ms
2110         CODE:
2111                 RETVAL = Mix_FadeOutChannel(which,ms);
2112         OUTPUT:
2113                 RETVAL
2114
2115 int
2116 MixFadeOutGroup ( which, ms )
2117         int which
2118         int ms
2119         CODE:
2120                 RETVAL = Mix_FadeOutGroup(which,ms);
2121         OUTPUT:
2122                 RETVAL
2123
2124 int
2125 MixFadeOutMusic ( ms )
2126         int ms
2127         CODE:
2128                 RETVAL = Mix_FadeOutMusic(ms);
2129         OUTPUT:
2130                 RETVAL
2131
2132 Mix_Fading
2133 MixFadingMusic()
2134         CODE:
2135                 RETVAL = Mix_FadingMusic();
2136         OUTPUT:
2137                 RETVAL
2138
2139 Mix_Fading
2140 MixFadingChannel( which )
2141         int which
2142         CODE:
2143                 RETVAL = Mix_FadingChannel(which);
2144         OUTPUT:
2145                 RETVAL
2146
2147 void
2148 MixPause ( channel )
2149         int channel
2150         CODE:
2151                 Mix_Pause(channel);
2152
2153 void
2154 MixResume ( channel )
2155         int channel
2156         CODE:
2157                 Mix_Resume(channel);
2158
2159 int
2160 MixPaused ( channel )
2161         int channel
2162         CODE:
2163                 RETVAL = Mix_Paused(channel);
2164         OUTPUT:
2165                 RETVAL
2166
2167 void
2168 MixPauseMusic ()
2169         CODE:
2170                 Mix_PauseMusic();
2171
2172 void
2173 MixResumeMusic ()
2174         CODE:
2175                 Mix_ResumeMusic();
2176
2177 void
2178 MixRewindMusic ()
2179         CODE:
2180                 Mix_RewindMusic();
2181
2182 int
2183 MixPausedMusic ()
2184         CODE:
2185                 RETVAL = Mix_PausedMusic();
2186         OUTPUT:
2187                 RETVAL
2188
2189 int
2190 MixPlaying( channel )
2191         int channel     
2192         CODE:
2193                 RETVAL = Mix_Playing(channel);
2194         OUTPUT:
2195                 RETVAL
2196
2197 int
2198 MixPlayingMusic()
2199         CODE:
2200                 RETVAL = Mix_PlayingMusic();
2201         OUTPUT:
2202                 RETVAL
2203
2204
2205 void
2206 MixCloseAudio ()
2207         CODE:
2208                 Mix_CloseAudio();
2209
2210 #endif
2211
2212 int
2213 GLLoadLibrary ( path )
2214         char *path
2215         CODE:
2216                 RETVAL = SDL_GL_LoadLibrary(path);
2217         OUTPUT:
2218                 RETVAL
2219
2220 void*
2221 GLGetProcAddress ( proc )
2222         char *proc
2223         CODE:
2224                 RETVAL = SDL_GL_GetProcAddress(proc);
2225         OUTPUT:
2226                 RETVAL
2227
2228 int
2229 GLSetAttribute ( attr,  value )
2230         int        attr
2231         int        value
2232         CODE:
2233                 RETVAL = SDL_GL_SetAttribute(attr, value);
2234         OUTPUT:
2235                 RETVAL
2236
2237 AV *
2238 GLGetAttribute ( attr )
2239         int        attr
2240         CODE:
2241                 int value;
2242                 RETVAL = newAV();
2243                 av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value)));
2244                 av_push(RETVAL,newSViv(value));
2245         OUTPUT:
2246                 RETVAL
2247
2248 void
2249 GLSwapBuffers ()
2250         CODE:
2251                 SDL_GL_SwapBuffers ();
2252
2253
2254 int
2255 BigEndian ()
2256         CODE:
2257                 RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN);
2258         OUTPUT:
2259                 RETVAL
2260
2261 int
2262 NumJoysticks ()
2263         CODE:
2264                 RETVAL = SDL_NumJoysticks();
2265         OUTPUT:
2266                 RETVAL
2267
2268 char *
2269 JoystickName ( index )
2270         int index
2271         CODE:
2272                 RETVAL = (char*)SDL_JoystickName(index);
2273         OUTPUT:
2274                 RETVAL
2275
2276 SDL_Joystick *
2277 JoystickOpen ( index ) 
2278         int index
2279         CODE:
2280                 RETVAL = SDL_JoystickOpen(index);
2281         OUTPUT:
2282                 RETVAL
2283
2284 int
2285 JoystickOpened ( index )
2286         int index
2287         CODE:
2288                 RETVAL = SDL_JoystickOpened(index);
2289         OUTPUT:
2290                 RETVAL
2291
2292 int
2293 JoystickIndex ( joystick )
2294         SDL_Joystick *joystick
2295         CODE:
2296                 RETVAL = SDL_JoystickIndex(joystick);
2297         OUTPUT:
2298                 RETVAL
2299
2300 int
2301 JoystickNumAxes ( joystick )
2302         SDL_Joystick *joystick
2303         CODE:
2304                 RETVAL = SDL_JoystickNumAxes(joystick);
2305         OUTPUT:
2306                 RETVAL
2307
2308 int
2309 JoystickNumBalls ( joystick )
2310         SDL_Joystick *joystick
2311         CODE:
2312                 RETVAL = SDL_JoystickNumBalls(joystick);
2313         OUTPUT:
2314                 RETVAL
2315
2316 int
2317 JoystickNumHats ( joystick )
2318         SDL_Joystick *joystick
2319         CODE:
2320                 RETVAL = SDL_JoystickNumHats(joystick);
2321         OUTPUT:
2322                 RETVAL
2323
2324 int
2325 JoystickNumButtons ( joystick )
2326         SDL_Joystick *joystick
2327         CODE:
2328                 RETVAL = SDL_JoystickNumButtons(joystick);
2329         OUTPUT:
2330                 RETVAL
2331
2332 void
2333 JoystickUpdate ()
2334         CODE:
2335                 SDL_JoystickUpdate();
2336
2337 Sint16
2338 JoystickGetAxis ( joystick, axis )
2339         SDL_Joystick *joystick
2340         int axis
2341         CODE:
2342                 RETVAL = SDL_JoystickGetAxis(joystick,axis);
2343         OUTPUT:
2344                 RETVAL
2345
2346 Uint8
2347 JoystickGetHat ( joystick, hat )
2348         SDL_Joystick *joystick
2349         int hat 
2350         CODE:
2351                 RETVAL = SDL_JoystickGetHat(joystick,hat);
2352         OUTPUT:
2353                 RETVAL
2354
2355 Uint8
2356 JoystickGetButton ( joystick, button)
2357         SDL_Joystick *joystick
2358         int button 
2359         CODE:
2360                 RETVAL = SDL_JoystickGetButton(joystick,button);
2361         OUTPUT:
2362                 RETVAL
2363
2364 AV *
2365 JoystickGetBall ( joystick, ball )
2366         SDL_Joystick *joystick
2367         int ball 
2368         CODE:
2369                 int success,dx,dy;
2370                 success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
2371                 RETVAL = newAV();
2372                 av_push(RETVAL,newSViv(success));
2373                 av_push(RETVAL,newSViv(dx));
2374                 av_push(RETVAL,newSViv(dy));
2375         OUTPUT:
2376                 RETVAL  
2377
2378 void
2379 JoystickClose ( joystick )
2380         SDL_Joystick *joystick
2381         CODE:
2382                 SDL_JoystickClose(joystick);
2383
2384 Sint16
2385 JoyAxisEventWhich ( e )
2386         SDL_Event *e
2387         CODE:
2388                 RETVAL = e->jaxis.which;
2389         OUTPUT:
2390                 RETVAL
2391
2392 Uint8
2393 JoyAxisEventAxis ( e )
2394         SDL_Event *e
2395         CODE:
2396                 RETVAL = e->jaxis.axis;
2397         OUTPUT:
2398                 RETVAL
2399
2400 Sint16
2401 JoyAxisEventValue ( e )
2402         SDL_Event *e
2403         CODE:
2404                 RETVAL = e->jaxis.value;
2405         OUTPUT:
2406                 RETVAL
2407
2408 Uint8
2409 JoyButtonEventWhich ( e )
2410         SDL_Event *e
2411         CODE:
2412                 RETVAL = e->jbutton.which;
2413         OUTPUT:
2414                 RETVAL
2415
2416 Uint8
2417 JoyButtonEventButton ( e )
2418         SDL_Event *e
2419         CODE:
2420                 RETVAL = e->jbutton.button;
2421         OUTPUT:
2422                 RETVAL
2423
2424 Uint8
2425 JoyButtonEventState ( e )
2426         SDL_Event *e
2427         CODE:
2428                 RETVAL = e->jbutton.state;
2429         OUTPUT:
2430                 RETVAL
2431         
2432 Uint8
2433 JoyHatEventWhich ( e )
2434         SDL_Event *e
2435         CODE:
2436                 RETVAL = e->jhat.which;
2437         OUTPUT:
2438                 RETVAL
2439
2440 Uint8
2441 JoyHatEventHat ( e )
2442         SDL_Event *e
2443         CODE:
2444                 RETVAL = e->jhat.hat;
2445         OUTPUT:
2446                 RETVAL
2447
2448 Uint8
2449 JoyHatEventValue ( e )
2450         SDL_Event *e
2451         CODE:
2452                 RETVAL = e->jhat.value;
2453         OUTPUT:
2454                 RETVAL
2455
2456 Uint8
2457 JoyBallEventWhich ( e )
2458         SDL_Event *e
2459         CODE: 
2460                 RETVAL = e->jball.which;
2461         OUTPUT:
2462                 RETVAL
2463
2464 Uint8
2465 JoyBallEventBall ( e )
2466         SDL_Event *e
2467         CODE:
2468                 RETVAL = e->jball.ball;
2469         OUTPUT:
2470                 RETVAL
2471
2472 Sint16
2473 JoyBallEventXrel ( e )
2474         SDL_Event *e
2475         CODE:
2476                 RETVAL = e->jball.xrel;
2477         OUTPUT:
2478                 RETVAL
2479
2480 Sint16
2481 JoyBallEventYrel ( e )
2482         SDL_Event *e
2483         CODE:
2484                 RETVAL = e->jball.yrel;
2485         OUTPUT:
2486                 RETVAL
2487
2488 void
2489 SetClipRect ( surface, rect )
2490         SDL_Surface *surface
2491         SDL_Rect *rect
2492         CODE:
2493                 SDL_SetClipRect(surface,rect);
2494         
2495 void
2496 GetClipRect ( surface, rect )
2497         SDL_Surface *surface
2498         SDL_Rect *rect;
2499         CODE:
2500                 SDL_GetClipRect(surface, rect);
2501
2502
2503 #ifdef HAVE_SDL_NET
2504
2505 int
2506 NetInit ()
2507         CODE:
2508                 RETVAL = SDLNet_Init();
2509         OUTPUT:
2510                 RETVAL
2511
2512 void
2513 NetQuit ()
2514         CODE:
2515                 SDLNet_Quit();
2516
2517 IPaddress*
2518 NetNewIPaddress ( host, port )
2519         Uint32 host
2520         Uint16 port
2521         CODE:
2522                 RETVAL = (IPaddress*) safemalloc(sizeof(IPaddress));
2523                 RETVAL->host = host;
2524                 RETVAL->port = port;
2525         OUTPUT:
2526                 RETVAL
2527
2528 Uint32
2529 NetIPaddressHost ( ip )
2530         IPaddress *ip
2531         CODE:
2532                 RETVAL = ip->host;
2533         OUTPUT:
2534                 RETVAL
2535
2536 Uint16
2537 NetIPaddressPort ( ip )
2538         IPaddress *ip
2539         CODE:
2540                 RETVAL = ip->port;
2541         OUTPUT:
2542                 RETVAL
2543
2544 void
2545 NetFreeIPaddress ( ip )
2546         IPaddress *ip
2547         CODE:
2548                 safefree(ip);
2549
2550 const char*
2551 NetResolveIP ( address )
2552         IPaddress *address
2553         CODE:
2554                 RETVAL = SDLNet_ResolveIP(address);
2555         OUTPUT:
2556                 RETVAL
2557
2558 int
2559 NetResolveHost ( address, host, port )
2560         IPaddress *address
2561         const char *host
2562         Uint16 port
2563         CODE:
2564                 RETVAL = SDLNet_ResolveHost(address,host,port);
2565         OUTPUT:
2566                 RETVAL
2567         
2568 TCPsocket
2569 NetTCPOpen ( ip )
2570         IPaddress *ip
2571         CODE:
2572                 RETVAL = SDLNet_TCP_Open(ip);
2573         OUTPUT:
2574                 RETVAL
2575
2576 TCPsocket
2577 NetTCPAccept ( server )
2578         TCPsocket server
2579         CODE:
2580                 RETVAL = SDLNet_TCP_Accept(server);
2581         OUTPUT:
2582                 RETVAL
2583
2584 IPaddress*
2585 NetTCPGetPeerAddress ( sock )
2586         TCPsocket sock
2587         CODE:
2588                 RETVAL = SDLNet_TCP_GetPeerAddress(sock);
2589         OUTPUT:
2590                 RETVAL
2591
2592 int
2593 NetTCPSend ( sock, data, len  )
2594         TCPsocket sock
2595         void *data
2596         int len
2597         CODE:
2598                 RETVAL = SDLNet_TCP_Send(sock,data,len);
2599         OUTPUT:
2600                 RETVAL
2601
2602 AV*
2603 NetTCPRecv ( sock, maxlen )
2604         TCPsocket sock
2605         int maxlen
2606         CODE:
2607                 int status;
2608                 void *buffer;
2609                 buffer = safemalloc(maxlen);
2610                 RETVAL = newAV();
2611                 status = SDLNet_TCP_Recv(sock,buffer,maxlen);
2612                 av_push(RETVAL,newSViv(status));
2613                 av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
2614         OUTPUT:
2615                 RETVAL  
2616         
2617 void
2618 NetTCPClose ( sock )
2619         TCPsocket sock
2620         CODE:
2621                 SDLNet_TCP_Close(sock);
2622
2623 UDPpacket*
2624 NetAllocPacket ( size )
2625         int size
2626         CODE:
2627                 RETVAL = SDLNet_AllocPacket(size);
2628         OUTPUT:
2629                 RETVAL
2630
2631 UDPpacket**
2632 NetAllocPacketV ( howmany, size )
2633         int howmany
2634         int size
2635         CODE:
2636                 RETVAL = SDLNet_AllocPacketV(howmany,size);
2637         OUTPUT:
2638                 RETVAL
2639
2640 int
2641 NetResizePacket ( packet, newsize )
2642         UDPpacket *packet
2643         int newsize
2644         CODE:
2645                 RETVAL = SDLNet_ResizePacket(packet,newsize);
2646         OUTPUT:
2647                 RETVAL
2648
2649 void
2650 NetFreePacket ( packet )
2651         UDPpacket *packet
2652         CODE:
2653                 SDLNet_FreePacket(packet);
2654
2655 void
2656 NetFreePacketV ( packet )
2657         UDPpacket **packet
2658         CODE:
2659                 SDLNet_FreePacketV(packet);
2660
2661 UDPsocket
2662 NetUDPOpen ( port )
2663         Uint16 port
2664         CODE:
2665                 RETVAL = SDLNet_UDP_Open(port);
2666         OUTPUT:
2667                 RETVAL
2668
2669 int
2670 NetUDPBind ( sock, channel, address )
2671         UDPsocket sock
2672         int channel
2673         IPaddress *address
2674         CODE:
2675                 RETVAL = SDLNet_UDP_Bind(sock,channel,address);
2676         OUTPUT:
2677                 RETVAL
2678
2679 void
2680 NetUDPUnbind ( sock, channel )
2681         UDPsocket sock
2682         int channel
2683         CODE:
2684                 SDLNet_UDP_Unbind(sock,channel);
2685
2686 IPaddress*
2687 NetUDPGetPeerAddress ( sock, channel )
2688         UDPsocket sock
2689         int channel
2690         CODE:
2691                 RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
2692         OUTPUT:
2693                 RETVAL
2694
2695 int
2696 NetUDPSendV ( sock, packets, npackets )
2697         UDPsocket sock
2698         UDPpacket **packets
2699         int npackets
2700         CODE:
2701                 RETVAL = SDLNet_UDP_SendV(sock,packets,npackets);
2702         OUTPUT:
2703                 RETVAL
2704
2705 int
2706 NetUDPSend ( sock, channel, packet )
2707         UDPsocket sock
2708         int channel
2709         UDPpacket *packet 
2710         CODE:
2711                 RETVAL = SDLNet_UDP_Send(sock,channel,packet);
2712         OUTPUT:
2713                 RETVAL
2714
2715 int
2716 NetUDPRecvV ( sock, packets )
2717         UDPsocket sock
2718         UDPpacket **packets
2719         CODE:
2720                 RETVAL = SDLNet_UDP_RecvV(sock,packets);
2721         OUTPUT:
2722                 RETVAL
2723
2724 int
2725 NetUDPRecv ( sock, packet )
2726         UDPsocket sock
2727         UDPpacket *packet
2728         CODE:
2729                 RETVAL = SDLNet_UDP_Recv(sock,packet);
2730         OUTPUT:
2731                 RETVAL
2732
2733 void
2734 NetUDPClose ( sock )
2735         UDPsocket sock
2736         CODE:
2737                 SDLNet_UDP_Close(sock);
2738
2739 SDLNet_SocketSet
2740 NetAllocSocketSet ( maxsockets )
2741         int maxsockets
2742         CODE:
2743                 RETVAL = SDLNet_AllocSocketSet(maxsockets);
2744         OUTPUT:
2745                 RETVAL
2746
2747 int
2748 NetTCP_AddSocket ( set, sock )
2749         SDLNet_SocketSet set
2750         TCPsocket sock
2751         CODE:
2752                 RETVAL = SDLNet_TCP_AddSocket(set,sock);
2753         OUTPUT:
2754                 RETVAL
2755
2756 int
2757 NetUDP_AddSocket ( set, sock )
2758         SDLNet_SocketSet set
2759         UDPsocket sock
2760         CODE:
2761                 RETVAL = SDLNet_UDP_AddSocket(set,sock);
2762         OUTPUT:
2763                 RETVAL
2764
2765 int
2766 NetTCP_DelSocket ( set, sock )
2767         SDLNet_SocketSet set
2768         TCPsocket sock
2769         CODE:
2770                 RETVAL = SDLNet_TCP_DelSocket(set,sock);
2771         OUTPUT:
2772                 RETVAL
2773
2774 int
2775 NetUDP_DelSocket ( set, sock )
2776         SDLNet_SocketSet set
2777         UDPsocket sock
2778         CODE:
2779                 RETVAL = SDLNet_UDP_DelSocket(set,sock);
2780         OUTPUT:
2781                 RETVAL
2782
2783 int
2784 NetCheckSockets ( set, timeout )
2785         SDLNet_SocketSet set
2786         Uint32 timeout
2787         CODE:
2788                 RETVAL = SDLNet_CheckSockets(set,timeout);
2789         OUTPUT:
2790                 RETVAL
2791
2792 int
2793 NetSocketReady ( sock )
2794         SDLNet_GenericSocket sock
2795         CODE:
2796                 RETVAL = SDLNet_SocketReady(sock);
2797         OUTPUT:
2798                 RETVAL
2799
2800 void
2801 NetFreeSocketSet ( set )
2802         SDLNet_SocketSet set
2803         CODE:
2804                 SDLNet_FreeSocketSet(set);
2805
2806 void
2807 NetWrite16 ( value, area )
2808         Uint16 value
2809         void *area
2810         CODE:
2811                 SDLNet_Write16(value,area);
2812
2813 void
2814 NetWrite32 ( value, area )
2815         Uint32 value
2816         void *area
2817         CODE:
2818                 SDLNet_Write32(value,area);
2819         
2820 Uint16
2821 NetRead16 ( area )
2822         void *area
2823         CODE:
2824                 RETVAL = SDLNet_Read16(area);
2825         OUTPUT:
2826                 RETVAL
2827
2828 Uint32
2829 NetRead32 ( area )
2830         void *area
2831         CODE:
2832                 RETVAL = SDLNet_Read32(area);
2833         OUTPUT:
2834                 RETVAL
2835
2836 #endif 
2837
2838 #ifdef HAVE_SDL_TTF
2839
2840 int
2841 TTFInit ()
2842         CODE:
2843                 RETVAL = TTF_Init();
2844         OUTPUT:
2845                 RETVAL
2846
2847 void
2848 TTFQuit ()
2849         CODE:
2850                 TTF_Quit();
2851
2852 TTF_Font*
2853 TTFOpenFont ( file, ptsize )
2854         char *file
2855         int ptsize
2856         CODE:
2857                 RETVAL = TTF_OpenFont(file,ptsize);
2858         OUTPUT:
2859                 RETVAL
2860
2861 int
2862 TTFGetFontStyle ( font )
2863         TTF_Font *font
2864         CODE:
2865                 RETVAL = TTF_GetFontStyle(font);
2866         OUTPUT:
2867                 RETVAL
2868
2869 void
2870 TTFSetFontStyle ( font, style )
2871         TTF_Font *font
2872         int style
2873         CODE:
2874                 TTF_SetFontStyle(font,style);
2875         
2876 int
2877 TTFFontHeight ( font )
2878         TTF_Font *font
2879         CODE:
2880                 RETVAL = TTF_FontHeight(font);
2881         OUTPUT:
2882                 RETVAL
2883
2884 int
2885 TTFFontAscent ( font )
2886         TTF_Font *font
2887         CODE:
2888                 RETVAL = TTF_FontAscent(font);
2889         OUTPUT:
2890                 RETVAL
2891
2892 int
2893 TTFFontDescent ( font )
2894         TTF_Font *font
2895         CODE:
2896                 RETVAL = TTF_FontDescent(font);
2897         OUTPUT:
2898                 RETVAL
2899
2900 int
2901 TTFFontLineSkip ( font )
2902         TTF_Font *font
2903         CODE:
2904                 RETVAL = TTF_FontLineSkip(font);
2905         OUTPUT:
2906                 RETVAL
2907
2908 AV*
2909 TTFGlyphMetrics ( font, ch )
2910         TTF_Font *font
2911         Uint16 ch
2912         CODE:
2913                 int minx, miny, maxx, maxy, advance;
2914                 RETVAL = newAV();
2915                 TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance);
2916                 av_push(RETVAL,newSViv(minx));
2917                 av_push(RETVAL,newSViv(miny));
2918                 av_push(RETVAL,newSViv(maxx));
2919                 av_push(RETVAL,newSViv(maxy));
2920                 av_push(RETVAL,newSViv(advance));
2921         OUTPUT:
2922                 RETVAL
2923
2924 AV*
2925 TTFSizeText ( font, text )
2926         TTF_Font *font
2927         char *text
2928         CODE:
2929                 int w,h;
2930                 RETVAL = newAV();
2931                 if(TTF_SizeText(font,text,&w,&h))
2932                 {
2933                         printf("TTF error at TTFSizeText: %s \n", TTF_GetError());
2934                         Perl_croak (aTHX_ "TTF error \n");
2935                 }
2936                 else
2937                 {
2938                         av_push(RETVAL,newSViv(w));
2939                         av_push(RETVAL,newSViv(h));
2940                         sv_2mortal((SV*)RETVAL);
2941                 }
2942                 
2943         
2944         OUTPUT:
2945                 RETVAL
2946
2947 AV*
2948 TTFSizeUTF8 ( font, text )
2949         TTF_Font *font
2950         char *text
2951         CODE:
2952                 int w,h;
2953                 RETVAL = newAV();
2954                 if(TTF_SizeUTF8(font,text,&w,&h))
2955                 {
2956                         av_push(RETVAL,newSViv(w));
2957                         av_push(RETVAL,newSViv(h));
2958                         sv_2mortal((SV*)RETVAL);
2959
2960                 }
2961                 else
2962                 {
2963                         printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError());
2964                         Perl_croak (aTHX_ "TTF error \n");
2965                 }
2966                 
2967         OUTPUT:
2968                 RETVAL
2969
2970 AV*
2971 TTFSizeUNICODE ( font, text )
2972         TTF_Font *font
2973         const Uint16 *text
2974         CODE:
2975                 int w,h;
2976                 RETVAL = newAV();
2977                 if(TTF_SizeUNICODE(font,text,&w,&h))
2978                 {
2979                         av_push(RETVAL,newSViv(w));
2980                         av_push(RETVAL,newSViv(h));
2981                         sv_2mortal((SV*)RETVAL);
2982
2983                 }
2984                 else
2985                 {
2986                         printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); 
2987                         Perl_croak (aTHX_ "TTF error \n");
2988                 }
2989
2990         OUTPUT:
2991                 RETVAL
2992
2993 SDL_Surface*
2994 TTFRenderTextSolid ( font, text, fg )
2995         TTF_Font *font
2996         char *text
2997         SDL_Color *fg
2998         CODE:
2999                 RETVAL = TTF_RenderText_Solid(font,text,*fg);
3000         OUTPUT:
3001                 RETVAL
3002
3003 SDL_Surface*
3004 TTFRenderUTF8Solid ( font, text, fg )
3005         TTF_Font *font
3006         char *text
3007         SDL_Color *fg
3008         CODE:
3009                 RETVAL = TTF_RenderUTF8_Solid(font,text,*fg);
3010         OUTPUT:
3011                 RETVAL
3012
3013 SDL_Surface*
3014 TTFRenderUNICODESolid ( font, text, fg )
3015         TTF_Font *font
3016         const Uint16 *text
3017         SDL_Color *fg
3018         CODE:
3019                 RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg);
3020         OUTPUT:
3021                 RETVAL
3022
3023 SDL_Surface*
3024 TTFRenderGlyphSolid ( font, ch, fg )
3025         TTF_Font *font
3026         Uint16 ch
3027         SDL_Color *fg
3028         CODE:
3029                 RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg);
3030         OUTPUT:
3031                 RETVAL
3032
3033 SDL_Surface*
3034 TTFRenderTextShaded ( font, text, fg, bg )
3035         TTF_Font *font
3036         char *text
3037         SDL_Color *fg
3038         SDL_Color *bg
3039         CODE:
3040                 RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg);
3041         OUTPUT:
3042                 RETVAL
3043
3044 SDL_Surface*
3045 TTFRenderUTF8Shaded( font, text, fg, bg )
3046         TTF_Font *font
3047         char *text
3048         SDL_Color *fg
3049         SDL_Color *bg
3050         CODE:
3051                 RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3052         OUTPUT:
3053                 RETVAL
3054
3055 SDL_Surface*
3056 TTFRenderUNICODEShaded( font, text, fg, bg )
3057         TTF_Font *font
3058         const Uint16 *text
3059         SDL_Color *fg
3060         SDL_Color *bg
3061         CODE:
3062                 RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg);
3063         OUTPUT:
3064                 RETVAL
3065
3066 SDL_Surface*
3067 TTFRenderGlyphShaded ( font, ch, fg, bg )
3068         TTF_Font *font
3069         Uint16 ch
3070         SDL_Color *fg
3071         SDL_Color *bg
3072         CODE:
3073                 RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg);
3074         OUTPUT:
3075                 RETVAL
3076
3077 SDL_Surface*
3078 TTFRenderTextBlended( font, text, fg )
3079         TTF_Font *font
3080         char *text
3081         SDL_Color *fg
3082         CODE:
3083                 RETVAL = TTF_RenderText_Blended(font,text,*fg);
3084         OUTPUT:
3085                 RETVAL
3086
3087 SDL_Surface*
3088 TTFRenderUTF8Blended( font, text, fg )
3089         TTF_Font *font
3090         char *text
3091         SDL_Color *fg
3092         CODE:
3093                 RETVAL = TTF_RenderUTF8_Blended(font,text,*fg);
3094         OUTPUT:
3095                 RETVAL
3096
3097 SDL_Surface*
3098 TTFRenderUNICODEBlended( font, text, fg )
3099         TTF_Font *font
3100         const Uint16 *text
3101         SDL_Color *fg
3102         CODE:
3103                 RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg);
3104         OUTPUT:
3105                 RETVAL
3106
3107 SDL_Surface*
3108 TTFRenderGlyphBlended( font, ch, fg )
3109         TTF_Font *font
3110         Uint16 ch
3111         SDL_Color *fg
3112         CODE:
3113                 RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg);
3114         OUTPUT:
3115                 RETVAL
3116
3117 void
3118 TTFCloseFont ( font )
3119         TTF_Font *font
3120         CODE:
3121                 TTF_CloseFont(font);
3122                 font=NULL; //to be safe http://sdl.beuc.net/sdl.wiki/SDL_ttf_copy_Functions_Management_TTF_CloseFont
3123
3124 SDL_Surface*
3125 TTFPutString ( font, mode, surface, x, y, fg, bg, text )
3126         TTF_Font *font
3127         int mode
3128         SDL_Surface *surface
3129         int x
3130         int y
3131         SDL_Color *fg
3132         SDL_Color *bg
3133         char *text
3134         CODE:
3135                 SDL_Surface *img;
3136                 SDL_Rect dest;
3137                 int w,h;
3138                 dest.x = x;
3139                 dest.y = y;
3140                 RETVAL = NULL;
3141                 switch (mode) {
3142                         case TEXT_SOLID:
3143                                 img = TTF_RenderText_Solid(font,text,*fg);
3144                                 TTF_SizeText(font,text,&w,&h);
3145                                 dest.w = w;
3146                                 dest.h = h;
3147                                 break;
3148                         case TEXT_SHADED:
3149                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3150                                 TTF_SizeText(font,text,&w,&h);
3151                                 dest.w = w;
3152                                 dest.h = h;
3153                                 break;
3154                         case TEXT_BLENDED:
3155                                 img = TTF_RenderText_Blended(font,text,*fg);
3156                                 TTF_SizeText(font,text,&w,&h);
3157                                 dest.w = w;
3158                                 dest.h = h;
3159                                 break;
3160                         case UTF8_SOLID:
3161                                 img = TTF_RenderUTF8_Solid(font,text,*fg);
3162                                 TTF_SizeUTF8(font,text,&w,&h);
3163                                 dest.w = w;
3164                                 dest.h = h;
3165                                 break;
3166                         case UTF8_SHADED:
3167                                 img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3168                                 TTF_SizeUTF8(font,text,&w,&h);
3169                                 dest.w = w;
3170                                 dest.h = h;
3171                                 break;
3172                         case UTF8_BLENDED:
3173                                 img = TTF_RenderUTF8_Blended(font,text,*fg);
3174                                 TTF_SizeUTF8(font,text,&w,&h);
3175                                 dest.w = w;
3176                                 dest.h = h;
3177                                 break;
3178                         case UNICODE_SOLID:
3179                                 img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg);
3180                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3181                                 dest.w = w;
3182                                 dest.h = h;
3183                                 break;
3184                         case UNICODE_SHADED:
3185                                 img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg);
3186                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3187                                 dest.w = w;
3188                                 dest.h = h;
3189                                 break;
3190                         case UNICODE_BLENDED:
3191                                 img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg);
3192                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3193                                 dest.w = w;
3194                                 dest.h = h;
3195                                 break;
3196                         default:
3197                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3198                                 TTF_SizeText(font,text,&w,&h);
3199                                 dest.w = w;
3200                                 dest.h = h;
3201                 }
3202                 if ( img && img->format && img->format->palette ) {
3203                         SDL_Color *c = &img->format->palette->colors[0];
3204                         Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
3205                         SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
3206                         if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
3207                                 SDL_FreeSurface(img);
3208                                 RETVAL = NULL;  
3209                         } else {
3210                                 RETVAL = img;
3211                         }
3212                 }
3213         OUTPUT:
3214                 RETVAL
3215
3216 #endif
3217
3218 SDL_Overlay*
3219 CreateYUVOverlay ( width, height, format, display )
3220         int width
3221         int height
3222         Uint32 format
3223         SDL_Surface *display
3224         CODE:
3225                 RETVAL = SDL_CreateYUVOverlay ( width, height, format, display );
3226         OUTPUT:
3227                 RETVAL
3228
3229 int
3230 LockYUVOverlay ( overlay )
3231         SDL_Overlay *overlay
3232         CODE:
3233                 RETVAL = SDL_LockYUVOverlay(overlay);
3234         OUTPUT:
3235                 RETVAL
3236
3237 void
3238 UnlockYUVOverlay ( overlay )
3239         SDL_Overlay *overlay
3240         CODE:
3241                 SDL_UnlockYUVOverlay(overlay);
3242
3243 int
3244 DisplayYUVOverlay ( overlay, dstrect )
3245         SDL_Overlay *overlay
3246         SDL_Rect *dstrect
3247         CODE:
3248                 RETVAL = SDL_DisplayYUVOverlay ( overlay, dstrect );
3249         OUTPUT:
3250                 RETVAL
3251
3252 void
3253 FreeYUVOverlay ( overlay )
3254         SDL_Overlay *overlay
3255         CODE:
3256                 SDL_FreeYUVOverlay ( overlay );
3257
3258 Uint32
3259 OverlayFormat ( overlay, ... )
3260         SDL_Overlay *overlay
3261         CODE:
3262                 if ( items > 1 ) 
3263                         overlay->format = SvIV(ST(1));
3264                 RETVAL = overlay->format;
3265         OUTPUT:
3266                 RETVAL
3267
3268 int 
3269 OverlayW ( overlay, ... )
3270         SDL_Overlay *overlay
3271         CODE:
3272                 if ( items > 1 ) 
3273                         overlay->w = SvIV(ST(1));
3274                 RETVAL = overlay->w;
3275         OUTPUT:
3276                 RETVAL
3277
3278 int
3279 OverlayH ( overlay, ... )
3280         SDL_Overlay *overlay
3281         CODE:
3282                 if ( items > 1 )
3283                         overlay->h = SvIV(ST(1));
3284                 RETVAL = overlay->h;
3285         OUTPUT:
3286                 RETVAL 
3287
3288 int
3289 OverlayPlanes ( overlay, ... )
3290         SDL_Overlay *overlay
3291         CODE:
3292                 if ( items > 1 )
3293                         overlay->planes = SvIV(ST(1));
3294                 RETVAL = overlay->planes;
3295         OUTPUT:
3296                 RETVAL
3297
3298 Uint32
3299 OverlayHW ( overlay )
3300         SDL_Overlay *overlay
3301         CODE:
3302                 RETVAL = overlay->hw_overlay;
3303         OUTPUT:
3304                 RETVAL
3305
3306 Uint16*
3307 OverlayPitches ( overlay )
3308         SDL_Overlay *overlay
3309         CODE:
3310                 RETVAL = overlay->pitches;
3311         OUTPUT:
3312                 RETVAL
3313
3314 Uint8**
3315 OverlayPixels ( overlay )
3316         SDL_Overlay *overlay
3317         CODE:
3318                 RETVAL = overlay->pixels;
3319         OUTPUT:
3320                 RETVAL
3321
3322 int
3323 WMToggleFullScreen ( surface )
3324         SDL_Surface *surface
3325         CODE:
3326                 RETVAL = SDL_WM_ToggleFullScreen(surface);
3327         OUTPUT:
3328                 RETVAL
3329
3330 Uint32
3331 WMGrabInput ( mode )
3332         Uint32 mode
3333         CODE:
3334                 RETVAL = SDL_WM_GrabInput(mode);
3335         OUTPUT:
3336                 RETVAL
3337
3338 int
3339 WMIconifyWindow ()
3340         CODE:
3341                 RETVAL = SDL_WM_IconifyWindow();
3342         OUTPUT:
3343                 RETVAL
3344
3345 int
3346 ResizeEventW ( e )
3347         SDL_Event *e
3348         CODE:
3349                 RETVAL = e->resize.w;
3350         OUTPUT:
3351                 RETVAL
3352
3353 int
3354 ResizeEventH ( e )
3355         SDL_Event *e
3356         CODE:
3357                 RETVAL = e->resize.h;
3358         OUTPUT:
3359                 RETVAL
3360
3361 char*
3362 AudioDriverName ()
3363         CODE:
3364                 char name[32];
3365                 RETVAL = SDL_AudioDriverName(name,32);
3366         OUTPUT:
3367                 RETVAL
3368
3369 Uint32
3370 GetKeyState ( k )
3371         SDLKey k
3372         CODE:
3373                 if (k >= SDLK_LAST) Perl_croak (aTHX_ "Key out of range");      
3374                 RETVAL = SDL_GetKeyState(NULL)[k];
3375         OUTPUT:
3376                 RETVAL
3377
3378 #ifdef HAVE_SMPEG
3379
3380 SMPEG_Info *
3381 NewSMPEGInfo()
3382         CODE:   
3383                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3384         OUTPUT:
3385                 RETVAL
3386
3387 void
3388 FreeSMPEGInfo ( info )
3389         SMPEG_Info *info
3390         CODE:   
3391                 safefree(info);
3392
3393 int
3394 SMPEGInfoHasAudio ( info )
3395         SMPEG_Info* info
3396         CODE:
3397                 RETVAL = info->has_audio;
3398         OUTPUT:
3399                 RETVAL
3400
3401 int
3402 SMPEGInfoHasVideo ( info )
3403         SMPEG_Info* info
3404         CODE:
3405                 RETVAL = info->has_video;
3406         OUTPUT:
3407                 RETVAL
3408
3409 int
3410 SMPEGInfoWidth ( info )
3411         SMPEG_Info* info
3412         CODE:
3413                 RETVAL = info->width;
3414         OUTPUT:
3415                 RETVAL
3416
3417 int
3418 SMPEGInfoHeight ( info )
3419         SMPEG_Info* info
3420         CODE:
3421                 RETVAL = info->height;
3422         OUTPUT:
3423                 RETVAL
3424
3425 int
3426 SMPEGInfoCurrentFrame ( info )
3427         SMPEG_Info* info
3428         CODE:
3429                 RETVAL = info->current_frame;
3430         OUTPUT:
3431                 RETVAL
3432
3433 double
3434 SMPEGInfoCurrentFPS ( info )
3435         SMPEG_Info* info
3436         CODE:
3437                 RETVAL = info->current_fps;
3438         OUTPUT:
3439                 RETVAL
3440
3441 int
3442 SMPEGInfoCurrentAudioFrame ( info )
3443         SMPEG_Info* info
3444         CODE:
3445                 RETVAL = info->audio_current_frame;
3446         OUTPUT:
3447                 RETVAL
3448
3449 int
3450 SMPEGInfoCurrentOffset ( info )
3451         SMPEG_Info* info
3452         CODE:
3453                 RETVAL = info->current_offset;
3454         OUTPUT:
3455                 RETVAL
3456
3457 int
3458 SMPEGInfoTotalSize ( info )
3459         SMPEG_Info* info
3460         CODE:
3461                 RETVAL = info->total_size;
3462         OUTPUT:
3463                 RETVAL
3464
3465 double
3466 SMPEGInfoCurrentTime ( info )
3467         SMPEG_Info* info
3468         CODE:
3469                 RETVAL = info->current_time;
3470         OUTPUT:
3471                 RETVAL
3472
3473 double
3474 SMPEGInfoTotalTime ( info )
3475         SMPEG_Info* info
3476         CODE:
3477                 RETVAL = info->total_time;
3478         OUTPUT:
3479                 RETVAL
3480
3481 char *
3482 SMPEGError ( mpeg )
3483         SMPEG* mpeg
3484         CODE:   
3485                 RETVAL = SMPEG_error(mpeg);
3486         OUTPUT:
3487                 RETVAL
3488
3489 SMPEG*
3490 NewSMPEG ( filename, info, use_audio )
3491         char* filename
3492         SMPEG_Info* info
3493         int use_audio
3494         CODE:   
3495 #ifdef HAVE_SDL_MIXER
3496                 RETVAL = SMPEG_new(filename,info,0);
3497 #else
3498                 RETVAL = SMPEG_new(filename,info,use_audio);
3499 #endif
3500         OUTPUT:
3501                 RETVAL
3502
3503 void
3504 FreeSMPEG ( mpeg )
3505         SMPEG* mpeg
3506         CODE:
3507                 SMPEG_delete(mpeg);
3508
3509 void
3510 SMPEGEnableAudio ( mpeg , flag )
3511         SMPEG* mpeg
3512         int flag
3513         CODE:   
3514                 SMPEG_enableaudio(mpeg,flag);
3515 #ifdef HAVE_SDL_MIXER
3516                 sdl_perl_use_smpeg_audio = flag;
3517 #endif
3518
3519 void
3520 SMPEGEnableVideo ( mpeg , flag )
3521         SMPEG* mpeg
3522         int flag
3523         CODE:   
3524                 SMPEG_enablevideo(mpeg,flag);
3525
3526 void
3527 SMPEGSetVolume ( mpeg , volume )
3528         SMPEG* mpeg
3529         int volume
3530         CODE:   
3531                 SMPEG_setvolume(mpeg,volume);
3532
3533 void
3534 SMPEGSetDisplay ( mpeg, dest, surfLock )
3535         SMPEG* mpeg
3536         SDL_Surface* dest
3537         SDL_mutex*  surfLock
3538         CODE:
3539                 SMPEG_setdisplay(mpeg,dest,surfLock,NULL);
3540
3541 void
3542 SMPEGScaleXY ( mpeg, w, h)
3543         SMPEG* mpeg
3544         int w
3545         int h
3546         CODE:
3547                 SMPEG_scaleXY(mpeg,w,h);
3548
3549 void
3550 SMPEGScale ( mpeg, scale )
3551         SMPEG* mpeg
3552         int scale
3553         CODE:
3554                 SMPEG_scale(mpeg,scale);
3555
3556 void
3557 SMPEGPlay ( mpeg )
3558         SMPEG* mpeg
3559         CODE:
3560                 SDL_AudioSpec audiofmt;
3561                 Uint16 format;
3562                 int freq, channels;
3563 #ifdef HAVE_SDL_MIXER
3564                 if  (sdl_perl_use_smpeg_audio ) {
3565                         SMPEG_enableaudio(mpeg, 0);
3566                         Mix_QuerySpec(&freq, &format, &channels);
3567                         audiofmt.format = format;
3568                         audiofmt.freq = freq;
3569                         audiofmt.channels = channels;
3570                         SMPEG_actualSpec(mpeg, &audiofmt);
3571                         Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
3572                         SMPEG_enableaudio(mpeg, 1);
3573                 }
3574 #endif
3575                 SMPEG_play(mpeg);
3576
3577 SMPEGstatus
3578 SMPEGStatus ( mpeg )
3579         SMPEG* mpeg
3580         CODE:
3581                 RETVAL = SMPEG_status(mpeg);
3582         OUTPUT:
3583                 RETVAL
3584
3585 void
3586 SMPEGPause ( mpeg )
3587         SMPEG* mpeg
3588         CODE:
3589                 SMPEG_pause(mpeg);
3590
3591 void
3592 SMPEGLoop ( mpeg, repeat )
3593         SMPEG* mpeg
3594         int repeat
3595         CODE:
3596                 SMPEG_loop(mpeg,repeat);
3597
3598 void
3599 SMPEGStop ( mpeg )
3600         SMPEG* mpeg
3601         CODE:
3602                 SMPEG_stop(mpeg);
3603 #ifdef HAVE_SDL_MIXER
3604                 Mix_HookMusic(NULL, NULL);
3605 #endif
3606
3607 void
3608 SMPEGRewind ( mpeg )
3609         SMPEG* mpeg
3610         CODE:
3611                 SMPEG_rewind(mpeg);
3612
3613 void
3614 SMPEGSeek ( mpeg, bytes )
3615         SMPEG* mpeg
3616         int bytes
3617         CODE:
3618                 SMPEG_seek(mpeg,bytes);
3619
3620 void
3621 SMPEGSkip ( mpeg, seconds )
3622         SMPEG* mpeg
3623         float seconds
3624         CODE:
3625                 SMPEG_skip(mpeg,seconds);
3626
3627 void
3628 SMPEGSetDisplayRegion ( mpeg, rect )
3629         SMPEG* mpeg
3630         SDL_Rect* rect
3631         CODE:
3632                 SMPEG_setdisplayregion(mpeg,rect->x,rect->y,rect->w,rect->h);
3633
3634 void
3635 SMPEGRenderFrame ( mpeg, frame )
3636         SMPEG* mpeg
3637         int frame
3638         CODE:
3639                 SMPEG_renderFrame(mpeg,frame);
3640
3641 SMPEG_Info *
3642 SMPEGGetInfo ( mpeg )
3643         SMPEG* mpeg
3644         CODE:
3645                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3646                 SMPEG_getinfo(mpeg,RETVAL);
3647         OUTPUT:
3648                 RETVAL
3649         
3650
3651 #endif
3652
3653 #ifdef HAVE_SDL_GFX
3654
3655 SDL_Surface *
3656 GFXRotoZoom ( src, angle, zoom, smooth)
3657         SDL_Surface * src
3658         double angle
3659         double zoom
3660         int smooth
3661         CODE:
3662                 RETVAL = rotozoomSurface( src, angle, zoom, smooth);
3663         OUTPUT:
3664                 RETVAL
3665
3666 SDL_Surface *
3667 GFXZoom ( src, zoomx, zoomy, smooth)
3668         SDL_Surface *src
3669         double zoomx
3670         double zoomy
3671         int smooth
3672         CODE:
3673                 RETVAL = zoomSurface( src, zoomx, zoomy, smooth);
3674         OUTPUT:
3675                 RETVAL
3676
3677 int
3678 GFXPixelColor ( dst, x, y, color )
3679         SDL_Surface* dst
3680         Sint16 x
3681         Sint16 y
3682         Uint32 color
3683         CODE:
3684                 RETVAL = pixelColor( dst, x, y, color);
3685         OUTPUT:
3686                 RETVAL
3687
3688 int
3689 GFXPixelRGBA ( dst, x, y, r, g, b, a )
3690         SDL_Surface* dst
3691         Sint16 x
3692         Sint16 y
3693         Uint8 r
3694         Uint8 g
3695         Uint8 b
3696         Uint8 a
3697         CODE:
3698                 RETVAL = pixelRGBA( dst, x, y, r, g, b, a );
3699         OUTPUT:
3700                 RETVAL
3701
3702 int
3703 GFXHlineColor ( dst, x1, x2, y, color )
3704         SDL_Surface* dst
3705         Sint16 x1
3706         Sint16 x2
3707         Sint16 y
3708         Uint32 color
3709         CODE:
3710                 RETVAL = hlineColor( dst, x1, x2, y, color );
3711         OUTPUT:
3712                 RETVAL
3713
3714 int
3715 GFXHlineRGBA ( dst, x1, x2, y, r, g, b, a )
3716         SDL_Surface* dst
3717         Sint16 x1
3718         Sint16 x2
3719         Sint16 y
3720         Uint8 r
3721         Uint8 g
3722         Uint8 b
3723         Uint8 a
3724         CODE:
3725                 RETVAL = hlineRGBA( dst, x1, x2, y, r, g, b, a );
3726         OUTPUT:
3727                 RETVAL
3728
3729 int
3730 GFXVlineColor ( dst, x, y1, y2, color )
3731         SDL_Surface* dst
3732         Sint16 x
3733         Sint16 y1
3734         Sint16 y2
3735         Uint32 color
3736         CODE:
3737                 RETVAL = vlineColor( dst, x, y1, y2, color );
3738         OUTPUT:
3739                 RETVAL
3740
3741 int
3742 GFXVlineRGBA ( dst, x, y1, y2, r, g, b, a )
3743         SDL_Surface* dst
3744         Sint16 x
3745         Sint16 y1
3746         Sint16 y2
3747         Uint8 r
3748         Uint8 g
3749         Uint8 b
3750         Uint8 a
3751         CODE:
3752                 RETVAL = vlineRGBA( dst, x, y1, y2, r, g, b, a );
3753         OUTPUT:
3754                 RETVAL
3755
3756 int
3757 GFXRectangleColor ( dst, x1, y1, x2, y2, color )
3758         SDL_Surface* dst
3759         Sint16 x1
3760         Sint16 y1
3761         Sint16 x2
3762         Sint16 y2
3763         Uint32 color
3764         CODE:
3765                 RETVAL = rectangleColor( dst, x1, y1, x2, y2, color );
3766         OUTPUT:
3767                 RETVAL
3768
3769 int
3770 GFXRectangleRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3771         SDL_Surface* dst
3772         Sint16 x1
3773         Sint16 y1
3774         Sint16 x2
3775         Sint16 y2
3776         Uint8 r
3777         Uint8 g
3778         Uint8 b
3779         Uint8 a
3780         CODE:
3781                 RETVAL = rectangleRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3782         OUTPUT:
3783                 RETVAL
3784
3785 int
3786 GFXBoxColor ( dst, x1, y1, x2, y2, color )
3787         SDL_Surface* dst
3788         Sint16 x1
3789         Sint16 y1
3790         Sint16 x2
3791         Sint16 y2
3792         Uint32 color
3793         CODE:
3794                 RETVAL = boxColor( dst, x1, y1, x2, y2, color );
3795         OUTPUT:
3796                 RETVAL
3797
3798 int
3799 GFXBoxRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3800         SDL_Surface* dst;
3801         Sint16 x1
3802         Sint16 y1
3803         Sint16 x2
3804         Sint16 y2
3805         Uint8 r
3806         Uint8 g
3807         Uint8 b
3808         Uint8 a
3809         CODE:
3810                 RETVAL = boxRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3811         OUTPUT:
3812                 RETVAL
3813
3814 int
3815 GFXLineColor ( dst, x1, y1, x2, y2, color )
3816         SDL_Surface* dst
3817         Sint16 x1
3818         Sint16 y1
3819         Sint16 x2
3820         Sint16 y2
3821         Uint32 color
3822         CODE:
3823                 RETVAL = lineColor( dst, x1, y1, x2, y2, color );
3824         OUTPUT:
3825                 RETVAL
3826
3827 int
3828 GFXLineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3829         SDL_Surface* dst
3830         Sint16 x1
3831         Sint16 y1
3832         Sint16 x2
3833         Sint16 y2
3834         Uint8 r
3835         Uint8 g
3836         Uint8 b
3837         Uint8 a
3838         CODE:
3839                 RETVAL = lineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3840         OUTPUT:
3841                 RETVAL
3842
3843 int
3844 GFXAalineColor ( dst, x1, y1, x2, y2, color )
3845         SDL_Surface* dst
3846         Sint16 x1
3847         Sint16 y1
3848         Sint16 x2
3849         Sint16 y2
3850         Uint32 color
3851         CODE:
3852                 RETVAL = aalineColor( dst, x1, y1, x2, y2, color );
3853         OUTPUT:
3854                 RETVAL
3855
3856 int
3857 GFXAalineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3858         SDL_Surface* dst
3859         Sint16 x1
3860         Sint16 y1
3861         Sint16 x2
3862         Sint16 y2
3863         Uint8 r
3864         Uint8 g
3865         Uint8 b
3866         Uint8 a
3867         CODE:
3868                 RETVAL = aalineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3869         OUTPUT:
3870                 RETVAL
3871
3872 int
3873 GFXCircleColor ( dst, x, y, r, color )
3874         SDL_Surface* dst
3875         Sint16 x
3876         Sint16 y
3877         Sint16 r
3878         Uint32 color
3879         CODE:
3880                 RETVAL = circleColor( dst, x, y, r, color );
3881         OUTPUT:
3882                 RETVAL
3883
3884 int
3885 GFXCircleRGBA ( dst, x, y, rad, r, g, b, a )
3886         SDL_Surface* dst
3887         Sint16 x
3888         Sint16 y
3889         Sint16 rad
3890         Uint8 r
3891         Uint8 g
3892         Uint8 b
3893         Uint8 a
3894         CODE:
3895                 RETVAL = circleRGBA( dst, x, y, rad, r, g, b, a );
3896         OUTPUT:
3897                 RETVAL
3898
3899 int
3900 GFXAacircleColor ( dst, x, y, r, color )
3901         SDL_Surface* dst
3902         Sint16 x
3903         Sint16 y
3904         Sint16 r
3905         Uint32 color
3906         CODE:
3907                 RETVAL = aacircleColor( dst, x, y, r, color );
3908         OUTPUT:
3909                 RETVAL
3910
3911 int
3912 GFXAacircleRGBA ( dst, x, y, rad, r, g, b, a )
3913         SDL_Surface* dst
3914         Sint16 x
3915         Sint16 y
3916         Sint16 rad
3917         Uint8 r
3918         Uint8 g
3919         Uint8 b
3920         Uint8 a
3921         CODE:
3922                 RETVAL = aacircleRGBA( dst, x, y, rad, r, g, b, a );
3923         OUTPUT:
3924                 RETVAL
3925
3926 int
3927 GFXFilledCircleColor ( dst, x, y, r, color )
3928         SDL_Surface* dst
3929         Sint16 x
3930         Sint16 y
3931         Sint16 r
3932         Uint32 color
3933         CODE:
3934                 RETVAL = filledCircleColor( dst, x, y, r, color );
3935         OUTPUT:
3936                 RETVAL
3937
3938 int
3939 GFXFilledCircleRGBA ( dst, x, y, rad, r, g, b, a )
3940         SDL_Surface* dst
3941         Sint16 x
3942         Sint16 y
3943         Sint16 rad
3944         Uint8 r
3945         Uint8 g
3946         Uint8 b
3947         Uint8 a
3948         CODE:
3949                 RETVAL = filledCircleRGBA( dst, x, y, rad, r, g, b, a );
3950         OUTPUT:
3951                 RETVAL
3952
3953 int
3954 GFXEllipseColor ( dst, x, y, rx, ry, color )
3955         SDL_Surface* dst
3956         Sint16 x
3957         Sint16 y
3958         Sint16 rx
3959         Sint16 ry
3960         Uint32 color
3961         CODE:
3962                 RETVAL = ellipseColor( dst, x, y, rx, ry, color );
3963         OUTPUT:
3964                 RETVAL
3965
3966 int
3967 GFXEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3968         SDL_Surface* dst
3969         Sint16 x
3970         Sint16 y
3971         Sint16  rx
3972         Sint16 ry
3973         Uint8 r
3974         Uint8 g
3975         Uint8 b
3976         Uint8 a
3977         CODE:
3978                 RETVAL = ellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3979         OUTPUT:
3980                 RETVAL
3981
3982 int
3983 GFXAaellipseColor ( dst, xc, yc, rx, ry, color )
3984         SDL_Surface* dst
3985         Sint16 xc
3986         Sint16 yc
3987         Sint16 rx
3988         Sint16 ry
3989         Uint32 color
3990         CODE:
3991                 RETVAL = aaellipseColor( dst, xc, yc, rx, ry, color );
3992         OUTPUT:
3993                 RETVAL
3994
3995 int
3996 GFXAaellipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3997         SDL_Surface* dst
3998         Sint16 x
3999         Sint16 y
4000         Sint16 rx
4001         Sint16 ry
4002         Uint8 r
4003         Uint8 g
4004         Uint8 b
4005         Uint8 a
4006         CODE:
4007                 RETVAL = aaellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4008         OUTPUT:
4009                 RETVAL
4010
4011 int
4012 GFXFilledEllipseColor ( dst, x, y, rx, ry, color )
4013         SDL_Surface* dst
4014         Sint16 x
4015         Sint16 y
4016         Sint16 rx
4017         Sint16 ry
4018         Uint32 color
4019         CODE:
4020                 RETVAL = filledEllipseColor( dst, x, y, rx, ry, color );
4021         OUTPUT:
4022                 RETVAL
4023
4024 int
4025 GFXFilledEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4026         SDL_Surface* dst
4027         Sint16 x
4028         Sint16 y
4029         Sint16 rx
4030         Sint16 ry
4031         Uint8 r
4032         Uint8 g
4033         Uint8 b
4034         Uint8 a
4035         CODE:
4036                 RETVAL = filledEllipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4037         OUTPUT:
4038                 RETVAL
4039
4040 int
4041 GFXFilledPieColor ( dst, x, y, rad, start, end, color )
4042         SDL_Surface* dst
4043         Sint16 x
4044         Sint16 y
4045         Sint16 rad
4046         Sint16 start
4047         Sint16 end
4048         Uint32 color
4049         CODE:
4050                 RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
4051         OUTPUT:
4052                 RETVAL
4053
4054 int
4055 GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
4056         SDL_Surface* dst
4057         Sint16 x
4058         Sint16 y
4059         Sint16 rad
4060         Sint16 start
4061         Sint16 end
4062         Uint8 r
4063         Uint8 g
4064         Uint8 b
4065         Uint8 a
4066         CODE:
4067                 RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
4068         OUTPUT:
4069                 RETVAL
4070
4071 int
4072 GFXPolygonColor ( dst, vx, vy, n, color )
4073         SDL_Surface* dst
4074         Sint16* vx
4075         Sint16* vy
4076         int n
4077         Uint32 color;
4078         CODE:
4079                 RETVAL = polygonColor( dst, vx, vy, n, color );
4080         OUTPUT:
4081                 RETVAL
4082
4083 int
4084 GFXPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4085         SDL_Surface* dst
4086         Sint16* vx
4087         Sint16* vy
4088         int n
4089         Uint8 r
4090         Uint8 g
4091         Uint8 b
4092         Uint8 a
4093         CODE:
4094                 RETVAL = polygonRGBA( dst, vx, vy, n, r, g, b, a );
4095         OUTPUT:
4096                 RETVAL
4097
4098 int
4099 GFXAapolygonColor ( dst, vx, vy, n, color )
4100         SDL_Surface* dst
4101         Sint16* vx
4102         Sint16* vy
4103         int n
4104         Uint32 color
4105         CODE:
4106                 RETVAL = aapolygonColor( dst, vx, vy, n, color );
4107         OUTPUT:
4108                 RETVAL
4109
4110 int
4111 GFXAapolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4112         SDL_Surface* dst
4113         Sint16* vx
4114         Sint16* vy
4115         int n
4116         Uint8 r
4117         Uint8 g
4118         Uint8 b
4119         Uint8 a
4120         CODE:
4121                 RETVAL = aapolygonRGBA( dst, vx, vy, n, r, g, b, a );
4122         OUTPUT:
4123                 RETVAL
4124
4125 int
4126 GFXFilledPolygonColor ( dst, vx, vy, n, color )
4127         SDL_Surface* dst
4128         Sint16* vx
4129         Sint16* vy
4130         int n
4131         int color
4132         CODE:
4133                 RETVAL = filledPolygonColor( dst, vx, vy, n, color );
4134         OUTPUT:
4135                 RETVAL
4136
4137 int
4138 GFXFilledPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4139         SDL_Surface* dst
4140         Sint16* vx
4141         Sint16* vy
4142         int n
4143         Uint8 r
4144         Uint8 g
4145         Uint8 b
4146         Uint8 a
4147         CODE:
4148                 RETVAL = filledPolygonRGBA( dst, vx, vy, n, r, g, b, a );
4149         OUTPUT:
4150                 RETVAL
4151
4152 int
4153 GFXCharacterColor ( dst, x, y, c, color )
4154         SDL_Surface* dst
4155         Sint16 x
4156         Sint16 y
4157         char c
4158         Uint32 color
4159         CODE:
4160                 RETVAL = characterColor( dst, x, y, c, color );
4161         OUTPUT:
4162                 RETVAL
4163
4164 int
4165 GFXCharacterRGBA ( dst, x, y, c, r, g, b, a )
4166         SDL_Surface* dst
4167         Sint16 x
4168         Sint16 y
4169         char c
4170         Uint8 r
4171         Uint8 g
4172         Uint8 b
4173         Uint8 a
4174         CODE:
4175                 RETVAL = characterRGBA( dst, x, y, c, r, g, b, a );
4176         OUTPUT:
4177                 RETVAL
4178
4179 int
4180 GFXStringColor ( dst, x, y, c, color )
4181         SDL_Surface* dst
4182         Sint16 x
4183         Sint16 y
4184         char* c
4185         Uint32 color
4186         CODE:
4187                 RETVAL = stringColor( dst, x, y, c, color );
4188         OUTPUT:
4189                 RETVAL
4190
4191 int
4192 GFXStringRGBA ( dst, x, y, c, r, g, b, a )
4193         SDL_Surface* dst
4194         Sint16 x
4195         Sint16 y
4196         char* c
4197         Uint8 r
4198         Uint8 g
4199         Uint8 b
4200         Uint8 a
4201         CODE:
4202                 RETVAL = stringRGBA( dst, x, y, c, r, g, b, a );
4203         OUTPUT:
4204                 RETVAL
4205
4206 #endif
4207
4208
4209 #ifdef HAVE_SDL_SVG
4210
4211 SDL_svg_context *
4212 SVG_Load ( filename )
4213         char* filename
4214         CODE:
4215                 RETVAL = SVG_Load(filename);
4216         OUTPUT:
4217                 RETVAL
4218
4219 SDL_svg_context *
4220 SVG_LoadBuffer ( data, len )
4221         char* data
4222         int len
4223         CODE:
4224                 RETVAL = SVG_LoadBuffer(data,len);
4225         OUTPUT:
4226                 RETVAL
4227
4228 int
4229 SVG_SetOffset ( source, xoff, yoff )
4230         SDL_svg_context* source
4231         double xoff
4232         double yoff
4233         CODE:
4234                 RETVAL = SVG_SetOffset(source,xoff,yoff);
4235         OUTPUT:
4236                 RETVAL
4237
4238 int
4239 SVG_SetScale ( source, xscale, yscale )
4240         SDL_svg_context* source
4241         double xscale
4242         double yscale
4243         CODE:
4244                 RETVAL = SVG_SetScale(source,xscale,yscale);
4245         OUTPUT:
4246                 RETVAL
4247
4248 int
4249 SVG_RenderToSurface ( source, x, y, dest )
4250         SDL_svg_context* source
4251         int x
4252         int y
4253         SDL_Surface* dest;
4254         CODE:
4255                 RETVAL = SVG_RenderToSurface(source,x,y,dest);
4256         OUTPUT:
4257                 RETVAL
4258
4259 void
4260 SVG_Free ( source )
4261         SDL_svg_context* source
4262         CODE:
4263                 SVG_Free(source);       
4264
4265 void
4266 SVG_Set_Flags ( source, flags )
4267         SDL_svg_context* source
4268         Uint32 flags
4269         CODE:
4270                 SVG_Set_Flags(source,flags);
4271
4272 float
4273 SVG_Width ( source )
4274         SDL_svg_context* source
4275         CODE:
4276                 RETVAL = SVG_Width(source);
4277         OUTPUT:
4278                 RETVAL
4279
4280 float
4281 SVG_HEIGHT ( source )
4282         SDL_svg_context* source
4283         CODE:
4284                 RETVAL = SVG_Height(source);
4285         OUTPUT:
4286                 RETVAL
4287
4288 void
4289 SVG_SetClipping ( source, minx, miny, maxx, maxy )
4290         SDL_svg_context* source
4291         int minx
4292         int miny
4293         int maxx
4294         int maxy
4295         CODE:
4296                 SVG_SetClipping(source,minx,miny,maxx,maxy);
4297
4298 int
4299 SVG_Version ( )
4300         CODE:
4301                 RETVAL = SVG_Version();
4302         OUTPUT:
4303                 RETVAL
4304
4305
4306 #endif
4307
4308 #ifdef HAVE_SDL_SOUND
4309
4310 Uint16
4311 SoundAudioInfoFormat ( audioinfo )
4312         Sound_AudioInfo* audioinfo
4313         CODE:
4314                 RETVAL = audioinfo->format;
4315         OUTPUT:
4316                 RETVAL
4317
4318 Uint8
4319 SoundAudioInfoChannels ( audioinfo )
4320         Sound_AudioInfo* audioinfo
4321         CODE:
4322                 RETVAL = audioinfo->channels;
4323         OUTPUT:
4324                 RETVAL
4325
4326 Uint32
4327 SoundAudioInforate ( audioinfo )
4328         Sound_AudioInfo* audioinfo
4329         CODE:
4330                 RETVAL = audioinfo->rate;
4331         OUTPUT:
4332                 RETVAL
4333
4334 AV*
4335 SoundDecoderInfoExtensions ( decoderinfo )
4336         Sound_DecoderInfo* decoderinfo
4337         CODE:
4338                 const char **ext;
4339                 for ( ext = decoderinfo->extensions; *ext != NULL; ext++ ){
4340                         av_push(RETVAL,newSVpv(*ext,0));
4341                 }
4342         OUTPUT:
4343                 RETVAL
4344
4345 const char*
4346 SoundDecoderInfoDescription ( decoderinfo )
4347         Sound_DecoderInfo* decoderinfo
4348         CODE:
4349                 RETVAL = decoderinfo->description;
4350         OUTPUT:
4351                 RETVAL
4352
4353 const char*
4354 SoundDecoderInfoAuthor ( decoderinfo )
4355         Sound_DecoderInfo* decoderinfo
4356         CODE:
4357                 RETVAL = decoderinfo->author;
4358         OUTPUT:
4359                 RETVAL
4360
4361 const char*
4362 SoundDecoderInfoUrl ( decoderinfo )
4363         Sound_DecoderInfo* decoderinfo
4364         CODE:
4365                 RETVAL = decoderinfo->url;
4366         OUTPUT:
4367                 RETVAL
4368
4369 const Sound_DecoderInfo*
4370 SoundSampleDecoder ( sample ) 
4371         Sound_Sample* sample
4372         CODE:
4373                 RETVAL = sample->decoder;
4374         OUTPUT:
4375                 RETVAL
4376
4377 Sound_AudioInfo* 
4378 SoundSampleDesired ( sample )
4379         Sound_Sample* sample
4380         CODE:
4381                 RETVAL = &sample->desired;
4382         OUTPUT:
4383                 RETVAL
4384
4385 Sound_AudioInfo*
4386 SoundSampleAcutal ( sample )
4387         Sound_Sample* sample
4388         CODE:
4389                 RETVAL = &sample->actual;
4390         OUTPUT:
4391                 RETVAL
4392
4393 char*
4394 SoundSampleBuffer ( sample )
4395         Sound_Sample* sample
4396         CODE:
4397                 RETVAL = sample->buffer;
4398         OUTPUT:
4399                 RETVAL
4400
4401 Uint32
4402 SoundSampleBufferSize ( sample )
4403         Sound_Sample* sample
4404         CODE:
4405                 RETVAL = sample->buffer_size;
4406         OUTPUT:
4407                 RETVAL
4408
4409 Uint32
4410 SoundSampleFlags ( sample )
4411         Sound_Sample* sample
4412         CODE:
4413                 RETVAL = (Uint32)sample->flags;
4414         OUTPUT:
4415                 RETVAL
4416
4417 int
4418 Sound_Init ( )
4419         CODE:
4420                 RETVAL = Sound_Init();
4421         OUTPUT:
4422                 RETVAL
4423
4424 int
4425 Sound_Quit ( )
4426         CODE:
4427                 RETVAL = Sound_Quit();
4428         OUTPUT:
4429                 RETVAL
4430
4431 AV*
4432 Sound_AvailableDecoders ( )
4433         CODE:
4434                 RETVAL = newAV();
4435                 const Sound_DecoderInfo** sdi;
4436                 sdi = Sound_AvailableDecoders();
4437                 if (sdi != NULL)  {
4438                         for (;*sdi != NULL; ++sdi) {
4439                                 av_push(RETVAL,sv_2mortal(newSViv(PTR2IV(*sdi))));
4440                         }
4441                 }
4442         OUTPUT:
4443                 RETVAL
4444
4445 const char*
4446 Sound_GetError ( )
4447         CODE:
4448                 RETVAL = Sound_GetError();
4449         OUTPUT:
4450                 RETVAL
4451
4452 void
4453 Sound_ClearError ( )
4454         CODE:
4455                 Sound_ClearError();
4456
4457 Sound_Sample*
4458 Sound_NewSample ( rw, ext, desired, buffsize )
4459         SDL_RWops* rw
4460         const char* ext
4461         Sound_AudioInfo* desired
4462         Uint32 buffsize
4463         CODE:
4464                 RETVAL = Sound_NewSample(rw,ext,desired,buffsize);
4465         OUTPUT:
4466                 RETVAL
4467
4468 Sound_Sample*
4469 Sound_NewSampleFromMem ( data, size, ext, desired, buffsize )
4470         const Uint8 *data
4471         Uint32 size
4472         const char* ext
4473         Sound_AudioInfo* desired
4474         Uint32 buffsize
4475         CODE:
4476                 RETVAL = Sound_NewSampleFromMem(data,size,ext,desired,buffsize);
4477         OUTPUT:
4478                 RETVAL
4479
4480 Sound_Sample*
4481 Sound_NewSampleFromFile ( fname, desired, buffsize )
4482         const char* fname
4483         Sound_AudioInfo* desired
4484         Uint32 buffsize
4485         CODE:
4486                 RETVAL = Sound_NewSampleFromFile(fname,desired,buffsize);
4487         OUTPUT:
4488                 RETVAL
4489
4490 void
4491 Sound_FreeSample ( sample )
4492         Sound_Sample* sample
4493         CODE:
4494                 Sound_FreeSample(sample);
4495
4496 Sint32
4497 Sound_GetDuration ( sample )
4498         Sound_Sample* sample
4499         CODE:
4500                 RETVAL = Sound_GetDuration(sample);
4501         OUTPUT:
4502                 RETVAL
4503
4504 int
4505 Sound_SetBufferSize ( sample, size )
4506         Sound_Sample* sample
4507         Uint32 size
4508         CODE:
4509                 RETVAL = Sound_SetBufferSize(sample,size);
4510         OUTPUT:
4511                 RETVAL
4512
4513 Uint32
4514 Sound_Decode ( sample )
4515         Sound_Sample* sample
4516         CODE:
4517                 RETVAL = Sound_Decode(sample);
4518         OUTPUT:
4519                 RETVAL
4520
4521 Uint32
4522 Sound_DecodeAll ( sample ) 
4523         Sound_Sample* sample
4524         CODE:
4525                 RETVAL = Sound_DecodeAll(sample);
4526         OUTPUT:
4527                 RETVAL
4528
4529 int
4530 Sound_Rewind ( sample )
4531         Sound_Sample* sample
4532         CODE:
4533                 RETVAL = Sound_Rewind(sample);
4534         OUTPUT:
4535                 RETVAL
4536
4537 int
4538 Sound_Seek ( sample, ms )
4539         Sound_Sample* sample
4540         Uint32 ms
4541         CODE:
4542                 RETVAL = Sound_Seek(sample,ms);
4543         OUTPUT:
4544                 RETVAL
4545
4546 #endif
4547
4548 MODULE = SDL            PACKAGE = SDL
4549 PROTOTYPES : DISABLE
4550
4551