12 static Uint16* av_to_uint16 (AV* av)
18 Uint16* table = (Uint16 *)safemalloc(sizeof(Uint16)*(len));
19 //fprintf( stderr, "Expecting 1,2,5,6 \n Length is %d \n", len);
20 for ( i = 0; i < len+1 ; i++ ){
21 SV ** temp = av_fetch(av,i,0);
24 table[i] = (Uint16 *) SvIV( *temp ) ;
25 /* fprintf( stderr, "table[%d] = ", i);
26 if (table[i] == NULL) { fprintf ( stderr, " NULL\n"); }
27 else{ fprintf(stderr, " %d \n", table[i]); } */
32 // warn("Got %d %d %d %d \n", table[0], table[1], table[2], table[3] );
41 MODULE = SDL::Video PACKAGE = SDL::Video PREFIX = video_
45 The Following are XS bindings to the Video category in the SDL API v2.1.13
47 Describe on the SDL API site.
49 See: L<http://www.libsdl.org/cgi/docwiki.cgi/SDL_API#head-813f033ec44914f267f32195aba7d9aff8c410c0>
54 video_get_video_surface()
56 char* CLASS = "SDL::Surface";
58 RETVAL = SDL_GetVideoSurface();
64 video_get_video_info()
66 char* CLASS = "SDL::VideoInfo";
68 RETVAL = (SDL_VideoInfo *) SDL_GetVideoInfo();
74 video_video_driver_name( )
78 if ( SDL_VideoDriverName(buffer, 1024) != NULL )
80 RETVAL = newSVpv(buffer, 0);
88 list_modes ( format, flags )
90 SDL_PixelFormat *format
95 mode = SDL_ListModes(format,flags);
96 if (mode == (SDL_Rect**)-1 ) {
97 av_push(RETVAL,newSVpv("all",0));
99 av_push(RETVAL,newSVpv("none",0));
101 for (;*mode;mode++) {
102 av_push(RETVAL,newSViv(PTR2IV(*mode)));
110 video_video_mode_ok ( width, height, bpp, flags )
116 RETVAL = SDL_VideoModeOK(width,height,bpp,flags);
122 video_set_video_mode ( width, height, bpp, flags )
128 char* CLASS = "SDL::Surface";
130 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
136 video_update_rect ( surface, x, y, w ,h )
143 SDL_UpdateRect(surface,x,y,w,h);
146 video_update_rects ( surface, ... )
151 if ( items < 2 ) return;
152 num_rects = items - 1;
153 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
154 for(i=0;i<num_rects;i++) {
155 rects[i] = *(SDL_Rect *)SvIV((SV*)SvRV( ST(i + 1) ));
157 SDL_UpdateRects(surface,num_rects,rects);
162 video_flip ( surface )
165 RETVAL = SDL_Flip(surface);
170 video_set_colors ( surface, start, ... )
174 SDL_Color *colors,*temp;
176 if ( items < 3 ) { RETVAL = 0;}
180 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
181 for ( i = 0; i < length ; i++ ) {
182 temp = (SDL_Color *)SvIV(ST(i+2));
183 colors[i].r = temp->r;
184 colors[i].g = temp->g;
185 colors[i].b = temp->b;
187 RETVAL = SDL_SetColors(surface, colors, start, length );
195 video_set_palette ( surface, flags, start, ... )
201 SDL_Color *colors,*temp;
209 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
210 for ( i = 0; i < length ; i++ ){
211 temp = (SDL_Color *)SvIV(ST(i+3));
212 colors[i].r = temp->r;
213 colors[i].g = temp->g;
214 colors[i].b = temp->b;
216 RETVAL = SDL_SetPalette(surface, flags, colors, start, length );
223 video_set_gamma(r, g, b)
230 warn( "SDL_SetGamma is unsupported in Windows. ");
232 RETVAL = SDL_SetGamma(r,g,b);
239 video_set_gamma_ramp( rt, gt, bt )
247 warn( "SDL_SetGammaRamp is unsupported in Windows. " );
249 Uint16 *redtable, *greentable, *bluetable;
250 redtable = av_to_uint16(rt);
251 greentable = av_to_uint16(gt);
252 bluetable = av_to_uint16(bt);
253 RETVAL = SDL_SetGammaRamp(redtable, greentable, bluetable);
254 if( redtable != NULL) { safefree(redtable); }
255 if( greentable != NULL) { safefree(greentable); }
256 if( bluetable != NULL) { safefree(bluetable); }