FS#144 - Implement copy "constructors" in CSFML

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1320 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-01-05 17:52:56 +00:00
parent da44e3d8e5
commit bc6beac402
38 changed files with 379 additions and 48 deletions

View File

@ -41,6 +41,16 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfSound* sfSound_Create(); CSFML_API sfSound* sfSound_Create();
////////////////////////////////////////////////////////////
/// Copy an existing sound
///
/// \param sound : Sound to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSound* sfSound_Copy(sfSound* sound);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing sound /// Destroy an existing sound
/// ///

View File

@ -68,6 +68,16 @@ CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const char* data, size_t
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate); CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// Copy an existing sound buffer
///
/// \param soundBuffer : Sound buffer to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing sound buffer /// Destroy an existing sound buffer
/// ///

View File

@ -53,6 +53,16 @@ CSFML_API sfFont* sfFont_CreateFromFile(const char* filename);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfFont* sfFont_CreateFromMemory(const char* data, size_t sizeInBytes); CSFML_API sfFont* sfFont_CreateFromMemory(const char* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Copy an existing font
///
/// \param font : Font to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfFont* sfFont_Copy(sfFont* font);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing font /// Destroy an existing font
/// ///

View File

@ -87,6 +87,16 @@ CSFML_API sfImage* sfImage_CreateFromFile(const char* filename);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromMemory(const char* data, size_t sizeInBytes); CSFML_API sfImage* sfImage_CreateFromMemory(const char* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Copy an existing image
///
/// \param image : Image to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_Copy(sfImage* image);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing image /// Destroy an existing image
/// ///
@ -128,7 +138,7 @@ CSFML_API void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfU
/// \param sourceRect : Sub-rectangle of the source image to copy /// \param sourceRect : Sub-rectangle of the source image to copy
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API void sfImage_Copy(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect); CSFML_API void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create the image from the current contents of the /// Create the image from the current contents of the

View File

@ -52,6 +52,16 @@ CSFML_API sfShader* sfShader_CreateFromFile(const char* filename);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromMemory(const char* effect); CSFML_API sfShader* sfShader_CreateFromMemory(const char* effect);
////////////////////////////////////////////////////////////
/// Copy an existing shader
///
/// \param shader : Shader to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_Copy(sfShader* shader);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing shader /// Destroy an existing shader
/// ///

View File

@ -79,6 +79,16 @@ CSFML_API sfShape* sfShape_CreateRectangle(float p1x, float p1y, float p2x, floa
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, float outline, sfColor outlineColor); CSFML_API sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, float outline, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Copy an existing shape
///
/// \param shape : Shape to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_Copy(sfShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing Shape /// Destroy an existing Shape
/// ///

View File

@ -43,6 +43,16 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfSprite* sfSprite_Create(); CSFML_API sfSprite* sfSprite_Create();
////////////////////////////////////////////////////////////
/// Copy an existing sprite
///
/// \param sprite : Sprite to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSprite* sfSprite_Copy(sfSprite* sprite);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing sprite /// Destroy an existing sprite
/// ///

View File

@ -55,6 +55,16 @@ typedef enum
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfText* sfText_Create(); CSFML_API sfText* sfText_Create();
////////////////////////////////////////////////////////////
/// Copy an existing text
///
/// \param text : Text to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfText* sfText_Copy(sfText* text);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing text /// Destroy an existing text
/// ///

View File

@ -47,6 +47,16 @@ CSFML_API sfView* sfView_Create();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfView* sfView_CreateFromRect(sfFloatRect rectangle); CSFML_API sfView* sfView_CreateFromRect(sfFloatRect rectangle);
////////////////////////////////////////////////////////////
/// Copy an existing view
///
/// \param view : View to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfView* sfView_Copy(sfView* view);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing view /// Destroy an existing view
/// ///

View File

@ -40,6 +40,16 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfPacket* sfPacket_Create(); CSFML_API sfPacket* sfPacket_Create();
////////////////////////////////////////////////////////////
/// Copy an existing packet
///
/// \param packet : Packet to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfPacket* sfPacket_Copy(sfPacket* packet);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing packet /// Destroy an existing packet
/// ///

View File

@ -41,6 +41,17 @@
CSFML_API sfSelectorTCP* sfSelectorTCP_Create(); CSFML_API sfSelectorTCP* sfSelectorTCP_Create();
CSFML_API sfSelectorUDP* sfSelectorUDP_Create(); CSFML_API sfSelectorUDP* sfSelectorUDP_Create();
////////////////////////////////////////////////////////////
/// Copy an existing selector
///
/// \param selector : Selector to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSelectorTCP* sfSelectorTCP_Copy(sfSelectorTCP* selector);
CSFML_API sfSelectorUDP* sfSelectorUDP_Copy(sfSelectorUDP* selector);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing selector /// Destroy an existing selector
/// ///

View File

@ -42,6 +42,16 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfSocketTCP* sfSocketTCP_Create(); CSFML_API sfSocketTCP* sfSocketTCP_Create();
////////////////////////////////////////////////////////////
/// Copy an existing TCP socket
///
/// \param socket : Socket to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSocketTCP* sfSocketTCP_Copy(sfSocketTCP* socket);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing TCP socket /// Destroy an existing TCP socket
/// ///

View File

@ -42,6 +42,16 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfSocketUDP* sfSocketUDP_Create(); CSFML_API sfSocketUDP* sfSocketUDP_Create();
////////////////////////////////////////////////////////////
/// Copy an existing UDP socket
///
/// \param socket : Socket to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSocketUDP* sfSocketUDP_Copy(sfSocketUDP* socket);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing UDP socket /// Destroy an existing UDP socket
/// ///

View File

@ -40,6 +40,16 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfClock* sfClock_Create(); CSFML_API sfClock* sfClock_Create();
////////////////////////////////////////////////////////////
/// Copy an existing clock
///
/// \param clock : Clock to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfClock* sfClock_Copy(sfClock* clock);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing clock /// Destroy an existing clock
/// ///

View File

@ -39,6 +39,17 @@ sfSound* sfSound_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing sound
////////////////////////////////////////////////////////////
sfSound* sfSound_Copy(sfSound* sound)
{
CSFML_CHECK_RETURN(sound, NULL);
return new sfSound(*sound);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing sound /// Destroy an existing sound
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -83,6 +83,17 @@ sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t sa
} }
////////////////////////////////////////////////////////////
/// Copy an existing sound buffer
////////////////////////////////////////////////////////////
sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer)
{
CSFML_CHECK_RETURN(soundBuffer, NULL);
return new sfSoundBuffer(*soundBuffer);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing sound buffer /// Destroy an existing sound buffer
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -33,6 +33,7 @@ EXPORTS
sfMusic_GetAttenuation sfMusic_GetAttenuation
sfMusic_GetPlayingOffset sfMusic_GetPlayingOffset
sfSound_Create sfSound_Create
sfSound_Copy
sfSound_Destroy sfSound_Destroy
sfSound_Play sfSound_Play
sfSound_Pause sfSound_Pause
@ -59,6 +60,7 @@ EXPORTS
sfSoundBuffer_CreateFromFile sfSoundBuffer_CreateFromFile
sfSoundBuffer_CreateFromMemory sfSoundBuffer_CreateFromMemory
sfSoundBuffer_CreateFromSamples sfSoundBuffer_CreateFromSamples
sfSoundBuffer_Copy
sfSoundBuffer_Destroy sfSoundBuffer_Destroy
sfSoundBuffer_SaveToFile sfSoundBuffer_SaveToFile
sfSoundBuffer_GetSamples sfSoundBuffer_GetSamples

View File

@ -33,6 +33,7 @@ EXPORTS
sfMusic_GetAttenuation sfMusic_GetAttenuation
sfMusic_GetPlayingOffset sfMusic_GetPlayingOffset
sfSound_Create sfSound_Create
sfSound_Copy
sfSound_Destroy sfSound_Destroy
sfSound_Play sfSound_Play
sfSound_Pause sfSound_Pause
@ -59,6 +60,7 @@ EXPORTS
sfSoundBuffer_CreateFromFile sfSoundBuffer_CreateFromFile
sfSoundBuffer_CreateFromMemory sfSoundBuffer_CreateFromMemory
sfSoundBuffer_CreateFromSamples sfSoundBuffer_CreateFromSamples
sfSoundBuffer_Copy
sfSoundBuffer_Destroy sfSoundBuffer_Destroy
sfSoundBuffer_SaveToFile sfSoundBuffer_SaveToFile
sfSoundBuffer_GetSamples sfSoundBuffer_GetSamples

View File

@ -62,6 +62,17 @@ sfFont* sfFont_CreateFromMemory(const char* data, size_t sizeInBytes)
} }
////////////////////////////////////////////////////////////
/// Copy an existing font
////////////////////////////////////////////////////////////
sfFont* sfFont_Copy(sfFont* font)
{
CSFML_CHECK_RETURN(font, NULL);
return new sfFont(*font);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing font /// Destroy an existing font
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -79,7 +90,7 @@ sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int character
sfGlyph glyph = {0, {0, 0, 0, 0}, {0, 0, 0, 0}}; sfGlyph glyph = {0, {0, 0, 0, 0}, {0, 0, 0, 0}};
CSFML_CHECK_RETURN(font, glyph); CSFML_CHECK_RETURN(font, glyph);
sf::Glyph SFMLGlyph = font->This.GetGlyph(codePoint, characterSize, bold); sf::Glyph SFMLGlyph = font->This.GetGlyph(codePoint, characterSize, bold == sfTrue);
glyph.Advance = SFMLGlyph.Advance; glyph.Advance = SFMLGlyph.Advance;
glyph.Rectangle.Left = SFMLGlyph.Rectangle.Left; glyph.Rectangle.Left = SFMLGlyph.Rectangle.Left;

View File

@ -108,6 +108,17 @@ sfImage* sfImage_CreateFromMemory(const char* data, size_t sizeInBytes)
} }
////////////////////////////////////////////////////////////
/// Copy an existing image
////////////////////////////////////////////////////////////
sfImage* sfImage_Copy(sfImage* image)
{
CSFML_CHECK_RETURN(image, NULL);
return new sfImage(*image);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing image /// Destroy an existing image
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -141,7 +152,7 @@ void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha
/// This function does a slow pixel copy and should only /// This function does a slow pixel copy and should only
/// be used at initialization time /// be used at initialization time
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfImage_Copy(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect) void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect)
{ {
CSFML_CHECK(source); CSFML_CHECK(source);
sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom); sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom);

