From: Tobias Leich Date: Fri, 27 Nov 2009 16:16:36 +0000 (+0100) Subject: docs for video X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=sdlgit%2FSDL-Site.git;a=commitdiff_plain;h=3774ca11c8c51b4784c7ada3a5b536c38f45447a docs for video --- diff --git a/htdocs/assets/Mouse.png b/htdocs/assets/Mouse.png new file mode 100644 index 0000000..73b42e6 Binary files /dev/null and b/htdocs/assets/Mouse.png differ diff --git a/htdocs/assets/Video.png b/htdocs/assets/Video.png new file mode 100644 index 0000000..921e25f Binary files /dev/null and b/htdocs/assets/Video.png differ diff --git a/htdocs/assets/Video_thumb.png b/htdocs/assets/Video_thumb.png new file mode 100644 index 0000000..c05ea9f Binary files /dev/null and b/htdocs/assets/Video_thumb.png differ diff --git a/pages/SDL-Mouse.html-inc b/pages/SDL-Mouse.html-inc index 46cbaf4..ecb828d 100644 --- a/pages/SDL-Mouse.html-inc +++ b/pages/SDL-Mouse.html-inc @@ -13,7 +13,7 @@
- +Mouse.png

NAME

Top

diff --git a/pages/SDL-Video.html-inc b/pages/SDL-Video.html-inc index 24a3f59..56f9900 100644 --- a/pages/SDL-Video.html-inc +++ b/pages/SDL-Video.html-inc @@ -58,7 +58,7 @@
- +Video.png

NAME

Top

@@ -558,24 +558,91 @@ SDL::get_gamma_ramp returns -1 on error.

set_gamma_ramp(rt,gt,bt)

-

Sets the gamma lookup tables for the display for each color component. Each table is an array of 256 Uint16 values, representing a +

 $set_gamma_ramp = SDL::Video::set_gamma_ramp( \@red_table, \@green_table, \@blue_table );
+
+
+

Sets the gamma lookup tables for the display for each color component. Each table is an array ref of 256 Uint16 values, representing a mapping between the input and output for that channel. The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision. You may pass NULL to any of the channels to leave them unchanged.

This function adjusts the gamma based on lookup tables, you can also have the gamma calculated based on a "gamma function" parameter -with SDL::set_gamma.

+with SDL::Video::set_gamma.

Not all display hardware is able to change gamma. -SDL::set_gamma_ramp returns -1 on error.

+SDL::Video::set_gamma_ramp returns -1 on error (or if gamma adjustment is not supported).

+

Example:

+
 use SDL;
