From 462c5723df73ba1cf4e017d39e210cf963a002c9 Mon Sep 17 00:00:00 2001 From: groogy Date: Thu, 11 Nov 2010 12:33:14 +0000 Subject: [PATCH] Finished VideoMode and changed some aliases in ContextSettings. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1634 4e206d99-4929-0410-ac5d-dfc041789085 --- .../sfml-window/window/ContextSettings.cpp | 12 +++++ .../ruby/sfml-window/window/VideoMode.cpp | 54 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/bindings/ruby/sfml-window/window/ContextSettings.cpp b/bindings/ruby/sfml-window/window/ContextSettings.cpp index b7c119335..631b63395 100644 --- a/bindings/ruby/sfml-window/window/ContextSettings.cpp +++ b/bindings/ruby/sfml-window/window/ContextSettings.cpp @@ -211,16 +211,28 @@ void Init_ContextSettings( void ) // Aliases rb_define_alias( globalContextSettingsClass, "depth", "depthBits" ); rb_define_alias( globalContextSettingsClass, "depth=", "depthBits=" ); + rb_define_alias( globalContextSettingsClass, "depth_bits", "depthBits" ); + rb_define_alias( globalContextSettingsClass, "depth_bits=", "depthBits=" ); rb_define_alias( globalContextSettingsClass, "stencil", "stencilBits" ); rb_define_alias( globalContextSettingsClass, "stencil=", "stencilBits=" ); + rb_define_alias( globalContextSettingsClass, "stencil_bits", "stencilBits" ); + rb_define_alias( globalContextSettingsClass, "stencil_bits=", "stencilBits=" ); rb_define_alias( globalContextSettingsClass, "antialiasing", "antialiasingLevel" ); rb_define_alias( globalContextSettingsClass, "antialiasing=", "antialiasingLevel=" ); + rb_define_alias( globalContextSettingsClass, "antialiasing_level", "antialiasingLevel" ); + rb_define_alias( globalContextSettingsClass, "antialiasing_level=", "antialiasingLevel=" ); rb_define_alias( globalContextSettingsClass, "major", "majorVersion" ); rb_define_alias( globalContextSettingsClass, "major=", "majorVersion=" ); + rb_define_alias( globalContextSettingsClass, "major_version", "majorVersion" ); + rb_define_alias( globalContextSettingsClass, "major_version=", "majorVersion=" ); rb_define_alias( globalContextSettingsClass, "minor", "minorVersion" ); rb_define_alias( globalContextSettingsClass, "minor=", "minorVersion=" ); + rb_define_alias( globalContextSettingsClass, "minor_version", "minorVersion" ); + rb_define_alias( globalContextSettingsClass, "minor_version=", "minorVersion=" ); + + } diff --git a/bindings/ruby/sfml-window/window/VideoMode.cpp b/bindings/ruby/sfml-window/window/VideoMode.cpp index a92c3b454..8e0f0d52c 100644 --- a/bindings/ruby/sfml-window/window/VideoMode.cpp +++ b/bindings/ruby/sfml-window/window/VideoMode.cpp @@ -65,6 +65,48 @@ static void VideoMode_Free( sf::VideoMode *anObject ) delete anObject; } +static VALUE VideoMode_GetWidth( VALUE self ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return INT2FIX( object->Width ); +} + +static VALUE VideoMode_SetWidth( VALUE self, VALUE aValue ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return INT2FIX( object->Width = NUM2UINT( aValue ) ); +} + +static VALUE VideoMode_GetHeight( VALUE self ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return INT2FIX( object->Height ); +} + +static VALUE VideoMode_SetHeight( VALUE self, VALUE aValue ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return INT2FIX( object->Height = NUM2UINT( aValue ) ); +} + +static VALUE VideoMode_GetBitsPerPixel( VALUE self ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return INT2FIX( object->BitsPerPixel ); +} + +static VALUE VideoMode_SetBitsPerPixel( VALUE self, VALUE aValue ) +{ + sf::VideoMode *object = NULL; + Data_Get_Struct( self, sf::VideoMode, object ); + return INT2FIX( object->BitsPerPixel = NUM2UINT( aValue ) ); +} + static VALUE VideoMode_GetDesktopMode( VALUE aKlass ) { sf::VideoMode *object = new sf::VideoMode( sf::VideoMode::GetDesktopMode() ); @@ -120,6 +162,18 @@ void Init_VideoMode( void ) rb_define_singleton_method( globalVideoModeClass, "getFullscreenModes", FUNCPTR( VideoMode_GetFullscreenModes ), 0 ); // Instance methods + rb_define_method( globalVideoModeClass, "width", FUNCPTR( VideoMode_GetWidth ), 0 ); + rb_define_method( globalVideoModeClass, "width=", FUNCPTR( VideoMode_SetWidth ), 1 ); + + rb_define_method( globalVideoModeClass, "height", FUNCPTR( VideoMode_GetWidth ), 0 ); + rb_define_method( globalVideoModeClass, "height=", FUNCPTR( VideoMode_SetWidth ), 1 ); + + rb_define_method( globalVideoModeClass, "bitsPerPixel", FUNCPTR( VideoMode_GetBitsPerPixel ), 0 ); + rb_define_method( globalVideoModeClass, "bitsPerPixel=", FUNCPTR( VideoMode_SetBitsPerPixel ), 1 ); // Aliases + rb_define_alias( globalVideoModeClass, "bits_per_pixel", "bitsPerPixel" ); + rb_define_alias( globalVideoModeClass, "bits_per_pixel=", "bitsPerPixel=" ); + rb_define_alias( globalVideoModeClass, "bpp", "bitsPerPixel" ); + rb_define_alias( globalVideoModeClass, "bpp=", "bitsPerPixel=" ); }