From 738b02c308b5a26f4f71aa9793133c55a36856a4 Mon Sep 17 00:00:00 2001 From: groogy Date: Fri, 19 Nov 2010 14:29:21 +0000 Subject: [PATCH] Well I made a test to check if Drawable worked, and it didn't... I had made some really bad mistakes but they are fixed now and the drawable test is working currently. Though it will be extended with functionality to render too. Will have to wait with that test for now as the function is actually not finished. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1680 4e206d99-4929-0410-ac5d-dfc041789085 --- bindings/ruby/sfml-graphics/graphics/Color.cpp | 16 ++++++++-------- .../ruby/sfml-graphics/graphics/Drawable.cpp | 6 ------ bindings/ruby/sfml-graphics/graphics/main.cpp | 4 ++-- bindings/ruby/testing/drawable-mixin.rb | 10 ++++++++++ 4 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 bindings/ruby/testing/drawable-mixin.rb diff --git a/bindings/ruby/sfml-graphics/graphics/Color.cpp b/bindings/ruby/sfml-graphics/graphics/Color.cpp index 2a99036d..d931fa17 100644 --- a/bindings/ruby/sfml-graphics/graphics/Color.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Color.cpp @@ -248,12 +248,12 @@ void Init_Color( void ) rb_define_attr( globalColorClass, "a", 1, 1 ); // Class constants - rb_define_const( globalColorClass, "Black", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 0, 0, 0 ) ); - rb_define_const( globalColorClass, "White", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 255, 255, 255 ) ); - rb_define_const( globalColorClass, "Red", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 255, 0, 0 ) ); - rb_define_const( globalColorClass, "Green", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 0, 255, 0 ) ); - rb_define_const( globalColorClass, "Blue", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 0, 0, 255 ) ); - rb_define_const( globalColorClass, "Yellow", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 255, 255, 0 ) ); - rb_define_const( globalColorClass, "Magneta", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 255, 0, 255 ) ); - rb_define_const( globalColorClass, "Cyan", rb_funcall( globalColorClass, rb_intern( "new" ), 3, 0, 255, 255 ) ); + rb_define_const( globalColorClass, "Black", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 0 ), INT2FIX( 0 ) ) ); + rb_define_const( globalColorClass, "White", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 255 ), INT2FIX( 255 ) ) ); + rb_define_const( globalColorClass, "Red", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 0 ), INT2FIX( 0 ) ) ); + rb_define_const( globalColorClass, "Green", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 255 ), INT2FIX( 0 ) ) ); + rb_define_const( globalColorClass, "Blue", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 0 ), INT2FIX( 255 ) ) ); + rb_define_const( globalColorClass, "Yellow", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 255 ), INT2FIX( 0 ) ) ); + rb_define_const( globalColorClass, "Magneta", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 255 ), INT2FIX( 0 ), INT2FIX( 255 ) ) ); + rb_define_const( globalColorClass, "Cyan", rb_funcall( globalColorClass, rb_intern( "new" ), 3, INT2FIX( 0 ), INT2FIX( 255 ), INT2FIX( 255 ) ) ); } diff --git a/bindings/ruby/sfml-graphics/graphics/Drawable.cpp b/bindings/ruby/sfml-graphics/graphics/Drawable.cpp index db273f95..5ca34c94 100644 --- a/bindings/ruby/sfml-graphics/graphics/Drawable.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Drawable.cpp @@ -486,20 +486,14 @@ void Init_Drawable( void ) rb_define_alias( globalDrawableModule, "position=", "setPosition" ); rb_define_alias( globalDrawableModule, "position", "getPosition" ); rb_define_alias( globalDrawableModule, "x=", "setX" ); - rb_define_alias( globalDrawableModule, "x", "getX" ); rb_define_alias( globalDrawableModule, "y=", "setY" ); - rb_define_alias( globalDrawableModule, "y", "getY" ); rb_define_alias( globalDrawableModule, "scale=", "setScale" ); rb_define_alias( globalDrawableModule, "scale", "getScale" ); rb_define_alias( globalDrawableModule, "scaleX=", "setScaleX" ); - rb_define_alias( globalDrawableModule, "scaleX", "getScaleX" ); rb_define_alias( globalDrawableModule, "scale_x=", "setScaleX" ); - rb_define_alias( globalDrawableModule, "scale_x", "getScaleX" ); rb_define_alias( globalDrawableModule, "scaleY=", "setScaleY" ); - rb_define_alias( globalDrawableModule, "scaleY", "getScaleY" ); rb_define_alias( globalDrawableModule, "scale_y=", "setScaleY" ); - rb_define_alias( globalDrawableModule, "scale_y", "getScaleY" ); rb_define_alias( globalDrawableModule, "origin=", "setOrigin" ); rb_define_alias( globalDrawableModule, "origin", "getOrigin" ); diff --git a/bindings/ruby/sfml-graphics/graphics/main.cpp b/bindings/ruby/sfml-graphics/graphics/main.cpp index 10c84777..7214d3e3 100644 --- a/bindings/ruby/sfml-graphics/graphics/main.cpp +++ b/bindings/ruby/sfml-graphics/graphics/main.cpp @@ -48,6 +48,7 @@ static bool CheckDependencies( void ) /* Available blending modes for drawable objects. */ static void CreateBlendEnum( void ) { + globalBlendNamespace = rb_define_module_under( globalSFMLNamespace, "Blend" ); rb_define_const( globalBlendNamespace, "Alpha", INT2FIX( sf::Blend::Alpha ) ); rb_define_const( globalBlendNamespace, "Add", INT2FIX( sf::Blend::Add ) ); rb_define_const( globalBlendNamespace, "Multiply", INT2FIX( sf::Blend::Multiply ) ); @@ -65,11 +66,10 @@ void Init_graphics( void ) globalVector2Class = RetrieveSFMLClass( "Vector2" ); globalVector3Class = RetrieveSFMLClass( "Vector3" ); globalWindowClass = RetrieveSFMLClass( "Window" ); + rb_define_const(globalSFMLNamespace, "GraphicsLoaded", Qtrue); CreateBlendEnum(); - rb_define_const(globalSFMLNamespace, "GraphicsLoaded", Qtrue); - Init_Color(); Init_Rect(); Init_Drawable(); diff --git a/bindings/ruby/testing/drawable-mixin.rb b/bindings/ruby/testing/drawable-mixin.rb new file mode 100644 index 00000000..9de44550 --- /dev/null +++ b/bindings/ruby/testing/drawable-mixin.rb @@ -0,0 +1,10 @@ +require 'sfml/system' +require 'sfml/window' +require 'sfml/graphics' + +class MyDrawable + include SFML::Drawable +end + +drawable = MyDrawable.new +p drawable.position