View File

@ -48,6 +48,12 @@ struct sfImage
OwnInstance = false; OwnInstance = false;
} }
sfImage(const sfImage& image)
{
This = image.This ? new sf::Image(*image.This) : NULL;
OwnInstance = true;
}
~sfImage() ~sfImage()
{ {
if (OwnInstance) if (OwnInstance)

View File

@ -65,6 +65,17 @@ sfShader* sfShader_CreateFromMemory(const char* effect)
} }
////////////////////////////////////////////////////////////
/// Copy an existing clock
////////////////////////////////////////////////////////////
sfShader* sfShader_Copy(sfShader* shader)
{
CSFML_CHECK_RETURN(shader, NULL);
return new sfShader(*shader);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing shader /// Destroy an existing shader
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -82,6 +82,17 @@ sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, flo
} }
////////////////////////////////////////////////////////////
/// Copy an existing shape
////////////////////////////////////////////////////////////
sfShape* sfShape_Copy(sfShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
return new sfShape(*shape);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing shape /// Destroy an existing shape
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -48,6 +48,17 @@ sfSprite* sfSprite_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing sprite
////////////////////////////////////////////////////////////
sfSprite* sfSprite_Copy(sfSprite* sprite)
{
CSFML_CHECK_RETURN(sprite, NULL);
return new sfSprite(*sprite);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing sprite /// Destroy an existing sprite
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -44,6 +44,17 @@ sfText* sfText_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing text
////////////////////////////////////////////////////////////
sfText* sfText_Copy(sfText* text)
{
CSFML_CHECK_RETURN(text, NULL);
return new sfText(*text);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing text /// Destroy an existing text
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -42,54 +42,65 @@ sfView* sfView_Create()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Construct a view from a rectangle /// Construct a view from a rectangle
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfView* sfView_CreateFromRect(sfFloatRect Rect) sfView* sfView_CreateFromRect(sfFloatRect rectangle)
{ {
return new sfView(Rect); return new sfView(rectangle);
}
////////////////////////////////////////////////////////////
/// Copy an existing view
////////////////////////////////////////////////////////////
sfView* sfView_Copy(sfView* view)
{
CSFML_CHECK_RETURN(view, NULL);
return new sfView(*view);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing view /// Destroy an existing view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_Destroy(sfView* View) void sfView_Destroy(sfView* view)
{ {
delete View; delete view;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the center of a view /// Change the center of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_SetCenter(sfView* View, float X, float Y) void sfView_SetCenter(sfView* view, float x, float y)
{ {
CSFML_CALL_PTR(View, SetCenter(X, Y)); CSFML_CALL_PTR(view, SetCenter(x, y));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the size of a view /// Change the size of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_SetSize(sfView* View, float Width, float Height) void sfView_SetSize(sfView* view, float width, float height)
{ {
CSFML_CALL_PTR(View, SetSize(Width, Height)); CSFML_CALL_PTR(view, SetSize(width, height));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the angle of rotation of a view /// Set the angle of rotation of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_SetRotation(sfView* View, float Angle) void sfView_SetRotation(sfView* view, float angle)
{ {
CSFML_CALL_PTR(View, SetRotation(Angle)); CSFML_CALL_PTR(view, SetRotation(angle));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the target viewport of a view /// Set the target viewport of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_SetViewport(sfView* View, sfFloatRect Viewport) void sfView_SetViewport(sfView* view, sfFloatRect viewport)
{ {
CSFML_CALL_PTR(View, SetViewport(sf::FloatRect(Viewport.Left, Viewport.Top, Viewport.Right, Viewport.Bottom))); CSFML_CALL_PTR(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Right, viewport.Bottom)));
} }
@ -97,105 +108,105 @@ void sfView_SetViewport(sfView* View, sfFloatRect Viewport)
/// Reset a view to the given rectangle. /// Reset a view to the given rectangle.
/// Note: this function resets the rotation angle to 0. /// Note: this function resets the rotation angle to 0.
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_Reset(sfView* View, sfFloatRect Rectangle) void sfView_Reset(sfView* view, sfFloatRect rectangle)
{ {
CSFML_CALL_PTR(View, Reset(sf::FloatRect(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom))); CSFML_CALL_PTR(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the X coordinate of the center of a view /// Get the X coordinate of the center of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfView_GetCenterX(const sfView* View) float sfView_GetCenterX(const sfView* view)
{ {
CSFML_CHECK_RETURN(View, 0.f); CSFML_CHECK_RETURN(view, 0.f);
return View->This->GetCenter().x; return view->This->GetCenter().x;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the Y coordinate of the center of a view /// Get the Y coordinate of the center of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfView_GetCenterY(const sfView* View) float sfView_GetCenterY(const sfView* view)
{ {
CSFML_CHECK_RETURN(View, 0.f); CSFML_CHECK_RETURN(view, 0.f);
return View->This->GetCenter().y; return view->This->GetCenter().y;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the width of the view /// Get the width of the view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfView_GetWidth(const sfView* View) float sfView_GetWidth(const sfView* view)
{ {
CSFML_CHECK_RETURN(View, 0.f); CSFML_CHECK_RETURN(view, 0.f);
return View->This->GetSize().x; return view->This->GetSize().x;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the height of the view /// Get the height of the view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfView_GetHeight(const sfView* View) float sfView_GetHeight(const sfView* view)
{ {
CSFML_CHECK_RETURN(View, 0.f); CSFML_CHECK_RETURN(view, 0.f);
return View->This->GetSize().y; return view->This->GetSize().y;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current rotation of a view /// Get the current rotation of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfView_GetRotation(const sfView* View) float sfView_GetRotation(const sfView* view)
{ {
CSFML_CALL_PTR_RETURN(View, GetRotation(), 0.f); CSFML_CALL_PTR_RETURN(view, GetRotation(), 0.f);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the target viewport of a view /// Get the target viewport of a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfFloatRect sfView_GetViewport(const sfView* View) sfFloatRect sfView_GetViewport(const sfView* view)
{ {
sfFloatRect Rect = {0, 0, 0, 0}; sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(View, Rect); CSFML_CHECK_RETURN(view, rect);
sf::FloatRect SFMLRect = View->This->GetViewport(); sf::FloatRect SFMLRect = view->This->GetViewport();
Rect.Left = SFMLRect.Left; rect.Left = SFMLRect.Left;
Rect.Top = SFMLRect.Top; rect.Top = SFMLRect.Top;
Rect.Right = SFMLRect.Right; rect.Right = SFMLRect.Right;
Rect.Bottom = SFMLRect.Bottom; rect.Bottom = SFMLRect.Bottom;
return Rect; return rect;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Move a view /// Move a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_Move(sfView* View, float OffsetX, float OffsetY) void sfView_Move(sfView* view, float offsetX, float offsetY)
{ {
CSFML_CALL_PTR(View, Move(OffsetX, OffsetY)); CSFML_CALL_PTR(view, Move(offsetX, offsetY));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Rotate a view /// Rotate a view
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_Rotate(sfView* View, float Angle) void sfView_Rotate(sfView* view, float angle)
{ {
CSFML_CALL_PTR(View, Rotate(Angle)); CSFML_CALL_PTR(view, Rotate(angle));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Resize a view rectangle to simulate a zoom / unzoom effect /// Resize a view rectangle to simulate a zoom / unzoom effect
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_Zoom(sfView* View, float Factor) void sfView_Zoom(sfView* view, float factor)
{ {
CSFML_CALL_PTR(View, Zoom(Factor)); CSFML_CALL_PTR(view, Zoom(factor));
} }

View File

@ -54,6 +54,12 @@ struct sfView
{ {
} }
sfView(const sfView& View) :
This(View.This ? new sf::View(*View.This) : NULL),
OwnInstance(true)
{
}
~sfView() ~sfView()
{ {
if (OwnInstance) if (OwnInstance)

View File

@ -17,10 +17,11 @@ EXPORTS
sfImage_CreateFromPixels sfImage_CreateFromPixels
sfImage_CreateFromFile sfImage_CreateFromFile
sfImage_CreateFromMemory sfImage_CreateFromMemory
sfImage_Copy
sfImage_Destroy sfImage_Destroy
sfImage_SaveToFile sfImage_SaveToFile
sfImage_CreateMaskFromColor sfImage_CreateMaskFromColor
sfImage_Copy sfImage_CopyImage
sfImage_CopyScreen sfImage_CopyScreen
sfImage_SetPixel sfImage_SetPixel
sfImage_GetPixel sfImage_GetPixel
@ -38,6 +39,7 @@ EXPORTS
sfIntRect_Intersects sfIntRect_Intersects
sfShader_CreateFromFile sfShader_CreateFromFile
sfShader_CreateFromMemory sfShader_CreateFromMemory
sfShader_Copy
sfShader_Destroy sfShader_Destroy
sfShader_SetParameter1 sfShader_SetParameter1
sfShader_SetParameter2 sfShader_SetParameter2
@ -51,6 +53,7 @@ EXPORTS
sfShape_CreateLine sfShape_CreateLine
sfShape_CreateRectangle sfShape_CreateRectangle
sfShape_CreateCircle sfShape_CreateCircle
sfShape_Copy
sfShape_Destroy sfShape_Destroy
sfShape_SetX sfShape_SetX
sfShape_SetY sfShape_SetY
@ -89,6 +92,7 @@ EXPORTS
sfShape_SetPointColor sfShape_SetPointColor
sfShape_SetPointOutlineColor sfShape_SetPointOutlineColor
sfSprite_Create sfSprite_Create
sfSprite_Copy
sfSprite_Destroy sfSprite_Destroy
sfSprite_SetX sfSprite_SetX
sfSprite_SetY sfSprite_SetY
@ -126,6 +130,7 @@ EXPORTS
sfSprite_GetPixel sfSprite_GetPixel
sfFont_CreateFromFile sfFont_CreateFromFile
sfFont_CreateFromMemory sfFont_CreateFromMemory
sfFont_Copy
sfFont_Destroy sfFont_Destroy
sfFont_GetGlyph sfFont_GetGlyph
sfFont_GetKerning sfFont_GetKerning
@ -133,6 +138,7 @@ EXPORTS
sfFont_GetImage sfFont_GetImage
sfFont_GetDefaultFont sfFont_GetDefaultFont
sfText_Create sfText_Create
sfText_Copy
sfText_Destroy sfText_Destroy
sfText_SetX sfText_SetX
sfText_SetY sfText_SetY
@ -227,6 +233,7 @@ EXPORTS
sfRenderWindow_ConvertCoords sfRenderWindow_ConvertCoords
sfView_Create sfView_Create
sfView_CreateFromRect sfView_CreateFromRect
sfView_Copy
sfView_Destroy sfView_Destroy
sfView_SetCenter sfView_SetCenter
sfView_SetSize sfView_SetSize

View File

@ -17,10 +17,11 @@ EXPORTS
sfImage_CreateFromPixels sfImage_CreateFromPixels
sfImage_CreateFromFile sfImage_CreateFromFile
sfImage_CreateFromMemory sfImage_CreateFromMemory
sfImage_Copy
sfImage_Destroy sfImage_Destroy
sfImage_SaveToFile sfImage_SaveToFile
sfImage_CreateMaskFromColor sfImage_CreateMaskFromColor
sfImage_Copy sfImage_CopyImage
sfImage_CopyScreen sfImage_CopyScreen
sfImage_SetPixel sfImage_SetPixel
sfImage_GetPixel sfImage_GetPixel
@ -38,6 +39,7 @@ EXPORTS
sfIntRect_Intersects sfIntRect_Intersects
sfShader_CreateFromFile sfShader_CreateFromFile
sfShader_CreateFromMemory sfShader_CreateFromMemory
sfShader_Copy
sfShader_Destroy sfShader_Destroy
sfShader_SetParameter1 sfShader_SetParameter1
sfShader_SetParameter2 sfShader_SetParameter2
@ -51,6 +53,7 @@ EXPORTS
sfShape_CreateLine sfShape_CreateLine
sfShape_CreateRectangle sfShape_CreateRectangle
sfShape_CreateCircle sfShape_CreateCircle
sfShape_Copy
sfShape_Destroy sfShape_Destroy
sfShape_SetX sfShape_SetX
sfShape_SetY sfShape_SetY
@ -89,6 +92,7 @@ EXPORTS
sfShape_SetPointColor sfShape_SetPointColor
sfShape_SetPointOutlineColor sfShape_SetPointOutlineColor
sfSprite_Create sfSprite_Create
sfSprite_Copy
sfSprite_Destroy sfSprite_Destroy
sfSprite_SetX sfSprite_SetX
sfSprite_SetY sfSprite_SetY
@ -126,6 +130,7 @@ EXPORTS
sfSprite_GetPixel sfSprite_GetPixel
sfFont_CreateFromFile sfFont_CreateFromFile
sfFont_CreateFromMemory sfFont_CreateFromMemory
sfFont_Copy
sfFont_Destroy sfFont_Destroy
sfFont_GetGlyph sfFont_GetGlyph
sfFont_GetKerning sfFont_GetKerning
@ -133,6 +138,7 @@ EXPORTS
sfFont_GetImage sfFont_GetImage
sfFont_GetDefaultFont sfFont_GetDefaultFont
sfText_Create sfText_Create
sfText_Copy
sfText_Destroy sfText_Destroy
sfText_SetX sfText_SetX
sfText_SetY sfText_SetY
@ -230,6 +236,7 @@ EXPORTS
sfRenderWindow_ConvertCoords sfRenderWindow_ConvertCoords
sfView_Create sfView_Create
sfView_CreateFromRect sfView_CreateFromRect
sfView_Copy
sfView_Destroy sfView_Destroy
sfView_SetCenter sfView_SetCenter
sfView_SetSize sfView_SetSize

View File

@ -67,6 +67,17 @@ sfPacket* sfPacket_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing packet
////////////////////////////////////////////////////////////
sfPacket* sfPacket_Copy(sfPacket* packet)
{
CSFML_CHECK_RETURN(packet, NULL);
return new sfPacket(*packet);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing packet /// Destroy an existing packet
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -37,6 +37,13 @@ sfSelectorTCP* sfSelectorTCP_Create() {return new sfSelectorTCP;}
sfSelectorUDP* sfSelectorUDP_Create() {return new sfSelectorUDP;} sfSelectorUDP* sfSelectorUDP_Create() {return new sfSelectorUDP;}
////////////////////////////////////////////////////////////
/// Copy an existing selector
////////////////////////////////////////////////////////////
sfSelectorTCP* sfSelectorTCP_Copy(sfSelectorTCP* selector) {CSFML_CHECK_RETURN(selector, NULL); return new sfSelectorTCP(*selector);}
sfSelectorUDP* sfSelectorUDP_Copy(sfSelectorUDP* selector) {CSFML_CHECK_RETURN(selector, NULL); return new sfSelectorUDP(*selector);}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing selector /// Destroy an existing selector
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -42,6 +42,17 @@ sfSocketTCP* sfSocketTCP_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing TCP socket
////////////////////////////////////////////////////////////
sfSocketTCP* sfSocketTCP_Copy(sfSocketTCP* socket)
{
CSFML_CHECK_RETURN(socket, NULL);
return new sfSocketTCP(*socket);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing TCP socket /// Destroy an existing TCP socket
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -42,6 +42,17 @@ sfSocketUDP* sfSocketUDP_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing UDP socket
////////////////////////////////////////////////////////////
sfSocketUDP* sfSocketUDP_Copy(sfSocketUDP* socket)
{
CSFML_CHECK_RETURN(socket, NULL);
return new sfSocketUDP(*socket);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing UDP socket /// Destroy an existing UDP socket
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -82,6 +82,7 @@ EXPORTS
sfSocketUDP_Close sfSocketUDP_Close
sfSocketUDP_IsValid sfSocketUDP_IsValid
sfPacket_Create sfPacket_Create
sfPacket_Copy
sfPacket_Destroy sfPacket_Destroy
sfPacket_Append sfPacket_Append
sfPacket_Clear sfPacket_Clear
@ -112,6 +113,7 @@ EXPORTS
sfPacket_WriteString sfPacket_WriteString
sfPacket_WriteWideString sfPacket_WriteWideString
sfSelectorTCP_Create sfSelectorTCP_Create
sfSelectorTCP_Copy
sfSelectorTCP_Destroy sfSelectorTCP_Destroy
sfSelectorTCP_Add sfSelectorTCP_Add
sfSelectorTCP_Remove sfSelectorTCP_Remove
@ -119,6 +121,7 @@ EXPORTS
sfSelectorTCP_Wait sfSelectorTCP_Wait
sfSelectorTCP_GetSocketReady sfSelectorTCP_GetSocketReady
sfSelectorUDP_Create sfSelectorUDP_Create
sfSelectorUDP_Copy
sfSelectorUDP_Destroy sfSelectorUDP_Destroy
sfSelectorUDP_Add sfSelectorUDP_Add
sfSelectorUDP_Remove sfSelectorUDP_Remove

View File

@ -59,6 +59,7 @@ EXPORTS
sfIPAddress_GetPublicAddress sfIPAddress_GetPublicAddress
sfIPAddress_LocalHost sfIPAddress_LocalHost
sfSocketTCP_Create sfSocketTCP_Create
sfSocketTCP_Copy
sfSocketTCP_Destroy sfSocketTCP_Destroy
sfSocketTCP_SetBlocking sfSocketTCP_SetBlocking
sfSocketTCP_Connect sfSocketTCP_Connect
@ -71,6 +72,7 @@ EXPORTS
sfSocketTCP_Close sfSocketTCP_Close
sfSocketTCP_IsValid sfSocketTCP_IsValid
sfSocketUDP_Create sfSocketUDP_Create
sfSocketUDP_Copy
sfSocketUDP_Destroy sfSocketUDP_Destroy
sfSocketUDP_SetBlocking sfSocketUDP_SetBlocking
sfSocketUDP_Bind sfSocketUDP_Bind
@ -82,6 +84,7 @@ EXPORTS
sfSocketUDP_Close sfSocketUDP_Close
sfSocketUDP_IsValid sfSocketUDP_IsValid
sfPacket_Create sfPacket_Create
sfPacket_Copy
sfPacket_Destroy sfPacket_Destroy
sfPacket_Append sfPacket_Append
sfPacket_Clear sfPacket_Clear
@ -112,6 +115,7 @@ EXPORTS
sfPacket_WriteString sfPacket_WriteString
sfPacket_WriteWideString sfPacket_WriteWideString
sfSelectorTCP_Create sfSelectorTCP_Create
sfSelectorTCP_Copy
sfSelectorTCP_Destroy sfSelectorTCP_Destroy
sfSelectorTCP_Add sfSelectorTCP_Add
sfSelectorTCP_Remove sfSelectorTCP_Remove
@ -119,6 +123,7 @@ EXPORTS
sfSelectorTCP_Wait sfSelectorTCP_Wait
sfSelectorTCP_GetSocketReady sfSelectorTCP_GetSocketReady
sfSelectorUDP_Create sfSelectorUDP_Create
sfSelectorUDP_Copy
sfSelectorUDP_Destroy sfSelectorUDP_Destroy
sfSelectorUDP_Add sfSelectorUDP_Add
sfSelectorUDP_Remove sfSelectorUDP_Remove

View File

@ -39,6 +39,17 @@ sfClock* sfClock_Create()
} }
////////////////////////////////////////////////////////////
/// Copy an existing clock
////////////////////////////////////////////////////////////
sfClock* sfClock_Copy(sfClock* clock)
{
CSFML_CHECK_RETURN(clock, NULL);
return new sfClock(*clock);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destroy an existing clock /// Destroy an existing clock
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -1,6 +1,7 @@
LIBRARY csfml-system-d LIBRARY csfml-system-d
EXPORTS EXPORTS
sfClock_Create sfClock_Create
sfClock_Copy
sfClock_Destroy sfClock_Destroy
sfClock_GetTime sfClock_GetTime
sfClock_Reset sfClock_Reset

View File

@ -1,6 +1,7 @@
LIBRARY csfml-system LIBRARY csfml-system
EXPORTS EXPORTS
sfClock_Create sfClock_Create
sfClock_Copy
sfClock_Destroy sfClock_Destroy
sfClock_GetTime sfClock_GetTime
sfClock_Reset sfClock_Reset