X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2FCore%2FVideo.xs;h=87b348cab470879da669a29a9f2bc82a13676ff8;hb=1e72b6a4c3c4e7a35952194412007d61c5bc3120;hp=753bca650ad5cd49750a51bcf90b7f5e3658b78d;hpb=7dda1934e967f3a8e07a01546aa498b4e53a08ed;p=sdlgit%2FSDL_perl.git diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 753bca6..87b348c 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -8,6 +8,30 @@ #include + +static Uint16* av_to_uint16 (AV* av) +{ + int len = av_len(av); + if( len != -1) + { + int i; + Uint16* table = (Uint16 *)safemalloc(sizeof(Uint16)*(len)); + for ( i = 0; i < len+1 ; i++ ){ + SV ** temp = av_fetch(av,i,0); + if( temp != NULL) + { + table[i] = (Uint16 *) SvIV( *temp ); + } + else { table[i] =0; } + + } + return table; + } + return NULL; +} + + + MODULE = SDL::Video PACKAGE = SDL::Video PREFIX = video_ =for documentation @@ -58,6 +82,7 @@ AV* list_modes ( format, flags ) Uint32 flags SDL_PixelFormat *format + CODE: SDL_Rect **mode; RETVAL = newAV(); @@ -75,5 +100,183 @@ list_modes ( format, flags ) RETVAL +int +video_video_mode_ok ( width, height, bpp, flags ) + int width + int height + int bpp + Uint32 flags + CODE: + RETVAL = SDL_VideoModeOK(width,height,bpp,flags); + OUTPUT: + RETVAL +SDL_Surface * +video_set_video_mode ( width, height, bpp, flags ) + int width + int height + int bpp + Uint32 flags + PREINIT: + char* CLASS = "SDL::Surface"; + CODE: + RETVAL = SDL_SetVideoMode(width,height,bpp,flags); + OUTPUT: + RETVAL + + +void +video_update_rect ( surface, x, y, w ,h ) + SDL_Surface *surface + int x + int y + int w + int h + CODE: + SDL_UpdateRect(surface,x,y,w,h); + +void +video_update_rects ( surface, ... ) + SDL_Surface *surface + CODE: + SDL_Rect *rects; + int num_rects,i; + if ( items < 2 ) return; + num_rects = items - 1; + rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items); + for(i=0;ir; + colors[i].g = temp->g; + colors[i].b = temp->b; + } + RETVAL = SDL_SetColors(surface, colors, start, length ); + safefree(colors); + } + + OUTPUT: + RETVAL + +int +video_set_palette ( surface, flags, start, ... ) + SDL_Surface *surface + int flags + int start + + CODE: + SDL_Color *colors,*temp; + int i, length; + if ( items < 4 ) { + RETVAL = 0; + } + else + { + length = items - 3; + colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1)); + for ( i = 0; i < length ; i++ ){ + temp = (SDL_Color *)SvIV(ST(i+3)); + colors[i].r = temp->r; + colors[i].g = temp->g; + colors[i].b = temp->b; + } + RETVAL = SDL_SetPalette(surface, flags, colors, start, length ); + safefree(colors); + } + OUTPUT: + RETVAL + +int +video_set_gamma(r, g, b) + float r; + float g; + float b; + CODE: + RETVAL = SDL_SetGamma(r,g,b); + OUTPUT: + RETVAL + + +int +video_set_gamma_ramp( rt, gt, bt ) + AV* rt; + AV* gt; + AV* bt; + CODE: + Uint16 *redtable, *greentable, *bluetable; + redtable = av_to_uint16(rt); + greentable = av_to_uint16(gt); + bluetable = av_to_uint16(bt); + RETVAL = SDL_SetGammaRamp(redtable, greentable, bluetable); + if( redtable != NULL) { safefree(redtable); } + if( greentable != NULL) { safefree(greentable); } + if( bluetable != NULL) { safefree(bluetable); } + OUTPUT: + RETVAL + + + +Uint32 +video_map_RGB ( 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 + +Uint32 +video_map_RGBA ( pixel_format, r, g, b, a ) + SDL_PixelFormat *pixel_format + Uint8 r + Uint8 g + Uint8 b + Uint8 a + CODE: + RETVAL = SDL_MapRGB(pixel_format,r,g,b); + OUTPUT: + RETVAL + +int +video_lock_surface ( surface ) + SDL_Surface *surface + CODE: + RETVAL = SDL_LockSurface(surface); + OUTPUT: + RETVAL + +void +video_unlock_surface ( surface ) + SDL_Surface *surface + CODE: + SDL_UnlockSurface(surface); +