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

+61
View File
@@ -0,0 +1,61 @@
////////////////////////////////////////////////////////////
//
// 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_CONTEXT_H
#define SFML_CONTEXT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Window/Types.h>
////////////////////////////////////////////////////////////
/// Construct a new context
///
/// \return New context
///
////////////////////////////////////////////////////////////
CSFML_API sfContext* sfContext_Create(void);
////////////////////////////////////////////////////////////
/// Destroy an existing context
///
/// \param context : Context to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfContext_Destroy(sfContext* context);
////////////////////////////////////////////////////////////
/// Activate or deactivate a context
///
/// \param context : Context to activate or deactivate
/// \param active : sfTrue to activate, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_API void sfContext_SetActive(sfContext* context, sfBool active);
#endif // SFML_CONTEXT_H
+178
View File
@@ -0,0 +1,178 @@
////////////////////////////////////////////////////////////
//
// 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_EVENT_H
#define SFML_EVENT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Window/Joystick.h>
#include <SFML/Window/Keyboard.h>
#include <SFML/Window/Mouse.h>
////////////////////////////////////////////////////////////
/// Definition of all the event types
////////////////////////////////////////////////////////////
typedef enum
{
sfEvtClosed,
sfEvtResized,
sfEvtLostFocus,
sfEvtGainedFocus,
sfEvtTextEntered,
sfEvtKeyPressed,
sfEvtKeyReleased,
sfEvtMouseWheelMoved,
sfEvtMouseButtonPressed,
sfEvtMouseButtonReleased,
sfEvtMouseMoved,
sfEvtMouseEntered,
sfEvtMouseLeft,
sfEvtJoystickButtonPressed,
sfEvtJoystickButtonReleased,
sfEvtJoystickMoved,
sfEvtJoystickConnected,
sfEvtJoystickDisconnected
} sfEventType;
////////////////////////////////////////////////////////////
/// Keyboard event parameters
////////////////////////////////////////////////////////////
struct sfKeyEvent
{
sfEventType Type;
sfKeyCode Code;
sfBool Alt;
sfBool Control;
sfBool Shift;
sfBool System;
};
////////////////////////////////////////////////////////////
/// Text event parameters
////////////////////////////////////////////////////////////
struct sfTextEvent
{
sfEventType Type;
sfUint32 Unicode;
};
////////////////////////////////////////////////////////////
/// Mouse move event parameters
////////////////////////////////////////////////////////////
struct sfMouseMoveEvent
{
sfEventType Type;
int X;
int Y;
};
////////////////////////////////////////////////////////////
/// Mouse buttons events parameters
////////////////////////////////////////////////////////////
struct sfMouseButtonEvent
{
sfEventType Type;
sfMouseButton Button;
int X;
int Y;
};
////////////////////////////////////////////////////////////
/// Mouse wheel events parameters
////////////////////////////////////////////////////////////
struct sfMouseWheelEvent
{
sfEventType Type;
int Delta;
int X;
int Y;
};
////////////////////////////////////////////////////////////
/// Joystick axis move event parameters
////////////////////////////////////////////////////////////
struct sfJoystickMoveEvent
{
sfEventType Type;
unsigned int JoystickId;
sfJoystickAxis Axis;
float Position;
};
////////////////////////////////////////////////////////////
/// Joystick buttons events parameters
////////////////////////////////////////////////////////////
struct sfJoystickButtonEvent
{
sfEventType Type;
unsigned int JoystickId;
unsigned int Button;
};
////////////////////////////////////////////////////////////
/// Joystick connection/disconnection event parameters
////////////////////////////////////////////////////////////
struct sfJoystickConnectEvent
{
sfEventType Type;
unsigned int JoystickId;
};
////////////////////////////////////////////////////////////
/// Size events parameters
////////////////////////////////////////////////////////////
struct sfSizeEvent
{
sfEventType Type;
unsigned int Width;
unsigned int Height;
};
////////////////////////////////////////////////////////////
/// sfEvent defines a system event and its parameters
////////////////////////////////////////////////////////////
typedef union
{
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
sfEventType Type; ///< Type of the event
struct sfSizeEvent Size;
struct sfKeyEvent Key;
struct sfTextEvent Text;
struct sfMouseMoveEvent MouseMove;
struct sfMouseButtonEvent MouseButton;
struct sfMouseWheelEvent MouseWheel;
struct sfJoystickMoveEvent JoystickMove;
struct sfJoystickButtonEvent JoystickButton;
struct sfJoystickConnectEvent JoystickConnect;
} sfEvent;
#endif // SFML_EVENT_H
+102
View File
@@ -0,0 +1,102 @@
////////////////////////////////////////////////////////////
//
// 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_INPUT_H
#define SFML_INPUT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/Types.h>
////////////////////////////////////////////////////////////
/// Get the state of a key
///
/// \param input : Input object
/// \param code : Key to check
///
/// \return sfTrue if key is down, sfFalse if key is up
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfInput_IsKeyDown(const sfInput* input, sfKeyCode code);
////////////////////////////////////////////////////////////
/// Get the state of a mouse button
///
/// \param input : Input object
/// \param button : Button to check
///
/// \return sfTrue if button is down, sfFalse if button is up
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfInput_IsMouseButtonDown(const sfInput* input, sfMouseButton button);
////////////////////////////////////////////////////////////
/// Get the state of a joystick button
///
/// \param input : Input object
/// \param joyId : Identifier of the joystick to check (0 or 1)
/// \param button : Button to check
///
/// \return sfTrue if button is down, sfFalse if button is up
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfInput_IsJoystickButtonDown(const sfInput* input, unsigned int joyId, unsigned int button);
////////////////////////////////////////////////////////////
/// Get the mouse X position
///
/// \param input : Input object
///
/// \return Current mouse left position, relative to owner window
///
////////////////////////////////////////////////////////////
CSFML_API int sfInput_GetMouseX(const sfInput* input);
////////////////////////////////////////////////////////////
/// Get the mouse Y position
///
/// \param input : Input object
///
/// \return Current mouse top position, relative to owner window
///
////////////////////////////////////////////////////////////
CSFML_API int sfInput_GetMouseY(const sfInput* input);
////////////////////////////////////////////////////////////
/// Get the joystick position on a given axis
///
/// \param input : Input object
/// \param joyId : Identifier of the joystick to check (0 or 1)
/// \param axis : Identifier of the axis to read
///
/// \return Current joystick position, in the range [-100, 100]
///
////////////////////////////////////////////////////////////
CSFML_API float sfInput_GetJoystickAxis(const sfInput* input, unsigned int joyId, sfJoyAxis axis);
#endif // SFML_INPUT_H
+135
View File
@@ -0,0 +1,135 @@
////////////////////////////////////////////////////////////
//
// 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_JOYSTICK_H
#define SFML_JOYSTICK_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Global joysticks capabilities
///
////////////////////////////////////////////////////////////
enum
{
sfJoystickCount = 8, ///< Maximum number of supported joysticks
sfJoystickButtonCount = 32, ///< Maximum number of supported buttons
sfJoystickAxisCount = 8 ///< Maximum number of supported axes
};
////////////////////////////////////////////////////////////
/// \brief Axes supported by SFML joysticks
///
////////////////////////////////////////////////////////////
typedef enum
{
sfJoystickX, ///< The X axis
sfJoystickY, ///< The Y axis
sfJoystickZ, ///< The Z axis
sfJoystickR, ///< The R axis
sfJoystickU, ///< The U axis
sfJoystickV, ///< The V axis
sfJoystickPovX, ///< The X axis of the point-of-view hat
sfJoystickPovY ///< The Y axis of the point-of-view hat
} sfJoystickAxis;
////////////////////////////////////////////////////////////
/// \brief Check if a joystick is connected
///
/// \param joystick Index of the joystick to check
///
/// \return sfTrue if the joystick is connected, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfJoystick_IsConnected(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Return the number of buttons supported by a joystick
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
///
/// \return Number of buttons supported by the joystick
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfJoystick_GetButtonCount(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick supports a given axis
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return sfTrue if the joystick supports the axis, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfJoystick_HasAxis(unsigned int joystick, sfJoystickAxis axis);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick button is pressed
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param button Button to check
///
/// \return sfTrue if the button is pressed, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfJoystick_IsButtonPressed(unsigned int joystick, unsigned int button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of a joystick axis
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return Current position of the axis, in range [-100 .. 100]
///
////////////////////////////////////////////////////////////
CSFML_API float sfJoystick_GetAxisPosition(unsigned int joystick, sfJoystickAxis axis);
////////////////////////////////////////////////////////////
/// \brief Update the states of all joysticks
///
/// This function is used internally by SFML, so you normally
/// don't have to call it explicitely. However, you may need to
/// call it if you have no window yet (or no window at all):
/// in this case the joysticks states are not updated automatically.
///
////////////////////////////////////////////////////////////
CSFML_API void sfJoystick_Update(void);
#endif // SFML_JOYSTICK_H
+156
View File
@@ -0,0 +1,156 @@
////////////////////////////////////////////////////////////
//
// 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_KEYBOARD_H
#define SFML_KEYBOARD_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Key codes
///
////////////////////////////////////////////////////////////
typedef enum
{
sfKeyA, ///< The A key
sfKeyB, ///< The B key
sfKeyC, ///< The C key
sfKeyD, ///< The D key
sfKeyE, ///< The E key
sfKeyF, ///< The F key
sfKeyG, ///< The G key
sfKeyH, ///< The H key
sfKeyI, ///< The I key
sfKeyJ, ///< The J key
sfKeyK, ///< The K key
sfKeyL, ///< The L key
sfKeyM, ///< The M key
sfKeyN, ///< The N key
sfKeyO, ///< The O key
sfKeyP, ///< The P key
sfKeyQ, ///< The Q key
sfKeyR, ///< The R key
sfKeyS, ///< The S key
sfKeyT, ///< The T key
sfKeyU, ///< The U key
sfKeyV, ///< The V key
sfKeyW, ///< The W key
sfKeyX, ///< The X key
sfKeyY, ///< The Y key
sfKeyZ, ///< The Z key
sfKeyNum0, ///< The 0 key
sfKeyNum1, ///< The 1 key
sfKeyNum2, ///< The 2 key
sfKeyNum3, ///< The 3 key
sfKeyNum4, ///< The 4 key
sfKeyNum5, ///< The 5 key
sfKeyNum6, ///< The 6 key
sfKeyNum7, ///< The 7 key
sfKeyNum8, ///< The 8 key
sfKeyNum9, ///< The 9 key
sfKeyEscape, ///< The Escape key
sfKeyLControl, ///< The left Control key
sfKeyLShift, ///< The left Shift key
sfKeyLAlt, ///< The left Alt key
sfKeyLSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
sfKeyRControl, ///< The right Control key
sfKeyRShift, ///< The right Shift key
sfKeyRAlt, ///< The right Alt key
sfKeyRSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
sfKeyMenu, ///< The Menu key
sfKeyLBracket, ///< The [ key
sfKeyRBracket, ///< The ] key
sfKeySemiColon, ///< The ; key
sfKeyComma, ///< The , key
sfKeyPeriod, ///< The . key
sfKeyQuote, ///< The ' key
sfKeySlash, ///< The / key
sfKeyBackSlash, ///< The \ key
sfKeyTilde, ///< The ~ key
sfKeyEqual, ///< The = key
sfKeyDash, ///< The - key
sfKeySpace, ///< The Space key
sfKeyReturn, ///< The Return key
sfKeyBack, ///< The Backspace key
sfKeyTab, ///< The Tabulation key
sfKeyPageUp, ///< The Page up key
sfKeyPageDown, ///< The Page down key
sfKeyEnd, ///< The End key
sfKeyHome, ///< The Home key
sfKeyInsert, ///< The Insert key
sfKeyDelete, ///< The Delete key
sfKeyAdd, ///< +
sfKeySubtract, ///< -
sfKeyMultiply, ///< *
sfKeyDivide, ///< /
sfKeyLeft, ///< Left arrow
sfKeyRight, ///< Right arrow
sfKeyUp, ///< Up arrow
sfKeyDown, ///< Down arrow
sfKeyNumpad0, ///< The numpad 0 key
sfKeyNumpad1, ///< The numpad 1 key
sfKeyNumpad2, ///< The numpad 2 key
sfKeyNumpad3, ///< The numpad 3 key
sfKeyNumpad4, ///< The numpad 4 key
sfKeyNumpad5, ///< The numpad 5 key
sfKeyNumpad6, ///< The numpad 6 key
sfKeyNumpad7, ///< The numpad 7 key
sfKeyNumpad8, ///< The numpad 8 key
sfKeyNumpad9, ///< The numpad 9 key
sfKeyF1, ///< The F1 key
sfKeyF2, ///< The F2 key
sfKeyF3, ///< The F3 key
sfKeyF4, ///< The F4 key
sfKeyF5, ///< The F5 key
sfKeyF6, ///< The F6 key
sfKeyF7, ///< The F7 key
sfKeyF8, ///< The F8 key
sfKeyF9, ///< The F8 key
sfKeyF10, ///< The F10 key
sfKeyF11, ///< The F11 key
sfKeyF12, ///< The F12 key
sfKeyF13, ///< The F13 key
sfKeyF14, ///< The F14 key
sfKeyF15, ///< The F15 key
sfKeyPause, ///< The Pause key
sfKeyCount ///< Keep last -- the total number of keyboard keys
} sfKeyCode;
////////////////////////////////////////////////////////////
/// \brief Check if a key is pressed
///
/// \param key Key to check
///
/// \return sfTrue if the key is pressed, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfKeyboard_IsKeyPressed(sfKeyCode key);
#endif // SFML_KEYBOARD_H
+74
View File
@@ -0,0 +1,74 @@
////////////////////////////////////////////////////////////
//
// 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_MOUSE_H
#define SFML_MOUSE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Mouse buttons
///
////////////////////////////////////////////////////////////
typedef enum
{
sfMouseLeft, ///< The left mouse button
sfMouseRight, ///< The right mouse button
sfMouseMiddle, ///< The middle (wheel) mouse button
sfMouseXButton1, ///< The first extra mouse button
sfMouseXButton2, ///< The second extra mouse button
sfMouseButtonCount ///< Keep last -- the total number of mouse buttons
} sfMouseButton;
////////////////////////////////////////////////////////////
/// \brief Check if a mouse button is pressed
///
/// \param button Button to check
///
/// \return sfTrue if the button is pressed, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfMouse_IsButtonPressed(sfMouseButton button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse
///
/// This function returns the current position of the mouse
/// cursor.
/// If the cursor is over a SFML window, the returned position
/// is relative to this window. Otherwise, the returned position
/// is in desktop coordinates.
///
/// \return Current position of the mouse
///
////////////////////////////////////////////////////////////
CSFML_API void sfMouse_GetPosition(int* x, int* y);
#endif // SFML_MOUSE_H
+33
View File
@@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////
//
// 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_WINDOW_TYPES_H
#define SFML_WINDOW_TYPES_H
typedef struct sfContext sfContext;
typedef struct sfWindow sfWindow;
#endif // SFML_WINDOW_TYPES_H
+77
View File
@@ -0,0 +1,77 @@
////////////////////////////////////////////////////////////
//
// 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_VIDEOMODE_H
#define SFML_VIDEOMODE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// sfVideoMode defines a video mode (width, height, bpp, frequency)
/// and provides functions for getting modes supported
/// by the display device
////////////////////////////////////////////////////////////
typedef struct
{
unsigned int Width; ///< Video mode width, in pixels
unsigned int Height; ///< Video mode height, in pixels
unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels
} sfVideoMode;
////////////////////////////////////////////////////////////
/// Get the current desktop video mode
///
/// \return Current desktop video mode
///
////////////////////////////////////////////////////////////
CSFML_API sfVideoMode sfVideoMode_GetDesktopMode(void);
////////////////////////////////////////////////////////////
/// Get all the supported video modes for fullscreen mode.
/// Modes are sorted from best to worst.
///
/// \param Count : Variable that will be filled with the number of modes
///
/// \return Pointer to an array of \a count video modes
///
////////////////////////////////////////////////////////////
CSFML_API const sfVideoMode* sfVideoMode_GetFullscreenModes(size_t* Count);
////////////////////////////////////////////////////////////
/// Tell whether or not a video mode is supported
///
/// \param mode : Video mode to check
///
///
/// \return True if video mode is supported, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfVideoMode_IsValid(sfVideoMode mode);
#endif // SFML_VIDEOMODE_H
+319
View File
@@ -0,0 +1,319 @@
////////////////////////////////////////////////////////////
//
// 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_WINDOW_H
#define SFML_WINDOW_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Types.h>
////////////////////////////////////////////////////////////
/// Enumeration of window creation styles
///
////////////////////////////////////////////////////////////
enum
{
sfNone = 0, ///< No border / title bar (this flag and all others are mutually exclusive)
sfTitlebar = 1 << 0, ///< Title bar + fixed border
sfResize = 1 << 1, ///< Titlebar + resizable border + maximize button
sfClose = 1 << 2, ///< Titlebar + close button
sfFullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive)
sfDefaultStyle = sfTitlebar | sfResize | sfClose ///< Default window style
};
////////////////////////////////////////////////////////////
/// Structure defining the window's creation settings
////////////////////////////////////////////////////////////
typedef struct
{
unsigned int DepthBits; ///< Bits of the depth buffer
unsigned int StencilBits; ///< Bits of the stencil buffer
unsigned int AntialiasingLevel; ///< Level of antialiasing
unsigned int MajorVersion; ///< Major number of the context version to create
unsigned int MinorVersion; ///< Minor number of the context version to create
} sfContextSettings;
////////////////////////////////////////////////////////////
/// Construct a new window
///
/// \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 sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long style, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// Construct a window from an existing control
///
/// \param handle : Platform-specific handle of the control
/// \param settings : Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_API sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// Destroy an existing window
///
/// \param window : Window to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_Destroy(sfWindow* window);
////////////////////////////////////////////////////////////
/// Close a window (but doesn't destroy the internal data)
///
/// \param window : Window to close
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_Close(sfWindow* window);
////////////////////////////////////////////////////////////
/// Tell whether or not a window is opened
///
/// \param window : Window object
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfWindow_IsOpened(const sfWindow* window);
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a window
///
/// \param window : Window object
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfWindow_GetWidth(const sfWindow* window);
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a window
///
/// \param window : Window object
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfWindow_GetHeight(const sfWindow* window);
////////////////////////////////////////////////////////////
/// Get the creation settings of a window
///
/// \param window : Window object
///
/// \return Settings used to create the window
///
////////////////////////////////////////////////////////////
CSFML_API sfContextSettings sfWindow_GetSettings(const sfWindow* window);
////////////////////////////////////////////////////////////
/// Get the event on top of events stack of a window, if any, and pop it
///
/// \param window : Window object
/// \param event : Event to fill, if any
///
/// \return sfTrue if an event was returned, sfFalse if events stack was empty
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfWindow_PollEvent(sfWindow* window, sfEvent* event);
////////////////////////////////////////////////////////////
/// Wait for an event and return it
///
/// \param window : Window object
/// \param event : Event to fill
///
/// \return sfFalse if an error occured
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event);
////////////////////////////////////////////////////////////
/// Enable / disable vertical synchronization on a window
///
/// \param window : Window object
/// \param enabled : sfTrue to enable v-sync, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
/// Show or hide the mouse cursor on a window
///
/// \param window : Window object
/// \param show : sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show);
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor on a window
///
/// \param window : Window 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 sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// Get the position of the mouse cursor on a window
///
/// \param window : Window 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 sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top);
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
///
/// \param window : Window object
/// \param left : Left position
/// \param top : Top position
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetPosition(sfWindow* window, int left, int top);
////////////////////////////////////////////////////////////
/// Change the size of the rendering region of a window
///
/// \param window : Window object
/// \param width : New Width
/// \param height : New Height
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetSize(sfWindow* window, unsigned int width, unsigned int height);
////////////////////////////////////////////////////////////
/// Change the title of a window
///
/// \param window : Window object
/// \param title : New title
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetTitle(sfWindow* window, const char* title);
////////////////////////////////////////////////////////////
/// Show or hide a window
///
/// \param window : Window object
/// \param show : sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_Show(sfWindow* window, sfBool show);
////////////////////////////////////////////////////////////
/// Enable or disable automatic key-repeat for keydown events.
/// Automatic key-repeat is enabled by default
///
/// \param window : Window object
/// \param enabled : sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
/// Change the window's icon
///
/// \param window : Window 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 sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels);
////////////////////////////////////////////////////////////
/// Activate or deactivate a window as the current target for rendering
///
/// \param window : Window object
/// \param active : sfTrue to activate, sfFalse to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfWindow_SetActive(sfWindow* window, sfBool active);
////////////////////////////////////////////////////////////
/// Display a window on screen
///
/// \param window : Window object
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_Display(sfWindow* window);
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
///
/// \param window : Window object
/// \param limit : Framerate limit, in frames per seconds (use 0 to disable limit)
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetFramerateLimit(sfWindow* window, unsigned int limit);
////////////////////////////////////////////////////////////
/// Get time elapsed since last frame of a window
///
/// \param window : Window object
///
/// \return Time elapsed, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfWindow_GetFrameTime(const sfWindow* window);
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
///
/// \param window : Window object
/// \param threshold : New threshold, in range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold);
////////////////////////////////////////////////////////////
/// Retrieve the Os-specific handle of a window
///
/// \param window : Window object
///
/// \return Window handle
///
////////////////////////////////////////////////////////////
CSFML_API sfWindowHandle sfWindow_GetSystemHandle(const sfWindow* window);
#endif // SFML_WINDOW_H
+57
View File
@@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////
//
// 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_WINDOWHANDLE_H
#define SFML_WINDOWHANDLE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// Define a low-level window handle type, specific to
/// each platform
////////////////////////////////////////////////////////////
#if defined(CSFML_SYSTEM_WINDOWS)
// Window handle is HWND (HWND__*) on Windows
struct HWND__;
typedef HWND__* sfWindowHandle;
#elif defined(CSFML_SYSTEM_LINUX) || defined(CSFML_SYSTEM_FREEBSD)
// Window handle is Window (unsigned long) on Unix - X11
typedef unsigned long sfWindowHandle;
#elif defined(CSFML_SYSTEM_MACOS)
// Window handle is NSWindow (void*) on Mac OS X - Cocoa
typedef void* sfWindowHandle;
#endif
#endif // SFML_WINDOWHANDLE_H