From 989521b63524591ad46569ed20d96de509081cb1 Mon Sep 17 00:00:00 2001 From: Kartik Thakore Date: Sun, 11 Aug 2013 18:09:00 -0400 Subject: [PATCH] Added all the pixel formats enum. Might have to move them later. WIP #2 --- lib/SDL2/Constants.pm | 40 +++++++ src/Core/Constants.xs | 250 ++++++++++++++++++++++++++++++++++++++++++ t/106_sdl2_texture.t | 9 +- 3 files changed, 296 insertions(+), 3 deletions(-) diff --git a/lib/SDL2/Constants.pm b/lib/SDL2/Constants.pm index 6fc1d47..a0401fc 100644 --- a/lib/SDL2/Constants.pm +++ b/lib/SDL2/Constants.pm @@ -96,6 +96,46 @@ our %EXPORT_TAGS = ( SDL_TEXTUREACCESS_STATIC SDL_TEXTUREACCESS_STREAMING ) + ], + 'SDL2::Texture/pixelformat' => [ + qw( + SDL_PIXELFORMAT_UNKNOWN + SDL_PIXELFORMAT_INDEX1LSB + SDL_PIXELFORMAT_INDEX1MSB + SDL_PIXELFORMAT_INDEX4LSB + SDL_PIXELFORMAT_INDEX4MSB + SDL_PIXELFORMAT_INDEX8 + SDL_PIXELFORMAT_RGB332 + SDL_PIXELFORMAT_RGB444 + SDL_PIXELFORMAT_RGB555 + SDL_PIXELFORMAT_BGR555 + SDL_PIXELFORMAT_ARGB4444 + SDL_PIXELFORMAT_RGBA4444 + SDL_PIXELFORMAT_ABGR4444 + SDL_PIXELFORMAT_BGRA4444 + SDL_PIXELFORMAT_ARGB1555 + SDL_PIXELFORMAT_RGBA5551 + SDL_PIXELFORMAT_ABGR1555 + SDL_PIXELFORMAT_BGRA5551 + SDL_PIXELFORMAT_RGB565 + SDL_PIXELFORMAT_BGR565 + SDL_PIXELFORMAT_RGB24 + SDL_PIXELFORMAT_BGR24 + SDL_PIXELFORMAT_RGB888 + SDL_PIXELFORMAT_RGBX8888 + SDL_PIXELFORMAT_BGR888 + SDL_PIXELFORMAT_BGRX8888 + SDL_PIXELFORMAT_ARGB8888 + SDL_PIXELFORMAT_RGBA8888 + SDL_PIXELFORMAT_ABGR8888 + SDL_PIXELFORMAT_BGRA8888 + SDL_PIXELFORMAT_ARGB2101010 + SDL_PIXELFORMAT_YV12 + SDL_PIXELFORMAT_IYUV + SDL_PIXELFORMAT_YUY2 + SDL_PIXELFORMAT_UYVY + SDL_PIXELFORMAT_YVYU + ) ] ); diff --git a/src/Core/Constants.xs b/src/Core/Constants.xs index 7d3f958..7fc05f5 100644 --- a/src/Core/Constants.xs +++ b/src/Core/Constants.xs @@ -27,4 +27,254 @@ constant_SDL_TEXTUREACCESS_STREAMING ( ) OUTPUT: RETVAL +int +constant_SDL_PIXELFORMAT_UNKNOWN () + CODE: + RETVAL = SDL_PIXELFORMAT_UNKNOWN; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_INDEX1LSB () + CODE: + RETVAL = SDL_PIXELFORMAT_INDEX1LSB; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_INDEX1MSB () + CODE: + RETVAL = SDL_PIXELFORMAT_INDEX1MSB; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_INDEX4LSB () + CODE: + RETVAL = SDL_PIXELFORMAT_INDEX4LSB; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_INDEX4MSB () + CODE: + RETVAL = SDL_PIXELFORMAT_INDEX4MSB; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_INDEX8 () + CODE: + RETVAL = SDL_PIXELFORMAT_INDEX8; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGB332 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGB332; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGB444 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGB444; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGB555 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGB555; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGR555 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGR555; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ARGB4444 () + CODE: + RETVAL = SDL_PIXELFORMAT_ARGB4444; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGBA4444 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGBA4444; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ABGR4444 () + CODE: + RETVAL = SDL_PIXELFORMAT_ABGR4444; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGRA4444 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGRA4444; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ARGB1555 () + CODE: + RETVAL = SDL_PIXELFORMAT_ARGB1555; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGBA5551 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGBA5551; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ABGR1555 () + CODE: + RETVAL = SDL_PIXELFORMAT_ABGR1555; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGRA5551 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGRA5551; + OUTPUT: + RETVAL +int +constant_SDL_PIXELFORMAT_RGB565 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGB565; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGR565 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGR565; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGB24 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGB24; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGR24 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGR24; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGB888 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGB888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGBX8888 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGBX8888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGR888 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGR888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGRX8888 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGRX8888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ARGB8888 () + CODE: + RETVAL = SDL_PIXELFORMAT_ARGB8888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_RGBA8888 () + CODE: + RETVAL = SDL_PIXELFORMAT_RGBA8888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ABGR8888 () + CODE: + RETVAL = SDL_PIXELFORMAT_ABGR8888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_BGRA8888 () + CODE: + RETVAL = SDL_PIXELFORMAT_BGRA8888; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_ARGB2101010 () + CODE: + RETVAL = SDL_PIXELFORMAT_ARGB2101010; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_YV12 () + CODE: + RETVAL = SDL_PIXELFORMAT_YV12; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_IYUV () + CODE: + RETVAL = SDL_PIXELFORMAT_IYUV; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_YUY2 () + CODE: + RETVAL = SDL_PIXELFORMAT_YUY2; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_UYVY () + CODE: + RETVAL = SDL_PIXELFORMAT_UYVY; + OUTPUT: + RETVAL + +int +constant_SDL_PIXELFORMAT_YVYU () + CODE: + RETVAL = SDL_PIXELFORMAT_YVYU; + OUTPUT: + RETVAL diff --git a/t/106_sdl2_texture.t b/t/106_sdl2_texture.t index 6707e6e..5bc777a 100644 --- a/t/106_sdl2_texture.t +++ b/t/106_sdl2_texture.t @@ -1,4 +1,4 @@ -use Test::More tests => 2; +use Test::More tests => 3; use SDL2pp; use SDL2::Window; use SDL2::Renderer; @@ -22,10 +22,13 @@ my $renderer = SDL2::Renderer->new($win, -1, SDL_RENDERER_SOFTWARE); #Hardware a can_ok('SDL2::Texture', qw/new/); -my $texture = SDL2::Texture->new($renderer, 0, SDL_TEXTUREACCESS_STATIC, 100, 100); +my $texture = SDL2::Texture->new($renderer, SDL_PIXELFORMAT_RGB332, SDL_TEXTUREACCESS_STATIC, 100, 100); fail( SDL2pp::get_error() ) unless $texture; -my $texture2 = SDL2::Texture->new($renderer, 0, SDL_TEXTUREACCESS_STREAMING, 100, 100); +my $texture2 = SDL2::Texture->new($renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 100, 100); fail( SDL2pp::get_error() ) unless $texture2; isa_ok($texture, 'SDL2::Texture'); +isa_ok($texture2, 'SDL2::Texture'); + +