Fixed test. But the returned value for the fuction SDL::TTFSizeUTF8 seems weird
[sdlgit/SDL_perl.git] / src / SDL.xs
index c327e5e..5f73b68 100644 (file)
@@ -97,7 +97,27 @@ static int sdl_perl_use_smpeg_audio = 0;
 #define HAVE_TLS_CONTEXT
 #endif
 
-#include "defines.h"
+/* For windows  */
+#ifndef SDL_PERL_DEFINES_H
+#define SDL_PERL_DEFINES_H
+
+#ifdef HAVE_TLS_CONTEXT
+PerlInterpreter *parent_perl = NULL;
+extern PerlInterpreter *parent_perl;
+#define GET_TLS_CONTEXT parent_perl =  PERL_GET_CONTEXT;
+#define ENTER_TLS_CONTEXT \
+        PerlInterpreter *current_perl = PERL_GET_CONTEXT; \
+               PERL_SET_CONTEXT(parent_perl); { \
+                                       PerlInterpreter *my_perl = parent_perl;
+#define LEAVE_TLS_CONTEXT \
+                                               } PERL_SET_CONTEXT(current_perl);
+#else
+#define GET_TLS_CONTEXT         /* TLS context not enabled */
+#define ENTER_TLS_CONTEXT       /* TLS context not enabled */
+#define LEAVE_TLS_CONTEXT       /* TLS context not enabled */
+#endif
+
+#endif
 
 Uint32 
 sdl_perl_timer_callback ( Uint32 interval, void* param )
@@ -1303,6 +1323,21 @@ ColorB ( color, ... )
        OUTPUT:
                RETVAL
 
+
+void
+ColorRGB ( color, ... )
+ SDL_Color *color
+ PPCODE:
+ if (items > 1 ) {
+ color->r = SvIV(ST(1));
+ color->g = SvIV(ST(2));
+ color->b = SvIV(ST(3));
+ }
+ mXPUSHi( color->r );
+ mXPUSHi( color->g );
+ mXPUSHi( color->b );
+ XSRETURN(3);
+
 void
 FreeColor ( color )
        SDL_Color *color
@@ -2411,7 +2446,7 @@ JoyAxisEventAxis ( e )
         OUTPUT:
                 RETVAL
 
-Uint8
+Sint16
 JoyAxisEventValue ( e )
         SDL_Event *e
         CODE:
@@ -2958,8 +2993,11 @@ TTFSizeUTF8 ( font, text )
                int w,h;
                RETVAL = newAV();
                TTF_SizeUTF8(font,text,&w,&h);
-               av_push(RETVAL,newSViv(w));
-               av_push(RETVAL,newSViv(h));
+                       av_push(RETVAL,newSViv(w));
+                       av_push(RETVAL,newSViv(h));
+               
+               sv_2mortal((SV*)RETVAL);
+               
        OUTPUT:
                RETVAL
 
@@ -3105,6 +3143,7 @@ TTFCloseFont ( font )
        TTF_Font *font
        CODE:
                TTF_CloseFont(font);
+               font=NULL; //to be safe http://sdl.beuc.net/sdl.wiki/SDL_ttf_copy_Functions_Management_TTF_CloseFont
 
 SDL_Surface*
 TTFPutString ( font, mode, surface, x, y, fg, bg, text )