Moved all bindings to the "bindings" sub-directory
Renamed the CSFML directory to c Renamed the DSFML directory to d --> bindings must now be updated to match the new organization! git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1630 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
0cc5563cac
commit
0e2297af28
417 changed files with 0 additions and 0 deletions
34
bindings/d/import/dsfml/window/all.d
Normal file
34
bindings/d/import/dsfml/window/all.d
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.all;
|
||||
|
||||
public import
|
||||
dsfml.window.event,
|
||||
dsfml.window.input,
|
||||
dsfml.window.videomode,
|
||||
dsfml.window.window,
|
||||
dsfml.window.windowhandle;
|
77
bindings/d/import/dsfml/window/context.d
Normal file
77
bindings/d/import/dsfml/window/context.d
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.context;
|
||||
|
||||
import dsfml.system.common;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Context : DSFMLObject
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
this()
|
||||
{
|
||||
super(sfContext_Create());
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
sfContext_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Params:
|
||||
* active =
|
||||
*/
|
||||
void setActive(bool active)
|
||||
{
|
||||
sfContext_SetActive(m_ptr, active);
|
||||
}
|
||||
|
||||
private:
|
||||
static extern(C)
|
||||
{
|
||||
SFMLClass function() sfContext_Create;
|
||||
void function(SFMLClass) sfContext_Destroy;
|
||||
void function(SFMLClass, bool) sfContext_SetActive;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-window-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
|
||||
mixin(loadFromSharedLib("sfContext_Create"));
|
||||
mixin(loadFromSharedLib("sfContext_Destroy"));
|
||||
mixin(loadFromSharedLib("sfContext_SetActive"));
|
||||
}
|
||||
}
|
326
bindings/d/import/dsfml/window/event.d
Normal file
326
bindings/d/import/dsfml/window/event.d
Normal file
|
@ -0,0 +1,326 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.event;
|
||||
|
||||
/**
|
||||
* Definition of key codes for keyboard events
|
||||
*
|
||||
* $(B Possibles values:)$(BR)
|
||||
* Except letters and numbers, you can use :$(BR)
|
||||
* * LCONTROL, LSHIFT, LALT, LSYSTEM, RCONTROL, RSHIFT, RALT, RSYSTEM.$(BR)
|
||||
* * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR)
|
||||
* * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR)
|
||||
* * ADD, SUBTRACT, MULTIPLY, DIVIDE, LEFT, RIGHT, UP, DOWN.$(BR)
|
||||
* * Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9.$(BR)
|
||||
* * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15.$(BR)
|
||||
*/
|
||||
enum KeyCode
|
||||
{
|
||||
A = 'a',
|
||||
B = 'b',
|
||||
C = 'c',
|
||||
D = 'd',
|
||||
E = 'e',
|
||||
F = 'f',
|
||||
G = 'g',
|
||||
H = 'h',
|
||||
I = 'i',
|
||||
J = 'j',
|
||||
K = 'k',
|
||||
L = 'l',
|
||||
M = 'm',
|
||||
N = 'n',
|
||||
O = 'o',
|
||||
P = 'p',
|
||||
Q = 'q',
|
||||
R = 'r',
|
||||
S = 's',
|
||||
T = 't',
|
||||
U = 'u',
|
||||
V = 'v',
|
||||
W = 'w',
|
||||
X = 'x',
|
||||
Y = 'y',
|
||||
Z = 'z',
|
||||
Num0 = '0',
|
||||
Num1 = '1',
|
||||
Num2 = '2',
|
||||
Num3 = '3',
|
||||
Num4 = '4',
|
||||
Num5 = '5',
|
||||
Num6 = '6',
|
||||
Num7 = '7',
|
||||
Num8 = '8',
|
||||
Num9 = '9',
|
||||
Escape = 256,
|
||||
LControl,
|
||||
LShift,
|
||||
LAlt,
|
||||
LSystem,
|
||||
RControl,
|
||||
RShist,
|
||||
RAlt,
|
||||
RSystem,
|
||||
Menu,
|
||||
LBracket,
|
||||
RBracket,
|
||||
Semicolon,
|
||||
Comma,
|
||||
Period,
|
||||
Quote,
|
||||
Slash,
|
||||
Backslash,
|
||||
Tilde,
|
||||
Equal,
|
||||
Dash,
|
||||
Space,
|
||||
Return,
|
||||
Back,
|
||||
Tab,
|
||||
PageUp,
|
||||
PageDown,
|
||||
End,
|
||||
Home,
|
||||
Insert,
|
||||
Delete,
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
Numpad0,
|
||||
Numpad1,
|
||||
Numpad2,
|
||||
Numpad3,
|
||||
Numpad4,
|
||||
Numpad5,
|
||||
Numpad6,
|
||||
Numpad7,
|
||||
Numpad8,
|
||||
Numpad9,
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
Pause,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Definition of button codes for mouse events
|
||||
*/
|
||||
enum MouseButtons
|
||||
{
|
||||
Left, ///
|
||||
Right, ///
|
||||
Middle, ///
|
||||
XButton1, ///
|
||||
XButton2 ///
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Definition of joystick axis for joystick events
|
||||
*/
|
||||
enum JoyAxis
|
||||
{
|
||||
AxisX, ///
|
||||
AxisY, ///
|
||||
AxisZ, ///
|
||||
AxisR, ///
|
||||
AxisU, ///
|
||||
AxisV, ///
|
||||
AxisPOV ///
|
||||
}
|
||||
|
||||
|
||||
/// EventType
|
||||
enum EventType
|
||||
{
|
||||
Closed,
|
||||
Resized,
|
||||
LostFocus,
|
||||
GainedFocus,
|
||||
TextEntered,
|
||||
KeyPressed,
|
||||
KeyReleased,
|
||||
MouseWheelMoved,
|
||||
MouseButtonPressed,
|
||||
MouseButtonReleased,
|
||||
MouseMoved,
|
||||
MouseEntered,
|
||||
MouseLeft,
|
||||
JoyButtonPressed,
|
||||
JoyButtonReleased,
|
||||
JoyMoved
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Event defines a system event and its parameters
|
||||
*/
|
||||
align(1) struct Event
|
||||
{
|
||||
/**
|
||||
* Enumeration of the different types of events. Accessing a value of another event that the one received (e.g. Event.Size.Width when receiving an KEYPRESSED event) will result in undefined behavior.
|
||||
* $(UL
|
||||
* $(LI CLOSED)
|
||||
* $(LI LOSTFOCUS)
|
||||
* $(LI GAINEDFOCUS)
|
||||
* $(LI RESIZED
|
||||
* $(UL
|
||||
* $(LI Event.Size.Width : new Width, in pixels.)
|
||||
* $(LI Event.Size.Height : new height, in pixels.)
|
||||
* )
|
||||
* )
|
||||
* $(LI TEXTENTERED
|
||||
* $(UL
|
||||
* $(LI Event.Text.Unicode : dchar entered.)
|
||||
* )
|
||||
* )
|
||||
* $(LI KEYPRESSED, KEYRELEASED
|
||||
* $(UL
|
||||
* $(LI Event.Key.Code : Key code of the key.)
|
||||
* $(LI Event.Key.Alt : Alt pressed ?)
|
||||
* $(LI Event.Key.Control : Control pressed ?)
|
||||
* $(LI Event.Key.Shift : Shift pressed ?)
|
||||
* )
|
||||
* )
|
||||
* $(LI MOUSEWHEELMOVED
|
||||
* $(UL
|
||||
* $(LI Event.MouseWheel.Delta : Wheel move (positive if forward, negative else.) )
|
||||
* )
|
||||
* )
|
||||
* $(LI MOUSEBUTTONPRESSED, MOUSEBUTTONRELEASED
|
||||
* $(UL
|
||||
* $(LI Event.MouseButton.Button : Mouse button pressed.)
|
||||
* $(LI Event.MouseButton.X : Cursor X position.)
|
||||
* $(LI Event.MouseButton.Y : Cursor X position.)
|
||||
* )
|
||||
* )
|
||||
* $(LI MOUSEMOVED
|
||||
* $(UL
|
||||
* $(LI Event.MouseMove.X : Cursor X position. Local coordinates.)
|
||||
* $(LI Event.MouseMove.Y : Cursor Y position. Local coordinates.)
|
||||
* )
|
||||
* )
|
||||
* $(LI MOUSEENTERED)
|
||||
* $(LI MOUSELEFT)
|
||||
* $(LI JOYBUTTONPRESSED, JOYBUTTONRELEASED
|
||||
* $(UL
|
||||
* $(LI Event.JoyButton.JoystickId : Id of the joystick.)
|
||||
* $(LI Event.JoyButton.Button : Joystick button pressed.)
|
||||
* )
|
||||
* )
|
||||
* $(LI JOYMOVED
|
||||
* $(UL
|
||||
* $(LI Event.JoyMove.JoystickId : Id of the joystick.)
|
||||
* $(LI Event.JoyMove.Axis : Moved axis.)
|
||||
* $(LI Event.JoyMove.Position : Actual position of the axis [-100, 100], except for POV [0, 360].)
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
EventType Type;
|
||||
|
||||
union
|
||||
{
|
||||
struct SText
|
||||
{
|
||||
dchar Unicode;
|
||||
}
|
||||
SText Text;
|
||||
|
||||
struct SKey
|
||||
{
|
||||
align(4): // cause bool is size 1
|
||||
KeyCode Code;
|
||||
bool Alt;
|
||||
bool Control;
|
||||
bool Shift;
|
||||
}
|
||||
SKey Key;
|
||||
|
||||
struct SMouseMove
|
||||
{
|
||||
int X;
|
||||
int Y;
|
||||
}
|
||||
SMouseMove MouseMove;
|
||||
|
||||
struct SMouseButton
|
||||
{
|
||||
MouseButtons Button;
|
||||
int X;
|
||||
int Y;
|
||||
}
|
||||
SMouseButton MouseButton;
|
||||
|
||||
struct SMouseWheel
|
||||
{
|
||||
int Delta;
|
||||
}
|
||||
SMouseWheel MouseWheel;
|
||||
|
||||
struct SJoyMove
|
||||
{
|
||||
uint JoystickId;
|
||||
JoyAxis Axis;
|
||||
float Position;
|
||||
}
|
||||
SJoyMove JoyMove;
|
||||
|
||||
struct SJoyButton
|
||||
{
|
||||
uint JoystickId;
|
||||
uint Button;
|
||||
}
|
||||
SJoyButton JoyButton;
|
||||
|
||||
struct SSize
|
||||
{
|
||||
uint Width;
|
||||
uint Height;
|
||||
}
|
||||
SSize Size;
|
||||
}
|
||||
}
|
152
bindings/d/import/dsfml/window/input.d
Normal file
152
bindings/d/import/dsfml/window/input.d
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.input;
|
||||
|
||||
import dsfml.system.common;
|
||||
|
||||
import dsfml.window.event;
|
||||
|
||||
/**
|
||||
* Input handles real-time input from keyboard and mouse.
|
||||
* Use it instead of events to handle continuous moves and more
|
||||
* game-friendly inputs
|
||||
*/
|
||||
class Input : DSFMLObject
|
||||
{
|
||||
public: // TODO: try to fix this, doesn't work with package
|
||||
this(SFMLClass input)
|
||||
{
|
||||
super(input, true);
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Get the state of a key
|
||||
*
|
||||
* Params:
|
||||
* key = Key to check
|
||||
*
|
||||
* Returns:
|
||||
* True if key is down, false if key is up
|
||||
*/
|
||||
bool isKeyDown(KeyCode key)
|
||||
{
|
||||
return cast(bool)sfInput_IsKeyDown(m_ptr, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of a mouse button
|
||||
*
|
||||
* Params:
|
||||
* button = Button to check
|
||||
*
|
||||
* Returns:
|
||||
* True if button is down, false if button is up
|
||||
*/
|
||||
bool isMouseButtonDown(MouseButtons button)
|
||||
{
|
||||
return cast(bool)sfInput_IsMouseButtonDown(m_ptr, button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of a joystick button
|
||||
*
|
||||
* Params:
|
||||
* joyId = Identifier of the joystick to check (0 or 1)
|
||||
* button = Button to check
|
||||
*
|
||||
* Returns:
|
||||
* True if button is down, false if button is up
|
||||
*/
|
||||
bool isJoystickButtonDown(uint joyId, uint button)
|
||||
{
|
||||
return cast(bool)sfInput_IsJoystickButtonDown(m_ptr, joyId, button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a joystick axis position
|
||||
*
|
||||
* Params:
|
||||
* joyId = Identifier of the joystick to check (0 or 1)
|
||||
* axis = Axis to get
|
||||
*
|
||||
* Returns:
|
||||
* Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])
|
||||
*/
|
||||
float getJoystickAxis(uint joyId, JoyAxis axis)
|
||||
{
|
||||
return sfInput_GetJoystickAxis(m_ptr, joyId, axis);
|
||||
}
|
||||
|
||||
@property
|
||||
{
|
||||
/**
|
||||
* Get the mouse X position
|
||||
*
|
||||
* Returns:
|
||||
* Current mouse left position, relative to owner window
|
||||
*/
|
||||
int mouseX()
|
||||
{
|
||||
return sfInput_GetMouseX(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mouse Y position
|
||||
*
|
||||
* Returns:
|
||||
* Current mouse top position, relative to owner window
|
||||
*
|
||||
*/
|
||||
int mouseY()
|
||||
{
|
||||
return sfInput_GetMouseY(m_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// External ====================================================================
|
||||
|
||||
static extern (C)
|
||||
{
|
||||
int function(SFMLClass, KeyCode) sfInput_IsKeyDown;
|
||||
int function(SFMLClass, MouseButtons) sfInput_IsMouseButtonDown;
|
||||
int function(SFMLClass, uint, uint) sfInput_IsJoystickButtonDown;
|
||||
int function(SFMLClass) sfInput_GetMouseX;
|
||||
int function(SFMLClass) sfInput_GetMouseY;
|
||||
float function(SFMLClass, uint, JoyAxis) sfInput_GetJoystickAxis;
|
||||
}
|
||||
|
||||
mixin(loadFromSharedLib2("csfml-window", "sfInput",
|
||||
"IsKeyDown", "IsMouseButtonDown", "IsJoystickButtonDown", "GetMouseX", "GetMouseY", "GetJoystickAxis"));
|
||||
}
|
105
bindings/d/import/dsfml/window/videomode.d
Normal file
105
bindings/d/import/dsfml/window/videomode.d
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.videomode;
|
||||
|
||||
import dsfml.system.common;
|
||||
|
||||
/**
|
||||
* VideoMode defines a video mode (width, height, bpp, frequency)
|
||||
* and provides static functions for getting modes supported
|
||||
* by the display device
|
||||
*/
|
||||
struct VideoMode
|
||||
{
|
||||
uint Width; /// Video mode width, in pixels
|
||||
uint Height; /// Video mode height, in pixels
|
||||
uint BitsPerPixel = 32; /// Video mode pixel depth, in bits per pixels
|
||||
|
||||
|
||||
@property
|
||||
{
|
||||
/**
|
||||
* Get the current desktop video mode
|
||||
*
|
||||
* Returns:
|
||||
* Current desktop video mode
|
||||
*/
|
||||
static VideoMode getDesktopMode()
|
||||
{
|
||||
return sfVideoMode_GetDesktopMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the supported video modes for fullscreen mode.
|
||||
* Modes are sorted from best to worst.
|
||||
*
|
||||
* Returns:
|
||||
* video mode array
|
||||
*/
|
||||
static VideoMode[] getFullscreenModes()
|
||||
{
|
||||
size_t arraySize;
|
||||
VideoMode* array = sfVideoMode_GetFullscreenModes(&arraySize); // TODO: check pointer?
|
||||
return array[0 .. arraySize];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether or not the video mode is supported
|
||||
*
|
||||
* Returns:
|
||||
* True if video mode is supported, false otherwise
|
||||
*/
|
||||
bool isValid()
|
||||
{
|
||||
return cast(bool)sfVideoMode_IsValid(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparison operator overload -- tell if two video modes are equal
|
||||
*
|
||||
* Params:
|
||||
* Other : Video mode to compare
|
||||
*
|
||||
* Returns:
|
||||
* True if modes are equal
|
||||
*/
|
||||
const bool opEquals(ref const(VideoMode) other)
|
||||
{
|
||||
return ((other.Width == Width) && (other.Height == Height) && (other.BitsPerPixel == BitsPerPixel));
|
||||
}
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
VideoMode function() sfVideoMode_GetDesktopMode;
|
||||
VideoMode* function(size_t*) sfVideoMode_GetFullscreenModes;
|
||||
int function(VideoMode) sfVideoMode_IsValid;
|
||||
}
|
||||
|
||||
mixin(loadFromSharedLib2("csfml-window", "sfVideoMode",
|
||||
"GetDesktopMode", "GetFullscreenModes", "IsValid"));
|
454
bindings/d/import/dsfml/window/window.d
Normal file
454
bindings/d/import/dsfml/window/window.d
Normal file
|
@ -0,0 +1,454 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.window;
|
||||
|
||||
import dsfml.window.event;
|
||||
import dsfml.window.input;
|
||||
import dsfml.window.videomode;
|
||||
import dsfml.window.windowhandle;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.stringutil;
|
||||
|
||||
|
||||
/**
|
||||
* Window style
|
||||
*/
|
||||
enum Style : uint
|
||||
{
|
||||
None = 0, /// No border / title bar (this flag and all others are mutually exclusive)
|
||||
Titlebar = 1 << 0, /// Title bar + fixed border
|
||||
Resize = 1 << 1, /// Titlebar + resizable border + maximize button
|
||||
Close = 1 << 2, /// Titlebar + close button
|
||||
Fullscreen = 1 << 3, /// Fullscreen mode (this flag and all others are mutually exclusive)
|
||||
|
||||
Default = Titlebar | Resize | Close /// Default window style
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Structure defining the creation settings of windows
|
||||
*/
|
||||
struct ContextSettings
|
||||
{
|
||||
uint DepthBits = 24; /// Bits of the depth buffer
|
||||
uint StencilBits = 8; /// Bits of the stencil buffer
|
||||
uint AntialiasingLevel = 0; /// Level of antialiasing
|
||||
uint MajorVersion = 3; /// Major number of the context version to create
|
||||
uint MinorVersion = 0; /// Minor number of the context version to create
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Window is a rendering window ; it can create a new window
|
||||
* or connect to an existing one
|
||||
*/
|
||||
class Window : DSFMLObject
|
||||
{
|
||||
protected:
|
||||
this(SFMLClass ptr)
|
||||
{
|
||||
super(ptr);
|
||||
}
|
||||
|
||||
Input m_input;
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
m_input = null;
|
||||
sfWindow_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct a new window
|
||||
*
|
||||
* Params:
|
||||
* mode = Video mode to use
|
||||
* title = Title of the window
|
||||
* windowStyle = Window style (Resize | Close by default)
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
this(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
super(sfWindow_Create(mode, toStringz(title), windowStyle, &settings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the window from an existing control
|
||||
*
|
||||
* Params:
|
||||
* handle = Platform-specific handle of the control
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
this(WindowHandle handle, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
super(sfWindow_CreateFromHandle(handle, &settings));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create (or recreate) the window
|
||||
*
|
||||
* Input created with getInput becomes invalid.
|
||||
*
|
||||
* Params:
|
||||
* mode = Video mode to use
|
||||
* title = Title of the window
|
||||
* windowStyle = Window style (Resize | Close by default)
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
void create(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
if (m_ptr !is null)
|
||||
dispose();
|
||||
|
||||
m_ptr = sfWindow_Create(mode, toStringz(title), windowStyle, &settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create (or recreate) the window from an existing control
|
||||
*
|
||||
* Input created with getInput becomes invalid.
|
||||
*
|
||||
* Params:
|
||||
* handle = Platform-specific handle of the control
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
void create(WindowHandle handle, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
if (m_ptr !is null)
|
||||
dispose();
|
||||
|
||||
m_ptr = sfWindow_CreateFromHandle(handle, &settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close (destroy) the window.
|
||||
* You can call create to recreate a valid window
|
||||
*/
|
||||
void close()
|
||||
{
|
||||
sfWindow_Close(m_ptr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the event on top of events stack, if any, and pop it
|
||||
*
|
||||
* Params:
|
||||
* eventReceived = Event to fill, if any
|
||||
*
|
||||
* Returns:
|
||||
* True if an event was returned, false if events stack was empty
|
||||
*/
|
||||
bool getEvent(out Event eventReceived)
|
||||
{
|
||||
return cast(bool) sfWindow_GetEvent(m_ptr, &eventReceived);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for an event and return it
|
||||
*
|
||||
* This function is blocking: if there's no pending event then it will wait until an event is received.
|
||||
* After this function returns (and no error occured), the \a event object is always valid and filled properly.
|
||||
* This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread
|
||||
* sleep as long as no new event is received.
|
||||
*
|
||||
* Params:
|
||||
* e Event to be returned
|
||||
*
|
||||
* Returns:
|
||||
* false if any error occured
|
||||
*/
|
||||
bool waitEvent(out Event e)
|
||||
{
|
||||
return sfWindow_WaitEvent(m_ptr, &e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the window
|
||||
*
|
||||
* Params:
|
||||
* state = True to show, false to hide
|
||||
*
|
||||
*/
|
||||
void show(bool state)
|
||||
{
|
||||
sfWindow_Show(m_ptr, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the window on screen
|
||||
*/
|
||||
void display()
|
||||
{
|
||||
sfWindow_Display(m_ptr);
|
||||
}
|
||||
|
||||
@property
|
||||
{
|
||||
/**
|
||||
* Tell whether or not a window is opened
|
||||
*
|
||||
* Returns:
|
||||
* True if window is currently open.
|
||||
*/
|
||||
bool isOpened()
|
||||
{
|
||||
return cast(bool) sfWindow_IsOpened(m_ptr);
|
||||
}
|
||||
/**
|
||||
* Get the width of the rendering region of the window
|
||||
*
|
||||
* Returns:
|
||||
* Width in pixels
|
||||
*/
|
||||
uint width()
|
||||
{
|
||||
return sfWindow_GetWidth(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the rendering region of the window
|
||||
*
|
||||
* Returns:
|
||||
* Height in pixels
|
||||
*/
|
||||
uint height()
|
||||
{
|
||||
return sfWindow_GetHeight(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the creation settings of a window
|
||||
*
|
||||
* Returns:
|
||||
* Settings used to create the window
|
||||
*/
|
||||
ContextSettings settings()
|
||||
{
|
||||
return sfWindow_GetSettings(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable / disable vertical synchronization
|
||||
*
|
||||
* Params:
|
||||
* enabled : True to enable v-sync, false to deactivate
|
||||
*/
|
||||
void useVerticalSync(bool enabled)
|
||||
{
|
||||
sfWindow_UseVerticalSync(m_ptr, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the mouse cursor
|
||||
*
|
||||
* Params:
|
||||
* show : True to show, false to hide
|
||||
*/
|
||||
void showMouseCursor(bool show)
|
||||
{
|
||||
sfWindow_ShowMouseCursor(m_ptr, show);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable automatic key-repeat for keydown events.
|
||||
* Automatic key-repeat is enabled by default.
|
||||
*
|
||||
* Params:
|
||||
* enabled = true to enable, false to disable
|
||||
*/
|
||||
void enableKeyRepeat(bool enabled)
|
||||
{
|
||||
sfWindow_EnableKeyRepeat(m_ptr, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the window as the current target for rendering
|
||||
*
|
||||
* Params:
|
||||
* active = True to activate, false to deactivate
|
||||
* Returns:
|
||||
* True if operation was successful, false otherwise
|
||||
*/
|
||||
bool active(bool active)
|
||||
{
|
||||
return cast(bool)sfWindow_SetActive(m_ptr, active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input manager of the window
|
||||
*
|
||||
* Returns:
|
||||
* An input manager
|
||||
* See_Also :
|
||||
* Input
|
||||
*/
|
||||
Input input()
|
||||
{
|
||||
if (m_input is null)
|
||||
m_input = new Input(sfWindow_GetInput(m_ptr));
|
||||
return m_input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the framerate to a maximum fixed frequency
|
||||
*
|
||||
* Params:
|
||||
* limit : Framerate limit, in frames per seconds (use 0 to disable limit)
|
||||
*/
|
||||
void framerateLimit(uint limit)
|
||||
{
|
||||
sfWindow_SetFramerateLimit(m_ptr, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time the last frame took
|
||||
*
|
||||
* Returns:
|
||||
* time in seconds
|
||||
*/
|
||||
float frameTime()
|
||||
{
|
||||
return sfWindow_GetFrameTime(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the joystick threshold, ie. the value below which
|
||||
* no move event will be generated
|
||||
*
|
||||
* Params:
|
||||
* threshold : New threshold, in range [0, 100]
|
||||
*/
|
||||
void joystickThreshold(float threshold)
|
||||
{
|
||||
sfWindow_SetJoystickThreshold(m_ptr, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Os-specific handle of a window
|
||||
*
|
||||
* Params:
|
||||
* renderWindow = Renderwindow object
|
||||
*/
|
||||
WindowHandle windowHandle()
|
||||
{
|
||||
return sfWindow_GetSystemHandle(m_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the position of the mouse cursor
|
||||
*
|
||||
* Params:
|
||||
* left = Left coordinate of the cursor, relative to the window
|
||||
* top = Top coordinate of the cursor, relative to the window
|
||||
*/
|
||||
void setCursorPosition(uint left, uint top)
|
||||
{
|
||||
sfWindow_SetCursorPosition(m_ptr, left, top);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the position of the window on screen.
|
||||
* Only works for top-level windows
|
||||
*
|
||||
* Params:
|
||||
* left = Left position
|
||||
* top = Top position
|
||||
*/
|
||||
void setPosition(int left, int top)
|
||||
{
|
||||
sfWindow_SetPosition(m_ptr, left, top);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the size of the rendering region of the window
|
||||
*
|
||||
* Params:
|
||||
* width : new width
|
||||
* height : new height
|
||||
*/
|
||||
void setSize(uint width, uint height)
|
||||
{
|
||||
sfWindow_SetSize(m_ptr, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the window's icon
|
||||
*
|
||||
* Params:
|
||||
* width = Icon's width, in pixels
|
||||
* height = Icon's height, in pixels
|
||||
* data = array of pixels in memory, format must be RGBA 32 bits
|
||||
*
|
||||
*/
|
||||
void setIcon(size_t width, size_t height, ubyte[] data)
|
||||
{
|
||||
sfWindow_SetIcon(m_ptr, width, height, data.ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// External ====================================================================
|
||||
static extern(C)
|
||||
{
|
||||
SFMLClass function(VideoMode, cchar*, Style, ContextSettings*)sfWindow_Create;
|
||||
SFMLClass function(WindowHandle, ContextSettings*) sfWindow_CreateFromHandle;
|
||||
void function(SFMLClass) sfWindow_Destroy;
|
||||
void function(SFMLClass) sfWindow_Close;
|
||||
int function(SFMLClass) sfWindow_IsOpened;
|
||||
uint function(SFMLClass) sfWindow_GetWidth;
|
||||
uint function(SFMLClass) sfWindow_GetHeight;
|
||||
ContextSettings function(SFMLClass Window) sfWindow_GetSettings;
|
||||
int function(SFMLClass, Event*) sfWindow_GetEvent;
|
||||
void function(SFMLClass, int) sfWindow_UseVerticalSync;
|
||||
void function(SFMLClass, int) sfWindow_ShowMouseCursor;
|
||||
void function(SFMLClass, uint, uint) sfWindow_SetCursorPosition;
|
||||
void function(SFMLClass, int, int) sfWindow_SetPosition;
|
||||
void function(SFMLClass, uint, uint) sfWindow_SetSize;
|
||||
void function(SFMLClass, int) sfWindow_Show;
|
||||
void function(SFMLClass, int) sfWindow_EnableKeyRepeat;
|
||||
void function(SFMLClass, size_t, size_t, ubyte*) sfWindow_SetIcon;
|
||||
int function(SFMLClass, int) sfWindow_SetActive;
|
||||
void function(SFMLClass) sfWindow_Display;
|
||||
SFMLClass function(SFMLClass) sfWindow_GetInput;
|
||||
void function(SFMLClass, uint) sfWindow_SetFramerateLimit;
|
||||
float function(SFMLClass) sfWindow_GetFrameTime;
|
||||
void function(SFMLClass, float) sfWindow_SetJoystickThreshold;
|
||||
|
||||
// DSFML2
|
||||
bool function(SFMLClass, void*) sfWindow_WaitEvent;
|
||||
WindowHandle function(SFMLClass) sfWindow_GetSystemHandle;
|
||||
}
|
||||
|
||||
mixin(loadFromSharedLib2("csfml-window", "sfWindow",
|
||||
"Create", "CreateFromHandle", "Destroy", "Close", "IsOpened", "GetWidth", "GetHeight", "GetSettings", "GetEvent", "UseVerticalSync",
|
||||
"ShowMouseCursor", "SetCursorPosition", "SetPosition", "SetSize", "Show", "EnableKeyRepeat", "SetIcon", "SetActive", "Display",
|
||||
"GetInput", "SetFramerateLimit", "GetFrameTime", "SetJoystickThreshold", "WaitEvent", "GetSystemHandle"));
|
||||
}
|
47
bindings/d/import/dsfml/window/windowhandle.d
Normal file
47
bindings/d/import/dsfml/window/windowhandle.d
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module dsfml.window.windowhandle;
|
||||
|
||||
/**
|
||||
* Define a low-level window handle type, specific to
|
||||
* each platform
|
||||
*/
|
||||
version(Windows)
|
||||
{
|
||||
// Windows defines a void* handle (HWND)
|
||||
typedef void* WindowHandle;
|
||||
}
|
||||
else version(linux)
|
||||
{
|
||||
// Unix - X11 defines an unsigned integer handle (Window)
|
||||
typedef ulong WindowHandle;
|
||||
}
|
||||
else version(darwin)
|
||||
{
|
||||
// Mac OS X defines a void* handle (NSWindow)
|
||||
typedef void* WindowHandle;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue