diff --git a/bindings/ruby/sfml-graphics/graphics/Color.cpp b/bindings/ruby/sfml-graphics/graphics/Color.cpp index 042dcf1f8..1bc659fce 100644 --- a/bindings/ruby/sfml-graphics/graphics/Color.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Color.cpp @@ -296,12 +296,12 @@ void Init_Color( void ) 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 ) ) ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Black" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "White" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Red" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Green" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Blue" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Yellow" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Magneta" ) ), rb_intern( "freeze" ), 0 ); - rb_funcall( rb_cvar( globalColorClass, rb_intern( "Cyan" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Black" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "White" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Red" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Green" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Blue" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Yellow" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Magneta" ) ), rb_intern( "freeze" ), 0 ); + rb_funcall( rb_cvar_get( globalColorClass, rb_intern( "Cyan" ) ), rb_intern( "freeze" ), 0 ); } diff --git a/bindings/ruby/sfml-graphics/graphics/Drawable.cpp b/bindings/ruby/sfml-graphics/graphics/Drawable.cpp index ad481022f..05a0fcd5b 100644 --- a/bindings/ruby/sfml-graphics/graphics/Drawable.cpp +++ b/bindings/ruby/sfml-graphics/graphics/Drawable.cpp @@ -611,7 +611,7 @@ void Init_Drawable( void ) globalDrawableModule = rb_define_module_under( sfml, "Drawable" ); // Class methods - rb_define_module_method( globalDrawableModule, "included", Drawable_Included, 1 ); + rb_define_module_function( globalDrawableModule, "included", Drawable_Included, 1 ); // Instance methods rb_define_method( globalDrawableModule, "initialize", Drawable_Initialize, -1 ); diff --git a/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp b/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp index dc20b0d5d..53a2d5755 100644 --- a/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp +++ b/bindings/ruby/sfml-graphics/graphics/RenderTarget.cpp @@ -25,12 +25,13 @@ #include "main.hpp" #include #include -#include +#include VALUE globalRenderTargetModule; VALUE globalRenderTargetInstanceClass; /* External classes */ +extern VALUE globalRenderWindowClass; extern VALUE globalVector2Class; extern VALUE globalRectClass; extern VALUE globalDrawableModule; @@ -83,7 +84,20 @@ static VALUE RenderTarget_Draw( int argc, VALUE *args, VALUE self ) { sf::RenderTarget *object = NULL; Data_Get_Struct( self, sf::RenderTarget, object ); - std::cout << object << std::endl; + + VALUE targetWrap = Qnil; + sf::RenderWindow *window = NULL; + sf::RenderImage *image = NULL; + + if( CLASS_OF( self ) == globalRenderWindowClass ) + { + Data_Get_Struct( self, sf::RenderWindow, window ); + } + else + { + Data_Get_Struct( self, sf::RenderImage, image ); + } + switch( argc ) { case 2: @@ -94,7 +108,7 @@ static VALUE RenderTarget_Draw( int argc, VALUE *args, VALUE self ) Data_Get_Struct( args[0], sf::Drawable, drawable ); sf::Shader *shader = NULL; Data_Get_Struct( args[1], sf::Shader, shader ); - object->Draw( *drawable, *shader ); + ( window != NULL ? window->Draw( *drawable, *shader ) : image->Draw( *drawable, *shader ) ); break; } case 1: @@ -102,7 +116,7 @@ static VALUE RenderTarget_Draw( int argc, VALUE *args, VALUE self ) VALIDATE_CLASS( args[0], globalDrawableModule, "object" ); sf::Drawable *drawable = NULL; Data_Get_Struct( args[0], sf::Drawable, drawable ); - object->Draw( *drawable ); + ( window != NULL ? window->Draw( *drawable ) : image->Draw( *drawable ) ); break; } default: