initial commit of DSFML2
some basic things work, much still has to be done - made as few changes as possible to make it compile under D2 - removed system.thread, use standard threads - lots of other changes git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1333 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
dd255a916d
commit
8431753ba3
58 changed files with 1297 additions and 1274 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
@ -30,6 +31,4 @@ public import
|
|||
dsfml.window.input,
|
||||
dsfml.window.videomode,
|
||||
dsfml.window.window,
|
||||
dsfml.window.windowhandle,
|
||||
dsfml.window.windowsettings,
|
||||
dsfml.window.windowstyle;
|
||||
dsfml.window.windowhandle;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
@ -23,26 +24,27 @@
|
|||
* source distribution.
|
||||
*/
|
||||
|
||||
module dsfml.window.windowsettings;
|
||||
module dsfml.window.common;
|
||||
|
||||
/**
|
||||
* Structure defining the creation settings of windows
|
||||
*/
|
||||
struct WindowSettings
|
||||
import dsfml.system.dllloader;
|
||||
|
||||
package extern(C)
|
||||
{
|
||||
///
|
||||
static WindowSettings opCall(uint depth = 24, uint stencil = 8, uint antialiasing = 0)
|
||||
{
|
||||
WindowSettings ret;
|
||||
|
||||
ret.DepthBits = depth;
|
||||
ret.StencilBits = stencil;
|
||||
ret.AntialiasingLevel = antialiasing;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint DepthBits; /// Bits of the depth buffer
|
||||
uint StencilBits; /// Bits of the stencil buffer
|
||||
uint AntialiasingLevel; /// Level of antialiasing
|
||||
void* function() sfContext_Create;
|
||||
void function(void*) sfContext_Destroy;
|
||||
void function(void*, 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"));
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* 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
|
||||
|
@ -23,16 +23,37 @@
|
|||
* source distribution.
|
||||
*/
|
||||
|
||||
module dsfml.window.windowstyle;
|
||||
module dsfml.window.context;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.window.common;
|
||||
|
||||
/**
|
||||
* Window style
|
||||
*/
|
||||
enum Style
|
||||
*
|
||||
*/
|
||||
class Context : DSFMLObject
|
||||
{
|
||||
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)
|
||||
/**
|
||||
*
|
||||
*/
|
||||
this()
|
||||
{
|
||||
super(sfContext_Create());
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
sfContext_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Params:
|
||||
* active =
|
||||
*/
|
||||
void setActive(bool active)
|
||||
{
|
||||
sfContext_SetActive(m_ptr, active);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
@ -150,7 +151,10 @@ private:
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-window-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
|
||||
sfInput_IsKeyDown = cast(pf_sfInput_IsKeyDown)dll.getSymbol("sfInput_IsKeyDown");
|
||||
sfInput_IsMouseButtonDown = cast(pf_sfInput_IsMouseButtonDown)dll.getSymbol("sfInput_IsMouseButtonDown");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
@ -33,15 +34,11 @@ import dsfml.system.common;
|
|||
* by the display device
|
||||
*/
|
||||
align(1) struct VideoMode
|
||||
{
|
||||
static VideoMode opCall(uint width, uint height, uint bitsPerPixel = 32)
|
||||
{
|
||||
VideoMode mode;
|
||||
mode.Width = width;
|
||||
mode.Height = height;
|
||||
mode.BitsPerPixel = bitsPerPixel;
|
||||
return mode;
|
||||
}
|
||||
{
|
||||
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
|
||||
|
||||
/**
|
||||
* Get the current desktop video mode
|
||||
*
|
||||
|
@ -88,7 +85,7 @@ align(1) struct VideoMode
|
|||
*/
|
||||
bool isValid()
|
||||
{
|
||||
return cast(bool)sfVideoMode_IsValid(*this);
|
||||
return cast(bool)sfVideoMode_IsValid(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,14 +97,10 @@ align(1) struct VideoMode
|
|||
* Returns:
|
||||
* True if modes are equal
|
||||
*/
|
||||
bool opEquals(VideoMode other)
|
||||
const bool opEquals(ref const(VideoMode) other)
|
||||
{
|
||||
return ((other.Width == Width) && (other.Height == Height) && (other.BitsPerPixel == BitsPerPixel));
|
||||
}
|
||||
|
||||
uint Width; /// Video mode width, in pixels
|
||||
uint Height; /// Video mode height, in pixels
|
||||
uint BitsPerPixel; /// Video mode pixel depth, in bits per pixels
|
||||
}
|
||||
|
||||
extern (C)
|
||||
|
@ -125,8 +118,11 @@ extern (C)
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-window-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
|
||||
sfVideoMode_GetDesktopMode = cast(pf_sfVideoMode_GetDesktopMode)dll.getSymbol("sfVideoMode_GetDesktopMode");
|
||||
sfVideoMode_GetMode = cast(pf_sfVideoMode_GetMode)dll.getSymbol("sfVideoMode_GetMode");
|
||||
sfVideoMode_GetModesCount = cast(pf_sfVideoMode_GetModesCount)dll.getSymbol("sfVideoMode_GetModesCount");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
@ -29,12 +30,37 @@ import dsfml.window.event;
|
|||
import dsfml.window.input;
|
||||
import dsfml.window.videomode;
|
||||
import dsfml.window.windowhandle;
|
||||
import dsfml.window.windowsettings;
|
||||
import dsfml.window.windowstyle;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.stringutil;
|
||||
|
||||
|
||||
/**
|
||||
* Window style
|
||||
*/
|
||||
enum Style
|
||||
{
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -48,9 +74,9 @@ class Window : DSFMLObject
|
|||
* mode = Video mode to use
|
||||
* title = Title of the window
|
||||
* windowStyle = Window style (Resize | Close by default)
|
||||
* settings = Window settings (default is default WindowSettings values)
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
this(VideoMode mode, char[] title, Style windowStyle = Style.RESIZE | Style.CLOSE, WindowSettings settings = WindowSettings())
|
||||
this(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
super(sfWindow_Create(mode, toStringz(title), windowStyle, settings));
|
||||
}
|
||||
|
@ -60,9 +86,9 @@ class Window : DSFMLObject
|
|||
*
|
||||
* Params:
|
||||
* handle = Platform-specific handle of the control
|
||||
* settings = Window settings (default is default WindowSettings values)
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
this(WindowHandle handle, WindowSettings settings = WindowSettings())
|
||||
this(WindowHandle handle, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
super(sfWindow_CreateFromHandle(handle, settings));
|
||||
}
|
||||
|
@ -82,9 +108,9 @@ class Window : DSFMLObject
|
|||
* mode = Video mode to use
|
||||
* title = Title of the window
|
||||
* windowStyle = Window style (Resize | Close by default)
|
||||
* settings = Window settings (default is default WindowSettings values)
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
void create(VideoMode mode, char[] title, Style windowStyle = Style.RESIZE | Style.CLOSE, WindowSettings settings = WindowSettings())
|
||||
void create(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
if (m_ptr !is null)
|
||||
dispose();
|
||||
|
@ -99,9 +125,9 @@ class Window : DSFMLObject
|
|||
*
|
||||
* Params:
|
||||
* handle = Platform-specific handle of the control
|
||||
* settings = Window settings (default is default WindowSettings values)
|
||||
* settings = Context settings (default is default ContextSettings values)
|
||||
*/
|
||||
void create(WindowHandle handle, WindowSettings settings = WindowSettings())
|
||||
void create(WindowHandle handle, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
if (m_ptr !is null)
|
||||
dispose();
|
||||
|
@ -126,7 +152,7 @@ class Window : DSFMLObject
|
|||
*/
|
||||
bool isOpened()
|
||||
{
|
||||
return cast(bool)sfWindow_IsOpened(m_ptr);
|
||||
return cast(bool) sfWindow_IsOpened(m_ptr);
|
||||
}
|
||||
/**
|
||||
* Get the width of the rendering region of the window
|
||||
|
@ -156,7 +182,7 @@ class Window : DSFMLObject
|
|||
* Returns:
|
||||
* Settings used to create the window
|
||||
*/
|
||||
WindowSettings getSettings()
|
||||
ContextSettings getSettings()
|
||||
{
|
||||
return sfWindow_GetSettings(m_ptr);
|
||||
}
|
||||
|
@ -355,14 +381,14 @@ private:
|
|||
// External ====================================================================
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function(VideoMode, char*, uint, WindowSettings) pf_sfWindow_Create;
|
||||
typedef void* function(WindowHandle, WindowSettings) pf_sfWindow_CreateFromHandle;
|
||||
typedef void* function(VideoMode, cchar*, uint, ContextSettings) pf_sfWindow_Create;
|
||||
typedef void* function(WindowHandle, ContextSettings) pf_sfWindow_CreateFromHandle;
|
||||
typedef void function(void*) pf_sfWindow_Destroy;
|
||||
typedef void function(void*) pf_sfWindow_Close;
|
||||
typedef int function(void*) pf_sfWindow_IsOpened;
|
||||
typedef uint function(void*) pf_sfWindow_GetWidth;
|
||||
typedef uint function(void*) pf_sfWindow_GetHeight;
|
||||
typedef WindowSettings function(void* Window) pf_sfWindow_GetSettings;
|
||||
typedef ContextSettings function(void* Window) pf_sfWindow_GetSettings;
|
||||
typedef int function(void*, Event*) pf_sfWindow_GetEvent;
|
||||
typedef void function(void*, int) pf_sfWindow_UseVerticalSync;
|
||||
typedef void function(void*, int) pf_sfWindow_ShowMouseCursor;
|
||||
|
@ -406,7 +432,10 @@ private:
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-window-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-window");
|
||||
|
||||
sfWindow_Create = cast(pf_sfWindow_Create)dll.getSymbol("sfWindow_Create");
|
||||
sfWindow_CreateFromHandle = cast(pf_sfWindow_CreateFromHandle)dll.getSymbol("sfWindow_CreateFromHandle");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue