mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Also had forgotten two breaks in a switch-statement in View.cpp git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1727 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
4de4d0832c
commit
fef70e1280
@ -31,12 +31,18 @@ extern VALUE globalRenderTargetModule;
|
||||
extern VALUE globalImageClass;
|
||||
extern VALUE globalDrawableModule;
|
||||
extern VALUE globalShaderClass;
|
||||
extern VALUE globalViewClass;
|
||||
|
||||
static void RenderImage_Free( sf::RenderImage *anObject )
|
||||
{
|
||||
delete anObject;
|
||||
}
|
||||
|
||||
static void View_Free( sf::View *anObject )
|
||||
{
|
||||
delete anObject;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_image.create( width, height, depthBuffer = false ) -> true or false
|
||||
*
|
||||
@ -240,6 +246,60 @@ static VALUE RenderImage_SetSmooth( VALUE self, VALUE aSmoothFlag )
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.setView( view )
|
||||
*
|
||||
* Change the current active view.
|
||||
*
|
||||
* The new view will affect everything that is drawn, until another view is activated. The render target keeps its own
|
||||
* copy of the view object, so it is not necessary to keep the original one alive as long as it is in use. To restore
|
||||
* the original view of the target, you can pass the result of getDefaultView() to this function.
|
||||
*/
|
||||
static VALUE RenderImage_SetView( VALUE self, VALUE aView )
|
||||
{
|
||||
VALIDATE_CLASS( aView, globalViewClass, "view" );
|
||||
sf::View *view = NULL;
|
||||
sf::RenderImage *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderImage, object );
|
||||
Data_Get_Struct( aView, sf::View, view );
|
||||
object->SetView( *view );
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.getView() -> view
|
||||
*
|
||||
* Retrieve the view currently in use in the render target.
|
||||
*/
|
||||
static VALUE RenderImage_GetView( VALUE self )
|
||||
{
|
||||
sf::RenderImage *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderImage, object );
|
||||
const sf::View &original = object->GetView();
|
||||
sf::View * view = new sf::View( original );
|
||||
VALUE rbData = Data_Wrap_Struct( globalViewClass, 0, View_Free, view );
|
||||
rb_obj_call_init( rbData, 0, 0 );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.getDefaultView() -> VIEW
|
||||
*
|
||||
* Get the default view of the render target.
|
||||
*
|
||||
* The default view has the initial size of the render target, and never changes after the target has been created.
|
||||
*/
|
||||
static VALUE RenderImage_GetDefaultView( VALUE self )
|
||||
{
|
||||
sf::RenderImage *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderImage, object );
|
||||
const sf::View &original = object->GetDefaultView();
|
||||
sf::View * view = new sf::View( original );
|
||||
VALUE rbData = Data_Wrap_Struct( globalViewClass, 0, View_Free, view );
|
||||
rb_obj_call_init( rbData, 0, 0 );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* RenderImage.new() -> render_image
|
||||
*
|
||||
@ -347,6 +407,9 @@ void Init_RenderImage( void )
|
||||
rb_define_method( globalRenderImageClass, "isSmooth", RenderImage_IsSmooth, 0 );
|
||||
rb_define_method( globalRenderImageClass, "setActive", RenderImage_SetActive, -1 );
|
||||
rb_define_method( globalRenderImageClass, "setSmooth", RenderImage_SetSmooth, 1 );
|
||||
rb_define_method( globalRenderImageClass, "getView", RenderImage_GetView, 0 );
|
||||
rb_define_method( globalRenderImageClass, "setView", RenderImage_SetView, 1 );
|
||||
rb_define_method( globalRenderImageClass, "getDefaultView", RenderImage_GetDefaultView, 0 );
|
||||
|
||||
// Class Aliases
|
||||
rb_define_alias( CLASS_OF( globalRenderImageClass ), "is_available", "isAvailable" );
|
||||
@ -363,4 +426,10 @@ void Init_RenderImage( void )
|
||||
rb_define_alias( globalRenderImageClass, "active=", "setActive" );
|
||||
|
||||
rb_define_alias( globalRenderImageClass, "smooth=", "setSmooth" );
|
||||
|
||||
rb_define_alias( globalRenderImageClass, "view=", "setView" );
|
||||
rb_define_alias( globalRenderImageClass, "view", "getView" );
|
||||
|
||||
rb_define_alias( globalRenderImageClass, "defaultView", "getDefaultView" );
|
||||
rb_define_alias( globalRenderImageClass, "default_view", "getDefaultView" );
|
||||
}
|
||||
|
@ -38,6 +38,11 @@ extern VALUE globalDrawableModule;
|
||||
extern VALUE globalShaderClass;
|
||||
extern VALUE globalViewClass;
|
||||
|
||||
static VALUE View_Free( sf::View *anObject )
|
||||
{
|
||||
delete anObject;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.clear( color = SFML::Color::Black )
|
||||
*
|
||||
@ -178,10 +183,10 @@ static VALUE RenderTarget_GetView( VALUE self )
|
||||
{
|
||||
sf::RenderTarget *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderTarget, object );
|
||||
const sf::View &view = object->GetView();
|
||||
VALUE rbData = Data_Wrap_Struct( globalViewClass, 0, 0, const_cast< sf::View * >( &view ) );
|
||||
const sf::View &original = object->GetView();
|
||||
sf::View * view = new sf::View( original );
|
||||
VALUE rbData = Data_Wrap_Struct( globalViewClass, 0, View_Free, view );
|
||||
rb_obj_call_init( rbData, 0, 0 );
|
||||
rb_iv_set( rbData, "@__owner_ref", self );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
|
@ -31,12 +31,18 @@ extern VALUE globalRenderTargetModule;
|
||||
extern VALUE globalWindowClass;
|
||||
extern VALUE globalDrawableModule;
|
||||
extern VALUE globalShaderClass;
|
||||
extern VALUE globalViewClass;
|
||||
|
||||
static void RenderWindow_Free( sf::RenderWindow *anObject )
|
||||
{
|
||||
delete anObject;
|
||||
}
|
||||
|
||||
static void View_Free( sf::View *anObject )
|
||||
{
|
||||
delete anObject;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_window.draw( drawable )
|
||||
* render_window.draw( drawable, shader )
|
||||
@ -78,6 +84,60 @@ static VALUE RenderWindow_Draw( int argc, VALUE *args, VALUE self )
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.setView( view )
|
||||
*
|
||||
* Change the current active view.
|
||||
*
|
||||
* The new view will affect everything that is drawn, until another view is activated. The render target keeps its own
|
||||
* copy of the view object, so it is not necessary to keep the original one alive as long as it is in use. To restore
|
||||
* the original view of the target, you can pass the result of getDefaultView() to this function.
|
||||
*/
|
||||
static VALUE RenderWindow_SetView( VALUE self, VALUE aView )
|
||||
{
|
||||
VALIDATE_CLASS( aView, globalViewClass, "view" );
|
||||
sf::View *view = NULL;
|
||||
sf::RenderWindow *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderWindow, object );
|
||||
Data_Get_Struct( aView, sf::View, view );
|
||||
object->SetView( *view );
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.getView() -> view
|
||||
*
|
||||
* Retrieve the view currently in use in the render target.
|
||||
*/
|
||||
static VALUE RenderWindow_GetView( VALUE self )
|
||||
{
|
||||
sf::RenderWindow *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderWindow, object );
|
||||
const sf::View &original = object->GetView();
|
||||
sf::View * view = new sf::View( original );
|
||||
VALUE rbData = Data_Wrap_Struct( globalViewClass, 0, View_Free, view );
|
||||
rb_obj_call_init( rbData, 0, 0 );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* render_target.getDefaultView() -> VIEW
|
||||
*
|
||||
* Get the default view of the render target.
|
||||
*
|
||||
* The default view has the initial size of the render target, and never changes after the target has been created.
|
||||
*/
|
||||
static VALUE RenderWindow_GetDefaultView( VALUE self )
|
||||
{
|
||||
sf::RenderWindow *object = NULL;
|
||||
Data_Get_Struct( self, sf::RenderWindow, object );
|
||||
const sf::View &original = object->GetDefaultView();
|
||||
sf::View * view = new sf::View( original );
|
||||
VALUE rbData = Data_Wrap_Struct( globalViewClass, 0, View_Free, view );
|
||||
rb_obj_call_init( rbData, 0, 0 );
|
||||
return rbData;
|
||||
}
|
||||
|
||||
/* call-seq:
|
||||
* Window.new() -> render_window
|
||||
* Window.new( mode, title, style = SFML::Style::Default, settings = SFML::ContextSettings.new ) -> render_window
|
||||
@ -197,4 +257,14 @@ void Init_RenderWindow( void )
|
||||
|
||||
// Instance methods
|
||||
rb_define_method( globalRenderWindowClass, "draw", RenderWindow_Draw, -1 );
|
||||
rb_define_method( globalRenderWindowClass, "getView", RenderWindow_GetView, 0 );
|
||||
rb_define_method( globalRenderWindowClass, "setView", RenderWindow_SetView, 1 );
|
||||
rb_define_method( globalRenderWindowClass, "getDefaultView", RenderWindow_GetDefaultView, 0 );
|
||||
|
||||
// Alias
|
||||
rb_define_alias( globalRenderWindowClass, "view=", "setView" );
|
||||
rb_define_alias( globalRenderWindowClass, "view", "getView" );
|
||||
|
||||
rb_define_alias( globalRenderWindowClass, "defaultView", "getDefaultView" );
|
||||
rb_define_alias( globalRenderWindowClass, "default_view", "getDefaultView" );
|
||||
}
|
||||
|
@ -278,11 +278,13 @@ static VALUE View_SetSize( int argc, VALUE * args, VALUE self )
|
||||
VALUE temp = Vector2_ForceType( args[0] );
|
||||
x = NUM2DBL( Vector2_GetX( temp ) );
|
||||
y = NUM2DBL( Vector2_GetY( temp ) );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
x = NUM2DBL( args[0] );
|
||||
y = NUM2DBL( args[1] );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
rb_raise( rb_eArgError, "Expected 1 or 2 arguments but was given %d", argc );
|
||||
|
Loading…
Reference in New Issue
Block a user