mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
Fixed some mistakes on my behalf and possibly the sf::RenderTarget::Draw segmentation fault. And I did it without dynamic cast!
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1717 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
90a61a6048
commit
2f46c7a85b
@ -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 );
|
||||
}
|
||||
|
@ -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 );
|
||||
|
@ -25,12 +25,13 @@
|
||||
#include "main.hpp"
|
||||
#include <SFML/Graphics/RenderTarget.hpp>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <iostream>
|
||||
#include <SFML/Graphics/RenderImage.hpp>
|
||||
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user