From: Kartik Thakore Date: Tue, 3 Nov 2009 14:13:35 +0000 (-0500) Subject: Implemented and add TODO tests for SDL::Video::GL_*. 97t/core_video.t done X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=46bbe1ed807a3ec67965e11a468e0141cfcc997c;p=sdlgit%2FSDL_perl.git Implemented and add TODO tests for SDL::Video::GL_*. 97t/core_video.t done --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 4c4c316..6b484ae 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -445,3 +445,46 @@ video_display_YUV_overlay ( overlay, dstrect ) RETVAL +int +video_GL_load_library ( path ) + char *path + CODE: + RETVAL = SDL_GL_LoadLibrary(path); + OUTPUT: + RETVAL + +void* +video_GL_get_proc_address ( proc ) + char *proc + CODE: + RETVAL = SDL_GL_GetProcAddress(proc); + OUTPUT: + RETVAL + +int +video_GL_set_attribute ( attr, value ) + int attr + int value + CODE: + RETVAL = SDL_GL_SetAttribute(attr, value); + OUTPUT: + RETVAL + +AV * +video_GL_get_attribute ( attr ) + int attr + CODE: + int value; + RETVAL = newAV(); + av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value))); + av_push(RETVAL,newSViv(value)); + OUTPUT: + RETVAL + +void +video_GL_swap_buffers () + CODE: + SDL_GL_SwapBuffers (); + + + diff --git a/src/SDL.xs b/src/SDL.xs index dfec9df..144f686 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -1873,48 +1873,6 @@ MixCloseAudio () #endif int -GLLoadLibrary ( path ) - char *path - CODE: - RETVAL = SDL_GL_LoadLibrary(path); - OUTPUT: - RETVAL - -void* -GLGetProcAddress ( proc ) - char *proc - CODE: - RETVAL = SDL_GL_GetProcAddress(proc); - OUTPUT: - RETVAL - -int -GLSetAttribute ( attr, value ) - int attr - int value - CODE: - RETVAL = SDL_GL_SetAttribute(attr, value); - OUTPUT: - RETVAL - -AV * -GLGetAttribute ( attr ) - int attr - CODE: - int value; - RETVAL = newAV(); - av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value))); - av_push(RETVAL,newSViv(value)); - OUTPUT: - RETVAL - -void -GLSwapBuffers () - CODE: - SDL_GL_SwapBuffers (); - - -int BigEndian () CODE: RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN); diff --git a/t/core_video.t b/t/core_video.t index 9a37f5c..531aa62 100644 --- a/t/core_video.t +++ b/t/core_video.t @@ -10,7 +10,7 @@ use Data::Dumper; use Test::More; use SDL::Rect; -plan ( tests => 44); +plan ( tests => 50); use_ok( 'SDL::Video' ); @@ -49,13 +49,41 @@ my @done = lock_YUV_overlay unlock_YUV_overlay display_YUV_overlay + GL_load_library + GL_get_proc_address + GL_get_attribute + GL_set_attribute + GL_swap_buffers /; can_ok ('SDL::Video', @done); #testing get_video_surface SDL::init(SDL_INIT_VIDEO); - + +#needs to be done before set_video_mode +my $glVal = SDL::Video::GL_load_library('this/should/fail'); + +is ($glVal, -1, '[GL_load_library] Failed appropraitly'); + +TODO: { +local $TODO = 'These should be tested with OS specific DLL or SO'; +is (SDL::Video::GL_load_library('t/realGL.so'), 0, '[GL_load_libary] returns 0 on success'); +# this gets set by GL_load_library => SDL_GL_LOADLIBARY. How do we get this from XS though? +# below t/realGL.so needs to use SDL_GL_LOADLIBRARY +isnt(SDL::Video::GL_get_proc_address('t/realGL.so'), NULL, '[GL_get_proc_address] returns not null on success'); +is (SDL::Video::GL_set_attribute( SDL_GL_DOUBLEBUFFER, 1) , 0 , '[GL_set_attribute] returns 0 on success'); +my $tdisplay = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); +my $value = -3; +SDL::Video::GL_set_attribute( SDL_GL_DOUBLEBUFFER, $value); +is ($value , 1 , '[GL_get_attribute] returns 1 on success as set above'); + +SDL::Video::GL_swap_buffers(); pass ( '[GL_swap_buffers] should work because Double Buffering is turned on'); + + +}; + + my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); if(!$display){ @@ -188,15 +216,9 @@ is($clip_rect->h, 200, '[get_clip_rect] returns a rect with h 200'); my @left = qw/ get_gamma_ramp - GL_load_library - GL_get_proc_address - GL_get_attribute - GL_set_attribute - GL_swap_buffers - GL_attr /; -my $why = '[Percentage Completion] '.int( 100 * $#done / ($#done + $#left) ) ."\% implementation. $#done / ".($#done+$#left); +my $why = '[Percentage Completion] '.int( 100 * ($#done +1) / ($#done + $#left + 2) ) ."\% implementation. ". ($#done +1)." / ".($#done+$#left + 2); TODO: {