lib/sdl: add access to texture pixels and alpha mask
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 17 Dec 2014 15:48:00 +0000 (10:48 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 14 Jan 2015 13:47:15 +0000 (08:47 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/sdl.nit

index 26ae459..168f123 100644 (file)
@@ -21,6 +21,7 @@ module sdl is
 end
 
 import mnit_display
+import c
 
 in "C header" `{
        #include <unistd.h>
@@ -244,6 +245,12 @@ extern class SDLImage
        redef fun height: Int `{ return recv->h; `}
 
        fun is_ok: Bool do return not address_is_null
+
+       # Returns a reference to the pixels of the texture
+       fun pixels: NativeCByteArray `{ return recv->pixels; `}
+
+       # Does this texture has an alpha mask?
+       fun amask: Bool `{ return recv->format->Amask; `}
 end
 
 # A simple rectangle