X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2FSDL.xs;h=defa68ca8bd9bf646a4d58ac892834d631b72a8a;hb=HEAD;hp=657bfadd87893dd37fe96bc566195abd66df36fb;hpb=c668d2c2bf8d490c66ba36b70c45367d597fe3f2;p=sdlgit%2FSDL_perl.git diff --git a/src/SDL.xs b/src/SDL.xs index 657bfad..defa68c 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -62,19 +62,6 @@ void (*mix_music_finished_cv)(); #include #endif -#ifdef HAVE_SDL_TTF -#include -#define TEXT_SOLID 1 -#define TEXT_SHADED 2 -#define TEXT_BLENDED 4 -#define UTF8_SOLID 8 -#define UTF8_SHADED 16 -#define UTF8_BLENDED 32 -#define UNICODE_SOLID 64 -#define UNICODE_SHADED 128 -#define UNICODE_BLENDED 256 -#endif - #ifdef HAVE_SMPEG #include #ifdef HAVE_SDL_MIXER @@ -93,11 +80,49 @@ static int sdl_perl_use_smpeg_audio = 0; #include #endif +#ifdef HAVE_SDL_TTF +#include +#endif + #ifdef USE_THREADS #define HAVE_TLS_CONTEXT #endif -#include "src/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 + +void +windows_force_driver () +{ + const SDL_version *version = SDL_Linked_Version(); + if(version->patch == 14) + { + putenv("SDL_VIDEODRIVER=directx"); + } + else + { + putenv("SDL_VIDEODRIVER=windib"); + } +} Uint32 sdl_perl_timer_callback ( Uint32 interval, void* param ) @@ -232,17 +257,20 @@ MODULE = SDL_perl PACKAGE = SDL PROTOTYPES : DISABLE char * -GetError () +get_error () CODE: RETVAL = SDL_GetError(); OUTPUT: RETVAL int -Init ( flags ) +init ( flags ) Uint32 flags CODE: INIT_NS_APPLICATION +#if defined WINDOWS || WIN32 + windows_force_driver(); +#endif RETVAL = SDL_Init(flags); #ifdef HAVE_TLS_CONTEXT Perl_call_atexit(PERL_GET_CONTEXT, (void*)sdl_perl_atexit,0); @@ -253,7 +281,7 @@ Init ( flags ) RETVAL int -InitSubSystem ( flags ) +init_subsystem ( flags ) Uint32 flags CODE: RETVAL = SDL_InitSubSystem(flags); @@ -261,19 +289,19 @@ InitSubSystem ( flags ) RETVAL void -QuitSubSystem ( flags ) +quit_subsystem ( flags ) Uint32 flags CODE: SDL_QuitSubSystem(flags); void -Quit () +quit () CODE: QUIT_NS_APPLICATION SDL_Quit(); int -WasInit ( flags ) +was_init ( flags ) Uint32 flags CODE: RETVAL = SDL_WasInit(flags); @@ -281,7 +309,7 @@ WasInit ( flags ) RETVAL void -Delay ( ms ) +delay ( ms ) int ms CODE: SDL_Delay(ms); @@ -715,7 +743,7 @@ KeyEventUnicode ( e ) RETVAL Uint8 -KeyEventScanCode ( e ) +key_scancode ( e ) SDL_Event *e CODE: RETVAL = e->key.keysym.scancode; @@ -763,7 +791,7 @@ MouseMotionYrel ( e ) RETVAL Uint8 -MouseButtonState ( e ) +button_state ( e ) SDL_Event *e CODE: RETVAL = e->button.state; @@ -771,7 +799,7 @@ MouseButtonState ( e ) RETVAL Uint8 -MouseButton ( e ) +button ( e ) SDL_Event *e CODE: RETVAL = e->button.button; @@ -779,7 +807,7 @@ MouseButton ( e ) RETVAL Uint16 -MouseButtonX ( e ) +button_x ( e ) SDL_Event *e CODE: RETVAL = e->button.x; @@ -787,7 +815,7 @@ MouseButtonX ( e ) RETVAL Uint16 -MouseButtonY ( e ) +button_y ( e ) SDL_Event *e CODE: RETVAL = e->button.y; @@ -831,29 +859,29 @@ SetModState ( state ) SDL_SetModState(state); char * -GetKeyName ( sym ) +get_key_name ( sym ) int sym CODE: RETVAL = SDL_GetKeyName(sym); OUTPUT: RETVAL +#ifdef HAVE_SDL_IMAGE + SDL_Surface * -CreateRGBSurface (flags, width, height, depth, Rmask, Gmask, Bmask, Amask ) - Uint32 flags - int width - int height - int depth - Uint32 Rmask - Uint32 Gmask - Uint32 Bmask - Uint32 Amask +IMG_Load ( filename ) + char *filename CODE: - RETVAL = SDL_CreateRGBSurface ( flags, width, height, - depth, Rmask, Gmask, Bmask, Amask ); - OUTPUT: + char* CLASS = "SDL::Surface"; + RETVAL = IMG_Load(filename); + OUTPUT: RETVAL +#endif + +=for comment + +Comment out for now as it does not compile SDL_Surface * CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask ) @@ -876,18 +904,6 @@ CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, OUTPUT: RETVAL -#ifdef HAVE_SDL_IMAGE - -SDL_Surface * -IMGLoad ( fname ) - char *fname - CODE: - RETVAL = IMG_Load(fname); - OUTPUT: - RETVAL - -#endif - SDL_Surface* SurfaceCopy ( surface ) SDL_Surface *surface @@ -1059,6 +1075,12 @@ SurfacePixels ( surface ) OUTPUT: RETVAL +=cut + +=for comment + +Comment out for now as it does not compile + SDL_Color* SurfacePixel ( surface, x, y, ... ) SDL_Surface *surface @@ -1152,6 +1174,7 @@ GetVideoSurface () OUTPUT: RETVAL +=cut HV * VideoInfo () @@ -1185,63 +1208,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 @@ -1261,53 +1227,7 @@ ListModes ( format, flags ) } OUTPUT: RETVAL - - -SDL_Color * -NewColor ( r, g, b ) - Uint8 r - Uint8 g - Uint8 b - CODE: - RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color)); - RETVAL->r = r; - RETVAL->g = g; - RETVAL->b = b; - OUTPUT: - RETVAL - -Uint8 -ColorR ( color, ... ) - SDL_Color *color - CODE: - if (items > 1 ) color->r = SvIV(ST(1)); - RETVAL = color->r; - OUTPUT: - RETVAL - -Uint8 -ColorG ( color, ... ) - SDL_Color *color - CODE: - if (items > 1 ) color->g = SvIV(ST(1)); - RETVAL = color->g; - OUTPUT: - RETVAL - -Uint8 -ColorB ( color, ... ) - SDL_Color *color - CODE: - if (items > 1 ) color->b = SvIV(ST(1)); - RETVAL = color->b; - OUTPUT: - RETVAL - -void -FreeColor ( color ) - SDL_Color *color - CODE: - return; safefree(color); +=skip SDL_Palette * NewPalette ( number ) @@ -1319,6 +1239,7 @@ NewPalette ( number ) RETVAL->ncolors = number; OUTPUT: RETVAL +=cut int PaletteNColors ( palette, ... ) @@ -1329,39 +1250,47 @@ PaletteNColors ( palette, ... ) OUTPUT: RETVAL -SDL_Color * -PaletteColors ( palette, index, ... ) - SDL_Palette *palette - int index - CODE: - if ( items > 2 ) { - palette->colors[index].r = SvUV(ST(2)); - palette->colors[index].g = SvUV(ST(3)); - palette->colors[index].b = SvUV(ST(4)); - } - RETVAL = (SDL_Color *)(palette->colors + index); - OUTPUT: - RETVAL +SDL_Surface * +SetVideoMode ( width, height, bpp, flags ) -int -VideoModeOK ( width, height, bpp, flags ) int width int height int bpp Uint32 flags + CODE: - RETVAL = SDL_VideoModeOK(width,height,bpp,flags); + char *CLASS = "SDL::Surface"; + RETVAL = SDL_SetVideoMode(width,height,bpp,flags); OUTPUT: RETVAL -SDL_Surface * -SetVideoMode ( width, height, bpp, flags ) - int width - int height - int bpp - Uint32 flags +int +Flip ( surface ) + SDL_Surface *surface CODE: - RETVAL = SDL_SetVideoMode(width,height,bpp,flags); + RETVAL = SDL_Flip(surface); + OUTPUT: + RETVAL + +int +BlitSurface ( src, src_rect, dest, dest_rect ) + SDL_Surface *src + SDL_Surface *dest + SDL_Rect *src_rect + SDL_Rect *dest_rect + CODE: + RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect); + OUTPUT: + RETVAL + +Uint32 +MapRGB ( pixel_format, r, g, b ) + SDL_PixelFormat *pixel_format + Uint8 r + Uint8 g + Uint8 b + CODE: + RETVAL = SDL_MapRGB(pixel_format,r,g,b); OUTPUT: RETVAL @@ -1375,25 +1304,65 @@ UpdateRect ( surface, x, y, w ,h ) CODE: SDL_UpdateRect(surface,x,y,w,h); +SDL_Surface * +DisplayFormat ( surface ) + SDL_Surface *surface + CODE: + char* CLASS = "SDL::Surface"; + RETVAL = SDL_DisplayFormat(surface); + OUTPUT: + RETVAL + +SDL_Surface * +DisplayFormatAlpha ( surface ) + SDL_Surface *surface + CODE: + char* CLASS = "SDL::Surface"; + RETVAL = SDL_DisplayFormatAlpha(surface); + OUTPUT: + RETVAL + void UpdateRects ( surface, ... ) SDL_Surface *surface CODE: - SDL_Rect *rects, *temp; + SDL_Rect *rects; int num_rects,i; if ( items < 2 ) return; - num_rects = items - 1; + num_rects = items - 1; rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items); for(i=0;ix; - rects[i].y = temp->y; - rects[i].w = temp->w; - rects[i].h = temp->h; - } + rects[i] = *(SDL_Rect *)SvIV((SV*)SvRV( ST(i + 1) )); + } SDL_UpdateRects(surface,num_rects,rects); safefree(rects); +=for comment + +Comment out for now as it does not compile + +int +VideoModeOK ( width, height, bpp, flags ) + int width + int height + int bpp + Uint32 flags + CODE: + RETVAL = SDL_VideoModeOK(width,height,bpp,flags); + OUTPUT: + RETVAL + +SDL_Surface * +SetVideoMode ( width, height, bpp, flags ) + int width + int height + int bpp + Uint32 flags + CODE: + RETVAL = SDL_SetVideoMode(width,height,bpp,flags); + OUTPUT: + RETVAL + int Flip ( surface ) SDL_Surface *surface @@ -1425,17 +1394,6 @@ all_done: RETVAL Uint32 -MapRGB ( surface, r, g, b ) - SDL_Surface *surface - Uint8 r - Uint8 g - Uint8 b - CODE: - RETVAL = SDL_MapRGB(surface->format,r,g,b); - OUTPUT: - RETVAL - -Uint32 MapRGBA ( surface, r, g, b, a ) SDL_Surface *surface Uint8 r @@ -1506,22 +1464,6 @@ SetAlpha ( surface, flag, alpha ) OUTPUT: RETVAL -SDL_Surface * -DisplayFormat ( surface ) - SDL_Surface *surface - CODE: - RETVAL = SDL_DisplayFormat(surface); - OUTPUT: - RETVAL - -SDL_Surface* -DisplayFormatAlpha ( surface ) - SDL_Surface *surface - CODE: - RETVAL = SDL_DisplayFormatAlpha(surface); - OUTPUT: - RETVAL - SDL_Surface* ConvertRGB ( surface ) SDL_Surface * surface @@ -1574,24 +1516,14 @@ ConvertRGBA ( surface ) OUTPUT: RETVAL -int -BlitSurface ( src, src_rect, dest, dest_rect ) - SDL_Surface *src - SDL_Rect *src_rect - SDL_Surface *dest - SDL_Rect *dest_rect - CODE: - RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect); - OUTPUT: - RETVAL +=cut int -FillRect ( dest, dest_rect, color ) +FillRect ( dest, dest_rect, pixel ) SDL_Surface *dest SDL_Rect *dest_rect - SDL_Color *color + Uint32 pixel CODE: - Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b); RETVAL = SDL_FillRect(dest,dest_rect,pixel); OUTPUT: RETVAL @@ -2215,6 +2147,15 @@ MixPlayingMusic() OUTPUT: RETVAL +int +MixSetPanning ( channel, left, right ) + int channel + int left + int right + CODE: + RETVAL = Mix_SetPanning(channel, left, right); + OUTPUT: + RETVAL void MixCloseAudio () @@ -2506,14 +2447,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 @@ -2851,367 +2790,6 @@ NetRead32 ( area ) #endif -#ifdef HAVE_SDL_TTF - -int -TTFInit () - CODE: - RETVAL = TTF_Init(); - OUTPUT: - RETVAL - -void -TTFQuit () - CODE: - TTF_Quit(); - -TTF_Font* -TTFOpenFont ( file, ptsize ) - char *file - int ptsize - CODE: - RETVAL = TTF_OpenFont(file,ptsize); - OUTPUT: - RETVAL - -int -TTFGetFontStyle ( font ) - TTF_Font *font - CODE: - RETVAL = TTF_GetFontStyle(font); - OUTPUT: - RETVAL - -void -TTFSetFontStyle ( font, style ) - TTF_Font *font - int style - CODE: - TTF_SetFontStyle(font,style); - -int -TTFFontHeight ( font ) - TTF_Font *font - CODE: - RETVAL = TTF_FontHeight(font); - OUTPUT: - RETVAL - -int -TTFFontAscent ( font ) - TTF_Font *font - CODE: - RETVAL = TTF_FontAscent(font); - OUTPUT: - RETVAL - -int -TTFFontDescent ( font ) - TTF_Font *font - CODE: - RETVAL = TTF_FontDescent(font); - OUTPUT: - RETVAL - -int -TTFFontLineSkip ( font ) - TTF_Font *font - CODE: - RETVAL = TTF_FontLineSkip(font); - OUTPUT: - RETVAL - -AV* -TTFGlyphMetrics ( font, ch ) - TTF_Font *font - Uint16 ch - CODE: - int minx, miny, maxx, maxy, advance; - RETVAL = newAV(); - TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance); - av_push(RETVAL,newSViv(minx)); - av_push(RETVAL,newSViv(miny)); - av_push(RETVAL,newSViv(maxx)); - av_push(RETVAL,newSViv(maxy)); - av_push(RETVAL,newSViv(advance)); - OUTPUT: - RETVAL - -AV* -TTFSizeText ( font, text ) - TTF_Font *font - char *text - CODE: - int w,h; - RETVAL = newAV(); - TTF_SizeText(font,text,&w,&h); - av_push(RETVAL,newSViv(w)); - av_push(RETVAL,newSViv(h)); - OUTPUT: - RETVAL - -AV* -TTFSizeUTF8 ( font, text ) - TTF_Font *font - char *text - CODE: - int w,h; - RETVAL = newAV(); - TTF_SizeUTF8(font,text,&w,&h); - av_push(RETVAL,newSViv(w)); - av_push(RETVAL,newSViv(h)); - OUTPUT: - RETVAL - -AV* -TTFSizeUNICODE ( font, text ) - TTF_Font *font - const Uint16 *text - CODE: - int w,h; - RETVAL = newAV(); - TTF_SizeUNICODE(font,text,&w,&h); - av_push(RETVAL,newSViv(w)); - av_push(RETVAL,newSViv(h)); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderTextSolid ( font, text, fg ) - TTF_Font *font - char *text - SDL_Color *fg - CODE: - RETVAL = TTF_RenderText_Solid(font,text,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderUTF8Solid ( font, text, fg ) - TTF_Font *font - char *text - SDL_Color *fg - CODE: - RETVAL = TTF_RenderUTF8_Solid(font,text,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderUNICODESolid ( font, text, fg ) - TTF_Font *font - const Uint16 *text - SDL_Color *fg - CODE: - RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderGlyphSolid ( font, ch, fg ) - TTF_Font *font - Uint16 ch - SDL_Color *fg - CODE: - RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderTextShaded ( font, text, fg, bg ) - TTF_Font *font - char *text - SDL_Color *fg - SDL_Color *bg - CODE: - RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderUTF8Shaded( font, text, fg, bg ) - TTF_Font *font - char *text - SDL_Color *fg - SDL_Color *bg - CODE: - RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderUNICODEShaded( font, text, fg, bg ) - TTF_Font *font - const Uint16 *text - SDL_Color *fg - SDL_Color *bg - CODE: - RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderGlyphShaded ( font, ch, fg, bg ) - TTF_Font *font - Uint16 ch - SDL_Color *fg - SDL_Color *bg - CODE: - RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderTextBlended( font, text, fg ) - TTF_Font *font - char *text - SDL_Color *fg - CODE: - RETVAL = TTF_RenderText_Blended(font,text,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderUTF8Blended( font, text, fg ) - TTF_Font *font - char *text - SDL_Color *fg - CODE: - RETVAL = TTF_RenderUTF8_Blended(font,text,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderUNICODEBlended( font, text, fg ) - TTF_Font *font - const Uint16 *text - SDL_Color *fg - CODE: - RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg); - OUTPUT: - RETVAL - -SDL_Surface* -TTFRenderGlyphBlended( font, ch, fg ) - TTF_Font *font - Uint16 ch - SDL_Color *fg - CODE: - RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg); - OUTPUT: - RETVAL - -void -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 ) - TTF_Font *font - int mode - SDL_Surface *surface - int x - int y - SDL_Color *fg - SDL_Color *bg - char *text - CODE: - SDL_Surface *img; - SDL_Rect dest; - int w,h; - dest.x = x; - dest.y = y; - RETVAL = NULL; - switch (mode) { - case TEXT_SOLID: - img = TTF_RenderText_Solid(font,text,*fg); - TTF_SizeText(font,text,&w,&h); - dest.w = w; - dest.h = h; - break; - case TEXT_SHADED: - img = TTF_RenderText_Shaded(font,text,*fg,*bg); - TTF_SizeText(font,text,&w,&h); - dest.w = w; - dest.h = h; - break; - case TEXT_BLENDED: - img = TTF_RenderText_Blended(font,text,*fg); - TTF_SizeText(font,text,&w,&h); - dest.w = w; - dest.h = h; - break; - case UTF8_SOLID: - img = TTF_RenderUTF8_Solid(font,text,*fg); - TTF_SizeUTF8(font,text,&w,&h); - dest.w = w; - dest.h = h; - break; - case UTF8_SHADED: - img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg); - TTF_SizeUTF8(font,text,&w,&h); - dest.w = w; - dest.h = h; - break; - case UTF8_BLENDED: - img = TTF_RenderUTF8_Blended(font,text,*fg); - TTF_SizeUTF8(font,text,&w,&h); - dest.w = w; - dest.h = h; - break; - case UNICODE_SOLID: - img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg); - TTF_SizeUNICODE(font,(Uint16*)text,&w,&h); - dest.w = w; - dest.h = h; - break; - case UNICODE_SHADED: - img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg); - TTF_SizeUNICODE(font,(Uint16*)text,&w,&h); - dest.w = w; - dest.h = h; - break; - case UNICODE_BLENDED: - img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg); - TTF_SizeUNICODE(font,(Uint16*)text,&w,&h); - dest.w = w; - dest.h = h; - break; - default: - img = TTF_RenderText_Shaded(font,text,*fg,*bg); - TTF_SizeText(font,text,&w,&h); - dest.w = w; - dest.h = h; - } - if ( img && img->format && img->format->palette ) { - SDL_Color *c = &img->format->palette->colors[0]; - Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b ); - SDL_SetColorKey(img,SDL_SRCCOLORKEY,key ); - if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) { - SDL_FreeSurface(img); - RETVAL = NULL; - } else { - RETVAL = img; - } - } - OUTPUT: - RETVAL - -#endif - -SDL_Overlay* -CreateYUVOverlay ( width, height, format, display ) - int width - int height - Uint32 format - SDL_Surface *display - CODE: - RETVAL = SDL_CreateYUVOverlay ( width, height, format, display ); - OUTPUT: - RETVAL - int LockYUVOverlay ( overlay ) SDL_Overlay *overlay @@ -3235,12 +2813,6 @@ DisplayYUVOverlay ( overlay, dstrect ) OUTPUT: RETVAL -void -FreeYUVOverlay ( overlay ) - SDL_Overlay *overlay - CODE: - SDL_FreeYUVOverlay ( overlay ); - Uint32 OverlayFormat ( overlay, ... ) SDL_Overlay *overlay @@ -3638,6 +3210,8 @@ SMPEGGetInfo ( mpeg ) #ifdef HAVE_SDL_GFX +=cut + SDL_Surface * GFXRotoZoom ( src, angle, zoom, smooth) SDL_Surface * src @@ -3660,6 +3234,8 @@ GFXZoom ( src, zoomx, zoomy, smooth) OUTPUT: RETVAL +=cut + int GFXPixelColor ( dst, x, y, color ) SDL_Surface* dst @@ -4531,6 +4107,64 @@ Sound_Seek ( sample, ms ) #endif +#ifdef HAVE_SDL_TTF + +int +TTF_Init () + CODE: + RETVAL = TTF_Init(); + OUTPUT: + RETVAL + +void +TTF_Quit () + CODE: + TTF_Quit(); + +TTF_Font* +TTF_OpenFont ( file, ptsize ) + char *file + int ptsize + CODE: + char* CLASS = "SDL::TTF_Font"; + RETVAL = TTF_OpenFont(file,ptsize); + OUTPUT: + RETVAL + +AV* +TTF_SizeText ( font, text ) + TTF_Font *font + char *text + CODE: + int w,h; + RETVAL = newAV(); + if(TTF_SizeText(font,text,&w,&h)) + { + printf("TTF error at TTFSizeText: %s \n", TTF_GetError()); + Perl_croak (aTHX_ "TTF error \n"); + } + else + { + av_push(RETVAL,newSViv(w)); + av_push(RETVAL,newSViv(h)); + sv_2mortal((SV*)RETVAL); + } + OUTPUT: + RETVAL + +SDL_Surface* +TTF_RenderText_Blended ( font, text, fg ) + TTF_Font *font + char *text + SDL_Color *fg + CODE: + char* CLASS = "SDL::Surface"; + RETVAL = TTF_RenderText_Blended(font,text,*fg); + OUTPUT: + RETVAL + +#endif + MODULE = SDL PACKAGE = SDL PROTOTYPES : DISABLE