Added Vector classes

Updated according to the latest modifications in SFML
This commit is contained in:
Laurent Gomila committed 2012-03-09 00:18:08 +01:00
1 parent 0b2a231121
commit 69433eb0a4
10 files changed
+348 -217

No files matched your search

+4 -13
View File
@@ -35,6 +35,7 @@
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/Vertex.h>
#include <SFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -58,24 +59,14 @@ CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_Create(unsigned int width, u
CSFML_GRAPHICS_API void sfRenderTexture_Destroy(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Get the width of the rendering region of a render texture
/// \brief Get the size of the rendering region of a render texture
///
/// \param renderTexture Render texture object
///
/// \return Width in pixels
/// \return Size in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Get the height of the rendering region of a render texture
///
/// \param renderTexture Render texture object
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture);
CSFML_GRAPHICS_API sfVector2u sfRenderTexture_GetSize(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate a render texture as the current target for rendering
+50 -51
View File
@@ -39,6 +39,7 @@
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Window.h>
#include <SFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -85,26 +86,6 @@ CSFML_GRAPHICS_API void sfRenderWindow_Close(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_IsOpen(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Get the width of the rendering region of a render window
///
/// \param renderWindow Render window object
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Get the height of the rendering region of a render window
///
/// \param renderWindow Render window object
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Get the creation settings of a render window
///
@@ -138,22 +119,14 @@ CSFML_GRAPHICS_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow,
CSFML_GRAPHICS_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event);
////////////////////////////////////////////////////////////
/// \brief Enable / disable vertical synchronization on a render window
/// \brief Get the position of a render window
///
/// \param renderWindow Render window object
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
///
/// \return Position in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor on a render window
///
/// \param renderWindow Render window object
/// \param show sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show);
CSFML_GRAPHICS_API sfVector2i sfRenderWindow_GetPosition(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Change the position of a render window on screen
@@ -161,21 +134,29 @@ CSFML_GRAPHICS_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWin
/// Only works for top-level windows
///
/// \param renderWindow Render window object
/// \param left Left position
/// \param top Top position
/// \param position New position, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top);
CSFML_GRAPHICS_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, sfVector2i position);
////////////////////////////////////////////////////////////
/// \brief Get the size of the rendering region of a render window
///
/// \param renderWindow Render window object
///
/// \return Size in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2u sfRenderWindow_GetSize(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Change the size of the rendering region of a render window
///
/// \param renderWindow Render window object
/// \param width New Width
/// \param height New Height
/// \param size New size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height);
CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Change the title of a render window
@@ -186,14 +167,43 @@ CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, uns
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title);
////////////////////////////////////////////////////////////
/// \brief Change a render window's icon
///
/// \param renderWindow Renderw indow 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_GRAPHICS_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a render window
///
/// \param renderWindow Render window object
/// \param visible sfTrue to show the window, sfFalse to hide it
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_SetVisible(sfRenderWindow* renderWindow, sfBool visible);
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor on a render window
///
/// \param renderWindow Render window object
/// \param show sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show);
CSFML_GRAPHICS_API void sfRenderWindow_SetMouseCursorVisible(sfRenderWindow* renderWindow, sfBool show);
////////////////////////////////////////////////////////////
/// \brief Enable / disable vertical synchronization on a render window
///
/// \param renderWindow Render window object
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_SetVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat for keydown events
@@ -204,18 +214,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool
/// \param enabled sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Change a render window's icon
///
/// \param renderWindow Renderw indow 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_GRAPHICS_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
CSFML_GRAPHICS_API void sfRenderWindow_SetKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate a render window as the current target for rendering
+2
View File
@@ -35,6 +35,8 @@
#include <SFML/System/Mutex.h>
#include <SFML/System/Sleep.h>
#include <SFML/System/Thread.h>
#include <SFML/System/Vector2.h>
#include <SFML/System/Vector3.h>
#endif // SFML_SYSTEM_H
+67
View File
@@ -0,0 +1,67 @@
////////////////////////////////////////////////////////////
//
// 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_VECTOR2_H
#define SFML_VECTOR2_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
////////////////////////////////////////////////////////////
/// \brief 2-component vector of integers
///
////////////////////////////////////////////////////////////
typedef struct
{
int x;
int y;
} sfVector2i;
////////////////////////////////////////////////////////////
/// \brief 2-component vector of unsigned integers
///
////////////////////////////////////////////////////////////
typedef struct
{
unsigned int x;
unsigned int y;
} sfVector2u;
////////////////////////////////////////////////////////////
/// \brief 2-component vector of floats
///
////////////////////////////////////////////////////////////
typedef struct
{
float x;
float y;
} sfVector2f;
#endif // SFML_VECTOR2_H
+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_VECTOR3_H
#define SFML_VECTOR3_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
////////////////////////////////////////////////////////////
/// \brief 3-component vector of floats
///
////////////////////////////////////////////////////////////
typedef struct
{
float x;
float y;
float z;
} sfVector3f;
#endif // SFML_VECTOR3_H
+70 -74
View File
@@ -33,6 +33,7 @@
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Types.h>
#include <SFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -141,32 +142,6 @@ CSFML_WINDOW_API void sfWindow_Close(sfWindow* window);
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfWindow_IsOpen(const sfWindow* window);
////////////////////////////////////////////////////////////
/// \brief Get the width of the rendering region of a window
///
/// The width doesn't include the titlebar and borders
/// of the window.
///
/// \param window Window object
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API unsigned int sfWindow_GetWidth(const sfWindow* window);
////////////////////////////////////////////////////////////
/// \brief Get the height of the rendering region of a window
///
/// The height doesn't include the titlebar and borders
/// of the window.
///
/// \param window Window object
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API unsigned int sfWindow_GetHeight(const sfWindow* window);
////////////////////////////////////////////////////////////
/// \brief Get the settings of the OpenGL context of a window
///
@@ -219,27 +194,14 @@ CSFML_WINDOW_API sfBool sfWindow_PollEvent(sfWindow* window, sfEvent* event);
CSFML_WINDOW_API sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event);
////////////////////////////////////////////////////////////
/// \brief Enable or disable vertical synchronization
///
/// Activating vertical synchronization will limit the number
/// of frames displayed to the refresh rate of the monitor.
/// This can avoid some visual artifacts, and limit the framerate
/// to a good value (but not constant across different computers).
///
/// \param window Window object
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor
/// \brief Get the position of a window
///
/// \param window Window object
/// \param show sfTrue to show, sfFalse to hide
///
/// \return Position in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show);
CSFML_WINDOW_API sfVector2i sfWindow_GetPosition(const sfWindow* window);
////////////////////////////////////////////////////////////
/// \brief Change the position of a window on screen
@@ -248,22 +210,33 @@ CSFML_WINDOW_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show);
/// (i.e. it will be ignored for windows created from
/// the handle of a child window/control).
///
/// \param window Window object
/// \param x Left position
/// \param y Top position
/// \param window Window object
/// \param position New position of the window, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetPosition(sfWindow* window, int left, int top);
CSFML_WINDOW_API void sfWindow_SetPosition(sfWindow* window, sfVector2i position);
////////////////////////////////////////////////////////////
/// \brief Get the size of the rendering region of a window
///
/// The size doesn't include the titlebar and borders
/// of the window.
///
/// \param window Window object
///
/// \return Size in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfVector2u sfWindow_GetSize(const sfWindow* window);
////////////////////////////////////////////////////////////
/// \brief Change the size of the rendering region of a window
///
/// \param window Window object
/// \param width New width, in pixels
/// \param height New height, in pixels
/// \param size New size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetSize(sfWindow* window, unsigned int width, unsigned int height);
CSFML_WINDOW_API void sfWindow_SetSize(sfWindow* window, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Change the title of a window
@@ -274,30 +247,6 @@ CSFML_WINDOW_API void sfWindow_SetSize(sfWindow* window, unsigned int width, uns
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetTitle(sfWindow* window, const char* title);
////////////////////////////////////////////////////////////
/// \brief Show or hide a window
///
/// \param window Window object
/// \param show sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_Show(sfWindow* window, sfBool show);
////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// If key repeat is enabled, you will receive repeated
/// KeyPress events while keeping a key pressed. If it is disabled,
/// you will only get a single event when the key is pressed.
///
/// Key repeat is enabled by default.
///
/// \param window Window object
/// \param enabled sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Change a window's icon
///
@@ -312,6 +261,53 @@ CSFML_WINDOW_API void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled)
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a window
///
/// \param window Window object
/// \param visible sfTrue to show the window, sfFalse to hide it
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetVisible(sfWindow* window, sfBool visible);
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor
///
/// \param window Window object
/// \param visible sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetMouseCursorVisible(sfWindow* window, sfBool visible);
////////////////////////////////////////////////////////////
/// \brief Enable or disable vertical synchronization
///
/// Activating vertical synchronization will limit the number
/// of frames displayed to the refresh rate of the monitor.
/// This can avoid some visual artifacts, and limit the framerate
/// to a good value (but not constant across different computers).
///
/// \param window Window object
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetVerticalSyncEnabled(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// If key repeat is enabled, you will receive repeated
/// KeyPress events while keeping a key pressed. If it is disabled,
/// you will only get a single event when the key is pressed.
///
/// Key repeat is enabled by default.
///
/// \param window Window object
/// \param enabled sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_SetKeyRepeatEnabled(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate a window as the current target
/// for OpenGL rendering