07b3d0b35a3b45d16a512ff62037bebe74206644
[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 SDL_Rect *
1209 NewRect ( x, y, w, h )
1210         Sint16 x
1211         Sint16 y
1212         Uint16 w
1213         Uint16 h
1214         CODE:
1215                 RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
1216                 RETVAL->x = x;
1217                 RETVAL->y = y;
1218                 RETVAL->w = w;
1219                 RETVAL->h = h;
1220         OUTPUT:
1221                 RETVAL
1222
1223 void
1224 FreeRect ( rect )
1225         SDL_Rect *rect
1226         CODE:
1227                 safefree(rect);
1228
1229 Sint16
1230 RectX ( rect, ... )
1231         SDL_Rect *rect
1232         CODE:
1233                 if (items > 1 ) rect->x = SvIV(ST(1)); 
1234                 RETVAL = rect->x;
1235         OUTPUT:
1236                 RETVAL
1237
1238 Sint16
1239 RectY ( rect, ... )
1240         SDL_Rect *rect
1241         CODE:
1242                 if (items > 1 ) rect->y = SvIV(ST(1)); 
1243                 RETVAL = rect->y;
1244         OUTPUT:
1245                 RETVAL
1246
1247 Uint16
1248 RectW ( rect, ... )
1249         SDL_Rect *rect
1250         CODE:
1251                 if (items > 1 ) rect->w = SvIV(ST(1)); 
1252                 RETVAL = rect->w;
1253         OUTPUT:
1254                 RETVAL
1255
1256 Uint16
1257 RectH ( rect, ... )
1258         SDL_Rect *rect
1259         CODE:
1260                 if (items > 1 ) rect->h = SvIV(ST(1)); 
1261                 RETVAL = rect->h;
1262         OUTPUT:
1263                 RETVAL
1264
1265 AV*
1266 ListModes ( format, flags )
1267         Uint32 flags
1268         SDL_PixelFormat *format
1269         CODE:
1270                 SDL_Rect **mode;
1271                 RETVAL = newAV();
1272                 mode = SDL_ListModes(format,flags);
1273                 if (mode == (SDL_Rect**)-1 ) {
1274                         av_push(RETVAL,newSVpv("all",0));
1275                 } else if (! mode ) {
1276                         av_push(RETVAL,newSVpv("none",0));
1277                 } else {
1278                         for (;*mode;mode++) {
1279                                 av_push(RETVAL,newSViv(PTR2IV(*mode)));
1280                         }
1281                 }
1282         OUTPUT:
1283                 RETVAL
1284
1285
1286 SDL_Color *
1287 NewColor ( r, g, b )
1288         Uint8 r
1289         Uint8 g
1290         Uint8 b
1291         CODE:
1292                 RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color));
1293                 RETVAL->r = r;
1294                 RETVAL->g = g;
1295                 RETVAL->b = b;
1296         OUTPUT:
1297                 RETVAL
1298
1299 Uint8
1300 ColorR ( color, ... )
1301         SDL_Color *color
1302         CODE:
1303                 if (items > 1 ) color->r = SvIV(ST(1)); 
1304                 RETVAL = color->r;
1305         OUTPUT:
1306                 RETVAL
1307
1308 Uint8
1309 ColorG ( color, ... )
1310         SDL_Color *color
1311         CODE:
1312                 if (items > 1 ) color->g = SvIV(ST(1)); 
1313                 RETVAL = color->g;
1314         OUTPUT:
1315                 RETVAL
1316
1317 Uint8
1318 ColorB ( color, ... )
1319         SDL_Color *color
1320         CODE:
1321                 if (items > 1 ) color->b = SvIV(ST(1)); 
1322                 RETVAL = color->b;
1323         OUTPUT:
1324                 RETVAL
1325
1326
1327 void
1328 ColorRGB ( color, ... )
1329  SDL_Color *color
1330  PPCODE:
1331  if (items > 1 ) {
1332  color->r = SvIV(ST(1));
1333  color->g = SvIV(ST(2));
1334  color->b = SvIV(ST(3));
1335  }
1336  mXPUSHi( color->r );
1337  mXPUSHi( color->g );
1338  mXPUSHi( color->b );
1339  XSRETURN(3);
1340
1341 void
1342 FreeColor ( color )
1343         SDL_Color *color
1344         CODE:
1345                 return; safefree(color);
1346
1347 SDL_Palette *
1348 NewPalette ( number )
1349         int number
1350         CODE:
1351                 RETVAL = (SDL_Palette *)safemalloc(sizeof(SDL_Palette));
1352                 RETVAL->colors = (SDL_Color *)safemalloc(number * 
1353                                                 sizeof(SDL_Color));
1354                 RETVAL->ncolors = number;
1355         OUTPUT:
1356                 RETVAL
1357
1358 int
1359 PaletteNColors ( palette, ... )
1360         SDL_Palette *palette
1361         CODE:
1362                 if ( items > 1 ) palette->ncolors = SvIV(ST(1));
1363                 RETVAL = palette->ncolors;
1364         OUTPUT:
1365                 RETVAL
1366
1367 SDL_Color *
1368 PaletteColors ( palette, index, ... )
1369         SDL_Palette *palette
1370         int index
1371         CODE:
1372                 if ( items > 2 ) {
1373                         palette->colors[index].r = SvUV(ST(2)); 
1374                         palette->colors[index].g = SvUV(ST(3)); 
1375                         palette->colors[index].b = SvUV(ST(4)); 
1376                 }
1377                 RETVAL = (SDL_Color *)(palette->colors + index);
1378         OUTPUT:
1379                 RETVAL
1380
1381 int
1382 VideoModeOK ( width, height, bpp, flags )
1383         int width
1384         int height
1385         int bpp
1386         Uint32 flags
1387         CODE:
1388                 RETVAL = SDL_VideoModeOK(width,height,bpp,flags);
1389         OUTPUT:
1390                 RETVAL
1391
1392 SDL_Surface *
1393 SetVideoMode ( width, height, bpp, flags )
1394         int width
1395         int height
1396         int bpp
1397         Uint32 flags
1398         CODE:
1399                 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
1400         OUTPUT:
1401                 RETVAL
1402
1403 void
1404 UpdateRect ( surface, x, y, w ,h )
1405         SDL_Surface *surface
1406         int x
1407         int y
1408         int w
1409         int h
1410         CODE:
1411                 SDL_UpdateRect(surface,x,y,w,h);
1412
1413 void
1414 UpdateRects ( surface, ... )
1415         SDL_Surface *surface
1416         CODE:
1417                 SDL_Rect *rects, *oldrects, *temp;
1418                 int num_rects,i;
1419                 if ( items < 2 ) return;
1420                 num_rects = items - 1;
1421                 oldrects = rects;       
1422                 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
1423                 for(i=0;i<num_rects;i++) {
1424                         temp = (SDL_Rect *)SvIV(ST(i+1));
1425                         rects[i].x = temp->x;
1426                         rects[i].y = temp->y;
1427                         rects[i].w = temp->w;
1428                         rects[i].h = temp->h;
1429                 } 
1430                 SDL_UpdateRects(surface,num_rects,rects);
1431                 safefree(rects);
1432                 safefree(oldrects);
1433
1434 int
1435 Flip ( surface )
1436         SDL_Surface *surface
1437         CODE:
1438                 RETVAL = SDL_Flip(surface);
1439         OUTPUT:
1440                 RETVAL
1441
1442 int
1443 SetColors ( surface, start, ... )
1444         SDL_Surface *surface
1445         int start
1446         CODE:
1447                 SDL_Color *colors,*temp;
1448                 int i, length;
1449                 if ( items < 3 ) { RETVAL = 0;  goto all_done; }
1450                 length = items - 2;
1451                 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
1452                 for ( i = 0; i < length ; i++ ) {
1453                         temp = (SDL_Color *)SvIV(ST(i+2));
1454                         colors[i].r = temp->r;
1455                         colors[i].g = temp->g;
1456                         colors[i].b = temp->b;
1457                 }
1458                 RETVAL = SDL_SetColors(surface, colors, start, length );
1459                 safefree(colors);
1460 all_done:
1461         OUTPUT: 
1462                 RETVAL
1463
1464 Uint32
1465 MapRGB ( surface, r, g, b )
1466         SDL_Surface *surface
1467         Uint8 r
1468         Uint8 g
1469         Uint8 b
1470         CODE:
1471                 RETVAL = SDL_MapRGB(surface->format,r,g,b);
1472         OUTPUT:
1473                 RETVAL
1474
1475 Uint32
1476 MapRGBA ( surface, r, g, b, a )
1477         SDL_Surface *surface
1478         Uint8 r
1479         Uint8 g
1480         Uint8 b
1481         Uint8 a
1482         CODE:
1483                 RETVAL = SDL_MapRGBA(surface->format,r,g,b,a);
1484         OUTPUT:
1485                 RETVAL
1486
1487 AV *
1488 GetRGB ( surface, pixel )
1489         SDL_Surface *surface
1490         Uint32 pixel
1491         CODE:
1492                 Uint8 r,g,b;
1493                 SDL_GetRGB(pixel,surface->format,&r,&g,&b);
1494                 RETVAL = newAV();
1495                 av_push(RETVAL,newSViv(r));
1496                 av_push(RETVAL,newSViv(g));
1497                 av_push(RETVAL,newSViv(b));
1498         OUTPUT:
1499                 RETVAL
1500
1501 AV *
1502 GetRGBA ( surface, pixel )
1503         SDL_Surface *surface
1504         Uint32 pixel
1505         CODE:
1506                 Uint8 r,g,b,a;
1507                 SDL_GetRGBA(pixel,surface->format,&r,&g,&b,&a);
1508                 RETVAL = newAV();
1509                 av_push(RETVAL,newSViv(r));
1510                 av_push(RETVAL,newSViv(g));
1511                 av_push(RETVAL,newSViv(b));
1512                 av_push(RETVAL,newSViv(a));
1513         OUTPUT:
1514                 RETVAL
1515
1516 int
1517 SaveBMP ( surface, filename )
1518         SDL_Surface *surface
1519         char *filename
1520         CODE:
1521                 RETVAL = SDL_SaveBMP(surface,filename);
1522         OUTPUT:
1523                 RETVAL  
1524
1525 int
1526 SetColorKey ( surface, flag, key )
1527         SDL_Surface *surface
1528         Uint32 flag
1529         SDL_Color *key
1530         CODE:
1531                 Uint32 pixel = SDL_MapRGB(surface->format,key->r,key->g,key->b);
1532                 RETVAL = SDL_SetColorKey(surface,flag,pixel);
1533         OUTPUT:
1534                 RETVAL
1535
1536 int
1537 SetAlpha ( surface, flag, alpha )
1538         SDL_Surface *surface
1539         Uint32 flag
1540         Uint8 alpha
1541         CODE:
1542                 RETVAL = SDL_SetAlpha(surface,flag,alpha);
1543         OUTPUT:
1544                 RETVAL
1545
1546 SDL_Surface *
1547 DisplayFormat ( surface )
1548         SDL_Surface *surface
1549         CODE:
1550                 RETVAL = SDL_DisplayFormat(surface);
1551         OUTPUT:
1552                 RETVAL
1553
1554 SDL_Surface*
1555 DisplayFormatAlpha ( surface )
1556         SDL_Surface *surface
1557         CODE:
1558                 RETVAL = SDL_DisplayFormatAlpha(surface);
1559         OUTPUT:
1560                 RETVAL
1561
1562 SDL_Surface*
1563 ConvertRGB ( surface )
1564         SDL_Surface * surface
1565         CODE:
1566                 SDL_PixelFormat fmt;
1567                 fmt.palette = NULL;
1568                 fmt.BitsPerPixel = 24;
1569                 fmt.BytesPerPixel = 3;
1570                 fmt.Rmask = 0x000000ff;
1571                 fmt.Gmask = 0x0000ff00;
1572                 fmt.Bmask = 0x00ff0000;
1573                 fmt.Amask = 0x00000000;
1574                 fmt.Rloss = 0;
1575                 fmt.Gloss = 0;
1576                 fmt.Bloss = 0;
1577                 fmt.Aloss = 0;
1578                 fmt.Rshift = 0;
1579                 fmt.Gshift = 8;
1580                 fmt.Bshift = 16;
1581                 fmt.Ashift = 24;
1582                 fmt.colorkey = 0;
1583                 fmt.alpha = 0;
1584                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1585         OUTPUT:
1586                 RETVAL
1587
1588 SDL_Surface* 
1589 ConvertRGBA ( surface )
1590         SDL_Surface * surface
1591         CODE:
1592                 SDL_PixelFormat fmt;
1593                 fmt.palette = NULL;
1594                 fmt.BitsPerPixel = 32;
1595                 fmt.BytesPerPixel = 4;
1596                 fmt.Rmask = 0x000000ff;
1597                 fmt.Gmask = 0x0000ff00;
1598                 fmt.Bmask = 0x00ff0000;
1599                 fmt.Amask = 0xff000000;
1600                 fmt.Rloss = 0;
1601                 fmt.Gloss = 0;
1602                 fmt.Bloss = 0;
1603                 fmt.Aloss = 0;
1604                 fmt.Rshift = 0;
1605                 fmt.Gshift = 8;
1606                 fmt.Bshift = 16;
1607                 fmt.Ashift = 24;
1608                 fmt.colorkey = 0;
1609                 fmt.alpha = 0;
1610                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1611         OUTPUT:
1612                 RETVAL
1613
1614 int
1615 BlitSurface ( src, src_rect, dest, dest_rect )
1616         SDL_Surface *src
1617         SDL_Rect *src_rect
1618         SDL_Surface *dest
1619         SDL_Rect *dest_rect
1620         CODE:
1621                 RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
1622         OUTPUT:
1623                 RETVAL
1624
1625 int
1626 FillRect ( dest, dest_rect, color )
1627         SDL_Surface *dest
1628         SDL_Rect *dest_rect
1629         SDL_Color *color
1630         CODE:
1631                 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
1632                 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
1633         OUTPUT:
1634                 RETVAL
1635
1636 Uint8
1637 GetAppState ()
1638         CODE:
1639                 RETVAL = SDL_GetAppState();
1640         OUTPUT:
1641                 RETVAL
1642
1643
1644 void
1645 WMSetCaption ( title, icon )
1646         char *title
1647         char *icon
1648         CODE:
1649                 SDL_WM_SetCaption(title,icon);
1650
1651 AV *
1652 WMGetCaption ()
1653         CODE:
1654                 char *title,*icon;
1655                 SDL_WM_GetCaption(&title,&icon);
1656                 RETVAL = newAV();
1657                 av_push(RETVAL,newSVpv(title,0));
1658                 av_push(RETVAL,newSVpv(icon,0));
1659         OUTPUT:
1660                 RETVAL
1661
1662 void
1663 WMSetIcon ( icon )
1664         SDL_Surface *icon
1665         CODE:
1666                 SDL_WM_SetIcon(icon,NULL);
1667
1668 void
1669 WarpMouse ( x, y )
1670         Uint16 x
1671         Uint16 y
1672         CODE:
1673                 SDL_WarpMouse(x,y);
1674
1675 AV*
1676 GetMouseState ()
1677         CODE:
1678                 Uint8 mask;
1679                 int x;
1680                 int y;
1681                 mask = SDL_GetMouseState(&x,&y);
1682                 RETVAL = newAV();
1683                 av_push(RETVAL,newSViv(mask));
1684                 av_push(RETVAL,newSViv(x));
1685                 av_push(RETVAL,newSViv(y));
1686         OUTPUT:
1687                 RETVAL  
1688
1689 AV*
1690 GetRelativeMouseState ()
1691         CODE:
1692                 Uint8 mask;
1693                 int x;
1694                 int y;
1695                 mask = SDL_GetRelativeMouseState(&x,&y);
1696                 RETVAL = newAV();
1697                 av_push(RETVAL,newSViv(mask));
1698                 av_push(RETVAL,newSViv(x));
1699                 av_push(RETVAL,newSViv(y));
1700         OUTPUT:
1701                 RETVAL  
1702
1703 SDL_Cursor *
1704 NewCursor ( data, mask, x ,y )
1705         SDL_Surface *data
1706         SDL_Surface *mask
1707         int x
1708         int y
1709         CODE:
1710                 RETVAL = SDL_CreateCursor((Uint8*)data->pixels,
1711                                 (Uint8*)mask->pixels,data->w,data->h,x,y);
1712         OUTPUT:
1713                 RETVAL
1714
1715 void
1716 FreeCursor ( cursor )
1717         SDL_Cursor *cursor
1718         CODE:
1719                 SDL_FreeCursor(cursor);
1720
1721 void
1722 SetCursor ( cursor )
1723         SDL_Cursor *cursor
1724         CODE:
1725                 SDL_SetCursor(cursor);
1726
1727 SDL_Cursor *
1728 GetCursor ()
1729         CODE:
1730                 RETVAL = SDL_GetCursor();
1731         OUTPUT:
1732                 RETVAL
1733
1734 int
1735 ShowCursor ( toggle )
1736         int toggle
1737         CODE:
1738                 RETVAL = SDL_ShowCursor(toggle);
1739         OUTPUT: 
1740                 RETVAL
1741
1742 SDL_AudioSpec *
1743 NewAudioSpec ( freq, format, channels, samples )
1744         int freq
1745         Uint16 format
1746         Uint8 channels
1747         Uint16 samples
1748         CODE:
1749                 RETVAL = (SDL_AudioSpec *)safemalloc(sizeof(SDL_AudioSpec));
1750                 RETVAL->freq = freq;
1751                 RETVAL->format = format;
1752                 RETVAL->channels = channels;
1753                 RETVAL->samples = samples;
1754         OUTPUT:
1755                 RETVAL
1756
1757 void
1758 FreeAudioSpec ( spec )
1759         SDL_AudioSpec *spec
1760         CODE:
1761                 safefree(spec);
1762
1763 SDL_AudioCVT *
1764 NewAudioCVT ( src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)
1765         Uint16 src_format
1766         Uint8 src_channels
1767         int src_rate
1768         Uint16 dst_format
1769         Uint8 dst_channels
1770         int dst_rate
1771         CODE:
1772                 RETVAL = (SDL_AudioCVT *)safemalloc(sizeof(SDL_AudioCVT));
1773                 if (SDL_BuildAudioCVT(RETVAL,src_format, src_channels, src_rate,
1774                         dst_format, dst_channels, dst_rate)) { 
1775                         safefree(RETVAL); RETVAL = NULL; }
1776         OUTPUT:
1777                 RETVAL
1778
1779 void
1780 FreeAudioCVT ( cvt )
1781         SDL_AudioCVT *cvt
1782         CODE:
1783                 safefree(cvt);
1784
1785 int
1786 ConvertAudioData ( cvt, data, len )
1787         SDL_AudioCVT *cvt
1788         Uint8 *data
1789         int len
1790         CODE:
1791                 cvt->len = len;
1792                 cvt->buf = (Uint8*) safemalloc(cvt->len*cvt->len_mult);
1793                 memcpy(cvt->buf,data,cvt->len);
1794                 RETVAL = SDL_ConvertAudio(cvt);
1795         OUTPUT:
1796                 RETVAL                  
1797
1798 int
1799 OpenAudio ( spec, callback )
1800         SDL_AudioSpec *spec
1801         SV* callback
1802         CODE:
1803                 spec->userdata = (void*)callback;
1804                 spec->callback = sdl_perl_audio_callback;
1805                 RETVAL = SDL_OpenAudio(spec,NULL);
1806         OUTPUT:
1807                 RETVAL
1808
1809 Uint32
1810 GetAudioStatus ()
1811         CODE:
1812                 RETVAL = SDL_GetAudioStatus ();
1813         OUTPUT:
1814                 RETVAL
1815
1816 void
1817 PauseAudio ( p_on )
1818         int p_on
1819         CODE:
1820                 SDL_PauseAudio(p_on);
1821         
1822 void
1823 LockAudio ()
1824         CODE:
1825                 SDL_LockAudio();
1826
1827 void
1828 UnlockAudio ()
1829         CODE:
1830                 SDL_UnlockAudio();
1831
1832 void
1833 CloseAudio ()
1834         CODE:
1835                 SDL_CloseAudio();
1836
1837 void
1838 FreeWAV ( buf )
1839         Uint8 *buf
1840         CODE:
1841                 SDL_FreeWAV(buf);
1842
1843 AV *
1844 LoadWAV ( filename, spec )
1845         char *filename
1846         SDL_AudioSpec *spec
1847         CODE:
1848                 SDL_AudioSpec *temp;
1849                 Uint8 *buf;
1850                 Uint32 len;
1851
1852                 RETVAL = newAV();
1853                 temp = SDL_LoadWAV(filename,spec,&buf,&len);
1854                 if ( ! temp ) goto error;
1855                 av_push(RETVAL,newSViv(PTR2IV(temp)));
1856                 av_push(RETVAL,newSViv(PTR2IV(buf)));
1857                 av_push(RETVAL,newSViv(len));
1858 error:
1859         OUTPUT:
1860                 RETVAL
1861         
1862 #ifdef HAVE_SDL_MIXER
1863
1864 void
1865 MixAudio ( dst, src, len, volume )
1866         Uint8 *dst
1867         Uint8 *src
1868         Uint32 len
1869         int volume
1870         CODE:
1871                 SDL_MixAudio(dst,src,len,volume);
1872
1873 int
1874 MixOpenAudio ( frequency, format, channels, chunksize )
1875         int frequency
1876         Uint16 format
1877         int channels
1878         int chunksize   
1879         CODE:
1880                 RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
1881         OUTPUT:
1882                 RETVAL
1883
1884 int
1885 MixAllocateChannels ( number )
1886         int number
1887         CODE:
1888                 RETVAL = Mix_AllocateChannels(number);
1889         OUTPUT:
1890                 RETVAL
1891
1892 AV *
1893 MixQuerySpec ()
1894         CODE:
1895                 int freq, channels, status;
1896                 Uint16 format;
1897                 status = Mix_QuerySpec(&freq,&format,&channels);
1898                 RETVAL = newAV();
1899                 av_push(RETVAL,newSViv(status));
1900                 av_push(RETVAL,newSViv(freq));
1901                 av_push(RETVAL,newSViv(format));
1902                 av_push(RETVAL,newSViv(channels));
1903         OUTPUT:
1904                 RETVAL
1905
1906 Mix_Chunk *
1907 MixLoadWAV ( filename )
1908         char *filename
1909         CODE:
1910                 RETVAL = Mix_LoadWAV(filename);
1911         OUTPUT:
1912                 RETVAL
1913
1914 Mix_Music *
1915 MixLoadMusic ( filename )
1916         char *filename
1917         CODE:
1918                 RETVAL = Mix_LoadMUS(filename);
1919         OUTPUT:
1920                 RETVAL
1921
1922 Mix_Chunk *
1923 MixQuickLoadWAV ( buf )
1924         Uint8 *buf
1925         CODE:
1926                 RETVAL = Mix_QuickLoad_WAV(buf);
1927         OUTPUT:
1928                 RETVAL
1929
1930 void
1931 MixFreeChunk( chunk )
1932         Mix_Chunk *chunk
1933         CODE:
1934                 Mix_FreeChunk(chunk);
1935
1936 void
1937 MixFreeMusic ( music )
1938         Mix_Music *music
1939         CODE:
1940                 Mix_FreeMusic(music);
1941
1942 void
1943 MixSetPostMixCallback ( func, arg )
1944         void *func
1945         void *arg
1946         CODE:
1947                 Mix_SetPostMix(func,arg);
1948
1949 void*
1950 PerlMixMusicHook ()
1951         CODE:
1952                 RETVAL = sdl_perl_music_callback;
1953         OUTPUT:
1954                 RETVAL
1955
1956 void
1957 MixSetMusicHook ( func, arg )
1958         void *func
1959         void *arg
1960         CODE:
1961                 Mix_HookMusic(func,arg);
1962
1963 void
1964 MixSetMusicFinishedHook ( func )
1965         void *func
1966         CODE:
1967                 mix_music_finished_cv = func;
1968                 Mix_HookMusicFinished(sdl_perl_music_finished_callback);
1969
1970 void *
1971 MixGetMusicHookData ()
1972         CODE:
1973                 RETVAL = Mix_GetMusicHookData();
1974         OUTPUT:
1975                 RETVAL
1976
1977 int
1978 MixReverseChannels ( number )
1979         int number
1980         CODE:
1981                 RETVAL = Mix_ReserveChannels ( number );
1982         OUTPUT:
1983                 RETVAL
1984
1985 int
1986 MixGroupChannel ( which, tag )
1987         int which
1988         int tag
1989         CODE:
1990                 RETVAL = Mix_GroupChannel(which,tag);
1991         OUTPUT:
1992                 RETVAL
1993
1994 int
1995 MixGroupChannels ( from, to, tag )
1996         int from
1997         int to
1998         int tag
1999         CODE:
2000                 RETVAL = Mix_GroupChannels(from,to,tag);
2001         OUTPUT:
2002                 RETVAL
2003
2004 int
2005 MixGroupAvailable ( tag )
2006         int tag
2007         CODE:
2008                 RETVAL = Mix_GroupAvailable(tag);
2009         OUTPUT:
2010                 RETVAL
2011
2012 int
2013 MixGroupCount ( tag )
2014         int tag
2015         CODE:
2016                 RETVAL = Mix_GroupCount(tag);
2017         OUTPUT:
2018                 RETVAL
2019
2020 int
2021 MixGroupOldest ( tag )
2022         int tag
2023         CODE:
2024                 RETVAL = Mix_GroupOldest(tag);
2025         OUTPUT:
2026                 RETVAL
2027
2028 int
2029 MixGroupNewer ( tag )
2030         int tag
2031         CODE:
2032                 RETVAL = Mix_GroupNewer(tag);
2033         OUTPUT:
2034                 RETVAL
2035
2036 int
2037 MixPlayChannel ( channel, chunk, loops )
2038         int channel
2039         Mix_Chunk *chunk
2040         int loops
2041         CODE:
2042                 RETVAL = Mix_PlayChannel(channel,chunk,loops);
2043         OUTPUT:
2044                 RETVAL
2045
2046 int
2047 MixPlayChannelTimed ( channel, chunk, loops, ticks )
2048         int channel
2049         Mix_Chunk *chunk
2050         int loops
2051         int ticks
2052         CODE:
2053                 RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
2054         OUTPUT:
2055                 RETVAL
2056
2057 int
2058 MixPlayMusic ( music, loops )
2059         Mix_Music *music
2060         int loops
2061         CODE:
2062                 RETVAL = Mix_PlayMusic(music,loops);
2063         OUTPUT:
2064                 RETVAL
2065
2066 int
2067 MixFadeInChannel ( channel, chunk, loops, ms )
2068         int channel
2069         Mix_Chunk *chunk
2070         int loops
2071         int ms
2072         CODE:
2073                 RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
2074         OUTPUT:
2075                 RETVAL
2076
2077 int
2078 MixFadeInChannelTimed ( channel, chunk, loops, ms, ticks )
2079         int channel
2080         Mix_Chunk *chunk
2081         int loops
2082         int ticks
2083         int ms
2084         CODE:
2085                 RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
2086         OUTPUT:
2087                 RETVAL
2088
2089 int
2090 MixFadeInMusic ( music, loops, ms )
2091         Mix_Music *music
2092         int loops
2093         int ms
2094         CODE:
2095                 RETVAL = Mix_FadeInMusic(music,loops,ms);
2096         OUTPUT:
2097                 RETVAL
2098
2099 int
2100 MixVolume ( channel, volume )
2101         int channel
2102         int volume
2103         CODE:   
2104                 RETVAL = Mix_Volume(channel,volume);
2105         OUTPUT:
2106                 RETVAL
2107
2108 int
2109 MixVolumeChunk ( chunk, volume )
2110         Mix_Chunk *chunk
2111         int volume
2112         CODE:
2113                 RETVAL = Mix_VolumeChunk(chunk,volume);
2114         OUTPUT:
2115                 RETVAL
2116
2117 int
2118 MixVolumeMusic ( volume )
2119         int volume
2120         CODE:
2121                 RETVAL = Mix_VolumeMusic(volume);
2122         OUTPUT:
2123                 RETVAL
2124
2125 int
2126 MixHaltChannel ( channel )
2127         int channel
2128         CODE:
2129                 RETVAL = Mix_HaltChannel(channel);
2130         OUTPUT:
2131                 RETVAL
2132
2133 int
2134 MixHaltGroup ( tag )
2135         int tag
2136         CODE:
2137                 RETVAL = Mix_HaltGroup(tag);
2138         OUTPUT:
2139                 RETVAL
2140
2141 int
2142 MixHaltMusic ()
2143         CODE:
2144                 RETVAL = Mix_HaltMusic();
2145         OUTPUT:
2146                 RETVAL
2147
2148 int
2149 MixExpireChannel ( channel, ticks )
2150         int channel
2151         int ticks
2152         CODE:
2153                 RETVAL = Mix_ExpireChannel ( channel,ticks);
2154         OUTPUT:
2155                 RETVAL
2156
2157 int
2158 MixFadeOutChannel ( which, ms )
2159         int which
2160         int ms
2161         CODE:
2162                 RETVAL = Mix_FadeOutChannel(which,ms);
2163         OUTPUT:
2164                 RETVAL
2165
2166 int
2167 MixFadeOutGroup ( which, ms )
2168         int which
2169         int ms
2170         CODE:
2171                 RETVAL = Mix_FadeOutGroup(which,ms);
2172         OUTPUT:
2173                 RETVAL
2174
2175 int
2176 MixFadeOutMusic ( ms )
2177         int ms
2178         CODE:
2179                 RETVAL = Mix_FadeOutMusic(ms);
2180         OUTPUT:
2181                 RETVAL
2182
2183 Mix_Fading
2184 MixFadingMusic()
2185         CODE:
2186                 RETVAL = Mix_FadingMusic();
2187         OUTPUT:
2188                 RETVAL
2189
2190 Mix_Fading
2191 MixFadingChannel( which )
2192         int which
2193         CODE:
2194                 RETVAL = Mix_FadingChannel(which);
2195         OUTPUT:
2196                 RETVAL
2197
2198 void
2199 MixPause ( channel )
2200         int channel
2201         CODE:
2202                 Mix_Pause(channel);
2203
2204 void
2205 MixResume ( channel )
2206         int channel
2207         CODE:
2208                 Mix_Resume(channel);
2209
2210 int
2211 MixPaused ( channel )
2212         int channel
2213         CODE:
2214                 RETVAL = Mix_Paused(channel);
2215         OUTPUT:
2216                 RETVAL
2217
2218 void
2219 MixPauseMusic ()
2220         CODE:
2221                 Mix_PauseMusic();
2222
2223 void
2224 MixResumeMusic ()
2225         CODE:
2226                 Mix_ResumeMusic();
2227
2228 void
2229 MixRewindMusic ()
2230         CODE:
2231                 Mix_RewindMusic();
2232
2233 int
2234 MixPausedMusic ()
2235         CODE:
2236                 RETVAL = Mix_PausedMusic();
2237         OUTPUT:
2238                 RETVAL
2239
2240 int
2241 MixPlaying( channel )
2242         int channel     
2243         CODE:
2244                 RETVAL = Mix_Playing(channel);
2245         OUTPUT:
2246                 RETVAL
2247
2248 int
2249 MixPlayingMusic()
2250         CODE:
2251                 RETVAL = Mix_PlayingMusic();
2252         OUTPUT:
2253                 RETVAL
2254
2255
2256 void
2257 MixCloseAudio ()
2258         CODE:
2259                 Mix_CloseAudio();
2260
2261 #endif
2262
2263 int
2264 GLLoadLibrary ( path )
2265         char *path
2266         CODE:
2267                 RETVAL = SDL_GL_LoadLibrary(path);
2268         OUTPUT:
2269                 RETVAL
2270
2271 void*
2272 GLGetProcAddress ( proc )
2273         char *proc
2274         CODE:
2275                 RETVAL = SDL_GL_GetProcAddress(proc);
2276         OUTPUT:
2277                 RETVAL
2278
2279 int
2280 GLSetAttribute ( attr,  value )
2281         int        attr
2282         int        value
2283         CODE:
2284                 RETVAL = SDL_GL_SetAttribute(attr, value);
2285         OUTPUT:
2286                 RETVAL
2287
2288 AV *
2289 GLGetAttribute ( attr )
2290         int        attr
2291         CODE:
2292                 int value;
2293                 RETVAL = newAV();
2294                 av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value)));
2295                 av_push(RETVAL,newSViv(value));
2296         OUTPUT:
2297                 RETVAL
2298
2299 void
2300 GLSwapBuffers ()
2301         CODE:
2302                 SDL_GL_SwapBuffers ();
2303
2304
2305 int
2306 BigEndian ()
2307         CODE:
2308                 RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN);
2309         OUTPUT:
2310                 RETVAL
2311
2312 int
2313 NumJoysticks ()
2314         CODE:
2315                 RETVAL = SDL_NumJoysticks();
2316         OUTPUT:
2317                 RETVAL
2318
2319 char *
2320 JoystickName ( index )
2321         int index
2322         CODE:
2323                 RETVAL = (char*)SDL_JoystickName(index);
2324         OUTPUT:
2325                 RETVAL
2326
2327 SDL_Joystick *
2328 JoystickOpen ( index ) 
2329         int index
2330         CODE:
2331                 RETVAL = SDL_JoystickOpen(index);
2332         OUTPUT:
2333                 RETVAL
2334
2335 int
2336 JoystickOpened ( index )
2337         int index
2338         CODE:
2339                 RETVAL = SDL_JoystickOpened(index);
2340         OUTPUT:
2341                 RETVAL
2342
2343 int
2344 JoystickIndex ( joystick )
2345         SDL_Joystick *joystick
2346         CODE:
2347                 RETVAL = SDL_JoystickIndex(joystick);
2348         OUTPUT:
2349                 RETVAL
2350
2351 int
2352 JoystickNumAxes ( joystick )
2353         SDL_Joystick *joystick
2354         CODE:
2355                 RETVAL = SDL_JoystickNumAxes(joystick);
2356         OUTPUT:
2357                 RETVAL
2358
2359 int
2360 JoystickNumBalls ( joystick )
2361         SDL_Joystick *joystick
2362         CODE:
2363                 RETVAL = SDL_JoystickNumBalls(joystick);
2364         OUTPUT:
2365                 RETVAL
2366
2367 int
2368 JoystickNumHats ( joystick )
2369         SDL_Joystick *joystick
2370         CODE:
2371                 RETVAL = SDL_JoystickNumHats(joystick);
2372         OUTPUT:
2373                 RETVAL
2374
2375 int
2376 JoystickNumButtons ( joystick )
2377         SDL_Joystick *joystick
2378         CODE:
2379                 RETVAL = SDL_JoystickNumButtons(joystick);
2380         OUTPUT:
2381                 RETVAL
2382
2383 void
2384 JoystickUpdate ()
2385         CODE:
2386                 SDL_JoystickUpdate();
2387
2388 Sint16
2389 JoystickGetAxis ( joystick, axis )
2390         SDL_Joystick *joystick
2391         int axis
2392         CODE:
2393                 RETVAL = SDL_JoystickGetAxis(joystick,axis);
2394         OUTPUT:
2395                 RETVAL
2396
2397 Uint8
2398 JoystickGetHat ( joystick, hat )
2399         SDL_Joystick *joystick
2400         int hat 
2401         CODE:
2402                 RETVAL = SDL_JoystickGetHat(joystick,hat);
2403         OUTPUT:
2404                 RETVAL
2405
2406 Uint8
2407 JoystickGetButton ( joystick, button)
2408         SDL_Joystick *joystick
2409         int button 
2410         CODE:
2411                 RETVAL = SDL_JoystickGetButton(joystick,button);
2412         OUTPUT:
2413                 RETVAL
2414
2415 AV *
2416 JoystickGetBall ( joystick, ball )
2417         SDL_Joystick *joystick
2418         int ball 
2419         CODE:
2420                 int success,dx,dy;
2421                 success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
2422                 RETVAL = newAV();
2423                 av_push(RETVAL,newSViv(success));
2424                 av_push(RETVAL,newSViv(dx));
2425                 av_push(RETVAL,newSViv(dy));
2426         OUTPUT:
2427                 RETVAL  
2428
2429 void
2430 JoystickClose ( joystick )
2431         SDL_Joystick *joystick
2432         CODE:
2433                 SDL_JoystickClose(joystick);
2434
2435 Sint16
2436 JoyAxisEventWhich ( e )
2437         SDL_Event *e
2438         CODE:
2439                 RETVAL = e->jaxis.which;
2440         OUTPUT:
2441                 RETVAL
2442
2443 Uint8
2444 JoyAxisEventAxis ( e )
2445         SDL_Event *e
2446         CODE:
2447                 RETVAL = e->jaxis.axis;
2448         OUTPUT:
2449                 RETVAL
2450
2451 Sint16
2452 JoyAxisEventValue ( e )
2453         SDL_Event *e
2454         CODE:
2455                 RETVAL = e->jaxis.value;
2456         OUTPUT:
2457                 RETVAL
2458
2459 Uint8
2460 JoyButtonEventWhich ( e )
2461         SDL_Event *e
2462         CODE:
2463                 RETVAL = e->jbutton.which;
2464         OUTPUT:
2465                 RETVAL
2466
2467 Uint8
2468 JoyButtonEventButton ( e )
2469         SDL_Event *e
2470         CODE:
2471                 RETVAL = e->jbutton.button;
2472         OUTPUT:
2473                 RETVAL
2474
2475 Uint8
2476 JoyButtonEventState ( e )
2477         SDL_Event *e
2478         CODE:
2479                 RETVAL = e->jbutton.state;
2480         OUTPUT:
2481                 RETVAL
2482         
2483 Uint8
2484 JoyHatEventWhich ( e )
2485         SDL_Event *e
2486         CODE:
2487                 RETVAL = e->jhat.which;
2488         OUTPUT:
2489                 RETVAL
2490
2491 Uint8
2492 JoyHatEventHat ( e )
2493         SDL_Event *e
2494         CODE:
2495                 RETVAL = e->jhat.hat;
2496         OUTPUT:
2497                 RETVAL
2498
2499 Uint8
2500 JoyHatEventValue ( e )
2501         SDL_Event *e
2502         CODE:
2503                 RETVAL = e->jhat.value;
2504         OUTPUT:
2505                 RETVAL
2506
2507 Uint8
2508 JoyBallEventWhich ( e )
2509         SDL_Event *e
2510         CODE: 
2511                 RETVAL = e->jball.which;
2512         OUTPUT:
2513                 RETVAL
2514
2515 Uint8
2516 JoyBallEventBall ( e )
2517         SDL_Event *e
2518         CODE:
2519                 RETVAL = e->jball.ball;
2520         OUTPUT:
2521                 RETVAL
2522
2523 Sint16
2524 JoyBallEventXrel ( e )
2525         SDL_Event *e
2526         CODE:
2527                 RETVAL = e->jball.xrel;
2528         OUTPUT:
2529                 RETVAL
2530
2531 Sint16
2532 JoyBallEventYrel ( e )
2533         SDL_Event *e
2534         CODE:
2535                 RETVAL = e->jball.yrel;
2536         OUTPUT:
2537                 RETVAL
2538
2539 void
2540 SetClipRect ( surface, rect )
2541         SDL_Surface *surface
2542         SDL_Rect *rect
2543         CODE:
2544                 SDL_SetClipRect(surface,rect);
2545         
2546 SDL_Rect*
2547 GetClipRect ( surface )
2548         SDL_Surface *surface
2549         CODE:
2550                 RETVAL = (SDL_Rect*) safemalloc(sizeof(SDL_Rect));
2551                 SDL_GetClipRect(surface,RETVAL);
2552         OUTPUT:
2553                 RETVAL
2554
2555
2556 #ifdef HAVE_SDL_NET
2557
2558 int
2559 NetInit ()
2560         CODE:
2561                 RETVAL = SDLNet_Init();
2562         OUTPUT:
2563                 RETVAL
2564
2565 void
2566 NetQuit ()
2567         CODE:
2568                 SDLNet_Quit();
2569
2570 IPaddress*
2571 NetNewIPaddress ( host, port )
2572         Uint32 host
2573         Uint16 port
2574         CODE:
2575                 RETVAL = (IPaddress*) safemalloc(sizeof(IPaddress));
2576                 RETVAL->host = host;
2577                 RETVAL->port = port;
2578         OUTPUT:
2579                 RETVAL
2580
2581 Uint32
2582 NetIPaddressHost ( ip )
2583         IPaddress *ip
2584         CODE:
2585                 RETVAL = ip->host;
2586         OUTPUT:
2587                 RETVAL
2588
2589 Uint16
2590 NetIPaddressPort ( ip )
2591         IPaddress *ip
2592         CODE:
2593                 RETVAL = ip->port;
2594         OUTPUT:
2595                 RETVAL
2596
2597 void
2598 NetFreeIPaddress ( ip )
2599         IPaddress *ip
2600         CODE:
2601                 safefree(ip);
2602
2603 const char*
2604 NetResolveIP ( address )
2605         IPaddress *address
2606         CODE:
2607                 RETVAL = SDLNet_ResolveIP(address);
2608         OUTPUT:
2609                 RETVAL
2610
2611 int
2612 NetResolveHost ( address, host, port )
2613         IPaddress *address
2614         const char *host
2615         Uint16 port
2616         CODE:
2617                 RETVAL = SDLNet_ResolveHost(address,host,port);
2618         OUTPUT:
2619                 RETVAL
2620         
2621 TCPsocket
2622 NetTCPOpen ( ip )
2623         IPaddress *ip
2624         CODE:
2625                 RETVAL = SDLNet_TCP_Open(ip);
2626         OUTPUT:
2627                 RETVAL
2628
2629 TCPsocket
2630 NetTCPAccept ( server )
2631         TCPsocket server
2632         CODE:
2633                 RETVAL = SDLNet_TCP_Accept(server);
2634         OUTPUT:
2635                 RETVAL
2636
2637 IPaddress*
2638 NetTCPGetPeerAddress ( sock )
2639         TCPsocket sock
2640         CODE:
2641                 RETVAL = SDLNet_TCP_GetPeerAddress(sock);
2642         OUTPUT:
2643                 RETVAL
2644
2645 int
2646 NetTCPSend ( sock, data, len  )
2647         TCPsocket sock
2648         void *data
2649         int len
2650         CODE:
2651                 RETVAL = SDLNet_TCP_Send(sock,data,len);
2652         OUTPUT:
2653                 RETVAL
2654
2655 AV*
2656 NetTCPRecv ( sock, maxlen )
2657         TCPsocket sock
2658         int maxlen
2659         CODE:
2660                 int status;
2661                 void *buffer;
2662                 buffer = safemalloc(maxlen);
2663                 RETVAL = newAV();
2664                 status = SDLNet_TCP_Recv(sock,buffer,maxlen);
2665                 av_push(RETVAL,newSViv(status));
2666                 av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
2667         OUTPUT:
2668                 RETVAL  
2669         
2670 void
2671 NetTCPClose ( sock )
2672         TCPsocket sock
2673         CODE:
2674                 SDLNet_TCP_Close(sock);
2675
2676 UDPpacket*
2677 NetAllocPacket ( size )
2678         int size
2679         CODE:
2680                 RETVAL = SDLNet_AllocPacket(size);
2681         OUTPUT:
2682                 RETVAL
2683
2684 UDPpacket**
2685 NetAllocPacketV ( howmany, size )
2686         int howmany
2687         int size
2688         CODE:
2689                 RETVAL = SDLNet_AllocPacketV(howmany,size);
2690         OUTPUT:
2691                 RETVAL
2692
2693 int
2694 NetResizePacket ( packet, newsize )
2695         UDPpacket *packet
2696         int newsize
2697         CODE:
2698                 RETVAL = SDLNet_ResizePacket(packet,newsize);
2699         OUTPUT:
2700                 RETVAL
2701
2702 void
2703 NetFreePacket ( packet )
2704         UDPpacket *packet
2705         CODE:
2706                 SDLNet_FreePacket(packet);
2707
2708 void
2709 NetFreePacketV ( packet )
2710         UDPpacket **packet
2711         CODE:
2712                 SDLNet_FreePacketV(packet);
2713
2714 UDPsocket
2715 NetUDPOpen ( port )
2716         Uint16 port
2717         CODE:
2718                 RETVAL = SDLNet_UDP_Open(port);
2719         OUTPUT:
2720                 RETVAL
2721
2722 int
2723 NetUDPBind ( sock, channel, address )
2724         UDPsocket sock
2725         int channel
2726         IPaddress *address
2727         CODE:
2728                 RETVAL = SDLNet_UDP_Bind(sock,channel,address);
2729         OUTPUT:
2730                 RETVAL
2731
2732 void
2733 NetUDPUnbind ( sock, channel )
2734         UDPsocket sock
2735         int channel
2736         CODE:
2737                 SDLNet_UDP_Unbind(sock,channel);
2738
2739 IPaddress*
2740 NetUDPGetPeerAddress ( sock, channel )
2741         UDPsocket sock
2742         int channel
2743         CODE:
2744                 RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
2745         OUTPUT:
2746                 RETVAL
2747
2748 int
2749 NetUDPSendV ( sock, packets, npackets )
2750         UDPsocket sock
2751         UDPpacket **packets
2752         int npackets
2753         CODE:
2754                 RETVAL = SDLNet_UDP_SendV(sock,packets,npackets);
2755         OUTPUT:
2756                 RETVAL
2757
2758 int
2759 NetUDPSend ( sock, channel, packet )
2760         UDPsocket sock
2761         int channel
2762         UDPpacket *packet 
2763         CODE:
2764                 RETVAL = SDLNet_UDP_Send(sock,channel,packet);
2765         OUTPUT:
2766                 RETVAL
2767
2768 int
2769 NetUDPRecvV ( sock, packets )
2770         UDPsocket sock
2771         UDPpacket **packets
2772         CODE:
2773                 RETVAL = SDLNet_UDP_RecvV(sock,packets);
2774         OUTPUT:
2775                 RETVAL
2776
2777 int
2778 NetUDPRecv ( sock, packet )
2779         UDPsocket sock
2780         UDPpacket *packet
2781         CODE:
2782                 RETVAL = SDLNet_UDP_Recv(sock,packet);
2783         OUTPUT:
2784                 RETVAL
2785
2786 void
2787 NetUDPClose ( sock )
2788         UDPsocket sock
2789         CODE:
2790                 SDLNet_UDP_Close(sock);
2791
2792 SDLNet_SocketSet
2793 NetAllocSocketSet ( maxsockets )
2794         int maxsockets
2795         CODE:
2796                 RETVAL = SDLNet_AllocSocketSet(maxsockets);
2797         OUTPUT:
2798                 RETVAL
2799
2800 int
2801 NetTCP_AddSocket ( set, sock )
2802         SDLNet_SocketSet set
2803         TCPsocket sock
2804         CODE:
2805                 RETVAL = SDLNet_TCP_AddSocket(set,sock);
2806         OUTPUT:
2807                 RETVAL
2808
2809 int
2810 NetUDP_AddSocket ( set, sock )
2811         SDLNet_SocketSet set
2812         UDPsocket sock
2813         CODE:
2814                 RETVAL = SDLNet_UDP_AddSocket(set,sock);
2815         OUTPUT:
2816                 RETVAL
2817
2818 int
2819 NetTCP_DelSocket ( set, sock )
2820         SDLNet_SocketSet set
2821         TCPsocket sock
2822         CODE:
2823                 RETVAL = SDLNet_TCP_DelSocket(set,sock);
2824         OUTPUT:
2825                 RETVAL
2826
2827 int
2828 NetUDP_DelSocket ( set, sock )
2829         SDLNet_SocketSet set
2830         UDPsocket sock
2831         CODE:
2832                 RETVAL = SDLNet_UDP_DelSocket(set,sock);
2833         OUTPUT:
2834                 RETVAL
2835
2836 int
2837 NetCheckSockets ( set, timeout )
2838         SDLNet_SocketSet set
2839         Uint32 timeout
2840         CODE:
2841                 RETVAL = SDLNet_CheckSockets(set,timeout);
2842         OUTPUT:
2843                 RETVAL
2844
2845 int
2846 NetSocketReady ( sock )
2847         SDLNet_GenericSocket sock
2848         CODE:
2849                 RETVAL = SDLNet_SocketReady(sock);
2850         OUTPUT:
2851                 RETVAL
2852
2853 void
2854 NetFreeSocketSet ( set )
2855         SDLNet_SocketSet set
2856         CODE:
2857                 SDLNet_FreeSocketSet(set);
2858
2859 void
2860 NetWrite16 ( value, area )
2861         Uint16 value
2862         void *area
2863         CODE:
2864                 SDLNet_Write16(value,area);
2865
2866 void
2867 NetWrite32 ( value, area )
2868         Uint32 value
2869         void *area
2870         CODE:
2871                 SDLNet_Write32(value,area);
2872         
2873 Uint16
2874 NetRead16 ( area )
2875         void *area
2876         CODE:
2877                 RETVAL = SDLNet_Read16(area);
2878         OUTPUT:
2879                 RETVAL
2880
2881 Uint32
2882 NetRead32 ( area )
2883         void *area
2884         CODE:
2885                 RETVAL = SDLNet_Read32(area);
2886         OUTPUT:
2887                 RETVAL
2888
2889 #endif 
2890
2891 #ifdef HAVE_SDL_TTF
2892
2893 int
2894 TTFInit ()
2895         CODE:
2896                 RETVAL = TTF_Init();
2897         OUTPUT:
2898                 RETVAL
2899
2900 void
2901 TTFQuit ()
2902         CODE:
2903                 TTF_Quit();
2904
2905 TTF_Font*
2906 TTFOpenFont ( file, ptsize )
2907         char *file
2908         int ptsize
2909         CODE:
2910                 RETVAL = TTF_OpenFont(file,ptsize);
2911         OUTPUT:
2912                 RETVAL
2913
2914 int
2915 TTFGetFontStyle ( font )
2916         TTF_Font *font
2917         CODE:
2918                 RETVAL = TTF_GetFontStyle(font);
2919         OUTPUT:
2920                 RETVAL
2921
2922 void
2923 TTFSetFontStyle ( font, style )
2924         TTF_Font *font
2925         int style
2926         CODE:
2927                 TTF_SetFontStyle(font,style);
2928         
2929 int
2930 TTFFontHeight ( font )
2931         TTF_Font *font
2932         CODE:
2933                 RETVAL = TTF_FontHeight(font);
2934         OUTPUT:
2935                 RETVAL
2936
2937 int
2938 TTFFontAscent ( font )
2939         TTF_Font *font
2940         CODE:
2941                 RETVAL = TTF_FontAscent(font);
2942         OUTPUT:
2943                 RETVAL
2944
2945 int
2946 TTFFontDescent ( font )
2947         TTF_Font *font
2948         CODE:
2949                 RETVAL = TTF_FontDescent(font);
2950         OUTPUT:
2951                 RETVAL
2952
2953 int
2954 TTFFontLineSkip ( font )
2955         TTF_Font *font
2956         CODE:
2957                 RETVAL = TTF_FontLineSkip(font);
2958         OUTPUT:
2959                 RETVAL
2960
2961 AV*
2962 TTFGlyphMetrics ( font, ch )
2963         TTF_Font *font
2964         Uint16 ch
2965         CODE:
2966                 int minx, miny, maxx, maxy, advance;
2967                 RETVAL = newAV();
2968                 TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance);
2969                 av_push(RETVAL,newSViv(minx));
2970                 av_push(RETVAL,newSViv(miny));
2971                 av_push(RETVAL,newSViv(maxx));
2972                 av_push(RETVAL,newSViv(maxy));
2973                 av_push(RETVAL,newSViv(advance));
2974         OUTPUT:
2975                 RETVAL
2976
2977 AV*
2978 TTFSizeText ( font, text )
2979         TTF_Font *font
2980         char *text
2981         CODE:
2982                 int w,h;
2983                 RETVAL = newAV();
2984                 if(TTF_SizeText(font,text,&w,&h))
2985                 {
2986                         av_push(RETVAL,newSViv(w));
2987                         av_push(RETVAL,newSViv(h));
2988                         sv_2mortal((SV*)RETVAL);
2989                 }
2990                 else
2991                 {
2992                          printf("TTF error at TTFSizeText: %s \n", TTF_GetError()); 
2993                          Perl_croak (aTHX_ "TTF error \n");     
2994         
2995                 }
2996                 
2997         
2998         OUTPUT:
2999                 RETVAL
3000
3001 AV*
3002 TTFSizeUTF8 ( font, text )
3003         TTF_Font *font
3004         char *text
3005         CODE:
3006                 int w,h;
3007                 RETVAL = newAV();
3008                 if(TTF_SizeUTF8(font,text,&w,&h))
3009                 {
3010                         av_push(RETVAL,newSViv(w));
3011                         av_push(RETVAL,newSViv(h));
3012                         sv_2mortal((SV*)RETVAL);
3013
3014                 }
3015                 else
3016                 {
3017                         printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError());
3018                         Perl_croak (aTHX_ "TTF error \n");
3019                 }
3020                 
3021         OUTPUT:
3022                 RETVAL
3023
3024 AV*
3025 TTFSizeUNICODE ( font, text )
3026         TTF_Font *font
3027         const Uint16 *text
3028         CODE:
3029                 int w,h;
3030                 RETVAL = newAV();
3031                 if(TTF_SizeUNICODE(font,text,&w,&h))
3032                 {
3033                         av_push(RETVAL,newSViv(w));
3034                         av_push(RETVAL,newSViv(h));
3035                         sv_2mortal((SV*)RETVAL);
3036
3037                 }
3038                 else
3039                 {
3040                         printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); 
3041                         Perl_croak (aTHX_ "TTF error \n");
3042                 }
3043
3044         OUTPUT:
3045                 RETVAL
3046
3047 SDL_Surface*
3048 TTFRenderTextSolid ( font, text, fg )
3049         TTF_Font *font
3050         char *text
3051         SDL_Color *fg
3052         CODE:
3053                 RETVAL = TTF_RenderText_Solid(font,text,*fg);
3054         OUTPUT:
3055                 RETVAL
3056
3057 SDL_Surface*
3058 TTFRenderUTF8Solid ( font, text, fg )
3059         TTF_Font *font
3060         char *text
3061         SDL_Color *fg
3062         CODE:
3063                 RETVAL = TTF_RenderUTF8_Solid(font,text,*fg);
3064         OUTPUT:
3065                 RETVAL
3066
3067 SDL_Surface*
3068 TTFRenderUNICODESolid ( font, text, fg )
3069         TTF_Font *font
3070         const Uint16 *text
3071         SDL_Color *fg
3072         CODE:
3073                 RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg);
3074         OUTPUT:
3075                 RETVAL
3076
3077 SDL_Surface*
3078 TTFRenderGlyphSolid ( font, ch, fg )
3079         TTF_Font *font
3080         Uint16 ch
3081         SDL_Color *fg
3082         CODE:
3083                 RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg);
3084         OUTPUT:
3085                 RETVAL
3086
3087 SDL_Surface*
3088 TTFRenderTextShaded ( font, text, fg, bg )
3089         TTF_Font *font
3090         char *text
3091         SDL_Color *fg
3092         SDL_Color *bg
3093         CODE:
3094                 RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg);
3095         OUTPUT:
3096                 RETVAL
3097
3098 SDL_Surface*
3099 TTFRenderUTF8Shaded( font, text, fg, bg )
3100         TTF_Font *font
3101         char *text
3102         SDL_Color *fg
3103         SDL_Color *bg
3104         CODE:
3105                 RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3106         OUTPUT:
3107                 RETVAL
3108
3109 SDL_Surface*
3110 TTFRenderUNICODEShaded( font, text, fg, bg )
3111         TTF_Font *font
3112         const Uint16 *text
3113         SDL_Color *fg
3114         SDL_Color *bg
3115         CODE:
3116                 RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg);
3117         OUTPUT:
3118                 RETVAL
3119
3120 SDL_Surface*
3121 TTFRenderGlyphShaded ( font, ch, fg, bg )
3122         TTF_Font *font
3123         Uint16 ch
3124         SDL_Color *fg
3125         SDL_Color *bg
3126         CODE:
3127                 RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg);
3128         OUTPUT:
3129                 RETVAL
3130
3131 SDL_Surface*
3132 TTFRenderTextBlended( font, text, fg )
3133         TTF_Font *font
3134         char *text
3135         SDL_Color *fg
3136         CODE:
3137                 RETVAL = TTF_RenderText_Blended(font,text,*fg);
3138         OUTPUT:
3139                 RETVAL
3140
3141 SDL_Surface*
3142 TTFRenderUTF8Blended( font, text, fg )
3143         TTF_Font *font
3144         char *text
3145         SDL_Color *fg
3146         CODE:
3147                 RETVAL = TTF_RenderUTF8_Blended(font,text,*fg);
3148         OUTPUT:
3149                 RETVAL
3150
3151 SDL_Surface*
3152 TTFRenderUNICODEBlended( font, text, fg )
3153         TTF_Font *font
3154         const Uint16 *text
3155         SDL_Color *fg
3156         CODE:
3157                 RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg);
3158         OUTPUT:
3159                 RETVAL
3160
3161 SDL_Surface*
3162 TTFRenderGlyphBlended( font, ch, fg )
3163         TTF_Font *font
3164         Uint16 ch
3165         SDL_Color *fg
3166         CODE:
3167                 RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg);
3168         OUTPUT:
3169                 RETVAL
3170
3171 void
3172 TTFCloseFont ( font )
3173         TTF_Font *font
3174         CODE:
3175                 TTF_CloseFont(font);
3176                 font=NULL; //to be safe http://sdl.beuc.net/sdl.wiki/SDL_ttf_copy_Functions_Management_TTF_CloseFont
3177
3178 SDL_Surface*
3179 TTFPutString ( font, mode, surface, x, y, fg, bg, text )
3180         TTF_Font *font
3181         int mode
3182         SDL_Surface *surface
3183         int x
3184         int y
3185         SDL_Color *fg
3186         SDL_Color *bg
3187         char *text
3188         CODE:
3189                 SDL_Surface *img;
3190                 SDL_Rect dest;
3191                 int w,h;
3192                 dest.x = x;
3193                 dest.y = y;
3194                 RETVAL = NULL;
3195                 switch (mode) {
3196                         case TEXT_SOLID:
3197                                 img = TTF_RenderText_Solid(font,text,*fg);
3198                                 TTF_SizeText(font,text,&w,&h);
3199                                 dest.w = w;
3200                                 dest.h = h;
3201                                 break;
3202                         case TEXT_SHADED:
3203                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3204                                 TTF_SizeText(font,text,&w,&h);
3205                                 dest.w = w;
3206                                 dest.h = h;
3207                                 break;
3208                         case TEXT_BLENDED:
3209                                 img = TTF_RenderText_Blended(font,text,*fg);
3210                                 TTF_SizeText(font,text,&w,&h);
3211                                 dest.w = w;
3212                                 dest.h = h;
3213                                 break;
3214                         case UTF8_SOLID:
3215                                 img = TTF_RenderUTF8_Solid(font,text,*fg);
3216                                 TTF_SizeUTF8(font,text,&w,&h);
3217                                 dest.w = w;
3218                                 dest.h = h;
3219                                 break;
3220                         case UTF8_SHADED:
3221                                 img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3222                                 TTF_SizeUTF8(font,text,&w,&h);
3223                                 dest.w = w;
3224                                 dest.h = h;
3225                                 break;
3226                         case UTF8_BLENDED:
3227                                 img = TTF_RenderUTF8_Blended(font,text,*fg);
3228                                 TTF_SizeUTF8(font,text,&w,&h);
3229                                 dest.w = w;
3230                                 dest.h = h;
3231                                 break;
3232                         case UNICODE_SOLID:
3233                                 img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg);
3234                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3235                                 dest.w = w;
3236                                 dest.h = h;
3237                                 break;
3238                         case UNICODE_SHADED:
3239                                 img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg);
3240                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3241                                 dest.w = w;
3242                                 dest.h = h;
3243                                 break;
3244                         case UNICODE_BLENDED:
3245                                 img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg);
3246                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3247                                 dest.w = w;
3248                                 dest.h = h;
3249                                 break;
3250                         default:
3251                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3252                                 TTF_SizeText(font,text,&w,&h);
3253                                 dest.w = w;
3254                                 dest.h = h;
3255                 }
3256                 if ( img && img->format && img->format->palette ) {
3257                         SDL_Color *c = &img->format->palette->colors[0];
3258                         Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
3259                         SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
3260                         if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
3261                                 SDL_FreeSurface(img);
3262                                 RETVAL = NULL;  
3263                         } else {
3264                                 RETVAL = img;
3265                         }
3266                 }
3267         OUTPUT:
3268                 RETVAL
3269
3270 #endif
3271
3272 SDL_Overlay*
3273 CreateYUVOverlay ( width, height, format, display )
3274         int width
3275         int height
3276         Uint32 format
3277         SDL_Surface *display
3278         CODE:
3279                 RETVAL = SDL_CreateYUVOverlay ( width, height, format, display );
3280         OUTPUT:
3281                 RETVAL
3282
3283 int
3284 LockYUVOverlay ( overlay )
3285         SDL_Overlay *overlay
3286         CODE:
3287                 RETVAL = SDL_LockYUVOverlay(overlay);
3288         OUTPUT:
3289                 RETVAL
3290
3291 void
3292 UnlockYUVOverlay ( overlay )
3293         SDL_Overlay *overlay
3294         CODE:
3295                 SDL_UnlockYUVOverlay(overlay);
3296
3297 int
3298 DisplayYUVOverlay ( overlay, dstrect )
3299         SDL_Overlay *overlay
3300         SDL_Rect *dstrect
3301         CODE:
3302                 RETVAL = SDL_DisplayYUVOverlay ( overlay, dstrect );
3303         OUTPUT:
3304                 RETVAL
3305
3306 void
3307 FreeYUVOverlay ( overlay )
3308         SDL_Overlay *overlay
3309         CODE:
3310                 SDL_FreeYUVOverlay ( overlay );
3311
3312 Uint32
3313 OverlayFormat ( overlay, ... )
3314         SDL_Overlay *overlay
3315         CODE:
3316                 if ( items > 1 ) 
3317                         overlay->format = SvIV(ST(1));
3318                 RETVAL = overlay->format;
3319         OUTPUT:
3320                 RETVAL
3321
3322 int 
3323 OverlayW ( overlay, ... )
3324         SDL_Overlay *overlay
3325         CODE:
3326                 if ( items > 1 ) 
3327                         overlay->w = SvIV(ST(1));
3328                 RETVAL = overlay->w;
3329         OUTPUT:
3330                 RETVAL
3331
3332 int
3333 OverlayH ( overlay, ... )
3334         SDL_Overlay *overlay
3335         CODE:
3336                 if ( items > 1 )
3337                         overlay->h = SvIV(ST(1));
3338                 RETVAL = overlay->h;
3339         OUTPUT:
3340                 RETVAL 
3341
3342 int
3343 OverlayPlanes ( overlay, ... )
3344         SDL_Overlay *overlay
3345         CODE:
3346                 if ( items > 1 )
3347                         overlay->planes = SvIV(ST(1));
3348                 RETVAL = overlay->planes;
3349         OUTPUT:
3350                 RETVAL
3351
3352 Uint32
3353 OverlayHW ( overlay )
3354         SDL_Overlay *overlay
3355         CODE:
3356                 RETVAL = overlay->hw_overlay;
3357         OUTPUT:
3358                 RETVAL
3359
3360 Uint16*
3361 OverlayPitches ( overlay )
3362         SDL_Overlay *overlay
3363         CODE:
3364                 RETVAL = overlay->pitches;
3365         OUTPUT:
3366                 RETVAL
3367
3368 Uint8**
3369 OverlayPixels ( overlay )
3370         SDL_Overlay *overlay
3371         CODE:
3372                 RETVAL = overlay->pixels;
3373         OUTPUT:
3374                 RETVAL
3375
3376 int
3377 WMToggleFullScreen ( surface )
3378         SDL_Surface *surface
3379         CODE:
3380                 RETVAL = SDL_WM_ToggleFullScreen(surface);
3381         OUTPUT:
3382                 RETVAL
3383
3384 Uint32
3385 WMGrabInput ( mode )
3386         Uint32 mode
3387         CODE:
3388                 RETVAL = SDL_WM_GrabInput(mode);
3389         OUTPUT:
3390                 RETVAL
3391
3392 int
3393 WMIconifyWindow ()
3394         CODE:
3395                 RETVAL = SDL_WM_IconifyWindow();
3396         OUTPUT:
3397                 RETVAL
3398
3399 int
3400 ResizeEventW ( e )
3401         SDL_Event *e
3402         CODE:
3403                 RETVAL = e->resize.w;
3404         OUTPUT:
3405                 RETVAL
3406
3407 int
3408 ResizeEventH ( e )
3409         SDL_Event *e
3410         CODE:
3411                 RETVAL = e->resize.h;
3412         OUTPUT:
3413                 RETVAL
3414
3415 char*
3416 AudioDriverName ()
3417         CODE:
3418                 char name[32];
3419                 RETVAL = SDL_AudioDriverName(name,32);
3420         OUTPUT:
3421                 RETVAL
3422
3423 Uint32
3424 GetKeyState ( k )
3425         SDLKey k
3426         CODE:
3427                 if (k >= SDLK_LAST) Perl_croak (aTHX_ "Key out of range");      
3428                 RETVAL = SDL_GetKeyState(NULL)[k];
3429         OUTPUT:
3430                 RETVAL
3431
3432 #ifdef HAVE_SMPEG
3433
3434 SMPEG_Info *
3435 NewSMPEGInfo()
3436         CODE:   
3437                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3438         OUTPUT:
3439                 RETVAL
3440
3441 void
3442 FreeSMPEGInfo ( info )
3443         SMPEG_Info *info
3444         CODE:   
3445                 safefree(info);
3446
3447 int
3448 SMPEGInfoHasAudio ( info )
3449         SMPEG_Info* info
3450         CODE:
3451                 RETVAL = info->has_audio;
3452         OUTPUT:
3453                 RETVAL
3454
3455 int
3456 SMPEGInfoHasVideo ( info )
3457         SMPEG_Info* info
3458         CODE:
3459                 RETVAL = info->has_video;
3460         OUTPUT:
3461                 RETVAL
3462
3463 int
3464 SMPEGInfoWidth ( info )
3465         SMPEG_Info* info
3466         CODE:
3467                 RETVAL = info->width;
3468         OUTPUT:
3469                 RETVAL
3470
3471 int
3472 SMPEGInfoHeight ( info )
3473         SMPEG_Info* info
3474         CODE:
3475                 RETVAL = info->height;
3476         OUTPUT:
3477                 RETVAL
3478
3479 int
3480 SMPEGInfoCurrentFrame ( info )
3481         SMPEG_Info* info
3482         CODE:
3483                 RETVAL = info->current_frame;
3484         OUTPUT:
3485                 RETVAL
3486
3487 double
3488 SMPEGInfoCurrentFPS ( info )
3489         SMPEG_Info* info
3490         CODE:
3491                 RETVAL = info->current_fps;
3492         OUTPUT:
3493                 RETVAL
3494
3495 int
3496 SMPEGInfoCurrentAudioFrame ( info )
3497         SMPEG_Info* info
3498         CODE:
3499                 RETVAL = info->audio_current_frame;
3500         OUTPUT:
3501                 RETVAL
3502
3503 int
3504 SMPEGInfoCurrentOffset ( info )
3505         SMPEG_Info* info
3506         CODE:
3507                 RETVAL = info->current_offset;
3508         OUTPUT:
3509                 RETVAL
3510
3511 int
3512 SMPEGInfoTotalSize ( info )
3513         SMPEG_Info* info
3514         CODE:
3515                 RETVAL = info->total_size;
3516         OUTPUT:
3517                 RETVAL
3518
3519 double
3520 SMPEGInfoCurrentTime ( info )
3521         SMPEG_Info* info
3522         CODE:
3523                 RETVAL = info->current_time;
3524         OUTPUT:
3525                 RETVAL
3526
3527 double
3528 SMPEGInfoTotalTime ( info )
3529         SMPEG_Info* info
3530         CODE:
3531                 RETVAL = info->total_time;
3532         OUTPUT:
3533                 RETVAL
3534
3535 char *
3536 SMPEGError ( mpeg )
3537         SMPEG* mpeg
3538         CODE:   
3539                 RETVAL = SMPEG_error(mpeg);
3540         OUTPUT:
3541                 RETVAL
3542
3543 SMPEG*
3544 NewSMPEG ( filename, info, use_audio )
3545         char* filename
3546         SMPEG_Info* info
3547         int use_audio
3548         CODE:   
3549 #ifdef HAVE_SDL_MIXER
3550                 RETVAL = SMPEG_new(filename,info,0);
3551 #else
3552                 RETVAL = SMPEG_new(filename,info,use_audio);
3553 #endif
3554         OUTPUT:
3555                 RETVAL
3556
3557 void
3558 FreeSMPEG ( mpeg )
3559         SMPEG* mpeg
3560         CODE:
3561                 SMPEG_delete(mpeg);
3562
3563 void
3564 SMPEGEnableAudio ( mpeg , flag )
3565         SMPEG* mpeg
3566         int flag
3567         CODE:   
3568                 SMPEG_enableaudio(mpeg,flag);
3569 #ifdef HAVE_SDL_MIXER
3570                 sdl_perl_use_smpeg_audio = flag;
3571 #endif
3572
3573 void
3574 SMPEGEnableVideo ( mpeg , flag )
3575         SMPEG* mpeg
3576         int flag
3577         CODE:   
3578                 SMPEG_enablevideo(mpeg,flag);
3579
3580 void
3581 SMPEGSetVolume ( mpeg , volume )
3582         SMPEG* mpeg
3583         int volume
3584         CODE:   
3585                 SMPEG_setvolume(mpeg,volume);
3586
3587 void
3588 SMPEGSetDisplay ( mpeg, dest, surfLock )
3589         SMPEG* mpeg
3590         SDL_Surface* dest
3591         SDL_mutex*  surfLock
3592         CODE:
3593                 SMPEG_setdisplay(mpeg,dest,surfLock,NULL);
3594
3595 void
3596 SMPEGScaleXY ( mpeg, w, h)
3597         SMPEG* mpeg
3598         int w
3599         int h
3600         CODE:
3601                 SMPEG_scaleXY(mpeg,w,h);
3602
3603 void
3604 SMPEGScale ( mpeg, scale )
3605         SMPEG* mpeg
3606         int scale
3607         CODE:
3608                 SMPEG_scale(mpeg,scale);
3609
3610 void
3611 SMPEGPlay ( mpeg )
3612         SMPEG* mpeg
3613         CODE:
3614                 SDL_AudioSpec audiofmt;
3615                 Uint16 format;
3616                 int freq, channels;
3617 #ifdef HAVE_SDL_MIXER
3618                 if  (sdl_perl_use_smpeg_audio ) {
3619                         SMPEG_enableaudio(mpeg, 0);
3620                         Mix_QuerySpec(&freq, &format, &channels);
3621                         audiofmt.format = format;
3622                         audiofmt.freq = freq;
3623                         audiofmt.channels = channels;
3624                         SMPEG_actualSpec(mpeg, &audiofmt);
3625                         Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
3626                         SMPEG_enableaudio(mpeg, 1);
3627                 }
3628 #endif
3629                 SMPEG_play(mpeg);
3630
3631 SMPEGstatus
3632 SMPEGStatus ( mpeg )
3633         SMPEG* mpeg
3634         CODE:
3635                 RETVAL = SMPEG_status(mpeg);
3636         OUTPUT:
3637                 RETVAL
3638
3639 void
3640 SMPEGPause ( mpeg )
3641         SMPEG* mpeg
3642         CODE:
3643                 SMPEG_pause(mpeg);
3644
3645 void
3646 SMPEGLoop ( mpeg, repeat )
3647         SMPEG* mpeg
3648         int repeat
3649         CODE:
3650                 SMPEG_loop(mpeg,repeat);
3651
3652 void
3653 SMPEGStop ( mpeg )
3654         SMPEG* mpeg
3655         CODE:
3656                 SMPEG_stop(mpeg);
3657 #ifdef HAVE_SDL_MIXER
3658                 Mix_HookMusic(NULL, NULL);
3659 #endif
3660
3661 void
3662 SMPEGRewind ( mpeg )
3663         SMPEG* mpeg
3664         CODE:
3665                 SMPEG_rewind(mpeg);
3666
3667 void
3668 SMPEGSeek ( mpeg, bytes )
3669         SMPEG* mpeg
3670         int bytes
3671         CODE:
3672                 SMPEG_seek(mpeg,bytes);
3673
3674 void
3675 SMPEGSkip ( mpeg, seconds )
3676         SMPEG* mpeg
3677         float seconds
3678         CODE:
3679                 SMPEG_skip(mpeg,seconds);
3680
3681 void
3682 SMPEGSetDisplayRegion ( mpeg, rect )
3683         SMPEG* mpeg
3684         SDL_Rect* rect
3685         CODE:
3686                 SMPEG_setdisplayregion(mpeg,rect->x,rect->y,rect->w,rect->h);
3687
3688 void
3689 SMPEGRenderFrame ( mpeg, frame )
3690         SMPEG* mpeg
3691         int frame
3692         CODE:
3693                 SMPEG_renderFrame(mpeg,frame);
3694
3695 SMPEG_Info *
3696 SMPEGGetInfo ( mpeg )
3697         SMPEG* mpeg
3698         CODE:
3699                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3700                 SMPEG_getinfo(mpeg,RETVAL);
3701         OUTPUT:
3702                 RETVAL
3703         
3704
3705 #endif
3706
3707 #ifdef HAVE_SDL_GFX
3708
3709 SDL_Surface *
3710 GFXRotoZoom ( src, angle, zoom, smooth)
3711         SDL_Surface * src
3712         double angle
3713         double zoom
3714         int smooth
3715         CODE:
3716                 RETVAL = rotozoomSurface( src, angle, zoom, smooth);
3717         OUTPUT:
3718                 RETVAL
3719
3720 SDL_Surface *
3721 GFXZoom ( src, zoomx, zoomy, smooth)
3722         SDL_Surface *src
3723         double zoomx
3724         double zoomy
3725         int smooth
3726         CODE:
3727                 RETVAL = zoomSurface( src, zoomx, zoomy, smooth);
3728         OUTPUT:
3729                 RETVAL
3730
3731 int
3732 GFXPixelColor ( dst, x, y, color )
3733         SDL_Surface* dst
3734         Sint16 x
3735         Sint16 y
3736         Uint32 color
3737         CODE:
3738                 RETVAL = pixelColor( dst, x, y, color);
3739         OUTPUT:
3740                 RETVAL
3741
3742 int
3743 GFXPixelRGBA ( dst, x, y, r, g, b, a )
3744         SDL_Surface* dst
3745         Sint16 x
3746         Sint16 y
3747         Uint8 r
3748         Uint8 g
3749         Uint8 b
3750         Uint8 a
3751         CODE:
3752                 RETVAL = pixelRGBA( dst, x, y, r, g, b, a );
3753         OUTPUT:
3754                 RETVAL
3755
3756 int
3757 GFXHlineColor ( dst, x1, x2, y, color )
3758         SDL_Surface* dst
3759         Sint16 x1
3760         Sint16 x2
3761         Sint16 y
3762         Uint32 color
3763         CODE:
3764                 RETVAL = hlineColor( dst, x1, x2, y, color );
3765         OUTPUT:
3766                 RETVAL
3767
3768 int
3769 GFXHlineRGBA ( dst, x1, x2, y, r, g, b, a )
3770         SDL_Surface* dst
3771         Sint16 x1
3772         Sint16 x2
3773         Sint16 y
3774         Uint8 r
3775         Uint8 g
3776         Uint8 b
3777         Uint8 a
3778         CODE:
3779                 RETVAL = hlineRGBA( dst, x1, x2, y, r, g, b, a );
3780         OUTPUT:
3781                 RETVAL
3782
3783 int
3784 GFXVlineColor ( dst, x, y1, y2, color )
3785         SDL_Surface* dst
3786         Sint16 x
3787         Sint16 y1
3788         Sint16 y2
3789         Uint32 color
3790         CODE:
3791                 RETVAL = vlineColor( dst, x, y1, y2, color );
3792         OUTPUT:
3793                 RETVAL
3794
3795 int
3796 GFXVlineRGBA ( dst, x, y1, y2, r, g, b, a )
3797         SDL_Surface* dst
3798         Sint16 x
3799         Sint16 y1
3800         Sint16 y2
3801         Uint8 r
3802         Uint8 g
3803         Uint8 b
3804         Uint8 a
3805         CODE:
3806                 RETVAL = vlineRGBA( dst, x, y1, y2, r, g, b, a );
3807         OUTPUT:
3808                 RETVAL
3809
3810 int
3811 GFXRectangleColor ( dst, x1, y1, x2, y2, color )
3812         SDL_Surface* dst
3813         Sint16 x1
3814         Sint16 y1
3815         Sint16 x2
3816         Sint16 y2
3817         Uint32 color
3818         CODE:
3819                 RETVAL = rectangleColor( dst, x1, y1, x2, y2, color );
3820         OUTPUT:
3821                 RETVAL
3822
3823 int
3824 GFXRectangleRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3825         SDL_Surface* dst
3826         Sint16 x1
3827         Sint16 y1
3828         Sint16 x2
3829         Sint16 y2
3830         Uint8 r
3831         Uint8 g
3832         Uint8 b
3833         Uint8 a
3834         CODE:
3835                 RETVAL = rectangleRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3836         OUTPUT:
3837                 RETVAL
3838
3839 int
3840 GFXBoxColor ( dst, x1, y1, x2, y2, color )
3841         SDL_Surface* dst
3842         Sint16 x1
3843         Sint16 y1
3844         Sint16 x2
3845         Sint16 y2
3846         Uint32 color
3847         CODE:
3848                 RETVAL = boxColor( dst, x1, y1, x2, y2, color );
3849         OUTPUT:
3850                 RETVAL
3851
3852 int
3853 GFXBoxRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3854         SDL_Surface* dst;
3855         Sint16 x1
3856         Sint16 y1
3857         Sint16 x2
3858         Sint16 y2
3859         Uint8 r
3860         Uint8 g
3861         Uint8 b
3862         Uint8 a
3863         CODE:
3864                 RETVAL = boxRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3865         OUTPUT:
3866                 RETVAL
3867
3868 int
3869 GFXLineColor ( dst, x1, y1, x2, y2, color )
3870         SDL_Surface* dst
3871         Sint16 x1
3872         Sint16 y1
3873         Sint16 x2
3874         Sint16 y2
3875         Uint32 color
3876         CODE:
3877                 RETVAL = lineColor( dst, x1, y1, x2, y2, color );
3878         OUTPUT:
3879                 RETVAL
3880
3881 int
3882 GFXLineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3883         SDL_Surface* dst
3884         Sint16 x1
3885         Sint16 y1
3886         Sint16 x2
3887         Sint16 y2
3888         Uint8 r
3889         Uint8 g
3890         Uint8 b
3891         Uint8 a
3892         CODE:
3893                 RETVAL = lineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3894         OUTPUT:
3895                 RETVAL
3896
3897 int
3898 GFXAalineColor ( dst, x1, y1, x2, y2, color )
3899         SDL_Surface* dst
3900         Sint16 x1
3901         Sint16 y1
3902         Sint16 x2
3903         Sint16 y2
3904         Uint32 color
3905         CODE:
3906                 RETVAL = aalineColor( dst, x1, y1, x2, y2, color );
3907         OUTPUT:
3908                 RETVAL
3909
3910 int
3911 GFXAalineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3912         SDL_Surface* dst
3913         Sint16 x1
3914         Sint16 y1
3915         Sint16 x2
3916         Sint16 y2
3917         Uint8 r
3918         Uint8 g
3919         Uint8 b
3920         Uint8 a
3921         CODE:
3922                 RETVAL = aalineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3923         OUTPUT:
3924                 RETVAL
3925
3926 int
3927 GFXCircleColor ( 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 = circleColor( dst, x, y, r, color );
3935         OUTPUT:
3936                 RETVAL
3937
3938 int
3939 GFXCircleRGBA ( 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 = circleRGBA( dst, x, y, rad, r, g, b, a );
3950         OUTPUT:
3951                 RETVAL
3952
3953 int
3954 GFXAacircleColor ( dst, x, y, r, color )
3955         SDL_Surface* dst
3956         Sint16 x
3957         Sint16 y
3958         Sint16 r
3959         Uint32 color
3960         CODE:
3961                 RETVAL = aacircleColor( dst, x, y, r, color );
3962         OUTPUT:
3963                 RETVAL
3964
3965 int
3966 GFXAacircleRGBA ( dst, x, y, rad, r, g, b, a )
3967         SDL_Surface* dst
3968         Sint16 x
3969         Sint16 y
3970         Sint16 rad
3971         Uint8 r
3972         Uint8 g
3973         Uint8 b
3974         Uint8 a
3975         CODE:
3976                 RETVAL = aacircleRGBA( dst, x, y, rad, r, g, b, a );
3977         OUTPUT:
3978                 RETVAL
3979
3980 int
3981 GFXFilledCircleColor ( dst, x, y, r, color )
3982         SDL_Surface* dst
3983         Sint16 x
3984         Sint16 y
3985         Sint16 r
3986         Uint32 color
3987         CODE:
3988                 RETVAL = filledCircleColor( dst, x, y, r, color );
3989         OUTPUT:
3990                 RETVAL
3991
3992 int
3993 GFXFilledCircleRGBA ( dst, x, y, rad, r, g, b, a )
3994         SDL_Surface* dst
3995         Sint16 x
3996         Sint16 y
3997         Sint16 rad
3998         Uint8 r
3999         Uint8 g
4000         Uint8 b
4001         Uint8 a
4002         CODE:
4003                 RETVAL = filledCircleRGBA( dst, x, y, rad, r, g, b, a );
4004         OUTPUT:
4005                 RETVAL
4006
4007 int
4008 GFXEllipseColor ( dst, x, y, rx, ry, color )
4009         SDL_Surface* dst
4010         Sint16 x
4011         Sint16 y
4012         Sint16 rx
4013         Sint16 ry
4014         Uint32 color
4015         CODE:
4016                 RETVAL = ellipseColor( dst, x, y, rx, ry, color );
4017         OUTPUT:
4018                 RETVAL
4019
4020 int
4021 GFXEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4022         SDL_Surface* dst
4023         Sint16 x
4024         Sint16 y
4025         Sint16  rx
4026         Sint16 ry
4027         Uint8 r
4028         Uint8 g
4029         Uint8 b
4030         Uint8 a
4031         CODE:
4032                 RETVAL = ellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4033         OUTPUT:
4034                 RETVAL
4035
4036 int
4037 GFXAaellipseColor ( dst, xc, yc, rx, ry, color )
4038         SDL_Surface* dst
4039         Sint16 xc
4040         Sint16 yc
4041         Sint16 rx
4042         Sint16 ry
4043         Uint32 color
4044         CODE:
4045                 RETVAL = aaellipseColor( dst, xc, yc, rx, ry, color );
4046         OUTPUT:
4047                 RETVAL
4048
4049 int
4050 GFXAaellipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4051         SDL_Surface* dst
4052         Sint16 x
4053         Sint16 y
4054         Sint16 rx
4055         Sint16 ry
4056         Uint8 r
4057         Uint8 g
4058         Uint8 b
4059         Uint8 a
4060         CODE:
4061                 RETVAL = aaellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4062         OUTPUT:
4063                 RETVAL
4064
4065 int
4066 GFXFilledEllipseColor ( dst, x, y, rx, ry, color )
4067         SDL_Surface* dst
4068         Sint16 x
4069         Sint16 y
4070         Sint16 rx
4071         Sint16 ry
4072         Uint32 color
4073         CODE:
4074                 RETVAL = filledEllipseColor( dst, x, y, rx, ry, color );
4075         OUTPUT:
4076                 RETVAL
4077
4078 int
4079 GFXFilledEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4080         SDL_Surface* dst
4081         Sint16 x
4082         Sint16 y
4083         Sint16 rx
4084         Sint16 ry
4085         Uint8 r
4086         Uint8 g
4087         Uint8 b
4088         Uint8 a
4089         CODE:
4090                 RETVAL = filledEllipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4091         OUTPUT:
4092                 RETVAL
4093
4094 int
4095 GFXFilledPieColor ( dst, x, y, rad, start, end, color )
4096         SDL_Surface* dst
4097         Sint16 x
4098         Sint16 y
4099         Sint16 rad
4100         Sint16 start
4101         Sint16 end
4102         Uint32 color
4103         CODE:
4104                 RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
4105         OUTPUT:
4106                 RETVAL
4107
4108 int
4109 GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
4110         SDL_Surface* dst
4111         Sint16 x
4112         Sint16 y
4113         Sint16 rad
4114         Sint16 start
4115         Sint16 end
4116         Uint8 r
4117         Uint8 g
4118         Uint8 b
4119         Uint8 a
4120         CODE:
4121                 RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
4122         OUTPUT:
4123                 RETVAL
4124
4125 int
4126 GFXPolygonColor ( dst, vx, vy, n, color )
4127         SDL_Surface* dst
4128         Sint16* vx
4129         Sint16* vy
4130         int n
4131         Uint32 color;
4132         CODE:
4133                 RETVAL = polygonColor( dst, vx, vy, n, color );
4134         OUTPUT:
4135                 RETVAL
4136
4137 int
4138 GFXPolygonRGBA ( 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 = polygonRGBA( dst, vx, vy, n, r, g, b, a );
4149         OUTPUT:
4150                 RETVAL
4151
4152 int
4153 GFXAapolygonColor ( dst, vx, vy, n, color )
4154         SDL_Surface* dst
4155         Sint16* vx
4156         Sint16* vy
4157         int n
4158         Uint32 color
4159         CODE:
4160                 RETVAL = aapolygonColor( dst, vx, vy, n, color );
4161         OUTPUT:
4162                 RETVAL
4163
4164 int
4165 GFXAapolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4166         SDL_Surface* dst
4167         Sint16* vx
4168         Sint16* vy
4169         int n
4170         Uint8 r
4171         Uint8 g
4172         Uint8 b
4173         Uint8 a
4174         CODE:
4175                 RETVAL = aapolygonRGBA( dst, vx, vy, n, r, g, b, a );
4176         OUTPUT:
4177                 RETVAL
4178
4179 int
4180 GFXFilledPolygonColor ( dst, vx, vy, n, color )
4181         SDL_Surface* dst
4182         Sint16* vx
4183         Sint16* vy
4184         int n
4185         int color
4186         CODE:
4187                 RETVAL = filledPolygonColor( dst, vx, vy, n, color );
4188         OUTPUT:
4189                 RETVAL
4190
4191 int
4192 GFXFilledPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4193         SDL_Surface* dst
4194         Sint16* vx
4195         Sint16* vy
4196         int n
4197         Uint8 r
4198         Uint8 g
4199         Uint8 b
4200         Uint8 a
4201         CODE:
4202                 RETVAL = filledPolygonRGBA( dst, vx, vy, n, r, g, b, a );
4203         OUTPUT:
4204                 RETVAL
4205
4206 int
4207 GFXCharacterColor ( dst, x, y, c, color )
4208         SDL_Surface* dst
4209         Sint16 x
4210         Sint16 y
4211         char c
4212         Uint32 color
4213         CODE:
4214                 RETVAL = characterColor( dst, x, y, c, color );
4215         OUTPUT:
4216                 RETVAL
4217
4218 int
4219 GFXCharacterRGBA ( dst, x, y, c, r, g, b, a )
4220         SDL_Surface* dst
4221         Sint16 x
4222         Sint16 y
4223         char c
4224         Uint8 r
4225         Uint8 g
4226         Uint8 b
4227         Uint8 a
4228         CODE:
4229                 RETVAL = characterRGBA( dst, x, y, c, r, g, b, a );
4230         OUTPUT:
4231                 RETVAL
4232
4233 int
4234 GFXStringColor ( dst, x, y, c, color )
4235         SDL_Surface* dst
4236         Sint16 x
4237         Sint16 y
4238         char* c
4239         Uint32 color
4240         CODE:
4241                 RETVAL = stringColor( dst, x, y, c, color );
4242         OUTPUT:
4243                 RETVAL
4244
4245 int
4246 GFXStringRGBA ( dst, x, y, c, r, g, b, a )
4247         SDL_Surface* dst
4248         Sint16 x
4249         Sint16 y
4250         char* c
4251         Uint8 r
4252         Uint8 g
4253         Uint8 b
4254         Uint8 a
4255         CODE:
4256                 RETVAL = stringRGBA( dst, x, y, c, r, g, b, a );
4257         OUTPUT:
4258                 RETVAL
4259
4260 #endif
4261
4262
4263 #ifdef HAVE_SDL_SVG
4264
4265 SDL_svg_context *
4266 SVG_Load ( filename )
4267         char* filename
4268         CODE:
4269                 RETVAL = SVG_Load(filename);
4270         OUTPUT:
4271                 RETVAL
4272
4273 SDL_svg_context *
4274 SVG_LoadBuffer ( data, len )
4275         char* data
4276         int len
4277         CODE:
4278                 RETVAL = SVG_LoadBuffer(data,len);
4279         OUTPUT:
4280                 RETVAL
4281
4282 int
4283 SVG_SetOffset ( source, xoff, yoff )
4284         SDL_svg_context* source
4285         double xoff
4286         double yoff
4287         CODE:
4288                 RETVAL = SVG_SetOffset(source,xoff,yoff);
4289         OUTPUT:
4290                 RETVAL
4291
4292 int
4293 SVG_SetScale ( source, xscale, yscale )
4294         SDL_svg_context* source
4295         double xscale
4296         double yscale
4297         CODE:
4298                 RETVAL = SVG_SetScale(source,xscale,yscale);
4299         OUTPUT:
4300                 RETVAL
4301
4302 int
4303 SVG_RenderToSurface ( source, x, y, dest )
4304         SDL_svg_context* source
4305         int x
4306         int y
4307         SDL_Surface* dest;
4308         CODE:
4309                 RETVAL = SVG_RenderToSurface(source,x,y,dest);
4310         OUTPUT:
4311                 RETVAL
4312
4313 void
4314 SVG_Free ( source )
4315         SDL_svg_context* source
4316         CODE:
4317                 SVG_Free(source);       
4318
4319 void
4320 SVG_Set_Flags ( source, flags )
4321         SDL_svg_context* source
4322         Uint32 flags
4323         CODE:
4324                 SVG_Set_Flags(source,flags);
4325
4326 float
4327 SVG_Width ( source )
4328         SDL_svg_context* source
4329         CODE:
4330                 RETVAL = SVG_Width(source);
4331         OUTPUT:
4332                 RETVAL
4333
4334 float
4335 SVG_HEIGHT ( source )
4336         SDL_svg_context* source
4337         CODE:
4338                 RETVAL = SVG_Height(source);
4339         OUTPUT:
4340                 RETVAL
4341
4342 void
4343 SVG_SetClipping ( source, minx, miny, maxx, maxy )
4344         SDL_svg_context* source
4345         int minx
4346         int miny
4347         int maxx
4348         int maxy
4349         CODE:
4350                 SVG_SetClipping(source,minx,miny,maxx,maxy);
4351
4352 int
4353 SVG_Version ( )
4354         CODE:
4355                 RETVAL = SVG_Version();
4356         OUTPUT:
4357                 RETVAL
4358
4359
4360 #endif
4361
4362 #ifdef HAVE_SDL_SOUND
4363
4364 Uint16
4365 SoundAudioInfoFormat ( audioinfo )
4366         Sound_AudioInfo* audioinfo
4367         CODE:
4368                 RETVAL = audioinfo->format;
4369         OUTPUT:
4370                 RETVAL
4371
4372 Uint8
4373 SoundAudioInfoChannels ( audioinfo )
4374         Sound_AudioInfo* audioinfo
4375         CODE:
4376                 RETVAL = audioinfo->channels;
4377         OUTPUT:
4378                 RETVAL
4379
4380 Uint32
4381 SoundAudioInforate ( audioinfo )
4382         Sound_AudioInfo* audioinfo
4383         CODE:
4384                 RETVAL = audioinfo->rate;
4385         OUTPUT:
4386                 RETVAL
4387
4388 AV*
4389 SoundDecoderInfoExtensions ( decoderinfo )
4390         Sound_DecoderInfo* decoderinfo
4391         CODE:
4392                 const char **ext;
4393                 for ( ext = decoderinfo->extensions; *ext != NULL; ext++ ){
4394                         av_push(RETVAL,newSVpv(*ext,0));
4395                 }
4396         OUTPUT:
4397                 RETVAL
4398
4399 const char*
4400 SoundDecoderInfoDescription ( decoderinfo )
4401         Sound_DecoderInfo* decoderinfo
4402         CODE:
4403                 RETVAL = decoderinfo->description;
4404         OUTPUT:
4405                 RETVAL
4406
4407 const char*
4408 SoundDecoderInfoAuthor ( decoderinfo )
4409         Sound_DecoderInfo* decoderinfo
4410         CODE:
4411                 RETVAL = decoderinfo->author;
4412         OUTPUT:
4413                 RETVAL
4414
4415 const char*
4416 SoundDecoderInfoUrl ( decoderinfo )
4417         Sound_DecoderInfo* decoderinfo
4418         CODE:
4419                 RETVAL = decoderinfo->url;
4420         OUTPUT:
4421                 RETVAL
4422
4423 const Sound_DecoderInfo*
4424 SoundSampleDecoder ( sample ) 
4425         Sound_Sample* sample
4426         CODE:
4427                 RETVAL = sample->decoder;
4428         OUTPUT:
4429                 RETVAL
4430
4431 Sound_AudioInfo* 
4432 SoundSampleDesired ( sample )
4433         Sound_Sample* sample
4434         CODE:
4435                 RETVAL = &sample->desired;
4436         OUTPUT:
4437                 RETVAL
4438
4439 Sound_AudioInfo*
4440 SoundSampleAcutal ( sample )
4441         Sound_Sample* sample
4442         CODE:
4443                 RETVAL = &sample->actual;
4444         OUTPUT:
4445                 RETVAL
4446
4447 char*
4448 SoundSampleBuffer ( sample )
4449         Sound_Sample* sample
4450         CODE:
4451                 RETVAL = sample->buffer;
4452         OUTPUT:
4453                 RETVAL
4454
4455 Uint32
4456 SoundSampleBufferSize ( sample )
4457         Sound_Sample* sample
4458         CODE:
4459                 RETVAL = sample->buffer_size;
4460         OUTPUT:
4461                 RETVAL
4462
4463 Uint32
4464 SoundSampleFlags ( sample )
4465         Sound_Sample* sample
4466         CODE:
4467                 RETVAL = (Uint32)sample->flags;
4468         OUTPUT:
4469                 RETVAL
4470
4471 int
4472 Sound_Init ( )
4473         CODE:
4474                 RETVAL = Sound_Init();
4475         OUTPUT:
4476                 RETVAL
4477
4478 int
4479 Sound_Quit ( )
4480         CODE:
4481                 RETVAL = Sound_Quit();
4482         OUTPUT:
4483                 RETVAL
4484
4485 AV*
4486 Sound_AvailableDecoders ( )
4487         CODE:
4488                 RETVAL = newAV();
4489                 const Sound_DecoderInfo** sdi;
4490                 sdi = Sound_AvailableDecoders();
4491                 if (sdi != NULL)  {
4492                         for (;*sdi != NULL; ++sdi) {
4493                                 av_push(RETVAL,sv_2mortal(newSViv(PTR2IV(*sdi))));
4494                         }
4495                 }
4496         OUTPUT:
4497                 RETVAL
4498
4499 const char*
4500 Sound_GetError ( )
4501         CODE:
4502                 RETVAL = Sound_GetError();
4503         OUTPUT:
4504                 RETVAL
4505
4506 void
4507 Sound_ClearError ( )
4508         CODE:
4509                 Sound_ClearError();
4510
4511 Sound_Sample*
4512 Sound_NewSample ( rw, ext, desired, buffsize )
4513         SDL_RWops* rw
4514         const char* ext
4515         Sound_AudioInfo* desired
4516         Uint32 buffsize
4517         CODE:
4518                 RETVAL = Sound_NewSample(rw,ext,desired,buffsize);
4519         OUTPUT:
4520                 RETVAL
4521
4522 Sound_Sample*
4523 Sound_NewSampleFromMem ( data, size, ext, desired, buffsize )
4524         const Uint8 *data
4525         Uint32 size
4526         const char* ext
4527         Sound_AudioInfo* desired
4528         Uint32 buffsize
4529         CODE:
4530                 RETVAL = Sound_NewSampleFromMem(data,size,ext,desired,buffsize);
4531         OUTPUT:
4532                 RETVAL
4533
4534 Sound_Sample*
4535 Sound_NewSampleFromFile ( fname, desired, buffsize )
4536         const char* fname
4537         Sound_AudioInfo* desired
4538         Uint32 buffsize
4539         CODE:
4540                 RETVAL = Sound_NewSampleFromFile(fname,desired,buffsize);
4541         OUTPUT:
4542                 RETVAL
4543
4544 void
4545 Sound_FreeSample ( sample )
4546         Sound_Sample* sample
4547         CODE:
4548                 Sound_FreeSample(sample);
4549
4550 Sint32
4551 Sound_GetDuration ( sample )
4552         Sound_Sample* sample
4553         CODE:
4554                 RETVAL = Sound_GetDuration(sample);
4555         OUTPUT:
4556                 RETVAL
4557
4558 int
4559 Sound_SetBufferSize ( sample, size )
4560         Sound_Sample* sample
4561         Uint32 size
4562         CODE:
4563                 RETVAL = Sound_SetBufferSize(sample,size);
4564         OUTPUT:
4565                 RETVAL
4566
4567 Uint32
4568 Sound_Decode ( sample )
4569         Sound_Sample* sample
4570         CODE:
4571                 RETVAL = Sound_Decode(sample);
4572         OUTPUT:
4573                 RETVAL
4574
4575 Uint32
4576 Sound_DecodeAll ( sample ) 
4577         Sound_Sample* sample
4578         CODE:
4579                 RETVAL = Sound_DecodeAll(sample);
4580         OUTPUT:
4581                 RETVAL
4582
4583 int
4584 Sound_Rewind ( sample )
4585         Sound_Sample* sample
4586         CODE:
4587                 RETVAL = Sound_Rewind(sample);
4588         OUTPUT:
4589                 RETVAL
4590
4591 int
4592 Sound_Seek ( sample, ms )
4593         Sound_Sample* sample
4594         Uint32 ms
4595         CODE:
4596                 RETVAL = Sound_Seek(sample,ms);
4597         OUTPUT:
4598                 RETVAL
4599
4600 #endif
4601
4602 MODULE = SDL            PACKAGE = SDL
4603 PROTOTYPES : DISABLE
4604
4605