+ use SDL::Video;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my (@red, @green, @blue);
+
+ my $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue );
+
+ $red[127] = 0xFF00;
+
+    $ret = SDL::Video::set_gamma_ramp( \@red, \@green, \@blue );
+
+    $ret = SDL::Video::get_gamma_ramp( \@red, \@green, \@blue );
+
+ if( -1 == $ret )
+ {
+     print( "an error occoured" );
+ }
+ else
+ {
+     printf( "for gamma = 1.0: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[255], $green[255], $blue[255] );
+     printf( "for gamma = 0.5: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[127], $green[127], $blue[127] );
+     printf( "for gamma = 0.0: red=0x%04X, green=0x%04X, blue=0x%04X\n", $red[0],   $green[0],   $blue[0]   );
+ }
+
+ SDL::quit();
+
+

map_RGB(pixel_format,r,g,b)

-

Maps the RGB color value to the specified SDL::pixel_format and returns the pixel value as a 32-bit int. +

 $pixel = SDL::Video::map_RGB( $pixel_format, $r, $g, $b );
+
+
+

Maps the RGB color value to the specified SDL::PixelFormat and returns the pixel value as a 32-bit int. If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned. If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

-

SDL::map_RGP returns a pixel value best approximating the given RGB color value for a given pixel format. -If the SDL::pixel_format's bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored +

SDL::Video::map_RGB returns a pixel value best approximating the given RGB color value for a given pixel format. +If the SDL::PixelFormat's bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

+
 use SDL;
+ use SDL::Video;
+ use SDL::PixelFormat;
+ use SDL::Surface;
+
+ SDL::init(SDL_INIT_VIDEO);
+
+ my $screen_surface = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
+ #                                                          ^-- 16 bits per pixel
+
+ $r = 0x9C;
+ $g = 0xDC;
+ $b = 0x67;
+
+ printf( "for 24bpp it is: 0x%02X 0x%02X 0x%02X\n", $r, $g, $b);
+
+ my $_16bit = SDL::Video::map_RGB( $screen_surface->format, $r, $g, $b );
+
+ # 16bpp is 5 bits red, 6 bits green and 5 bits blue
+ # we will obtain the values for each color and calculating them back to 24bit color system
+ $r = (($_16bit & 0b1111100000000000) >> 11) / 0b11111  * 0b11111111;
+ $g = (($_16bit & 0b0000011111100000) >>  5) / 0b111111 * 0b11111111;
+ $b =  ($_16bit & 0b0000000000011111)        / 0b11111  * 0b11111111;
+
+ printf( "for 16bpp it is: 0x%02X 0x%02X 0x%02X\n", $r, $g, $b );
+
+ # so color #9CDC67 becomes #9CDE62
+
+ SDL::quit();
+
+

map_RGBA(pixel_format,r,g,b,a)

diff --git a/pages/documentation.html-inc b/pages/documentation.html-inc index cd5dbbe..3ffbeee 100644 --- a/pages/documentation.html-inc +++ b/pages/documentation.html-inc @@ -1,2 +1,2 @@
-

Documentation (latest development branch)

Core
thumbSDL- Simple DirectMedia Layer for Perl
Structure
thumbSDL::AudioCVT- Audio Conversion Structure
thumbSDL::AudioSpec- SDL Bindings for structure SDL::AudioSpec
CDROM
thumbSDL::CDROM- SDL Bindings for the CDROM device
Structure
thumbSDL::CD- SDL Bindings for structure SDL_CD
thumbSDL::CDTrack- SDL Bindings for structure SDL_CDTrack
Events
thumbSDL::Events- Bindings to the Events Category in SDL API
Structure
thumbSDL::Event- General event structure
Joystick
thumbSDL::Joystick- SDL Bindings for the Joystick device
Structure
thumbSDL::Mixer::MixChunk- SDL Bindings for structure SDL_MixChunk
Mouse
thumbSDL::Mouse- SDL Bindings for the Mouse device
Structure
thumbSDL::Cursor- Mouse cursor structure
MultiThread
thumbSDL::MultiThread- Bindings to the MultiThread category in SDL API
Structure
thumbSDL::Version- SDL Bindings for structure SDL_Version
Video
thumbSDL::Video- Bindings to the video category in SDL API
Structure
thumbSDL::Color- Format independent color description
thumbSDL::Overlay- YUV Video overlay
thumbSDL::Palette- Color palette for 8-bit pixel formats
thumbSDL::PixelFormat- Stores surface format information
thumbSDL::Rect- Defines a rectangular area
thumbSDL::Surface- Graphic surface structure.
thumbSDL::VideoInfo- Video Target Information

Cookbook
thumbSDL::Cookbook
thumbSDL::Cookbook::PDL

Extension
thumbSDL::App- a SDL perl extension

Mixer
thumbSDL::Mixer- a SDL perl extension
TODO
Core
Audio
thumbSDL::Audio- SDL Bindings for Audio
Structure
thumbSDL::Mixer::MixMusic- SDL Bindings for structure SDL_MixMusic
Structure
thumbSDL::RWOps- SDL Bindings to SDL_RWOPs

Tutorials
thumbSDL::Tutorial- introduction to Perl SDL
thumbSDL::Tutorial::Animation
thumbSDL::Tutorial::Images
thumbSDL::Tutorial::LunarLander- a small tutorial on Perl SDL
thumbSDL::Tutorial::Pong
thumbSDL::Tutorial::Tetris

UNCATEGORIZED
thumbSDL::Font- a SDL perl extension
thumbSDL::Game::Palette- a perl extension
thumbSDL::MPEG- a SDL perl extension
thumbSDL::Music- a perl extension
thumbSDL::OpenGL- a perl extension
thumbSDL::SFont- a perl extension
thumbSDL::SMPEG- a SDL perl extension
thumbSDL::Sound- a perl extension
thumbSDL::TTFont- a SDL perl extension
thumbSDL::Timer- a SDL perl extension for managing timers.
thumbSDL::Tool::Font- a perl extension
thumbSDL::Tool::Graphic
thumbSDL::old-cdrom- a SDL perl extension for managing CD-ROM drives
+

Documentation (latest development branch)

Core
thumbSDL- Simple DirectMedia Layer for Perl
Structure
thumbSDL::AudioCVT- Audio Conversion Structure
thumbSDL::AudioSpec- SDL Bindings for structure SDL::AudioSpec
CDROM
thumbSDL::CDROM- SDL Bindings for the CDROM device
Structure
thumbSDL::CD- SDL Bindings for structure SDL_CD
thumbSDL::CDTrack- SDL Bindings for structure SDL_CDTrack
Events
thumbSDL::Events- Bindings to the Events Category in SDL API
Structure
thumbSDL::Event- General event structure
Joystick
thumbSDL::Joystick- SDL Bindings for the Joystick device
Structure
thumbSDL::Mixer::MixChunk- SDL Bindings for structure SDL_MixChunk
Mouse
thumbSDL::Mouse- SDL Bindings for the Mouse device
Structure
thumbSDL::Cursor- Mouse cursor structure
MultiThread
thumbSDL::MultiThread- Bindings to the MultiThread category in SDL API
Structure
thumbSDL::Version- SDL Bindings for structure SDL_Version
Video
thumbSDL::Video- Bindings to the video category in SDL API
Structure
thumbSDL::Color- Format independent color description
thumbSDL::Overlay- YUV Video overlay
thumbSDL::Palette- Color palette for 8-bit pixel formats
thumbSDL::PixelFormat- Stores surface format information
thumbSDL::Rect- Defines a rectangular area
thumbSDL::Surface- Graphic surface structure.
thumbSDL::VideoInfo- Video Target Information

Cookbook
thumbSDL::Cookbook
thumbSDL::Cookbook::PDL

Extension
thumbSDL::App- a SDL perl extension

Mixer
thumbSDL::Mixer- a SDL perl extension
TODO
Core
Audio
thumbSDL::Audio- SDL Bindings for Audio
Structure
thumbSDL::Mixer::MixMusic- SDL Bindings for structure SDL_MixMusic
Structure
thumbSDL::RWOps- SDL Bindings to SDL_RWOPs

Tutorials
thumbSDL::Tutorial- introduction to Perl SDL
thumbSDL::Tutorial::Animation
thumbSDL::Tutorial::Images
thumbSDL::Tutorial::LunarLander- a small tutorial on Perl SDL
thumbSDL::Tutorial::Pong
thumbSDL::Tutorial::Tetris

UNCATEGORIZED
thumbSDL::Font- a SDL perl extension
thumbSDL::Game::Palette- a perl extension
thumbSDL::MPEG- a SDL perl extension
thumbSDL::Music- a perl extension
thumbSDL::OpenGL- a perl extension
thumbSDL::SFont- a perl extension
thumbSDL::SMPEG- a SDL perl extension
thumbSDL::Sound- a perl extension
thumbSDL::TTFont- a SDL perl extension
thumbSDL::Timer- a SDL perl extension for managing timers.
thumbSDL::Tool::Font- a perl extension
thumbSDL::Tool::Graphic
thumbSDL::old-cdrom- a SDL perl extension for managing CD-ROM drives