Initial commit -- moved from https://github.com/LaurentGomila/SFML (bindings/c)

This commit is contained in:
Laurent Gomila committed 2011-07-06 22:39:55 +02:00
commit 45d3b05d65
141 files changed
+19124

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_BLENDMODE_H
#define SFML_BLENDMODE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// Enumerate the blending modes for drawable objects
////////////////////////////////////////////////////////////
typedef enum
{
sfBlendAlpha, ///< Pixel = Src * a + Dest * (1 - a)
sfBlendAdd, ///< Pixel = Src + Dest
sfBlendMultiply, ///< Pixel = Src * Dest
sfBlendNone ///< No blending
} sfBlendMode;
#endif // SFML_BLENDMODE_H
+107
View File
@@ -0,0 +1,107 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_COLOR_H
#define SFML_COLOR_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// sfColor is an utility class for manipulating colors
////////////////////////////////////////////////////////////
typedef struct
{
sfUint8 r;
sfUint8 g;
sfUint8 b;
sfUint8 a;
} sfColor;
////////////////////////////////////////////////////////////
/// Define some common colors
////////////////////////////////////////////////////////////
CSFML_API sfColor sfBlack;
CSFML_API sfColor sfWhite;
CSFML_API sfColor sfRed;
CSFML_API sfColor sfGreen;
CSFML_API sfColor sfBlue;
CSFML_API sfColor sfYellow;
CSFML_API sfColor sfMagenta;
CSFML_API sfColor sfCyan;
////////////////////////////////////////////////////////////
/// Construct a color from its 3 RGB components
///
/// \param red : Red component (0 .. 255)
/// \param green : Green component (0 .. 255)
/// \param blue : Blue component (0 .. 255)
///
/// \return sfColor constructed from the components
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfColor_FromRGB(sfUint8 red, sfUint8 green, sfUint8 blue);
////////////////////////////////////////////////////////////
/// Construct a color from its 4 RGBA components
///
/// \param red : Red component (0 .. 255)
/// \param green : Green component (0 .. 255)
/// \param blue : Blue component (0 .. 255)
/// \param alpha : Alpha component (0 .. 255)
///
/// \return sfColor constructed from the components
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfColor_FromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha);
////////////////////////////////////////////////////////////
/// Add two colors
///
/// \param color1 : First color
/// \param color2 : Second color
///
/// \return Component-wise saturated addition of the two colors
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfColor_Add(sfColor color1, sfColor color2);
////////////////////////////////////////////////////////////
/// Modulate two colors
///
/// \param color1 : First color
/// \param color2 : Second color
///
/// \return Component-wise multiplication of the two colors
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfColor_Modulate(sfColor color1, sfColor color2);
#endif // SFML_COLOR_H
+132
View File
@@ -0,0 +1,132 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_FONT_H
#define SFML_FONT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Glyph.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Create a new font from a file
///
/// \param filename : Path of the font file to load
///
/// \return A new sfFont object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfFont* sfFont_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
/// Create a new image font a file in memory
///
/// \param data : Pointer to the file data in memory
/// \param sizeInBytes : Size of the data to load, in bytes
///
/// \return A new sfFont object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfFont* sfFont_CreateFromMemory(const void* 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
///
/// \param font : Font to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfFont_Destroy(sfFont* font);
////////////////////////////////////////////////////////////
/// Get a glyph in a font
///
/// \param font : Source font
/// \param codePoint : Unicode code point of the character to get
/// \param characterSize : Character size, in pixels
/// \param bold Retrieve the bold version or the regular one?
///
/// \return The corresponding glyph
///
////////////////////////////////////////////////////////////
CSFML_API sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold);
////////////////////////////////////////////////////////////
/// Get the kerning value corresponding to a given pair of characters in a font
///
/// \param font : Source font
/// \param first : Unicode code point of the first character
/// \param second : Unicode code point of the second character
/// \param characterSize : Character size, in pixels
///
/// \return Kerning offset, in pixels
///
////////////////////////////////////////////////////////////
CSFML_API int sfFont_GetKerning(sfFont* font, sfUint32 first, sfUint32 second, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// Get the line spacing value
///
/// \param font : Source font
/// \param codePoint : Unicode code point of the character to get
/// \param characterSize : Character size, in pixels
///
/// \return Line spacing, in pixels
///
////////////////////////////////////////////////////////////
CSFML_API int sfFont_GetLineSpacing(sfFont* font, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// Get the image containing the glyphs of a given size in a font
///
/// \param font : Source font
/// \param characterSize : Character size, in pixels
///
/// \return Read-only pointer to the image
///
////////////////////////////////////////////////////////////
CSFML_API const sfImage* sfFont_GetImage(sfFont* font, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// Get the built-in default font (Arial)
///
/// \return Pointer to the default font
///
////////////////////////////////////////////////////////////
CSFML_API const sfFont* sfFont_GetDefaultFont(void);
#endif // SFML_IMAGE_H
+45
View File
@@ -0,0 +1,45 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_GLYPH_H
#define SFML_GLYPH_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Rect.h>
////////////////////////////////////////////////////////////
/// sfGlyph describes a glyph (a visual character)
////////////////////////////////////////////////////////////
typedef struct
{
int Advance; ///< Offset to move horizontically to the next character
sfIntRect Bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline
sfIntRect SubRect; ///< Texture coordinates of the glyph inside the font's image
} sfGlyph;
#endif // SFML_GLYPH_H
+246
View File
@@ -0,0 +1,246 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_IMAGE_H
#define SFML_IMAGE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Create a new image filled with a color
///
/// \param width : Image width
/// \param height : Image height
/// \param color : Image color
///
/// \return A new sfImage object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromColor(unsigned int width, unsigned int height, sfColor color);
////////////////////////////////////////////////////////////
/// Create a new image from an array of pixels in memory
///
/// \param width : Image width
/// \param height : Image height
/// \param data : Pointer to the pixels in memory (assumed format is RGBA)
///
/// \return A new sfImage object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromPixels(unsigned int width, unsigned int height, const sfUint8* data);
////////////////////////////////////////////////////////////
/// Create a new image from a file
///
/// \param filename : Path of the image file to load
///
/// \return A new sfImage object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
/// Create a new image from a file in memory
///
/// \param data : Pointer to the file data in memory
/// \param sizeInBytes : Size of the data to load, in bytes
///
/// \return A new sfImage object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromMemory(const void* 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
///
/// \param image : Image to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfImage_Destroy(sfImage* image);
////////////////////////////////////////////////////////////
/// Save the content of an image to a file
///
/// \param image : Image to save
/// \param filename : Path of the file to save (overwritten if already exist)
///
/// \return sfTrue if saving was successful
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfImage_SaveToFile(const sfImage* image, const char* filename);
////////////////////////////////////////////////////////////
/// Create a transparency mask for an image from a specified colorkey
///
/// \param image : Image to modify
/// \param colorKey : Color to become transparent
/// \param alpha : Alpha value to use for transparent pixels
///
////////////////////////////////////////////////////////////
CSFML_API void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha);
////////////////////////////////////////////////////////////
/// Copy pixels from another image onto this one.
/// This function does a slow pixel copy and should only
/// be used at initialization time
///
/// \param image : Destination image
/// \param source : Source image to copy
/// \param destX : X coordinate of the destination position
/// \param destY : Y coordinate of the destination position
/// \param sourceRect : Sub-rectangle of the source image to copy
///
////////////////////////////////////////////////////////////
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
/// given window
///
/// \param image : Destination image
/// \param window : Window to capture
/// \param sourceRect : Sub-rectangle of the screen to copy (empty by default - entire image)
///
/// \return True if creation was successful
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfImage_CopyScreen(sfImage* image, sfRenderWindow* window, sfIntRect sourceRect);
////////////////////////////////////////////////////////////
/// Change the color of a pixel of an image
///
/// \param image : Image to modify
/// \param x : X coordinate of pixel in the image
/// \param y : Y coordinate of pixel in the image
/// \param color : New color for pixel (X, Y)
///
////////////////////////////////////////////////////////////
CSFML_API void sfImage_SetPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color);
////////////////////////////////////////////////////////////
/// Get a pixel from an image
///
/// \param image : Image to read
/// \param x : X coordinate of pixel in the image
/// \param y : Y coordinate of pixel in the image
///
/// \return Color of pixel (x, y)
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfImage_GetPixel(const sfImage* image, unsigned int x, unsigned int y);
////////////////////////////////////////////////////////////
/// Get a read-only pointer to the array of pixels of an image (8 bits integers RGBA)
/// Array size is sfImage_GetWidth(img) x sfImage_GetHeight(img) x 4
/// This pointer becomes invalid if you reload or resize the image
///
/// \param image : Image to read
///
/// \return Pointer to the array of pixels
///
////////////////////////////////////////////////////////////
CSFML_API const sfUint8* sfImage_GetPixelsPtr(const sfImage* image);
////////////////////////////////////////////////////////////
/// Update a sub-rectangle of the image from an array of pixels
///
/// Warning: for performances reasons, this function doesn't
/// perform any check; thus you're responsible of ensuring that
/// \a rectangle does not exceed the image size, and that
/// \a pixels contains enough elements.
///
/// \param image : Image to update
/// \param rectangle : Sub-rectangle of the image to update
/// \param pixels : Array of pixels to write to the image
///
////////////////////////////////////////////////////////////
CSFML_API void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle);
////////////////////////////////////////////////////////////
/// Bind the image for rendering
///
/// \param image : Image to bind
///
////////////////////////////////////////////////////////////
CSFML_API void sfImage_Bind(const sfImage* image);
////////////////////////////////////////////////////////////
/// Enable or disable image smooth filter
///
/// \param image : Image to modify
/// \param smooth : sfTrue to enable smoothing filter, false to disable it
///
////////////////////////////////////////////////////////////
CSFML_API void sfImage_SetSmooth(sfImage* image, sfBool smooth);
////////////////////////////////////////////////////////////
/// Return the width of the image
///
/// \param image : Image to read
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfImage_GetWidth(const sfImage* image);
////////////////////////////////////////////////////////////
/// Return the height of the image
///
/// \param image : Image to read
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfImage_GetHeight(const sfImage* image);
////////////////////////////////////////////////////////////
/// Tells whether the smoothing filter is enabled or not on an image
///
/// \param image : Image to read
///
/// \return sfTrue if the smoothing filter is enabled
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfImage_IsSmooth(const sfImage* image);
#endif // SFML_IMAGE_H
+81
View File
@@ -0,0 +1,81 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_RECT_H
#define SFML_RECT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// sfFloatRect and sfIntRect are utility classes for
/// manipulating rectangles.
////////////////////////////////////////////////////////////
typedef struct
{
float Left;
float Top;
float Width;
float Height;
} sfFloatRect;
typedef struct
{
int Left;
int Top;
int Width;
int Height;
} sfIntRect;
////////////////////////////////////////////////////////////
/// Check if a point is inside a rectangle's area
///
/// \param rect : Rectangle to test
/// \param x : X coordinate of the point to test
/// \param y : Y coordinate of the point to test
///
/// \return sfTrue if the point is inside
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfFloatRect_Contains(const sfFloatRect* rect, float x, float y);
CSFML_API sfBool sfIntRect_Contains(const sfIntRect* rect, int x, int y);
////////////////////////////////////////////////////////////
/// Check intersection between two rectangles
///
/// \param rect1 : First rectangle to test
/// \param rect2 : Second rectangle to test
/// \param intersection : Rectangle to be filled with overlapping rect (can be NULL)
///
/// \return sfTrue if rectangles overlap
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2, sfFloatRect* intersection);
CSFML_API sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection);
#endif // SFML_RECT_H
+206
View File
@@ -0,0 +1,206 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_RENDERIMAGE_H
#define SFML_RENDERIMAGE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Construct a new renderimage
///
/// \param width : Width of the renderimage
/// \param height : Height of the renderimage
/// \param depthBuffer : Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the renderimage)
///
////////////////////////////////////////////////////////////
CSFML_API sfRenderImage* sfRenderImage_Create(unsigned int width, unsigned int height, sfBool depthBuffer);
////////////////////////////////////////////////////////////
/// Destroy an existing renderimage
///
/// \param renderImage : renderimage to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_Destroy(sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a renderimage
///
/// \param renderImage : Renderimage object
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfRenderImage_GetWidth(const sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a renderimage
///
/// \param renderImage : Renderimage object
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfRenderImage_GetHeight(const sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Activate or deactivate a renderimage as the current target for rendering
///
/// \param renderImage : Renderimage object
/// \param active : sfTrue to activate, sfFalse to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfRenderImage_SetActive(sfRenderImage* renderImage, sfBool active);
////////////////////////////////////////////////////////////
/// Save the current OpenGL render states and matrices
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_SaveGLStates(sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Restore the previously saved OpenGL render states and matrices
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_RestoreGLStates(sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Update the contents of the target image
///
/// \param renderImage : Renderimage object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_Display(sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Draw something on a renderimage
///
/// \param renderImage : Renderimage to draw in
/// \param sprite / text / shape : Object to draw
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_DrawSprite(sfRenderImage* renderImage, const sfSprite* sprite);
CSFML_API void sfRenderImage_DrawShape (sfRenderImage* renderImage, const sfShape* shape);
CSFML_API void sfRenderImage_DrawText (sfRenderImage* renderImage, const sfText* text);
////////////////////////////////////////////////////////////
/// Draw something on a renderimage with a shader
///
/// \param renderImage : Renderimage to draw in
/// \param sprite / text / shape : Object to draw
/// \param shader : Shader to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_DrawSpriteWithShader(sfRenderImage* renderImage, const sfSprite* sprite, const sfShader* shader);
CSFML_API void sfRenderImage_DrawShapeWithShader (sfRenderImage* renderImage, const sfShape* shape, const sfShader* shader);
CSFML_API void sfRenderImage_DrawTextWithShader (sfRenderImage* renderImage, const sfText* text, const sfShader* shader);
////////////////////////////////////////////////////////////
/// Clear the renderimage with the given color
///
/// \param renderImage : Renderimage to modify
/// \param color : Fill color
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_Clear(sfRenderImage* renderImage, sfColor color);
////////////////////////////////////////////////////////////
/// Change the current active view of a renderimage
///
/// \param renderImage : Renderimage to modify
/// \param view : Pointer to the new view
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_SetView(sfRenderImage* renderImage, const sfView* view);
////////////////////////////////////////////////////////////
/// Get the current active view of a renderimage
///
/// \param renderImage : Renderimage
///
/// \return Current active view
///
////////////////////////////////////////////////////////////
CSFML_API const sfView* sfRenderImage_GetView(const sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Get the default view of a renderimage
///
/// \param renderImage : Renderimage
///
/// \return Default view of the renderimage
///
////////////////////////////////////////////////////////////
CSFML_API const sfView* sfRenderImage_GetDefaultView(const sfRenderImage* renderImage);
////////////////////////////////////////////////////////////
/// Get the viewport of a view applied to this target
///
/// \param renderImage : Renderimage object
/// \param view : Target view
///
/// \return Viewport rectangle, expressed in pixels in the current target
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfRenderImage_GetViewport(const sfRenderImage* renderImage, const sfView* view);
////////////////////////////////////////////////////////////
/// Convert a point in image coordinates into view coordinates
///
/// \param renderImage : Renderimage object
/// \param windowX : X coordinate of the point to convert, relative to the image
/// \param windowY : Y coordinate of the point to convert, relative to the image
/// \param viewX : Pointer to fill with the X coordinate of the converted point
/// \param viewY : Pointer to fill with the Y coordinate of the converted point
/// \param targetView : Target view to convert the point to (pass NULL to use the current view)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderImage_ConvertCoords(const sfRenderImage* renderImage, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
////////////////////////////////////////////////////////////
/// Get the target image
///
/// \param renderImage : Renderimage object
///
/// \return Pointer to the target image
///
////////////////////////////////////////////////////////////
CSFML_API const sfImage* sfRenderImage_GetImage(const sfRenderImage* renderImage);
#endif // SFML_RENDERIMAGE_H
+385
View File
@@ -0,0 +1,385 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_RENDERWINDOW_H
#define SFML_RENDERWINDOW_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Window.h>
////////////////////////////////////////////////////////////
/// Construct a new renderwindow
///
/// \param mode : Video mode to use
/// \param title : Title of the window
/// \param style : Window style
/// \param settings : Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_API sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsigned long style, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// Construct a renderwindow from an existing control
///
/// \param handle : Platform-specific handle of the control
/// \param settings : Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_API sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// Destroy an existing renderwindow
///
/// \param renderWindow : Renderwindow to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Destroy(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Close a renderwindow (but doesn't destroy the internal data)
///
/// \param renderWindow : Renderwindow to close
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Close(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Tell whether or not a renderwindow is opened
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfRenderWindow_IsOpened(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a window
///
/// \param renderWindow : Renderwindow object
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a window
///
/// \param renderWindow : Renderwindow object
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the creation settings of a window
///
/// \param renderWindow : Renderwindow object
///
/// \return Settings used to create the window
///
////////////////////////////////////////////////////////////
CSFML_API sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the event on top of events stack of a window, if any, and pop it
///
/// \param renderWindow : Renderwindow object
/// \param event : Event to fill, if any
///
/// \return sfTrue if an event was returned, sfFalse if events stack was empty
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event);
////////////////////////////////////////////////////////////
/// Wait for an event and return it
///
/// \param renderWindow : Renderwindow object
/// \param event : Event to fill
///
/// \return sfFalse if an error occured
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event);
////////////////////////////////////////////////////////////
/// Enable / disable vertical synchronization on a window
///
/// \param renderWindow : Renderwindow object
/// \param enabled : sfTrue to enable v-sync, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// Show or hide the mouse cursor on a window
///
/// \param renderWindow : RenderWindow object
/// \param show : sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show);
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor on a window
///
/// \param renderWindow : Renderwindow object
/// \param left : Left coordinate of the cursor, relative to the window
/// \param top : Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetCursorPosition(sfRenderWindow* renderWindow, unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
///
/// \param renderWindow : Renderwindow object
/// \param left : Left position
/// \param top : Top position
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top);
////////////////////////////////////////////////////////////
/// Change the size of the rendering region of a window
///
/// \param renderWindow : Renderwindow object
/// \param width : New Width
/// \param height : New Height
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height);
////////////////////////////////////////////////////////////
/// Change the title of a window
///
/// \param renderWindow : Renderwindow object
/// \param title : New title
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title);
////////////////////////////////////////////////////////////
/// Show or hide a window
///
/// \param renderWindow : Renderwindow object
/// \param show : sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show);
////////////////////////////////////////////////////////////
/// Enable or disable automatic key-repeat for keydown events.
/// Automatic key-repeat is enabled by default
///
/// \param renderWindow : Renderwindow object
/// \param enabled : sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// Change the window's icon
///
/// \param renderWindow : Renderwindow object
/// \param width : Icon's width, in pixels
/// \param height : Icon's height, in pixels
/// \param pixels : Pointer to the pixels in memory, format must be RGBA 32 bits
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
////////////////////////////////////////////////////////////
/// Activate or deactivate a window as the current target for rendering
///
/// \param renderWindow : Renderwindow object
/// \param active : sfTrue to activate, sfFalse to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active);
////////////////////////////////////////////////////////////
/// Save the current OpenGL render states and matrices
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SaveGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Restore the previously saved OpenGL render states and matrices
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_RestoreGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Display a window on screen
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Display(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
///
/// \param renderWindow : Renderwindow object
/// \param limit : Framerate limit, in frames per seconds (use 0 to disable limit)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit);
////////////////////////////////////////////////////////////
/// Get time elapsed since last frame of a window
///
/// \param renderWindow : Renderwindow object
///
/// \return Time elapsed, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
///
/// \param renderWindow : Renderwindow object
/// \param threshold : New threshold, in range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold);
////////////////////////////////////////////////////////////
/// Retrieve the Os-specific handle of a window
///
/// \param renderWindow : Renderwindow object
///
/// \return Window handle
///
////////////////////////////////////////////////////////////
CSFML_API sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow
///
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / text / shape : Object to draw
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* sprite);
CSFML_API void sfRenderWindow_DrawShape (sfRenderWindow* renderWindow, const sfShape* shape);
CSFML_API void sfRenderWindow_DrawText (sfRenderWindow* renderWindow, const sfText* text);
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow with a shader
///
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / text / shape : Object to draw
/// \param shader : Shader to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, const sfSprite* sprite, const sfShader* shader);
CSFML_API void sfRenderWindow_DrawShapeWithShader (sfRenderWindow* renderWindow, const sfShape* shape, const sfShader* shader);
CSFML_API void sfRenderWindow_DrawTextWithShader (sfRenderWindow* renderWindow, const sfText* text, const sfShader* shader);
////////////////////////////////////////////////////////////
/// Clear the screen with the given color
///
/// \param renderWindow : Renderwindow to modify
/// \param color : Fill color
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color);
////////////////////////////////////////////////////////////
/// Change the current active view of a renderwindow
///
/// \param renderWindow : Renderwindow to modify
/// \param view : Pointer to the new view
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view);
////////////////////////////////////////////////////////////
/// Get the current active view of a renderwindow
///
/// \param renderWindow : Renderwindow
///
/// \return Current active view
///
////////////////////////////////////////////////////////////
CSFML_API const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the default view of a renderwindow
///
/// \param renderWindow : Renderwindow
///
/// \return Default view of the render window
///
////////////////////////////////////////////////////////////
CSFML_API const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the viewport of a view applied to this target
///
/// \param renderWindow : Renderwindow
/// \param view : Target view
///
/// \return Viewport rectangle, expressed in pixels in the current target
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const sfView* view);
////////////////////////////////////////////////////////////
/// Convert a point in window coordinates into view coordinates
///
/// \param renderWindow : Target Renderwindow
/// \param windowX : X coordinate of the point to convert, relative to the window
/// \param windowY : Y coordinate of the point to convert, relative to the window
/// \param viewX : Pointer to fill with the X coordinate of the converted point
/// \param viewY : Pointer to fill with the Y coordinate of the converted point
/// \param targetView : Target view to convert the point to (pass NULL to use the current view)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
#endif // SFML_RENDERWINDOW_H
+157
View File
@@ -0,0 +1,157 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SHADER_H
#define SFML_SHADER_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Create a new shader from a file
///
/// \param filename : File to load
///
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
/// Create a new shader from an effect source code
///
/// \param effect : Source code of the effect
///
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
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
///
/// \param shader : Shader to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_Destroy(sfShader* shader);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (1 float)
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x : Value to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter1(sfShader* shader, const char* name, float x);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (2 floats)
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x, y : Values to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter2(sfShader* shader, const char* name, float x, float y);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (3 floats)
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x, y, z : Values to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter3(sfShader* shader, const char* name, float x, float y, float z);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (4 floats)
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x, y, z, w : Values to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter4(sfShader* shader, const char* name, float x, float y, float z, float w);
////////////////////////////////////////////////////////////
/// Set a texture parameter in a shader
///
/// \param shader : Shader to modify
/// \param name : Texture name in the effect
/// \param texture : Image to set
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetTexture(sfShader* shader, const char* name, const sfImage* texture);
////////////////////////////////////////////////////////////
/// Set the current texture parameter in a shader
///
/// \param shader : Shader to modify
/// \param name : Texture name in the effect
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetCurrentTexture(sfShader* shader, const char* name);
////////////////////////////////////////////////////////////
/// Bind a shader for rendering
///
/// \param shader : Shader to bind
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_Bind(const sfShader* shader);
////////////////////////////////////////////////////////////
/// Unbind a shader
///
/// \param shader : Shader to unbind
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_Unbind(const sfShader* shader);
////////////////////////////////////////////////////////////
/// Tell whether or not the system supports shaders
///
/// \return sfTrue if the system can use shaders
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfShader_IsAvailable(void);
#endif // SFML_SHADER_H
+464
View File
@@ -0,0 +1,464 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SHAPE_H
#define SFML_SHAPE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Create a new shape
///
/// \return A new sfShape object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_Create(void);
////////////////////////////////////////////////////////////
/// Create a new shape made of a single line
///
/// \param p1x, p1y : Position of the first point
/// \param p2x, p2y : Position second point
/// \param thickness : Line thickness
/// \param color : Color used to draw the line
/// \param outline : Outline thickness
/// \param outlineColor : Color used to draw the outline
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y, float thickness, sfColor color, float outline, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Create a new shape made of a single rectangle
///
/// \param left, top : Top-left corner of the rectangle
/// \param width, height : Size of the rectangle
/// \param color : Color used to fill the rectangle
/// \param outline : Outline thickness
/// \param outlineColor : Color used to draw the outline
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Create a new shape made of a single circle
///
/// \param x, y : Position of the center
/// \param radius : Radius
/// \param color : Color used to fill the circle
/// \param outline : Outline thickness
/// \param outlineColor : Color used to draw the outline
///
////////////////////////////////////////////////////////////
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
///
/// \param Shape : Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Destroy(sfShape* shape);
////////////////////////////////////////////////////////////
/// Set the X position of a shape
///
/// \param shape : Shape to modify
/// \param x : New X coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetX(sfShape* shape, float x);
////////////////////////////////////////////////////////////
/// Set the Y position of a shape
///
/// \param shape : Shape to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetY(sfShape* shape, float y);
////////////////////////////////////////////////////////////
/// Set the position of a shape
///
/// \param shape : Shape to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPosition(sfShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a shape
///
/// \param shape : Shape to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetScaleX(sfShape* shape, float scale);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a shape
///
/// \param shape : Shape to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetScaleY(sfShape* shape, float scale);
////////////////////////////////////////////////////////////
/// Set the scale of a shape
///
/// \param shape : Shape to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetScale(sfShape* shape, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a shape
///
/// \param shape : Shape to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetRotation(sfShape* shape, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a shape, in coordinates relative to
/// its left-top corner
///
/// \param shape : Shape to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetOrigin(sfShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a shape
///
/// \param shape : Shape to modify
/// \param color : New color
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetColor(sfShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// Set the blending mode for a shape
///
/// \param shape : Shape to modify
/// \param mode : New blending mode
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetBlendMode(sfShape* shape, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a shape
///
/// \param shape : Shape to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetX(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the Y position of a shape
///
/// \param shape : Shape to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetY(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a shape
///
/// \param shape : Shape to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetScaleX(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a shape
///
/// \param shape : Shape to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetScaleY(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the orientation of a shape
///
/// \param shape : Shape to read
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetRotation(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a shape
///
/// \param shape : Shape to read
///
/// \return Current X origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetOriginX(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the Y position of the origin a shape
///
/// \param shape : Shape to read
///
/// \return Current Y origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetOriginY(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the color of a shape
///
/// \param shape : Shape to read
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfShape_GetColor(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a shape
///
/// \param shape : Shape to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfShape_GetBlendMode(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Move a shape
///
/// \param shape : Shape to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Move(sfShape* shape, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a shape
///
/// \param shape : Shape to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Scale(sfShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a shape
///
/// \param shape : Shape to modify
/// \param angle : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Rotate(sfShape* shape, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the shape's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
///
/// \param shape : Shape object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_TransformToLocal(const sfShape* shape, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Transform a point from the shape's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
///
/// \param shape : Shape object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_TransformToGlobal(const sfShape* shape, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Add a point to a shape
///
/// \param shape : Shape to modify
/// \param x, y : Position of the point
/// \param color : Color of the point
/// \param outlineColor : Outline color of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_AddPoint(sfShape* shape, float x, float y, sfColor color, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Enable or disable filling a shape.
/// Fill is enabled by default
///
/// \param shape : Shape to modify
/// \param enable : True to enable, false to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_EnableFill(sfShape* shape, sfBool enable);
////////////////////////////////////////////////////////////
/// Enable or disable drawing a shape outline.
/// Outline is enabled by default
///
/// \param shape : Shape to modify
/// \param enable : True to enable, false to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_EnableOutline(sfShape* shape, sfBool enable);
////////////////////////////////////////////////////////////
/// Change the thickness of a shape outline
///
/// \param shape : Shape to modify
/// \param thickness : New thickness
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetOutlineThickness(sfShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// Get the thickness of a shape outline
///
/// \param shape : Shape to read
///
/// \param return Current outline thickness
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetOutlineThickness(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the number of points composing a shape
///
/// \param shape : Shape to read
///
/// \return Total number of points
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfShape_GetPointsCount(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get a the position of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param x : Variable to fill with the X coordinate of the point
/// \param y : Variable to fill with the Y coordinate of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_GetPointPosition(const sfShape* shape, unsigned int index, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get a the color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
///
/// \return Color of the point
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfShape_GetPointColor(const sfShape* shape, unsigned int index);
////////////////////////////////////////////////////////////
/// Get a the outline color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
///
/// \return Outline color of the point
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfShape_GetPointOutlineColor(const sfShape* shape, unsigned int index);
////////////////////////////////////////////////////////////
/// Set a the position of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param x : X coordinate of the point
/// \param y : Y coordinate of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPointPosition(sfShape* shape, unsigned int index, float x, float y);
////////////////////////////////////////////////////////////
/// Set a the color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param color : Color of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPointColor(sfShape* shape, unsigned int index, sfColor color);
////////////////////////////////////////////////////////////
/// Set a the outline color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param color : Outline color of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color);
#endif // SFML_SHAPE_H
+403
View File
@@ -0,0 +1,403 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SPRITE_H
#define SFML_SPRITE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Create a new sprite
///
/// \return A new sfSprite object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfSprite* sfSprite_Create(void);
////////////////////////////////////////////////////////////
/// Copy an existing sprite
///
/// \param sprite : Sprite to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfSprite* sfSprite_Copy(sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Destroy an existing sprite
///
/// \param sprite : Sprite to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Destroy(sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Set the X position of a sprite
///
/// \param sprite : Sprite to modify
/// \param x : New X coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetX(sfSprite* sprite, float x);
////////////////////////////////////////////////////////////
/// Set the T position of a sprite
///
/// \param sprite : Sprite to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetY(sfSprite* sprite, float y);
////////////////////////////////////////////////////////////
/// Set the position of a sprite
///
/// \param sprite : Sprite to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetPosition(sfSprite* sprite, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a sprite
///
/// \param sprite : Sprite to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetScaleX(sfSprite* sprite, float scale);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a sprite
///
/// \param sprite : Sprite to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetScaleY(sfSprite* sprite, float scale);
////////////////////////////////////////////////////////////
/// Set the scale of a sprite
///
/// \param sprite : Sprite to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetScale(sfSprite* sprite, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a sprite
///
/// \param sprite : Sprite to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetRotation(sfSprite* sprite, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a sprite, in coordinates relative to
/// its left-top corner
///
/// \param sprite : Sprite to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetOrigin(sfSprite* sprite, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a sprite
///
/// \param sprite : Sprite to modify
/// \param color : New color
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetColor(sfSprite* sprite, sfColor color);
////////////////////////////////////////////////////////////
/// Set the blending mode for a sprite
///
/// \param sprite : Sprite to modify
/// \param mode : New blending mode
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetBlendMode(sfSprite* sprite, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetX(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the Y position of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetY(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetScaleX(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetScaleY(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the orientation of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetRotation(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current X origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetOriginX(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the Y position of the origin a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current Y origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetOriginY(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the color of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfSprite_GetColor(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfSprite_GetBlendMode(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Move a sprite
///
/// \param sprite : Sprite to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Move(sfSprite* sprite, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a sprite
///
/// \param sprite : Sprite to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a sprite
///
/// \param sprite : Sprite to modify
/// \param angle : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Rotate(sfSprite* sprite, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the sprite's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
///
/// \param sprite : Sprite object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_TransformToLocal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Transform a point from the sprite's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
///
/// \param sprite : Sprite object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_TransformToGlobal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Change the image of a sprite
///
/// \param sprite : Sprite to modify
/// \param image : New image
/// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new image
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetImage(sfSprite* sprite, const sfImage* image, sfBool adjustToNewSize);
////////////////////////////////////////////////////////////
/// Set the sub-rectangle of a sprite inside the source image
///
/// \param sprite : Sprite to modify
/// \param rectangle : New sub-rectangle
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle);
////////////////////////////////////////////////////////////
/// Resize a sprite (by changing its scale factors)
///
/// \param sprite : Sprite to modify
/// \param width : New width (must be strictly positive)
/// \param height : New height (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Resize(sfSprite* sprite, float width, float height);
////////////////////////////////////////////////////////////
/// Flip a sprite horizontally
///
/// \param sprite : Sprite to modify
/// \param flipped : sfTrue to flip the sprite
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_FlipX(sfSprite* sprite, sfBool flipped);
////////////////////////////////////////////////////////////
/// Flip a sprite vertically
///
/// \param sprite : Sprite to modify
/// \param flipped : sfTrue to flip the sprite
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_FlipY(sfSprite* sprite, sfBool flipped);
////////////////////////////////////////////////////////////
/// Get the source image of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Pointer to the image (can be NULL)
///
////////////////////////////////////////////////////////////
CSFML_API const sfImage* sfSprite_GetImage(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the sub-rectangle of a sprite inside the source image
///
/// \param sprite : Sprite to read
///
/// \return Sub-rectangle
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfSprite_GetSubRect(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get a sprite width
///
/// \param sprite : Sprite to read
///
/// \return Width of the sprite
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetWidth(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get a sprite height
///
/// \param sprite : Sprite to read
///
/// \return Height of the sprite
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetHeight(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the color of a given pixel in a sprite
///
/// \param sprite : Sprite to read
/// \param x : X coordinate of the pixel to get
/// \param y : Y coordinate of the pixel to get
///
/// \return Color of pixel (X, Y)
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfSprite_GetPixel(const sfSprite* sprite, unsigned int x, unsigned int y);
#endif // SFML_SPRITE_H
+434
View File
@@ -0,0 +1,434 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_TEXT_H
#define SFML_TEXT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// sfText styles
////////////////////////////////////////////////////////////
typedef enum
{
sfTextRegular = 0, ///< Regular characters, no style
sfTextBold = 1 << 0, ///< Characters are bold
sfTextItalic = 1 << 1, ///< Characters are in italic
sfTextUnderlined = 1 << 2 ///< Characters are underlined
} sfTextStyle;
////////////////////////////////////////////////////////////
/// Create a new text
///
/// \return A new sfText object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfText* sfText_Create(void);
////////////////////////////////////////////////////////////
/// Copy an existing text
///
/// \param text : Text to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfText* sfText_Copy(sfText* text);
////////////////////////////////////////////////////////////
/// Destroy an existing text
///
/// \param text : Text to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Destroy(sfText* text);
////////////////////////////////////////////////////////////
/// Set the X position of a text
///
/// \param text : String to modify
/// \param x : New X coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetX(sfText* text, float x);
////////////////////////////////////////////////////////////
/// Set the Y position of a text
///
/// \param text : String to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetY(sfText* text, float y);
////////////////////////////////////////////////////////////
/// Set the position of a text
///
/// \param text : String to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetPosition(sfText* text, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a text
///
/// \param text : String to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetScaleX(sfText* text, float scale);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a text
///
/// \param text : String to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetScaleY(sfText* text, float scale);
////////////////////////////////////////////////////////////
/// Set the scale of a text
///
/// \param text : String to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetScale(sfText* text, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a text
///
/// \param text : String to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetRotation(sfText* text, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a text, in coordinates
/// relative to its left-top corner
///
/// \param text : String to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetOrigin(sfText* text, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a text
///
/// \param text : String to modify
/// \param color : New color
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetColor(sfText* text, sfColor color);
////////////////////////////////////////////////////////////
/// Set the blending mode for a text
///
/// \param text : String to modify
/// \param mode : New blending mode
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetBlendMode(sfText* text, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a text
///
/// \param text : String to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetX(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the top Y of a text
///
/// \param text : String to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetY(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a text
///
/// \param text : String to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetScaleX(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a text
///
/// \param text : String to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetScaleY(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the orientation of a text
///
/// \param text : String to read
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetRotation(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a text
///
/// \param text : String to read
///
/// \return Current X origin position
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetOriginX(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the top Y of the origin of a text
///
/// \param text : String to read
///
/// \return Current Y origin position
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetOriginY(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the color of a text
///
/// \param text : String to read
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfText_GetColor(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a text
///
/// \param text : String to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfText_GetBlendMode(const sfText* text);
////////////////////////////////////////////////////////////
/// Move a text
///
/// \param text : String to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Move(sfText* text, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a text
///
/// \param text : String to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Scale(sfText* text, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a text
///
/// \param text : String to modify
/// \param angle : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Rotate(sfText* text, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the string's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
///
/// \param text : String object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_TransformToLocal(const sfText* text, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Transform a point from the string's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
///
/// \param text : String object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_TransformToGlobal(const sfText* text, float pointX, float pointY, float* X, float* y);
////////////////////////////////////////////////////////////
/// Set the string of a text (from a multibyte string)
///
/// \param text : Text to modify
/// \param string : New string
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetString(sfText* text, const char* string);
////////////////////////////////////////////////////////////
/// Set the string of a text (from a unicode string)
///
/// \param text : Text to modify
/// \param string : New string
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetUnicodeString(sfText* text, const sfUint32* string);
////////////////////////////////////////////////////////////
/// Set the font of a text
///
/// \param text : String to modify
/// \param font : Font to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetFont(sfText* text, const sfFont* font);
////////////////////////////////////////////////////////////
/// Set the size of a text
///
/// \param text : String to modify
/// \param size : New size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetCharacterSize(sfText* text, unsigned int size);
////////////////////////////////////////////////////////////
/// Set the style of a text
///
/// \param text : String to modify
/// \param style : New style (see sfTextStyle enum)
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetStyle(sfText* text, unsigned long style);
////////////////////////////////////////////////////////////
/// Get the string of a text (returns a unicode string)
///
/// \param text : String to read
///
/// \return String as UTF-32
///
////////////////////////////////////////////////////////////
CSFML_API const sfUint32* sfText_GetUnicodeString(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the text of a text (returns an ANSI string)
///
/// \param text : String to read
///
/// \return String an a locale-dependant ANSI string
///
////////////////////////////////////////////////////////////
CSFML_API const char* sfText_GetString(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the font used by a text
///
/// \param text : String to read
///
/// \return Pointer to the font
///
////////////////////////////////////////////////////////////
CSFML_API const sfFont* sfText_GetFont(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the size of the characters of a text
///
/// \param text : String to read
///
/// \return Size of the characters
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfText_GetCharacterSize(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the style of a text
///
/// \param text : String to read
///
/// \return Current string style (see sfTextStyle enum)
///
////////////////////////////////////////////////////////////
CSFML_API unsigned long sfText_GetStyle(const sfText* text);
////////////////////////////////////////////////////////////
/// Return the visual position of the Index-th character of the text,
/// in coordinates relative to the string
/// (note : translation, origin, rotation and scale are not applied)
///
/// \param text : String to read
/// \param index : Index of the character
/// \param x : Value to fill with the X coordinate of the position
/// \param y : Value to fill with the y coordinate of the position
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_GetCharacterPos(const sfText* text, size_t index, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get the bounding rectangle of a text on screen
///
/// \param text : String to read
///
/// \return Rectangle contaning the string in screen coordinates
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfText_GetRect(const sfText* text);
#endif // SFML_TEXT_H
+40
View File
@@ -0,0 +1,40 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_GRAPHICS_TYPES_H
#define SFML_GRAPHICS_TYPES_H
typedef struct sfFont sfFont;
typedef struct sfImage sfImage;
typedef struct sfShader sfShader;
typedef struct sfRenderImage sfRenderImage;
typedef struct sfRenderWindow sfRenderWindow;
typedef struct sfShape sfShape;
typedef struct sfSprite sfSprite;
typedef struct sfText sfText;
typedef struct sfView sfView;
#endif // SFML_GRAPHICS_TYPES_H
+209
View File
@@ -0,0 +1,209 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_VIEW_H
#define SFML_VIEW_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Construct a default view (1000x1000)
///
////////////////////////////////////////////////////////////
CSFML_API sfView* sfView_Create(void);
////////////////////////////////////////////////////////////
/// Construct a view from a rectangle
///
/// \param rectangle : Rectangle defining the bounds of the view
///
////////////////////////////////////////////////////////////
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
///
/// \param view : View to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Destroy(sfView* view);
////////////////////////////////////////////////////////////
/// Change the center of a view
///
/// \param view : View to modify
/// \param x : X coordinate of the new center
/// \param y : Y coordinate of the new center
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetCenter(sfView* view, float x, float y);
////////////////////////////////////////////////////////////
/// Change the size of a view
///
/// \param view : View to modify
/// \param width : New width
/// \param height : New height
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetSize(sfView* view, float width, float height);
////////////////////////////////////////////////////////////
/// Set the angle of rotation of a view
///
/// \param view : View to modify
/// \param angle : New angle, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetRotation(sfView* view, float angle);
////////////////////////////////////////////////////////////
/// Set the target viewport of a view
///
/// The viewport is the rectangle into which the contents of the
/// view are displayed, expressed as a factor (between 0 and 1)
/// of the size of the RenderTarget to which the view is applied.
///
/// \param view : View to modify
/// \param viewport : New viewport
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetViewport(sfView* view, sfFloatRect viewport);
////////////////////////////////////////////////////////////
/// Reset a view to the given rectangle.
/// Note: this function resets the rotation angle to 0.
///
/// \param view : View to modify
/// \param rectangle : Rectangle defining the position and size of the view
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Reset(sfView* view, sfFloatRect rectangle);
////////////////////////////////////////////////////////////
/// Get the X coordinate of the center of a view
///
/// \param view : View to read
///
/// \return X coordinate of the center of the view
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetCenterX(const sfView* view);
////////////////////////////////////////////////////////////
/// Get the Y coordinate of the center of a view
///
/// \param view : View to read
///
/// \return Y coordinate of the center of the view
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetCenterY(const sfView* view);
////////////////////////////////////////////////////////////
/// Get the width of the view
///
/// \param view : View to read
///
/// \return Width of the view
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetWidth(const sfView* view);
////////////////////////////////////////////////////////////
/// Get the height of the view
///
/// \param view : View to read
///
/// \return Height of the view
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetHeight(const sfView* view);
////////////////////////////////////////////////////////////
/// Get the current rotation of a view
///
/// \param view : View to read
///
/// \return Rotation of the view, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetRotation(const sfView* view);
////////////////////////////////////////////////////////////
/// Get the target viewport of a view
///
/// \param view : View to read
///
/// \return Viewport rectangle, expressed as a factor of the target size
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfView_GetViewport(const sfView* view);
////////////////////////////////////////////////////////////
/// Move a view
///
/// \param view : View to move
/// \param offsetX : Offset to move the view, on X axis
/// \param offsetY : Offset to move the view, on Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Move(sfView* view, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Rotate a view
///
/// \param view : View to rotate
/// \param angle : Angle in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Rotate(sfView* view, float angle);
////////////////////////////////////////////////////////////
/// Resize a view rectangle to simulate a zoom / unzoom effect
///
/// \param view : View to zoom
/// \param factor : Zoom factor to apply, relative to the current zoom
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Zoom(sfView* view, float factor);
#endif // SFML_VIEW_H