From bc6beac402bebab344591e1d7ecc5a114232ddbd Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Tue, 5 Jan 2010 17:52:56 +0000 Subject: [PATCH] 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 --- CSFML/include/SFML/Audio/Sound.h | 10 ++ CSFML/include/SFML/Audio/SoundBuffer.h | 10 ++ CSFML/include/SFML/Graphics/Font.h | 10 ++ CSFML/include/SFML/Graphics/Image.h | 12 ++- CSFML/include/SFML/Graphics/Shader.h | 10 ++ CSFML/include/SFML/Graphics/Shape.h | 10 ++ CSFML/include/SFML/Graphics/Sprite.h | 10 ++ CSFML/include/SFML/Graphics/Text.h | 10 ++ CSFML/include/SFML/Graphics/View.h | 10 ++ CSFML/include/SFML/Network/Packet.h | 10 ++ CSFML/include/SFML/Network/Selector.h | 11 +++ CSFML/include/SFML/Network/SocketTCP.h | 10 ++ CSFML/include/SFML/Network/SocketUDP.h | 10 ++ CSFML/include/SFML/System/Clock.h | 10 ++ CSFML/src/SFML/Audio/Sound.cpp | 11 +++ CSFML/src/SFML/Audio/SoundBuffer.cpp | 11 +++ CSFML/src/SFML/Audio/csfml-audio-d.def | 2 + CSFML/src/SFML/Audio/csfml-audio.def | 2 + CSFML/src/SFML/Graphics/Font.cpp | 13 ++- CSFML/src/SFML/Graphics/Image.cpp | 13 ++- CSFML/src/SFML/Graphics/ImageStruct.h | 6 ++ CSFML/src/SFML/Graphics/Shader.cpp | 11 +++ CSFML/src/SFML/Graphics/Shape.cpp | 11 +++ CSFML/src/SFML/Graphics/Sprite.cpp | 11 +++ CSFML/src/SFML/Graphics/Text.cpp | 11 +++ CSFML/src/SFML/Graphics/View.cpp | 97 +++++++++++--------- CSFML/src/SFML/Graphics/ViewStruct.h | 6 ++ CSFML/src/SFML/Graphics/csfml-graphics-d.def | 9 +- CSFML/src/SFML/Graphics/csfml-graphics.def | 9 +- CSFML/src/SFML/Network/Packet.cpp | 11 +++ CSFML/src/SFML/Network/Selector.cpp | 7 ++ CSFML/src/SFML/Network/SocketTCP.cpp | 11 +++ CSFML/src/SFML/Network/SocketUDP.cpp | 11 +++ CSFML/src/SFML/Network/csfml-network-d.def | 3 + CSFML/src/SFML/Network/csfml-network.def | 5 + CSFML/src/SFML/System/Clock.cpp | 11 +++ CSFML/src/SFML/System/csfml-system-d.def | 1 + CSFML/src/SFML/System/csfml-system.def | 1 + 38 files changed, 379 insertions(+), 48 deletions(-) diff --git a/CSFML/include/SFML/Audio/Sound.h b/CSFML/include/SFML/Audio/Sound.h index f79fa969c..73e1430a2 100644 --- a/CSFML/include/SFML/Audio/Sound.h +++ b/CSFML/include/SFML/Audio/Sound.h @@ -41,6 +41,16 @@ //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Audio/SoundBuffer.h b/CSFML/include/SFML/Audio/SoundBuffer.h index 70d7213e9..f8ee8e11f 100644 --- a/CSFML/include/SFML/Audio/SoundBuffer.h +++ b/CSFML/include/SFML/Audio/SoundBuffer.h @@ -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); +//////////////////////////////////////////////////////////// +/// 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 /// diff --git a/CSFML/include/SFML/Graphics/Font.h b/CSFML/include/SFML/Graphics/Font.h index d112ce32b..7e64d0b9b 100644 --- a/CSFML/include/SFML/Graphics/Font.h +++ b/CSFML/include/SFML/Graphics/Font.h @@ -53,6 +53,16 @@ CSFML_API sfFont* sfFont_CreateFromFile(const char* filename); //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Graphics/Image.h b/CSFML/include/SFML/Graphics/Image.h index 647f1fc0e..8575049ca 100644 --- a/CSFML/include/SFML/Graphics/Image.h +++ b/CSFML/include/SFML/Graphics/Image.h @@ -87,6 +87,16 @@ CSFML_API sfImage* sfImage_CreateFromFile(const char* filename); //////////////////////////////////////////////////////////// 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 /// @@ -128,7 +138,7 @@ CSFML_API void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfU /// \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 diff --git a/CSFML/include/SFML/Graphics/Shader.h b/CSFML/include/SFML/Graphics/Shader.h index 571bfe808..36426c6ab 100644 --- a/CSFML/include/SFML/Graphics/Shader.h +++ b/CSFML/include/SFML/Graphics/Shader.h @@ -52,6 +52,16 @@ CSFML_API sfShader* sfShader_CreateFromFile(const char* filename); //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Graphics/Shape.h b/CSFML/include/SFML/Graphics/Shape.h index 6eb401716..bb4ee9130 100644 --- a/CSFML/include/SFML/Graphics/Shape.h +++ b/CSFML/include/SFML/Graphics/Shape.h @@ -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); +//////////////////////////////////////////////////////////// +/// Copy an existing shape +/// +/// \param shape : Shape to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_API sfShape* sfShape_Copy(sfShape* shape); + //////////////////////////////////////////////////////////// /// Destroy an existing Shape /// diff --git a/CSFML/include/SFML/Graphics/Sprite.h b/CSFML/include/SFML/Graphics/Sprite.h index b895e84c8..33c806b71 100644 --- a/CSFML/include/SFML/Graphics/Sprite.h +++ b/CSFML/include/SFML/Graphics/Sprite.h @@ -43,6 +43,16 @@ //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Graphics/Text.h b/CSFML/include/SFML/Graphics/Text.h index a30fdb0a6..6e66e9caf 100644 --- a/CSFML/include/SFML/Graphics/Text.h +++ b/CSFML/include/SFML/Graphics/Text.h @@ -55,6 +55,16 @@ typedef enum //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Graphics/View.h b/CSFML/include/SFML/Graphics/View.h index 60443dcbd..28eb8132f 100644 --- a/CSFML/include/SFML/Graphics/View.h +++ b/CSFML/include/SFML/Graphics/View.h @@ -47,6 +47,16 @@ CSFML_API sfView* sfView_Create(); //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Network/Packet.h b/CSFML/include/SFML/Network/Packet.h index 6bed159f6..98295e14a 100644 --- a/CSFML/include/SFML/Network/Packet.h +++ b/CSFML/include/SFML/Network/Packet.h @@ -40,6 +40,16 @@ //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Network/Selector.h b/CSFML/include/SFML/Network/Selector.h index 3a601e14e..206f95ad5 100644 --- a/CSFML/include/SFML/Network/Selector.h +++ b/CSFML/include/SFML/Network/Selector.h @@ -41,6 +41,17 @@ CSFML_API sfSelectorTCP* sfSelectorTCP_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 /// diff --git a/CSFML/include/SFML/Network/SocketTCP.h b/CSFML/include/SFML/Network/SocketTCP.h index acac5690b..81d846640 100644 --- a/CSFML/include/SFML/Network/SocketTCP.h +++ b/CSFML/include/SFML/Network/SocketTCP.h @@ -42,6 +42,16 @@ //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/Network/SocketUDP.h b/CSFML/include/SFML/Network/SocketUDP.h index 18e68b5ad..ba2216f12 100644 --- a/CSFML/include/SFML/Network/SocketUDP.h +++ b/CSFML/include/SFML/Network/SocketUDP.h @@ -42,6 +42,16 @@ //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/include/SFML/System/Clock.h b/CSFML/include/SFML/System/Clock.h index 52bfb7c4d..672ee80ae 100644 --- a/CSFML/include/SFML/System/Clock.h +++ b/CSFML/include/SFML/System/Clock.h @@ -40,6 +40,16 @@ //////////////////////////////////////////////////////////// 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 /// diff --git a/CSFML/src/SFML/Audio/Sound.cpp b/CSFML/src/SFML/Audio/Sound.cpp index 6521c16da..fa3b8f386 100644 --- a/CSFML/src/SFML/Audio/Sound.cpp +++ b/CSFML/src/SFML/Audio/Sound.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Audio/SoundBuffer.cpp b/CSFML/src/SFML/Audio/SoundBuffer.cpp index f97e41b39..fe452a594 100644 --- a/CSFML/src/SFML/Audio/SoundBuffer.cpp +++ b/CSFML/src/SFML/Audio/SoundBuffer.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Audio/csfml-audio-d.def b/CSFML/src/SFML/Audio/csfml-audio-d.def index 8c7a296d8..adbbd3a17 100644 --- a/CSFML/src/SFML/Audio/csfml-audio-d.def +++ b/CSFML/src/SFML/Audio/csfml-audio-d.def @@ -33,6 +33,7 @@ EXPORTS sfMusic_GetAttenuation sfMusic_GetPlayingOffset sfSound_Create + sfSound_Copy sfSound_Destroy sfSound_Play sfSound_Pause @@ -59,6 +60,7 @@ EXPORTS sfSoundBuffer_CreateFromFile sfSoundBuffer_CreateFromMemory sfSoundBuffer_CreateFromSamples + sfSoundBuffer_Copy sfSoundBuffer_Destroy sfSoundBuffer_SaveToFile sfSoundBuffer_GetSamples diff --git a/CSFML/src/SFML/Audio/csfml-audio.def b/CSFML/src/SFML/Audio/csfml-audio.def index cd484dd36..825d529e7 100644 --- a/CSFML/src/SFML/Audio/csfml-audio.def +++ b/CSFML/src/SFML/Audio/csfml-audio.def @@ -33,6 +33,7 @@ EXPORTS sfMusic_GetAttenuation sfMusic_GetPlayingOffset sfSound_Create + sfSound_Copy sfSound_Destroy sfSound_Play sfSound_Pause @@ -59,6 +60,7 @@ EXPORTS sfSoundBuffer_CreateFromFile sfSoundBuffer_CreateFromMemory sfSoundBuffer_CreateFromSamples + sfSoundBuffer_Copy sfSoundBuffer_Destroy sfSoundBuffer_SaveToFile sfSoundBuffer_GetSamples diff --git a/CSFML/src/SFML/Graphics/Font.cpp b/CSFML/src/SFML/Graphics/Font.cpp index 8ae737dd4..ef6e9a113 100644 --- a/CSFML/src/SFML/Graphics/Font.cpp +++ b/CSFML/src/SFML/Graphics/Font.cpp @@ -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 //////////////////////////////////////////////////////////// @@ -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}}; 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.Rectangle.Left = SFMLGlyph.Rectangle.Left; diff --git a/CSFML/src/SFML/Graphics/Image.cpp b/CSFML/src/SFML/Graphics/Image.cpp index b0cbdf0d3..e04cd7bba 100644 --- a/CSFML/src/SFML/Graphics/Image.cpp +++ b/CSFML/src/SFML/Graphics/Image.cpp @@ -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 //////////////////////////////////////////////////////////// @@ -141,7 +152,7 @@ void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha /// This function does a slow pixel copy and should only /// 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); sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom); diff --git a/CSFML/src/SFML/Graphics/ImageStruct.h b/CSFML/src/SFML/Graphics/ImageStruct.h index c62894304..d00326808 100644 --- a/CSFML/src/SFML/Graphics/ImageStruct.h +++ b/CSFML/src/SFML/Graphics/ImageStruct.h @@ -48,6 +48,12 @@ struct sfImage OwnInstance = false; } + sfImage(const sfImage& image) + { + This = image.This ? new sf::Image(*image.This) : NULL; + OwnInstance = true; + } + ~sfImage() { if (OwnInstance) diff --git a/CSFML/src/SFML/Graphics/Shader.cpp b/CSFML/src/SFML/Graphics/Shader.cpp index 3ba8ed5c9..9f609e790 100644 --- a/CSFML/src/SFML/Graphics/Shader.cpp +++ b/CSFML/src/SFML/Graphics/Shader.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Graphics/Shape.cpp b/CSFML/src/SFML/Graphics/Shape.cpp index 485bfe73c..10fa42149 100644 --- a/CSFML/src/SFML/Graphics/Shape.cpp +++ b/CSFML/src/SFML/Graphics/Shape.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Graphics/Sprite.cpp b/CSFML/src/SFML/Graphics/Sprite.cpp index 7fdf75616..2bb7a5618 100644 --- a/CSFML/src/SFML/Graphics/Sprite.cpp +++ b/CSFML/src/SFML/Graphics/Sprite.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Graphics/Text.cpp b/CSFML/src/SFML/Graphics/Text.cpp index f3ffb77b1..7089dce89 100644 --- a/CSFML/src/SFML/Graphics/Text.cpp +++ b/CSFML/src/SFML/Graphics/Text.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Graphics/View.cpp b/CSFML/src/SFML/Graphics/View.cpp index 3735c2030..d888b4133 100644 --- a/CSFML/src/SFML/Graphics/View.cpp +++ b/CSFML/src/SFML/Graphics/View.cpp @@ -42,54 +42,65 @@ sfView* sfView_Create() //////////////////////////////////////////////////////////// /// 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 //////////////////////////////////////////////////////////// -void sfView_Destroy(sfView* View) +void sfView_Destroy(sfView* view) { - delete View; + delete 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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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. /// 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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -sfFloatRect sfView_GetViewport(const sfView* View) +sfFloatRect sfView_GetViewport(const sfView* view) { - sfFloatRect Rect = {0, 0, 0, 0}; - CSFML_CHECK_RETURN(View, Rect); + sfFloatRect rect = {0, 0, 0, 0}; + CSFML_CHECK_RETURN(view, rect); - sf::FloatRect SFMLRect = View->This->GetViewport(); - Rect.Left = SFMLRect.Left; - Rect.Top = SFMLRect.Top; - Rect.Right = SFMLRect.Right; - Rect.Bottom = SFMLRect.Bottom; + sf::FloatRect SFMLRect = view->This->GetViewport(); + rect.Left = SFMLRect.Left; + rect.Top = SFMLRect.Top; + rect.Right = SFMLRect.Right; + rect.Bottom = SFMLRect.Bottom; - return Rect; + return rect; } //////////////////////////////////////////////////////////// /// 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 //////////////////////////////////////////////////////////// -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 //////////////////////////////////////////////////////////// -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)); } diff --git a/CSFML/src/SFML/Graphics/ViewStruct.h b/CSFML/src/SFML/Graphics/ViewStruct.h index 4d6262e6f..a1c3056dd 100644 --- a/CSFML/src/SFML/Graphics/ViewStruct.h +++ b/CSFML/src/SFML/Graphics/ViewStruct.h @@ -54,6 +54,12 @@ struct sfView { } + sfView(const sfView& View) : + This(View.This ? new sf::View(*View.This) : NULL), + OwnInstance(true) + { + } + ~sfView() { if (OwnInstance) diff --git a/CSFML/src/SFML/Graphics/csfml-graphics-d.def b/CSFML/src/SFML/Graphics/csfml-graphics-d.def index 84b635110..cff2fa725 100644 --- a/CSFML/src/SFML/Graphics/csfml-graphics-d.def +++ b/CSFML/src/SFML/Graphics/csfml-graphics-d.def @@ -17,10 +17,11 @@ EXPORTS sfImage_CreateFromPixels sfImage_CreateFromFile sfImage_CreateFromMemory + sfImage_Copy sfImage_Destroy sfImage_SaveToFile sfImage_CreateMaskFromColor - sfImage_Copy + sfImage_CopyImage sfImage_CopyScreen sfImage_SetPixel sfImage_GetPixel @@ -38,6 +39,7 @@ EXPORTS sfIntRect_Intersects sfShader_CreateFromFile sfShader_CreateFromMemory + sfShader_Copy sfShader_Destroy sfShader_SetParameter1 sfShader_SetParameter2 @@ -51,6 +53,7 @@ EXPORTS sfShape_CreateLine sfShape_CreateRectangle sfShape_CreateCircle + sfShape_Copy sfShape_Destroy sfShape_SetX sfShape_SetY @@ -89,6 +92,7 @@ EXPORTS sfShape_SetPointColor sfShape_SetPointOutlineColor sfSprite_Create + sfSprite_Copy sfSprite_Destroy sfSprite_SetX sfSprite_SetY @@ -126,6 +130,7 @@ EXPORTS sfSprite_GetPixel sfFont_CreateFromFile sfFont_CreateFromMemory + sfFont_Copy sfFont_Destroy sfFont_GetGlyph sfFont_GetKerning @@ -133,6 +138,7 @@ EXPORTS sfFont_GetImage sfFont_GetDefaultFont sfText_Create + sfText_Copy sfText_Destroy sfText_SetX sfText_SetY @@ -227,6 +233,7 @@ EXPORTS sfRenderWindow_ConvertCoords sfView_Create sfView_CreateFromRect + sfView_Copy sfView_Destroy sfView_SetCenter sfView_SetSize diff --git a/CSFML/src/SFML/Graphics/csfml-graphics.def b/CSFML/src/SFML/Graphics/csfml-graphics.def index cb01bf35a..ac75f1cfe 100644 --- a/CSFML/src/SFML/Graphics/csfml-graphics.def +++ b/CSFML/src/SFML/Graphics/csfml-graphics.def @@ -17,10 +17,11 @@ EXPORTS sfImage_CreateFromPixels sfImage_CreateFromFile sfImage_CreateFromMemory + sfImage_Copy sfImage_Destroy sfImage_SaveToFile sfImage_CreateMaskFromColor - sfImage_Copy + sfImage_CopyImage sfImage_CopyScreen sfImage_SetPixel sfImage_GetPixel @@ -38,6 +39,7 @@ EXPORTS sfIntRect_Intersects sfShader_CreateFromFile sfShader_CreateFromMemory + sfShader_Copy sfShader_Destroy sfShader_SetParameter1 sfShader_SetParameter2 @@ -51,6 +53,7 @@ EXPORTS sfShape_CreateLine sfShape_CreateRectangle sfShape_CreateCircle + sfShape_Copy sfShape_Destroy sfShape_SetX sfShape_SetY @@ -89,6 +92,7 @@ EXPORTS sfShape_SetPointColor sfShape_SetPointOutlineColor sfSprite_Create + sfSprite_Copy sfSprite_Destroy sfSprite_SetX sfSprite_SetY @@ -126,6 +130,7 @@ EXPORTS sfSprite_GetPixel sfFont_CreateFromFile sfFont_CreateFromMemory + sfFont_Copy sfFont_Destroy sfFont_GetGlyph sfFont_GetKerning @@ -133,6 +138,7 @@ EXPORTS sfFont_GetImage sfFont_GetDefaultFont sfText_Create + sfText_Copy sfText_Destroy sfText_SetX sfText_SetY @@ -230,6 +236,7 @@ EXPORTS sfRenderWindow_ConvertCoords sfView_Create sfView_CreateFromRect + sfView_Copy sfView_Destroy sfView_SetCenter sfView_SetSize diff --git a/CSFML/src/SFML/Network/Packet.cpp b/CSFML/src/SFML/Network/Packet.cpp index 252608e5e..cb83176db 100644 --- a/CSFML/src/SFML/Network/Packet.cpp +++ b/CSFML/src/SFML/Network/Packet.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Network/Selector.cpp b/CSFML/src/SFML/Network/Selector.cpp index 2d3d3aecc..a1deb6f01 100644 --- a/CSFML/src/SFML/Network/Selector.cpp +++ b/CSFML/src/SFML/Network/Selector.cpp @@ -37,6 +37,13 @@ sfSelectorTCP* sfSelectorTCP_Create() {return new sfSelectorTCP;} 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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Network/SocketTCP.cpp b/CSFML/src/SFML/Network/SocketTCP.cpp index 9a920fc38..73b5a38ca 100644 --- a/CSFML/src/SFML/Network/SocketTCP.cpp +++ b/CSFML/src/SFML/Network/SocketTCP.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Network/SocketUDP.cpp b/CSFML/src/SFML/Network/SocketUDP.cpp index 417cad02a..efad583e0 100644 --- a/CSFML/src/SFML/Network/SocketUDP.cpp +++ b/CSFML/src/SFML/Network/SocketUDP.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/Network/csfml-network-d.def b/CSFML/src/SFML/Network/csfml-network-d.def index 216476292..ae4309b5f 100644 --- a/CSFML/src/SFML/Network/csfml-network-d.def +++ b/CSFML/src/SFML/Network/csfml-network-d.def @@ -82,6 +82,7 @@ EXPORTS sfSocketUDP_Close sfSocketUDP_IsValid sfPacket_Create + sfPacket_Copy sfPacket_Destroy sfPacket_Append sfPacket_Clear @@ -112,6 +113,7 @@ EXPORTS sfPacket_WriteString sfPacket_WriteWideString sfSelectorTCP_Create + sfSelectorTCP_Copy sfSelectorTCP_Destroy sfSelectorTCP_Add sfSelectorTCP_Remove @@ -119,6 +121,7 @@ EXPORTS sfSelectorTCP_Wait sfSelectorTCP_GetSocketReady sfSelectorUDP_Create + sfSelectorUDP_Copy sfSelectorUDP_Destroy sfSelectorUDP_Add sfSelectorUDP_Remove diff --git a/CSFML/src/SFML/Network/csfml-network.def b/CSFML/src/SFML/Network/csfml-network.def index 2a27d528f..8a5381b32 100644 --- a/CSFML/src/SFML/Network/csfml-network.def +++ b/CSFML/src/SFML/Network/csfml-network.def @@ -59,6 +59,7 @@ EXPORTS sfIPAddress_GetPublicAddress sfIPAddress_LocalHost sfSocketTCP_Create + sfSocketTCP_Copy sfSocketTCP_Destroy sfSocketTCP_SetBlocking sfSocketTCP_Connect @@ -71,6 +72,7 @@ EXPORTS sfSocketTCP_Close sfSocketTCP_IsValid sfSocketUDP_Create + sfSocketUDP_Copy sfSocketUDP_Destroy sfSocketUDP_SetBlocking sfSocketUDP_Bind @@ -82,6 +84,7 @@ EXPORTS sfSocketUDP_Close sfSocketUDP_IsValid sfPacket_Create + sfPacket_Copy sfPacket_Destroy sfPacket_Append sfPacket_Clear @@ -112,6 +115,7 @@ EXPORTS sfPacket_WriteString sfPacket_WriteWideString sfSelectorTCP_Create + sfSelectorTCP_Copy sfSelectorTCP_Destroy sfSelectorTCP_Add sfSelectorTCP_Remove @@ -119,6 +123,7 @@ EXPORTS sfSelectorTCP_Wait sfSelectorTCP_GetSocketReady sfSelectorUDP_Create + sfSelectorUDP_Copy sfSelectorUDP_Destroy sfSelectorUDP_Add sfSelectorUDP_Remove diff --git a/CSFML/src/SFML/System/Clock.cpp b/CSFML/src/SFML/System/Clock.cpp index 32df2d6a7..f19deff6a 100644 --- a/CSFML/src/SFML/System/Clock.cpp +++ b/CSFML/src/SFML/System/Clock.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/CSFML/src/SFML/System/csfml-system-d.def b/CSFML/src/SFML/System/csfml-system-d.def index 122a804c9..9592e9b86 100644 --- a/CSFML/src/SFML/System/csfml-system-d.def +++ b/CSFML/src/SFML/System/csfml-system-d.def @@ -1,6 +1,7 @@ LIBRARY csfml-system-d EXPORTS sfClock_Create + sfClock_Copy sfClock_Destroy sfClock_GetTime sfClock_Reset diff --git a/CSFML/src/SFML/System/csfml-system.def b/CSFML/src/SFML/System/csfml-system.def index da7c42473..baf1668f0 100644 --- a/CSFML/src/SFML/System/csfml-system.def +++ b/CSFML/src/SFML/System/csfml-system.def @@ -1,6 +1,7 @@ LIBRARY csfml-system EXPORTS sfClock_Create + sfClock_Copy sfClock_Destroy sfClock_GetTime sfClock_Reset