Better error reporting for SDL::Video::map_RGB[A]
Kartik Thakore [Fri, 6 Nov 2009 15:36:56 +0000 (10:36 -0500)]
src/Core/Video.xs

index 6b484ae..c47fa5a 100644 (file)
@@ -250,7 +250,16 @@ video_map_RGB ( pixel_format, r, g, b )
        Uint8 g
        Uint8 b
        CODE:
-               RETVAL = SDL_MapRGB(pixel_format,r,g,b);
+               Uint32 value = SDL_MapRGB(pixel_format, r,g,b);
+               if(value > 0)  
+               { 
+                RETVAL = value; 
+               }
+               else
+               {
+               warn( "SDL_MapRGB failed: %s", SDL_GetError() );
+               RETVAL = -1;  
+               }
        OUTPUT:
                RETVAL
 
@@ -262,7 +271,17 @@ video_map_RGBA ( pixel_format, r, g, b, a )
        Uint8 b 
        Uint8 a
        CODE:
-               RETVAL = SDL_MapRGBA(pixel_format,r,g,b,a);
+               Uint32 value = SDL_MapRGBA(pixel_format, r,g,b,a );
+               if(value > 0)  
+               { 
+                RETVAL = value; 
+               }
+               else
+               {
+               warn( "SDL_MapRGBA failed: %s", SDL_GetError() );
+               RETVAL = -1;  
+               }
+       
        OUTPUT:
                RETVAL