X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2FSDL.xs;h=135f1ca93b5b520ed1344f009b69ced4239e9745;hb=50d0e9aca27e76457937927dd6ead320674bbe22;hp=c327e5e02babe82e548ba53a583a4fa6c8a760d3;hpb=7b6a53a1f5064ca5b8ab0243f7bcf6209e6bf5a4;p=sdlgit%2FSDL_perl.git diff --git a/src/SDL.xs b/src/SDL.xs index c327e5e..135f1ca 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -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 ) @@ -1185,63 +1205,6 @@ VideoInfo () OUTPUT: RETVAL -SDL_Rect * -NewRect ( x, y, w, h ) - Sint16 x - Sint16 y - Uint16 w - Uint16 h - CODE: - RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect)); - RETVAL->x = x; - RETVAL->y = y; - RETVAL->w = w; - RETVAL->h = h; - OUTPUT: - RETVAL - -void -FreeRect ( rect ) - SDL_Rect *rect - CODE: - safefree(rect); - -Sint16 -RectX ( rect, ... ) - SDL_Rect *rect - CODE: - if (items > 1 ) rect->x = SvIV(ST(1)); - RETVAL = rect->x; - OUTPUT: - RETVAL - -Sint16 -RectY ( rect, ... ) - SDL_Rect *rect - CODE: - if (items > 1 ) rect->y = SvIV(ST(1)); - RETVAL = rect->y; - OUTPUT: - RETVAL - -Uint16 -RectW ( rect, ... ) - SDL_Rect *rect - CODE: - if (items > 1 ) rect->w = SvIV(ST(1)); - RETVAL = rect->w; - OUTPUT: - RETVAL - -Uint16 -RectH ( rect, ... ) - SDL_Rect *rect - CODE: - if (items > 1 ) rect->h = SvIV(ST(1)); - RETVAL = rect->h; - OUTPUT: - RETVAL - AV* ListModes ( format, flags ) Uint32 flags @@ -1303,6 +1266,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 @@ -1379,10 +1357,11 @@ void UpdateRects ( surface, ... ) SDL_Surface *surface CODE: - SDL_Rect *rects, *temp; + SDL_Rect *rects, *oldrects, *temp; int num_rects,i; if ( items < 2 ) return; - num_rects = items - 1; + num_rects = items - 1; + oldrects = rects; rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items); for(i=0;iformat,color->r,color->g,color->b); RETVAL = SDL_FillRect(dest,dest_rect,pixel); @@ -2411,7 +2397,7 @@ JoyAxisEventAxis ( e ) OUTPUT: RETVAL -Uint8 +Sint16 JoyAxisEventValue ( e ) SDL_Event *e CODE: @@ -2506,14 +2492,12 @@ SetClipRect ( surface, rect ) CODE: SDL_SetClipRect(surface,rect); -SDL_Rect* -GetClipRect ( surface ) +void +GetClipRect ( surface, rect ) SDL_Surface *surface + SDL_Rect *rect; CODE: - RETVAL = (SDL_Rect*) safemalloc(sizeof(SDL_Rect)); - SDL_GetClipRect(surface,RETVAL); - OUTPUT: - RETVAL + SDL_GetClipRect(surface, rect); #ifdef HAVE_SDL_NET @@ -2944,9 +2928,20 @@ TTFSizeText ( font, text ) CODE: int w,h; RETVAL = newAV(); - TTF_SizeText(font,text,&w,&h); - av_push(RETVAL,newSViv(w)); - av_push(RETVAL,newSViv(h)); + if(TTF_SizeText(font,text,&w,&h)) + { + av_push(RETVAL,newSViv(w)); + av_push(RETVAL,newSViv(h)); + sv_2mortal((SV*)RETVAL); + } + else + { + printf("TTF error at TTFSizeText: %s \n", TTF_GetError()); + Perl_croak (aTHX_ "TTF error \n"); + + } + + OUTPUT: RETVAL @@ -2957,9 +2952,19 @@ TTFSizeUTF8 ( font, text ) CODE: int w,h; RETVAL = newAV(); - TTF_SizeUTF8(font,text,&w,&h); - av_push(RETVAL,newSViv(w)); - av_push(RETVAL,newSViv(h)); + if(TTF_SizeUTF8(font,text,&w,&h)) + { + av_push(RETVAL,newSViv(w)); + av_push(RETVAL,newSViv(h)); + sv_2mortal((SV*)RETVAL); + + } + else + { + printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError()); + Perl_croak (aTHX_ "TTF error \n"); + } + OUTPUT: RETVAL @@ -2970,9 +2975,19 @@ TTFSizeUNICODE ( font, text ) CODE: int w,h; RETVAL = newAV(); - TTF_SizeUNICODE(font,text,&w,&h); - av_push(RETVAL,newSViv(w)); - av_push(RETVAL,newSViv(h)); + if(TTF_SizeUNICODE(font,text,&w,&h)) + { + av_push(RETVAL,newSViv(w)); + av_push(RETVAL,newSViv(h)); + sv_2mortal((SV*)RETVAL); + + } + else + { + printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); + Perl_croak (aTHX_ "TTF error \n"); + } + OUTPUT: RETVAL @@ -3105,6 +3120,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 )