11 #define WARNMSG "is unsupported in windows. Contact us at #sdl irc.perl.org or sdl-devel@perl.org for help."
13 static Uint16* av_to_uint16 (AV* av)
19 Uint16* table = (Uint16 *)safemalloc(sizeof(Uint16)*(len));
20 //fprintf( stderr, "Expecting 1,2,5,6 \n Length is %d \n", len);
21 for ( i = 0; i < len+1 ; i++ ){
22 SV ** temp = av_fetch(av,i,0);
25 table[i] = (Uint16 *) SvIV( *temp ) ;
26 /* fprintf( stderr, "table[%d] = ", i);
27 if (table[i] == NULL) { fprintf ( stderr, " NULL\n"); }
28 else{ fprintf(stderr, " %d \n", table[i]); } */
33 // warn("Got %d %d %d %d \n", table[0], table[1], table[2], table[3] );
42 MODULE = SDL::Video PACKAGE = SDL::Video PREFIX = video_
46 The Following are XS bindings to the Video category in the SDL API v2.1.13
48 Describe on the SDL API site.
50 See: L<http://www.libsdl.org/cgi/docwiki.cgi/SDL_API#head-813f033ec44914f267f32195aba7d9aff8c410c0>
55 video_get_video_surface()
57 char* CLASS = "SDL::Surface";
59 RETVAL = SDL_GetVideoSurface();
65 video_get_video_info()
67 char* CLASS = "SDL::VideoInfo";
69 RETVAL = (SDL_VideoInfo *) SDL_GetVideoInfo();
75 video_video_driver_name( )
79 if ( SDL_VideoDriverName(buffer, 1024) != NULL )
81 RETVAL = newSVpv(buffer, 0);
89 list_modes ( format, flags )
91 SDL_PixelFormat *format
96 mode = SDL_ListModes(format,flags);
97 if (mode == (SDL_Rect**)-1 ) {
98 av_push(RETVAL,newSVpv("all",0));
100 av_push(RETVAL,newSVpv("none",0));
102 for (;*mode;mode++) {
103 av_push(RETVAL,newSViv(PTR2IV(*mode)));
111 video_video_mode_ok ( width, height, bpp, flags )
117 RETVAL = SDL_VideoModeOK(width,height,bpp,flags);
123 video_set_video_mode ( width, height, bpp, flags )
129 char* CLASS = "SDL::Surface";
131 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
137 video_update_rect ( surface, x, y, w ,h )
144 SDL_UpdateRect(surface,x,y,w,h);
147 video_update_rects ( surface, ... )
152 if ( items < 2 ) return;
153 num_rects = items - 1;
154 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
155 for(i=0;i<num_rects;i++) {
156 rects[i] = *(SDL_Rect *)SvIV((SV*)SvRV( ST(i + 1) ));
158 SDL_UpdateRects(surface,num_rects,rects);
163 video_flip ( surface )
166 RETVAL = SDL_Flip(surface);
171 video_set_colors ( surface, start, ... )
175 SDL_Color *colors,*temp;
177 if ( items < 3 ) { RETVAL = 0;}
181 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
182 for ( i = 0; i < length ; i++ ) {
183 temp = (SDL_Color *)SvIV(ST(i+2));
184 colors[i].r = temp->r;
185 colors[i].g = temp->g;
186 colors[i].b = temp->b;
188 RETVAL = SDL_SetColors(surface, colors, start, length );
196 video_set_palette ( surface, flags, start, ... )
202 SDL_Color *colors,*temp;
210 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
211 for ( i = 0; i < length ; i++ ){
212 temp = (SDL_Color *)SvIV(ST(i+3));
213 colors[i].r = temp->r;
214 colors[i].g = temp->g;
215 colors[i].b = temp->b;
217 RETVAL = SDL_SetPalette(surface, flags, colors, start, length );
224 video_set_gamma(r, g, b)
230 #if defined WIN32 || WINDOWS
231 warn( "set_gamma: %s", WARNMSG );
233 RETVAL = SDL_SetGamma(r,g,b);
241 video_set_gamma_ramp( rt, gt, bt )
246 #if defined WIN32 || WINDOWS
247 warn( "set_gamma_ramp: %s", WARNMSG );
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); }