From: Kartik Thakore Date: Fri, 23 Oct 2009 22:44:22 +0000 (-0400) Subject: Added list_modes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7dda1934e967f3a8e07a01546aa498b4e53a08ed;p=sdlgit%2FSDL_perl.git Added list_modes --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 29a18ee..753bca6 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -53,3 +53,27 @@ video_video_driver_name( ) XSRETURN_UNDEF; OUTPUT: RETVAL + +AV* +list_modes ( format, flags ) + Uint32 flags + SDL_PixelFormat *format + CODE: + SDL_Rect **mode; + RETVAL = newAV(); + mode = SDL_ListModes(format,flags); + if (mode == (SDL_Rect**)-1 ) { + av_push(RETVAL,newSVpv("all",0)); + } else if (! mode ) { + av_push(RETVAL,newSVpv("none",0)); + } else { + for (;*mode;mode++) { + av_push(RETVAL,newSViv(PTR2IV(*mode))); + } + } + OUTPUT: + RETVAL + + + + diff --git a/t/core_video.t b/t/core_video.t index 16a7da0..66c9503 100644 --- a/t/core_video.t +++ b/t/core_video.t @@ -13,6 +13,7 @@ can_ok ('SDL::Video', qw/ get_video_surface get_video_info video_driver_name + list_modes /); #testing get_video_surface @@ -35,7 +36,6 @@ pass '[video_driver_name] This is your driver name: '.$driver_name; pass "Are we still alive?"; =skip - list_modes video_mode_ok set_video_mode update_rect