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
@ -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
|
||||
@ -172,7 +173,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfListener_SetGlobalVolume = cast(pf_sfListener_SetGlobalVolume)dll.getSymbol("sfListener_SetGlobalVolume");
|
||||
sfListener_GetGlobalVolume = cast(pf_sfListener_GetGlobalVolume)dll.getSymbol("sfListener_GetGlobalVolume");
|
||||
|
@ -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
|
||||
@ -45,12 +46,12 @@ class Music : DSFMLObject
|
||||
* filename = Path of the file to open
|
||||
*
|
||||
*/
|
||||
this(char[] filename)
|
||||
this(string filename)
|
||||
{
|
||||
if (filename is null || filename.length == 0)
|
||||
throw new LoadingException("LoadingException : Filename is invalid.");
|
||||
|
||||
super(sfMusic_CreateFromFile(toStringz(filename)));
|
||||
if (filename is null || filename.length == 0)
|
||||
throw new LoadingException("LoadingException : Filename is invalid.");
|
||||
|
||||
super(sfMusic_CreateFromFile(toStringz(filename)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,15 +63,15 @@ class Music : DSFMLObject
|
||||
*/
|
||||
this(byte[] data)
|
||||
{
|
||||
if (data is null || data.length == 0)
|
||||
throw new Exception("LoadingException : Memory stream is invalid.");
|
||||
|
||||
super(m_ptr = sfMusic_CreateFromMemory(data.ptr, data.length));
|
||||
if (data is null || data.length == 0)
|
||||
throw new Exception("LoadingException : Memory stream is invalid.");
|
||||
|
||||
super(m_ptr = sfMusic_CreateFromMemory(data.ptr, data.length));
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
sfMusic_Destroy(m_ptr);
|
||||
sfMusic_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,7 +79,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void play()
|
||||
{
|
||||
sfMusic_Play(m_ptr);
|
||||
sfMusic_Play(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +87,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void stop()
|
||||
{
|
||||
sfMusic_Stop(m_ptr);
|
||||
sfMusic_Stop(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +95,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void pause()
|
||||
{
|
||||
sfMusic_Pause(m_ptr);
|
||||
sfMusic_Pause(m_ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +107,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
uint getChannelsCount()
|
||||
{
|
||||
return sfMusic_GetChannelsCount(m_ptr);
|
||||
return sfMusic_GetChannelsCount(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +118,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
uint getSampleRate()
|
||||
{
|
||||
return sfMusic_GetSampleRate(m_ptr);
|
||||
return sfMusic_GetSampleRate(m_ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -129,7 +130,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
float getDuration()
|
||||
{
|
||||
return sfMusic_GetDuration(m_ptr);
|
||||
return sfMusic_GetDuration(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +141,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
SoundStatus getStatus()
|
||||
{
|
||||
return sfMusic_GetStatus(m_ptr);
|
||||
return sfMusic_GetStatus(m_ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +153,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
bool getLoop()
|
||||
{
|
||||
return cast(bool)sfMusic_GetLoop(m_ptr);
|
||||
return cast(bool)sfMusic_GetLoop(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,7 +164,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
float getPitch()
|
||||
{
|
||||
return sfMusic_GetPitch(m_ptr);
|
||||
return sfMusic_GetPitch(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,20 +175,20 @@ class Music : DSFMLObject
|
||||
*/
|
||||
float getVolume()
|
||||
{
|
||||
return sfMusic_GetVolume(m_ptr);
|
||||
return sfMusic_GetVolume(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sound position
|
||||
*
|
||||
* Returns:
|
||||
* Current position of the music.
|
||||
* Current position of the music.
|
||||
*/
|
||||
Vector3f getPosition()
|
||||
{
|
||||
Vector3f ret;
|
||||
sfMusic_GetPosition(m_ptr, &ret.x, &ret.y, &ret.z);
|
||||
return ret;
|
||||
Vector3f ret;
|
||||
sfMusic_GetPosition(m_ptr, &ret.x, &ret.y, &ret.z);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +199,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
float getMinDistance()
|
||||
{
|
||||
return sfMusic_GetMinDistance(m_ptr);
|
||||
return sfMusic_GetMinDistance(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +211,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
float getAttenuation()
|
||||
{
|
||||
return sfMusic_GetAttenuation(m_ptr);
|
||||
return sfMusic_GetAttenuation(m_ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -223,7 +224,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void setLoop(bool loop)
|
||||
{
|
||||
sfMusic_SetLoop(m_ptr, loop);
|
||||
sfMusic_SetLoop(m_ptr, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +237,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void setPitch(float pitch)
|
||||
{
|
||||
sfMusic_SetPitch(m_ptr, pitch);
|
||||
sfMusic_SetPitch(m_ptr, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,11 +251,11 @@ class Music : DSFMLObject
|
||||
void setVolume(float volume)
|
||||
in
|
||||
{
|
||||
assert (volume >= 0.f && volume <= 100.f);
|
||||
assert (volume >= 0.f && volume <= 100.f);
|
||||
}
|
||||
body
|
||||
{
|
||||
sfMusic_SetVolume(m_ptr, volume);
|
||||
sfMusic_SetVolume(m_ptr, volume);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -269,7 +270,7 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void setPosition(float x, float y, float z)
|
||||
{
|
||||
sfMusic_SetPosition(m_ptr, x, y, z);
|
||||
sfMusic_SetPosition(m_ptr, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,10 +283,9 @@ class Music : DSFMLObject
|
||||
*/
|
||||
void setPosition(Vector3f position)
|
||||
{
|
||||
sfMusic_SetPosition(m_ptr, position.x, position.y, position.z);
|
||||
sfMusic_SetPosition(m_ptr, position.x, position.y, position.z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the minimum distance - closer than thsi distance
|
||||
* the listener will hear the sound at its maximum volume.
|
||||
@ -293,10 +293,10 @@ class Music : DSFMLObject
|
||||
*
|
||||
* Params:
|
||||
* minDistance = new minimum distance for the sound
|
||||
*/
|
||||
*/
|
||||
void setMinDistance(float minDistance)
|
||||
{
|
||||
sfMusic_SetMinDistance(m_ptr, minDistance);
|
||||
sfMusic_SetMinDistance(m_ptr, minDistance);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -305,92 +305,101 @@ class Music : DSFMLObject
|
||||
* The default attenuation factor 1.0
|
||||
*
|
||||
* Params:
|
||||
* attenuation = new attenuation factor for the sound
|
||||
*/
|
||||
* attenuation = new attenuation factor for the sound
|
||||
*/
|
||||
void setAttenuation(float attenuation)
|
||||
{
|
||||
sfMusic_SetAttenuation(m_ptr, attenuation);
|
||||
sfMusic_SetAttenuation(m_ptr, attenuation);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Make the music's position relative to the listener's position, or absolute.
|
||||
* The default value is false (absolute)
|
||||
*
|
||||
* Params:
|
||||
* relative = True to set the position relative, false to set it absolute
|
||||
*/
|
||||
void setRelativeToListener(bool relative)
|
||||
{
|
||||
sfMusic_SetRelativeToListener(m_ptr, relative);
|
||||
}
|
||||
|
||||
// External ====================================================================
|
||||
/**
|
||||
* Tell if the music's position is relative to the listener's
|
||||
* position, or if it's absolute
|
||||
*
|
||||
* Returns:
|
||||
* true if the position is relative, sfFalse if it's absolute
|
||||
*/
|
||||
bool isRelativeToListener()
|
||||
{
|
||||
return sfMusic_IsRelativeToListener(m_ptr);
|
||||
}
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function(char*) pf_sfMusic_CreateFromFile;
|
||||
typedef void* function(byte*, size_t) pf_sfMusic_CreateFromMemory;
|
||||
typedef void function(void*) pf_sfMusic_Destroy;
|
||||
typedef void function(void*, int) pf_sfMusic_SetLoop;
|
||||
typedef bool function(void*) pf_sfMusic_GetLoop;
|
||||
typedef float function(void*) pf_sfMusic_GetDuration;
|
||||
typedef void function(void*) pf_sfMusic_Play;
|
||||
typedef void function(void*) pf_sfMusic_Pause;
|
||||
typedef void function(void*) pf_sfMusic_Stop;
|
||||
typedef uint function(void*) pf_sfMusic_GetChannelsCount;
|
||||
typedef uint function(void*) pf_sfMusic_GetSampleRate;
|
||||
typedef SoundStatus function(void*) pf_sfMusic_GetStatus;
|
||||
typedef void function(void*, float) pf_sfMusic_SetPitch;
|
||||
typedef void function(void*, float) pf_sfMusic_SetVolume;
|
||||
typedef void function(void*, float, float, float) pf_sfMusic_SetPosition;
|
||||
typedef float function(void*) pf_sfMusic_GetPitch;
|
||||
typedef float function(void*) pf_sfMusic_GetVolume;
|
||||
typedef void function(void*, float*, float*, float*) pf_sfMusic_GetPosition;
|
||||
typedef float function(void*) pf_sfMusic_GetMinDistance;
|
||||
typedef float function(void*) pf_sfMusic_GetAttenuation;
|
||||
typedef void function(void*, float) pf_sfMusic_SetMinDistance;
|
||||
typedef void function(void*, float) pf_sfMusic_SetAttenuation;
|
||||
|
||||
static pf_sfMusic_CreateFromFile sfMusic_CreateFromFile;
|
||||
static pf_sfMusic_CreateFromMemory sfMusic_CreateFromMemory;
|
||||
static pf_sfMusic_Destroy sfMusic_Destroy;
|
||||
static pf_sfMusic_SetLoop sfMusic_SetLoop;
|
||||
static pf_sfMusic_GetLoop sfMusic_GetLoop;
|
||||
static pf_sfMusic_GetDuration sfMusic_GetDuration;
|
||||
static pf_sfMusic_Play sfMusic_Play;
|
||||
static pf_sfMusic_Pause sfMusic_Pause;
|
||||
static pf_sfMusic_Stop sfMusic_Stop;
|
||||
static pf_sfMusic_GetChannelsCount sfMusic_GetChannelsCount;
|
||||
static pf_sfMusic_GetSampleRate sfMusic_GetSampleRate;
|
||||
static pf_sfMusic_GetStatus sfMusic_GetStatus;
|
||||
static pf_sfMusic_SetPitch sfMusic_SetPitch;
|
||||
static pf_sfMusic_SetVolume sfMusic_SetVolume;
|
||||
static pf_sfMusic_SetPosition sfMusic_SetPosition;
|
||||
static pf_sfMusic_GetPitch sfMusic_GetPitch;
|
||||
static pf_sfMusic_GetVolume sfMusic_GetVolume;
|
||||
static pf_sfMusic_GetPosition sfMusic_GetPosition;
|
||||
static pf_sfMusic_GetMinDistance sfMusic_GetMinDistance;
|
||||
static pf_sfMusic_GetAttenuation sfMusic_GetAttenuation;
|
||||
static pf_sfMusic_SetMinDistance sfMusic_SetMinDistance;
|
||||
static pf_sfMusic_SetAttenuation sfMusic_SetAttenuation;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfMusic_CreateFromFile = cast(pf_sfMusic_CreateFromFile)dll.getSymbol("sfMusic_CreateFromFile");
|
||||
sfMusic_CreateFromMemory = cast(pf_sfMusic_CreateFromMemory)dll.getSymbol("sfMusic_CreateFromMemory");
|
||||
sfMusic_Destroy = cast(pf_sfMusic_Destroy)dll.getSymbol("sfMusic_Destroy");
|
||||
sfMusic_SetLoop = cast(pf_sfMusic_SetLoop)dll.getSymbol("sfMusic_SetLoop");
|
||||
sfMusic_GetLoop = cast(pf_sfMusic_GetLoop)dll.getSymbol("sfMusic_GetLoop");
|
||||
sfMusic_GetDuration = cast(pf_sfMusic_GetDuration)dll.getSymbol("sfMusic_GetDuration");
|
||||
sfMusic_Play = cast(pf_sfMusic_Play)dll.getSymbol("sfMusic_Play");
|
||||
sfMusic_Pause = cast(pf_sfMusic_Pause)dll.getSymbol("sfMusic_Pause");
|
||||
sfMusic_Stop = cast(pf_sfMusic_Stop)dll.getSymbol("sfMusic_Stop");
|
||||
sfMusic_GetChannelsCount = cast(pf_sfMusic_GetChannelsCount)dll.getSymbol("sfMusic_GetChannelsCount");
|
||||
sfMusic_GetSampleRate = cast(pf_sfMusic_GetSampleRate)dll.getSymbol("sfMusic_GetSampleRate");
|
||||
sfMusic_GetStatus = cast(pf_sfMusic_GetStatus)dll.getSymbol("sfMusic_GetStatus");
|
||||
sfMusic_SetPitch = cast(pf_sfMusic_SetPitch)dll.getSymbol("sfMusic_SetPitch");
|
||||
sfMusic_SetVolume = cast(pf_sfMusic_SetVolume)dll.getSymbol("sfMusic_SetVolume");
|
||||
sfMusic_SetPosition = cast(pf_sfMusic_SetPosition)dll.getSymbol("sfMusic_SetPosition");
|
||||
sfMusic_GetPitch = cast(pf_sfMusic_GetPitch)dll.getSymbol("sfMusic_GetPitch");
|
||||
sfMusic_GetVolume = cast(pf_sfMusic_GetVolume)dll.getSymbol("sfMusic_GetVolume");
|
||||
sfMusic_GetPosition = cast(pf_sfMusic_GetPosition)dll.getSymbol("sfMusic_GetPosition");
|
||||
sfMusic_GetMinDistance = cast(pf_sfMusic_GetMinDistance)dll.getSymbol("sfMusic_GetMinDistance");
|
||||
sfMusic_GetAttenuation = cast(pf_sfMusic_GetAttenuation)dll.getSymbol("sfMusic_GetAttenuation");
|
||||
sfMusic_SetMinDistance = cast(pf_sfMusic_SetMinDistance)dll.getSymbol("sfMusic_SetMinDistance");
|
||||
sfMusic_SetAttenuation = cast(pf_sfMusic_SetAttenuation)dll.getSymbol("sfMusic_SetAttenuation");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
extern(C)
|
||||
{
|
||||
void* function(cchar*) sfMusic_CreateFromFile;
|
||||
void* function(byte*, size_t) sfMusic_CreateFromMemory;
|
||||
void function(void*) sfMusic_Destroy;
|
||||
void function(void*, int) sfMusic_SetLoop;
|
||||
bool function(void*) sfMusic_GetLoop;
|
||||
float function(void*) sfMusic_GetDuration;
|
||||
void function(void*) sfMusic_Play;
|
||||
void function(void*) sfMusic_Pause;
|
||||
void function(void*) sfMusic_Stop;
|
||||
uint function(void*) sfMusic_GetChannelsCount;
|
||||
uint function(void*) sfMusic_GetSampleRate;
|
||||
SoundStatus function(void*) sfMusic_GetStatus;
|
||||
void function(void*, float) sfMusic_SetPitch;
|
||||
void function(void*, float) sfMusic_SetVolume;
|
||||
void function(void*, float, float, float) sfMusic_SetPosition;
|
||||
float function(void*) sfMusic_GetPitch;
|
||||
float function(void*) sfMusic_GetVolume;
|
||||
void function(void*, float*, float*, float*)sfMusic_GetPosition;
|
||||
float function(void*) sfMusic_GetMinDistance;
|
||||
float function(void*) sfMusic_GetAttenuation;
|
||||
void function(void*, float) sfMusic_SetMinDistance;
|
||||
void function(void*, float) sfMusic_SetAttenuation;
|
||||
|
||||
|
||||
void function(void*, bool) sfMusic_SetRelativeToListener;
|
||||
bool function(void*) sfMusic_IsRelativeToListener;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
mixin(loadFromSharedLib("sfMusic_CreateFromFile"));
|
||||
mixin(loadFromSharedLib("sfMusic_CreateFromMemory"));
|
||||
mixin(loadFromSharedLib("sfMusic_Destroy"));
|
||||
mixin(loadFromSharedLib("sfMusic_SetLoop"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetLoop"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetDuration"));
|
||||
mixin(loadFromSharedLib("sfMusic_Play"));
|
||||
mixin(loadFromSharedLib("sfMusic_Pause"));
|
||||
mixin(loadFromSharedLib("sfMusic_Stop"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetChannelsCount"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetSampleRate"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetStatus"));
|
||||
mixin(loadFromSharedLib("sfMusic_SetPitch"));
|
||||
mixin(loadFromSharedLib("sfMusic_SetVolume"));
|
||||
mixin(loadFromSharedLib("sfMusic_SetPosition"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetPitch"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetVolume"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetPosition"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetMinDistance"));
|
||||
mixin(loadFromSharedLib("sfMusic_GetAttenuation"));
|
||||
mixin(loadFromSharedLib("sfMusic_SetMinDistance"));
|
||||
mixin(loadFromSharedLib("sfMusic_SetAttenuation"));
|
||||
|
||||
mixin(loadFromSharedLib("sfMusic_SetRelativeToListener"));
|
||||
mixin(loadFromSharedLib("sfMusic_IsRelativeToListener"));
|
||||
}
|
@ -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
|
||||
@ -330,6 +331,30 @@ class Sound : DSFMLObject
|
||||
return sfSound_GetPlayingOffset(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the sound's position relative to the listener's position, or absolute.
|
||||
* The default value is false (absolute)
|
||||
*
|
||||
* Params:
|
||||
* relative = True to set the position relative, false to set it absolute
|
||||
*/
|
||||
void setRelativeToListener(bool relative)
|
||||
{
|
||||
sfSound_SetRelativeToListener(m_ptr, relative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the sound's position is relative to the listener's
|
||||
* position, or if it's absolute
|
||||
*
|
||||
* Returns:
|
||||
* true if the position is relative, sfFalse if it's absolute
|
||||
*/
|
||||
bool isRelativeToListener()
|
||||
{
|
||||
return sfSound_IsRelativeToListener(m_ptr);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
SoundBuffer m_buffer;
|
||||
@ -360,6 +385,9 @@ private:
|
||||
typedef void function(void*, float) pf_sfSound_SetMinDistance;
|
||||
typedef void function(void*, float) pf_sfSound_SetAttenuation;
|
||||
typedef void function(void*, float) pf_sfSound_SetPlayingOffset;
|
||||
|
||||
static void function(void*, bool) sfSound_SetRelativeToListener;
|
||||
static bool function(void*) sfSound_IsRelativeToListener;
|
||||
|
||||
static pf_sfSound_Create sfSound_Create;
|
||||
static pf_sfSound_Destroy sfSound_Destroy;
|
||||
@ -387,7 +415,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfSound_Create = cast(pf_sfSound_Create)dll.getSymbol("sfSound_Create");
|
||||
sfSound_Destroy = cast(pf_sfSound_Destroy)dll.getSymbol("sfSound_Destroy");
|
||||
@ -411,5 +442,9 @@ private:
|
||||
sfSound_SetMinDistance = cast(pf_sfSound_SetMinDistance)dll.getSymbol("sfSound_SetMinDistance");
|
||||
sfSound_SetAttenuation = cast(pf_sfSound_SetAttenuation)dll.getSymbol("sfSound_SetAttenuation");
|
||||
sfSound_SetPlayingOffset = cast(pf_sfSound_SetPlayingOffset)dll.getSymbol("sfSound_SetPlayingOffset");
|
||||
|
||||
mixin(loadFromSharedLib("sfSound_SetRelativeToListener"));
|
||||
mixin(loadFromSharedLib("sfSound_IsRelativeToListener"));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -45,7 +46,7 @@ class SoundBuffer : DSFMLObject
|
||||
* Throws:
|
||||
* LoadingException on failure
|
||||
*/
|
||||
this(char[] filename)
|
||||
this(string filename)
|
||||
{
|
||||
if (filename is null || filename.length == 0)
|
||||
throw new LoadingException("LoadingException : Filename is invalid.");
|
||||
@ -106,7 +107,7 @@ class SoundBuffer : DSFMLObject
|
||||
* Returns:
|
||||
* True if saving has been successful
|
||||
*/
|
||||
bool saveToFile(char[] filename)
|
||||
bool saveToFile(string filename)
|
||||
{
|
||||
if (filename !is null && filename.length > 0 )
|
||||
{
|
||||
@ -184,11 +185,11 @@ private:
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function(char*) pf_sfSoundBuffer_CreateFromFile;
|
||||
typedef void* function(cchar*) pf_sfSoundBuffer_CreateFromFile;
|
||||
typedef void* function(byte*, size_t) pf_sfSoundBuffer_CreateFromMemory;
|
||||
typedef void* function(short*, size_t, uint, uint) pf_sfSoundBuffer_CreateFromSamples;
|
||||
typedef void function(void*) pf_sfSoundBuffer_Destroy;
|
||||
typedef int function(void*, char*) pf_sfSoundBuffer_SaveToFile;
|
||||
typedef int function(void*, cchar*) pf_sfSoundBuffer_SaveToFile;
|
||||
typedef short* function(void*) pf_sfSoundBuffer_GetSamples;
|
||||
typedef size_t function(void*) pf_sfSoundBuffer_GetSamplesCount;
|
||||
typedef uint function(void*) pf_sfSoundBuffer_GetSampleRate;
|
||||
@ -209,7 +210,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfSoundBuffer_CreateFromFile = cast(pf_sfSoundBuffer_CreateFromFile)dll.getSymbol("sfSoundBuffer_CreateFromFile");
|
||||
sfSoundBuffer_CreateFromMemory = cast(pf_sfSoundBuffer_CreateFromMemory)dll.getSymbol("sfSoundBuffer_CreateFromMemory");
|
||||
|
@ -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
|
||||
@ -95,7 +96,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfSoundBufferRecorder_Create = cast(pf_sfSoundBufferRecorder_Create)dll.getSymbol("sfSoundBufferRecorder_Create");
|
||||
sfSoundBufferRecorder_Destroy = cast(pf_sfSoundBufferRecorder_Destroy)dll.getSymbol("sfSoundBufferRecorder_Destroy");
|
||||
|
@ -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,7 +34,8 @@ import dsfml.system.sleep;
|
||||
import dsfml.system.linkedlist;
|
||||
import dsfml.system.mutex;
|
||||
import dsfml.system.lock;
|
||||
import dsfml.system.thread;
|
||||
//import dsfml.system.thread;
|
||||
import core.thread;
|
||||
|
||||
/**
|
||||
* SoundRecorder is an interface for capturing sound data.
|
||||
@ -93,7 +95,7 @@ abstract class SoundRecorder : DSFMLObject
|
||||
{
|
||||
sfSoundRecorder_Start(m_ptr, sampleRate);
|
||||
m_t = new Thread(&threadPoll);
|
||||
m_t.launch();
|
||||
m_t.start();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +105,7 @@ abstract class SoundRecorder : DSFMLObject
|
||||
{
|
||||
sfSoundRecorder_Stop(m_ptr);
|
||||
m_flag = false;
|
||||
m_t.wait();
|
||||
m_t.join();
|
||||
m_t = null;
|
||||
}
|
||||
|
||||
@ -246,7 +248,7 @@ private:
|
||||
/*
|
||||
* Managed thread loop
|
||||
*/
|
||||
void threadPoll(void* user)
|
||||
void threadPoll()
|
||||
{
|
||||
while (m_flag)
|
||||
{
|
||||
@ -303,7 +305,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfSoundRecorder_Create = cast(pf_sfSoundRecorder_Create)dll.getSymbol("sfSoundRecorder_Create");
|
||||
sfSoundRecorder_Destroy = cast(pf_sfSoundRecorder_Destroy)dll.getSymbol("sfSoundRecorder_Destroy");
|
||||
|
@ -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
|
||||
@ -32,7 +33,8 @@ import dsfml.system.linkedlist;
|
||||
import dsfml.system.lock;
|
||||
import dsfml.system.mutex;
|
||||
import dsfml.system.sleep;
|
||||
import dsfml.system.thread;
|
||||
//import dsfml.system.thread;
|
||||
import core.thread;
|
||||
|
||||
import dsfml.audio.sound;
|
||||
import dsfml.audio.soundstatus;
|
||||
@ -87,7 +89,7 @@ abstract class SoundStream : DSFMLObject
|
||||
if (getStatus() != SoundStatus.PAUSED)
|
||||
{
|
||||
m_t = new Thread(&threadPoll);
|
||||
m_t.launch();
|
||||
m_t.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ abstract class SoundStream : DSFMLObject
|
||||
{
|
||||
m_flag = false;
|
||||
sfSoundStream_Stop(m_ptr);
|
||||
m_t.wait();
|
||||
m_t.join();
|
||||
if (m_dummy !is null)
|
||||
delete m_dummy;
|
||||
}
|
||||
@ -323,6 +325,31 @@ abstract class SoundStream : DSFMLObject
|
||||
if (m_ptr !is null)
|
||||
sfSoundStream_SetLoop(m_ptr, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the sound stream's position relative to the listener's position, or absolute.
|
||||
* The default value is false (absolute)
|
||||
*
|
||||
* Params:
|
||||
* relative = True to set the position relative, false to set it absolute
|
||||
*/
|
||||
void setRelativeToListener(bool relative)
|
||||
{
|
||||
sfSoundStream_SetRelativeToListener(m_ptr, relative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the sound stream's position is relative to the listener's
|
||||
* position, or if it's absolute
|
||||
*
|
||||
* Returns:
|
||||
* true if the position is relative, sfFalse if it's absolute
|
||||
*/
|
||||
bool isRelativeToListener()
|
||||
{
|
||||
return sfSoundStream_IsRelativeToListener(m_ptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Protected constructor
|
||||
@ -417,7 +444,7 @@ private:
|
||||
}
|
||||
|
||||
// Managed thread loop
|
||||
void threadPoll(void* dummy)
|
||||
void threadPoll()
|
||||
{
|
||||
short[] data;
|
||||
bool ret = true;
|
||||
@ -497,7 +524,10 @@ private:
|
||||
typedef int function(void*) pf_sfSoundStream_GetLoop;
|
||||
typedef void function(void*, int) pf_sfSoundStream_SetLoop;
|
||||
|
||||
|
||||
typedef bool function(void*) pf_sfSoundStream_IsRelativeToListener;
|
||||
typedef void function(void*, bool) pf_sfSoundStream_SetRelativeToListener;
|
||||
|
||||
|
||||
static pf_sfSoundStream_Create sfSoundStream_Create;
|
||||
static pf_sfSoundStream_Destroy sfSoundStream_Destroy;
|
||||
static pf_sfSoundStream_Play sfSoundStream_Play;
|
||||
@ -519,11 +549,18 @@ private:
|
||||
static pf_sfSoundStream_GetPlayingOffset sfSoundStream_GetPlayingOffset;
|
||||
static pf_sfSoundStream_GetLoop sfSoundStream_GetLoop;
|
||||
static pf_sfSoundStream_SetLoop sfSoundStream_SetLoop;
|
||||
|
||||
|
||||
static pf_sfSoundStream_IsRelativeToListener sfSoundStream_IsRelativeToListener;
|
||||
static pf_sfSoundStream_SetRelativeToListener sfSoundStream_SetRelativeToListener;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-audio-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-audio");
|
||||
|
||||
sfSoundStream_Create = cast(pf_sfSoundStream_Create)dll.getSymbol("sfSoundStream_Create");
|
||||
sfSoundStream_Destroy = cast(pf_sfSoundStream_Destroy)dll.getSymbol("sfSoundStream_Destroy");
|
||||
@ -546,5 +583,8 @@ private:
|
||||
sfSoundStream_GetPlayingOffset = cast(pf_sfSoundStream_GetPlayingOffset)dll.getSymbol("sfSoundStream_GetPlayingOffset");
|
||||
sfSoundStream_GetLoop = cast(pf_sfSoundStream_GetLoop)dll.getSymbol("sfSoundStream_GetLoop");
|
||||
sfSoundStream_SetLoop = cast(pf_sfSoundStream_SetLoop)dll.getSymbol("sfSoundStream_SetLoop");
|
||||
|
||||
sfSoundStream_IsRelativeToListener = cast(pf_sfSoundStream_IsRelativeToListener) dll.getSymbol("sfSoundStream_IsRelativeToListener");
|
||||
sfSoundStream_SetRelativeToListener = cast(pf_sfSoundStream_SetRelativeToListener) dll.getSymbol("sfSoundStream_SetRelativeToListener");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -31,11 +32,11 @@ public import
|
||||
dsfml.graphics.font,
|
||||
dsfml.graphics.idrawable,
|
||||
dsfml.graphics.image,
|
||||
dsfml.graphics.postfx,
|
||||
dsfml.graphics.shader,
|
||||
dsfml.graphics.rect,
|
||||
dsfml.graphics.renderwindow,
|
||||
dsfml.graphics.shape,
|
||||
dsfml.graphics.sprite,
|
||||
dsfml.graphics.string,
|
||||
dsfml.graphics.text,
|
||||
dsfml.graphics.textstyle,
|
||||
dsfml.graphics.view;
|
||||
|
@ -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
|
||||
@ -31,6 +32,11 @@ module dsfml.graphics.color;
|
||||
*/
|
||||
struct Color
|
||||
{
|
||||
ubyte r; /// Red component
|
||||
ubyte g; /// Green component
|
||||
ubyte b; /// Blue component
|
||||
ubyte a = 255; /// Alpha (transparency) component
|
||||
|
||||
/**
|
||||
* Construct the color from its 4 RGBA components
|
||||
*
|
||||
@ -40,6 +46,7 @@ struct Color
|
||||
* b = Blue component (0 .. 255)
|
||||
* a = Alpha component (0 .. 255) (255 by default)
|
||||
*/
|
||||
/*
|
||||
static Color opCall(ubyte r, ubyte g, ubyte b, ubyte a = 255)
|
||||
{
|
||||
Color c;
|
||||
@ -50,11 +57,11 @@ struct Color
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Operator == and != overload to compare two colors
|
||||
*/
|
||||
int opEquals(Color color2)
|
||||
const bool opEquals(ref const(Color) color2)
|
||||
{
|
||||
return
|
||||
(r == color2.r)
|
||||
@ -67,10 +74,10 @@ struct Color
|
||||
*/
|
||||
Color opAdd(Color color2)
|
||||
{
|
||||
ubyte r = this.r + color2.r > 255 ? 255 : this.r + color2.r;
|
||||
ubyte g = this.g + color2.g > 255 ? 255 : this.g + color2.g;
|
||||
ubyte b = this.b + color2.b > 255 ? 255 : this.b + color2.b;
|
||||
ubyte a = this.a + color2.a > 255 ? 255 : this.a + color2.a;
|
||||
ubyte r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r);
|
||||
ubyte g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g);
|
||||
ubyte b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b);
|
||||
ubyte a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a);
|
||||
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
@ -80,12 +87,12 @@ struct Color
|
||||
*/
|
||||
Color opAddAssign(Color color2)
|
||||
{
|
||||
this.r = this.r + color2.r > 255 ? 255 : this.r + color2.r;
|
||||
this.g = this.g + color2.g > 255 ? 255 : this.g + color2.g;
|
||||
this.b = this.b + color2.b > 255 ? 255 : this.b + color2.b;
|
||||
this.a = this.a + color2.a > 255 ? 255 : this.a + color2.a;
|
||||
this.r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r);
|
||||
this.g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g);
|
||||
this.b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b);
|
||||
this.a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a);
|
||||
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,10 +100,10 @@ struct Color
|
||||
*/
|
||||
Color opMul(Color color2)
|
||||
{
|
||||
ubyte r = this.r * color2.r / 255;
|
||||
ubyte g = this.g * color2.g / 255;
|
||||
ubyte b = this.b * color2.b / 255;
|
||||
ubyte a = this.a * color2.a / 255;
|
||||
ubyte r = cast(ubyte) (this.r * color2.r / 255);
|
||||
ubyte g = cast(ubyte) (this.g * color2.g / 255);
|
||||
ubyte b = cast(ubyte) (this.b * color2.b / 255);
|
||||
ubyte a = cast(ubyte) (this.a * color2.a / 255);
|
||||
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
@ -106,19 +113,14 @@ struct Color
|
||||
*/
|
||||
Color opMulAssign(Color color2)
|
||||
{
|
||||
this.r = this.r * color2.r / 255;
|
||||
this.g = this.g * color2.g / 255;
|
||||
this.b = this.b * color2.b / 255;
|
||||
this.a = this.a * color2.a / 255;
|
||||
this.r = cast(ubyte) (this.r * color2.r / 255);
|
||||
this.g = cast(ubyte) (this.g * color2.g / 255);
|
||||
this.b = cast(ubyte) (this.b * color2.b / 255);
|
||||
this.a = cast(ubyte) (this.a * color2.a / 255);
|
||||
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
ubyte r; /// Red component
|
||||
ubyte g; /// Green component
|
||||
ubyte b; /// Blue component
|
||||
ubyte a = 255; /// Alpha (transparency) component
|
||||
|
||||
static const Color BLACK = {0, 0, 0}; /// Black predefined color
|
||||
static const Color WHITE = {255, 255, 255}; /// White predefined color
|
||||
static const Color RED = {255, 0, 0}; /// Red predefined color
|
||||
|
168
DSFML/import/dsfml/graphics/common.d
Normal file
168
DSFML/import/dsfml/graphics/common.d
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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.graphics.common;
|
||||
|
||||
private import dsfml.system.common,
|
||||
dsfml.window.window,
|
||||
dsfml.window.windowhandle,
|
||||
dsfml.graphics.color,
|
||||
dsfml.graphics.rect,
|
||||
dsfml.graphics.font,
|
||||
dsfml.window.videomode;
|
||||
|
||||
package extern (C)
|
||||
{
|
||||
// sfFont
|
||||
void* function() sfFont_Create;
|
||||
void* function(cchar*) sfFont_CreateFromFile;
|
||||
void* function(ubyte*, size_t) sfFont_CreateFromMemory;
|
||||
void function(void*) sfFont_Destroy;
|
||||
void* function() sfFont_GetDefaultFont;
|
||||
|
||||
Glyph function(void*, uint, uint, bool) sfFont_GetGlyph;
|
||||
|
||||
// sfRenderWindow
|
||||
void* function(VideoMode, cchar*, uint, ContextSettings*) sfRenderWindow_Create;
|
||||
void* function(WindowHandle, ContextSettings*) sfRenderWindow_CreateFromHandle;
|
||||
void function(void*) sfRenderWindow_Destroy;
|
||||
void* function(void*) sfRenderWindow_GetInput;
|
||||
// bool function(void*) sfRenderWindow_IsOpened;
|
||||
|
||||
void function(void*, void*) sfRenderWindow_DrawSprite;
|
||||
void function(void*, void*) sfRenderWindow_DrawShape;
|
||||
void function(void*, void*) sfRenderWindow_DrawText;
|
||||
|
||||
void function(void*, void*, void*) sfRenderWindow_DrawSpriteWithShader;
|
||||
void function(void*, void*, void*) sfRenderWindow_DrawShapeWithShader;
|
||||
void function(void*, void*, void*) sfRenderWindow_DrawTextWithShader;
|
||||
|
||||
void* function(void*) sfRenderWindow_Capture;
|
||||
void function(void*, Color) sfRenderWindow_Clear;
|
||||
void function(void*, void*) sfRenderWindow_SetView;
|
||||
void* function(void*) sfRenderWindow_GetView;
|
||||
void* function (void*) sfRenderWindow_GetDefaultView;
|
||||
void function(void*, uint, uint, float*, float*, void*) sfRenderWindow_ConvertCoords;
|
||||
|
||||
// sfShader
|
||||
void* function(cchar*) sfShader_CreateFromFile;
|
||||
void* function(cchar*) sfShader_CreateFromMemory;
|
||||
void function(void*) sfShader_Destroy;
|
||||
void function(void*, cchar*, float) sfShader_SetParameter1;
|
||||
void function(void*, cchar*, float, float) sfShader_SetParameter2;
|
||||
void function(void*, cchar*, float, float, float) sfShader_SetParameter3;
|
||||
void function(void*, cchar*, float, float, float, float) sfShader_SetParameter4;
|
||||
void function(void*, cchar*, void*) sfShader_SetTexture;
|
||||
int function() sfShader_IsAvailable;
|
||||
void function(void*) sfShader_Bind;
|
||||
void function(void*) sfShader_Unbind;
|
||||
|
||||
// sfView
|
||||
void* function() sfView_Create;
|
||||
void* function(sfFloatRect) sfView_CreateFromRect;
|
||||
void function(void*) sfView_Destroy;
|
||||
void function(void*, float, float) sfView_SetCenter;
|
||||
void function(void*, float, float) sfView_SetSize;
|
||||
void function(void*, sfFloatRect) sfView_SetViewport;
|
||||
float function(void*) sfView_GetCenterX;
|
||||
float function(void*) sfView_GetCenterY;
|
||||
float function(void*) sfView_GetWidth;
|
||||
float function(void*) sfView_GetHeight;
|
||||
sfFloatRect function(void*) sfView_GetViewport;
|
||||
void function(void*, float, float) sfView_Move;
|
||||
void function(void*, float) sfView_Zoom;
|
||||
|
||||
void function(void*, float) sfView_SetRotation;
|
||||
float function(void*) sfView_GetRotation;
|
||||
void function(void*, float) sfView_Rotate;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-graphics-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
// sfFont
|
||||
mixin(loadFromSharedLib("sfFont_CreateFromFile"));
|
||||
mixin(loadFromSharedLib("sfFont_CreateFromMemory"));
|
||||
mixin(loadFromSharedLib("sfFont_Destroy"));
|
||||
mixin(loadFromSharedLib("sfFont_GetDefaultFont"));
|
||||
mixin(loadFromSharedLib("sfFont_GetGlyph"));
|
||||
|
||||
// sfRenderWindow
|
||||
mixin(loadFromSharedLib("sfRenderWindow_Create"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_CreateFromHandle"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_Destroy"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_GetInput"));
|
||||
|
||||
mixin(loadFromSharedLib("sfRenderWindow_DrawSprite"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_DrawShape"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_DrawText"));
|
||||
|
||||
mixin(loadFromSharedLib("sfRenderWindow_DrawSpriteWithShader"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_DrawShapeWithShader"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_DrawTextWithShader"));
|
||||
|
||||
mixin(loadFromSharedLib("sfRenderWindow_Clear"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_SetView"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_GetView"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_GetDefaultView"));
|
||||
mixin(loadFromSharedLib("sfRenderWindow_ConvertCoords"));
|
||||
|
||||
// sfShader
|
||||
mixin(loadFromSharedLib("sfShader_CreateFromFile"));
|
||||
mixin(loadFromSharedLib("sfShader_CreateFromMemory"));
|
||||
mixin(loadFromSharedLib("sfShader_Destroy"));
|
||||
mixin(loadFromSharedLib("sfShader_SetParameter1"));
|
||||
mixin(loadFromSharedLib("sfShader_SetParameter2"));
|
||||
mixin(loadFromSharedLib("sfShader_SetParameter3"));
|
||||
mixin(loadFromSharedLib("sfShader_SetParameter4"));
|
||||
mixin(loadFromSharedLib("sfShader_SetTexture"));
|
||||
mixin(loadFromSharedLib("sfShader_IsAvailable"));
|
||||
mixin(loadFromSharedLib("sfShader_Bind"));
|
||||
mixin(loadFromSharedLib("sfShader_Unbind"));
|
||||
|
||||
// sfView
|
||||
mixin(loadFromSharedLib("sfView_Create"));
|
||||
mixin(loadFromSharedLib("sfView_CreateFromRect"));
|
||||
mixin(loadFromSharedLib("sfView_Destroy"));
|
||||
mixin(loadFromSharedLib("sfView_SetCenter"));
|
||||
mixin(loadFromSharedLib("sfView_SetSize"));
|
||||
mixin(loadFromSharedLib("sfView_SetViewport"));
|
||||
mixin(loadFromSharedLib("sfView_GetCenterX"));
|
||||
mixin(loadFromSharedLib("sfView_GetCenterY"));
|
||||
mixin(loadFromSharedLib("sfView_GetWidth"));
|
||||
mixin(loadFromSharedLib("sfView_GetHeight"));
|
||||
mixin(loadFromSharedLib("sfView_GetViewport"));
|
||||
mixin(loadFromSharedLib("sfView_Move"));
|
||||
mixin(loadFromSharedLib("sfView_Zoom"));
|
||||
|
||||
mixin(loadFromSharedLib("sfView_SetRotation"));
|
||||
mixin(loadFromSharedLib("sfView_GetRotation"));
|
||||
mixin(loadFromSharedLib("sfView_Rotate"));
|
||||
}
|
@ -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
|
||||
@ -32,13 +33,13 @@ import dsfml.graphics.idrawable;
|
||||
import dsfml.graphics.color;
|
||||
import dsfml.graphics.blendmode;
|
||||
import dsfml.graphics.renderwindow;
|
||||
|
||||
import dsfml.graphics.shader;
|
||||
|
||||
package
|
||||
{
|
||||
struct sfSprite{};
|
||||
struct sfShape{};
|
||||
struct sfString{};
|
||||
struct sfText{};
|
||||
}
|
||||
|
||||
/*
|
||||
@ -47,6 +48,18 @@ package
|
||||
*/
|
||||
package class Drawableimpl(T) : DSFMLObject, IDrawable
|
||||
{
|
||||
protected:
|
||||
this()
|
||||
{
|
||||
super(sfDrawable_Create());
|
||||
}
|
||||
|
||||
this(void* ptr)
|
||||
{
|
||||
super(ptr);
|
||||
}
|
||||
|
||||
public:
|
||||
void setX(float x)
|
||||
{
|
||||
sfDrawable_SetX(m_ptr, x);
|
||||
@ -91,14 +104,14 @@ package class Drawableimpl(T) : DSFMLObject, IDrawable
|
||||
sfDrawable_SetScale(m_ptr, scale.x, scale.y);
|
||||
}
|
||||
|
||||
void setCenter(float centerX, float centerY)
|
||||
void setOrigin(float originX, float originY)
|
||||
{
|
||||
sfDrawable_SetCenter(m_ptr, centerX, centerY);
|
||||
sfDrawable_SetOrigin(m_ptr, originX, originY);
|
||||
}
|
||||
|
||||
void setCenter(Vector2f center)
|
||||
void setOrigin(Vector2f origin)
|
||||
{
|
||||
sfDrawable_SetCenter(m_ptr, center.x, center.y);
|
||||
sfDrawable_SetOrigin(m_ptr, origin.x, origin.y);
|
||||
}
|
||||
|
||||
void setRotation(float angle)
|
||||
@ -126,9 +139,9 @@ package class Drawableimpl(T) : DSFMLObject, IDrawable
|
||||
return Vector2f(sfDrawable_GetScaleX(m_ptr), sfDrawable_GetScaleY(m_ptr));
|
||||
}
|
||||
|
||||
Vector2f getCenter()
|
||||
Vector2f getOrigin()
|
||||
{
|
||||
return Vector2f(sfDrawable_GetCenterX(m_ptr), sfDrawable_GetCenterY(m_ptr));
|
||||
return Vector2f(sfDrawable_GetOriginX(m_ptr), sfDrawable_GetOriginY(m_ptr));
|
||||
}
|
||||
|
||||
float getRotation()
|
||||
@ -191,23 +204,17 @@ package class Drawableimpl(T) : DSFMLObject, IDrawable
|
||||
{
|
||||
sfRenderWindow_DrawThis(window.getNativePointer, m_ptr);
|
||||
}
|
||||
|
||||
void renderWithShader(RenderWindow window, Shader shader)
|
||||
{
|
||||
sfRenderWindow_DrawThisWithShader(window.getNativePointer, m_ptr, shader.getNativePointer);
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
sfDrawable_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
this()
|
||||
{
|
||||
super(sfDrawable_Create());
|
||||
}
|
||||
|
||||
this(void* ptr)
|
||||
{
|
||||
super(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
extern (C)
|
||||
@ -221,7 +228,7 @@ private:
|
||||
typedef void function(void*, float) pf_sfDrawable_SetScaleY;
|
||||
typedef void function(void*, float, float) pf_sfDrawable_SetScale;
|
||||
typedef void function(void*, float) pf_sfDrawable_SetRotation;
|
||||
typedef void function(void*, float, float) pf_sfDrawable_SetCenter;
|
||||
typedef void function(void*, float, float) pf_sfDrawable_SetOrigin;
|
||||
typedef void function(void*, Color) pf_sfDrawable_SetColor;
|
||||
typedef void function(void*, BlendMode) pf_sfDrawable_SetBlendMode;
|
||||
typedef float function(void*) pf_sfDrawable_GetX;
|
||||
@ -229,8 +236,8 @@ private:
|
||||
typedef float function(void*) pf_sfDrawable_GetScaleX;
|
||||
typedef float function(void*) pf_sfDrawable_GetScaleY;
|
||||
typedef float function(void*) pf_sfDrawable_GetRotation;
|
||||
typedef float function(void*) pf_sfDrawable_GetCenterX;
|
||||
typedef float function(void*) pf_sfDrawable_GetCenterY;
|
||||
typedef float function(void*) pf_sfDrawable_GetOriginX;
|
||||
typedef float function(void*) pf_sfDrawable_GetOriginY;
|
||||
typedef Color function(void*) pf_sfDrawable_GetColor;
|
||||
typedef BlendMode function(void*) pf_sfDrawable_GetBlendMode;
|
||||
typedef void function(void*, float, float) pf_sfDrawable_Move;
|
||||
@ -240,6 +247,7 @@ private:
|
||||
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToGlobal;
|
||||
|
||||
typedef void function(void*, void*) pf_sfRenderWindow_DrawThis;
|
||||
typedef void function(void*, void*, void*) pf_sfRenderWindow_DrawThisWithShader;
|
||||
|
||||
static pf_sfDrawable_Create sfDrawable_Create;
|
||||
static pf_sfDrawable_Destroy sfDrawable_Destroy;
|
||||
@ -250,7 +258,7 @@ private:
|
||||
static pf_sfDrawable_SetScaleY sfDrawable_SetScaleY;
|
||||
static pf_sfDrawable_SetScale sfDrawable_SetScale;
|
||||
static pf_sfDrawable_SetRotation sfDrawable_SetRotation;
|
||||
static pf_sfDrawable_SetCenter sfDrawable_SetCenter;
|
||||
static pf_sfDrawable_SetOrigin sfDrawable_SetOrigin;
|
||||
static pf_sfDrawable_SetColor sfDrawable_SetColor;
|
||||
static pf_sfDrawable_SetBlendMode sfDrawable_SetBlendMode;
|
||||
static pf_sfDrawable_GetX sfDrawable_GetX;
|
||||
@ -258,8 +266,8 @@ private:
|
||||
static pf_sfDrawable_GetScaleX sfDrawable_GetScaleX;
|
||||
static pf_sfDrawable_GetScaleY sfDrawable_GetScaleY;
|
||||
static pf_sfDrawable_GetRotation sfDrawable_GetRotation;
|
||||
static pf_sfDrawable_GetCenterX sfDrawable_GetCenterX;
|
||||
static pf_sfDrawable_GetCenterY sfDrawable_GetCenterY;
|
||||
static pf_sfDrawable_GetOriginX sfDrawable_GetOriginX;
|
||||
static pf_sfDrawable_GetOriginY sfDrawable_GetOriginY;
|
||||
static pf_sfDrawable_GetColor sfDrawable_GetColor;
|
||||
static pf_sfDrawable_GetBlendMode sfDrawable_GetBlendMode;
|
||||
static pf_sfDrawable_Move sfDrawable_Move;
|
||||
@ -269,23 +277,27 @@ private:
|
||||
static pf_sfDrawable_TransformToGlobal sfDrawable_TransformToGlobal;
|
||||
|
||||
static pf_sfRenderWindow_DrawThis sfRenderWindow_DrawThis;
|
||||
static pf_sfRenderWindow_DrawThisWithShader sfRenderWindow_DrawThisWithShader;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-graphics-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
static if (is (T : sfSprite))
|
||||
{
|
||||
char[] symbol = "sfSprite";
|
||||
string symbol = "sfSprite";
|
||||
}
|
||||
else static if (is (T : sfString))
|
||||
else static if (is (T : sfText))
|
||||
{
|
||||
char[] symbol = "sfString";
|
||||
string symbol = "sfText";
|
||||
}
|
||||
else static if (is (T : sfShape))
|
||||
{
|
||||
char[] symbol = "sfShape";
|
||||
string symbol = "sfShape";
|
||||
}
|
||||
|
||||
sfDrawable_Create = cast(pf_sfDrawable_Create)dll.getSymbol(symbol ~ "_Create");
|
||||
@ -297,7 +309,7 @@ private:
|
||||
sfDrawable_SetScaleY = cast(pf_sfDrawable_SetScaleY)dll.getSymbol(symbol ~ "_SetScaleY");
|
||||
sfDrawable_SetScale = cast(pf_sfDrawable_SetScale)dll.getSymbol(symbol ~ "_SetScale");
|
||||
sfDrawable_SetRotation = cast(pf_sfDrawable_SetRotation)dll.getSymbol(symbol ~ "_SetRotation");
|
||||
sfDrawable_SetCenter = cast(pf_sfDrawable_SetCenter)dll.getSymbol(symbol ~ "_SetCenter");
|
||||
sfDrawable_SetOrigin = cast(pf_sfDrawable_SetOrigin)dll.getSymbol(symbol ~ "_SetOrigin");
|
||||
sfDrawable_SetColor = cast(pf_sfDrawable_SetColor)dll.getSymbol(symbol ~ "_SetColor");
|
||||
sfDrawable_SetBlendMode = cast(pf_sfDrawable_SetBlendMode)dll.getSymbol(symbol ~ "_SetBlendMode");
|
||||
sfDrawable_GetX = cast(pf_sfDrawable_GetX)dll.getSymbol(symbol ~ "_GetX");
|
||||
@ -305,8 +317,8 @@ private:
|
||||
sfDrawable_GetScaleX = cast(pf_sfDrawable_GetScaleX)dll.getSymbol(symbol ~ "_GetScaleX");
|
||||
sfDrawable_GetScaleY = cast(pf_sfDrawable_GetScaleY)dll.getSymbol(symbol ~ "_GetScaleX");
|
||||
sfDrawable_GetRotation = cast(pf_sfDrawable_GetRotation)dll.getSymbol(symbol ~ "_GetRotation");
|
||||
sfDrawable_GetCenterX = cast(pf_sfDrawable_GetCenterX)dll.getSymbol(symbol ~ "_GetCenterX");
|
||||
sfDrawable_GetCenterY = cast(pf_sfDrawable_GetCenterY)dll.getSymbol(symbol ~ "_GetCenterY");
|
||||
sfDrawable_GetOriginX = cast(pf_sfDrawable_GetOriginX)dll.getSymbol(symbol ~ "_GetOriginX");
|
||||
sfDrawable_GetOriginY = cast(pf_sfDrawable_GetOriginY)dll.getSymbol(symbol ~ "_GetOriginY");
|
||||
sfDrawable_GetColor = cast(pf_sfDrawable_GetColor)dll.getSymbol(symbol ~ "_GetColor");
|
||||
sfDrawable_GetBlendMode = cast(pf_sfDrawable_GetBlendMode)dll.getSymbol(symbol ~ "_GetBlendMode");
|
||||
sfDrawable_Move = cast(pf_sfDrawable_Move)dll.getSymbol(symbol ~ "_Move");
|
||||
@ -316,5 +328,6 @@ private:
|
||||
sfDrawable_TransformToGlobal = cast(pf_sfDrawable_TransformToGlobal)dll.getSymbol(symbol ~ "_TransformToGlobal");
|
||||
|
||||
sfRenderWindow_DrawThis = cast(pf_sfRenderWindow_DrawThis)dll.getSymbol("sfRenderWindow_Draw" ~ symbol[2..$]);
|
||||
sfRenderWindow_DrawThisWithShader = cast(pf_sfRenderWindow_DrawThisWithShader)dll.getSymbol("sfRenderWindow_Draw" ~ symbol[2..$] ~ "WithShader");
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -25,9 +26,21 @@
|
||||
|
||||
module dsfml.graphics.font;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.exception;
|
||||
import dsfml.system.stringutil;
|
||||
import dsfml.system.common,
|
||||
dsfml.system.exception,
|
||||
dsfml.system.stringutil;
|
||||
|
||||
import dsfml.graphics.common,
|
||||
dsfml.graphics.rect;
|
||||
|
||||
|
||||
/// Glyph describes a glyph (a visual character)
|
||||
struct Glyph
|
||||
{
|
||||
int Advance; /// Offset to move horizontically to the next character
|
||||
sfIntRect Rectangle; /// Bounding rectangle of the glyph, in relative coordinates
|
||||
sfFloatRect TexCoords; /// Texture coordinates of the glyph inside the bitmap font
|
||||
}
|
||||
|
||||
/**
|
||||
* Font is the low-level class for loading and
|
||||
@ -35,7 +48,11 @@ import dsfml.system.stringutil;
|
||||
*/
|
||||
class Font : DSFMLObject
|
||||
{
|
||||
/**
|
||||
private:
|
||||
static Font s_default;
|
||||
public:
|
||||
|
||||
/**
|
||||
* Get SFML default built-in font (Arial)
|
||||
*/
|
||||
static Font getDefaultFont()
|
||||
@ -50,15 +67,13 @@ class Font : DSFMLObject
|
||||
*
|
||||
* Params:
|
||||
* filename = font file to load
|
||||
* charSize = size of characters (30 by default)
|
||||
* charset = characters set to generate (empty by default - takes the ASCII range [31, 255])
|
||||
*/
|
||||
this(char[] filename, uint charSize = 30, dchar[] charset = null)
|
||||
this(string filename)
|
||||
{
|
||||
if (filename is null || filename.length == 0)
|
||||
throw new LoadingException("LoadingException : Filename is invalid.");
|
||||
|
||||
super(sfFont_CreateFromFile(toStringz(filename), charSize, toStringz(charset)));
|
||||
super(sfFont_CreateFromFile(toStringz(filename)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,15 +81,13 @@ class Font : DSFMLObject
|
||||
*
|
||||
* Params:
|
||||
* data = data to load
|
||||
* charSize = size of characters (30 by default)
|
||||
* charset = characters set to generate (empty by default - takes the ASCII range [31, 255])
|
||||
*/
|
||||
this(byte[] data, uint charSize = 30, dchar[] charset = null)
|
||||
this(ubyte[] data)
|
||||
{
|
||||
if (data is null || data.length == 0)
|
||||
throw new Exception("LoadingException : Memory stream is invalid.");
|
||||
|
||||
super(sfFont_CreateFromMemory(data.ptr, data.length, charSize, toStringz(charset)));
|
||||
super(sfFont_CreateFromMemory(data.ptr, data.length));
|
||||
}
|
||||
|
||||
|
||||
@ -84,40 +97,10 @@ class Font : DSFMLObject
|
||||
}
|
||||
|
||||
|
||||
|
||||
package:
|
||||
|
||||
this(void* ptr)
|
||||
{
|
||||
super(ptr, true);
|
||||
}
|
||||
|
||||
private:
|
||||
static Font s_default;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function() pf_sfFont_Create;
|
||||
typedef void* function(char*, uint, dchar*) pf_sfFont_CreateFromFile;
|
||||
typedef void* function(byte*, size_t, uint, dchar*) pf_sfFont_CreateFromMemory;
|
||||
typedef void function(void*) pf_sfFont_Destroy;
|
||||
typedef void* function() pf_sfFont_GetDefaultFont;
|
||||
|
||||
static pf_sfFont_Create sfFont_Create;
|
||||
static pf_sfFont_CreateFromFile sfFont_CreateFromFile;
|
||||
static pf_sfFont_CreateFromMemory sfFont_CreateFromMemory;
|
||||
static pf_sfFont_Destroy sfFont_Destroy;
|
||||
static pf_sfFont_GetDefaultFont sfFont_GetDefaultFont;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfFont_Create = cast(pf_sfFont_Create) dll.getSymbol("sfFont_Create");
|
||||
sfFont_CreateFromFile = cast(pf_sfFont_CreateFromFile) dll.getSymbol("sfFont_CreateFromFile");
|
||||
sfFont_CreateFromMemory = cast(pf_sfFont_CreateFromMemory) dll.getSymbol("sfFont_CreateFromMemory");
|
||||
sfFont_Destroy = cast(pf_sfFont_Destroy) dll.getSymbol("sfFont_Destroy");
|
||||
sfFont_GetDefaultFont = cast(pf_sfFont_GetDefaultFont) dll.getSymbol("sfFont_GetDefaultFont");
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -27,15 +28,16 @@ module dsfml.graphics.idrawable;
|
||||
|
||||
import dsfml.system.vector2;
|
||||
|
||||
import dsfml.graphics.color;
|
||||
import dsfml.graphics.blendmode;
|
||||
import dsfml.graphics.renderwindow;
|
||||
import dsfml.graphics.color,
|
||||
dsfml.graphics.blendmode,
|
||||
dsfml.graphics.renderwindow,
|
||||
dsfml.graphics.shader;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for drawable object
|
||||
*
|
||||
* Shape, String and Sprite implement IDrawable
|
||||
* Shape, Text and Sprite implement IDrawable
|
||||
*/
|
||||
interface IDrawable
|
||||
{
|
||||
@ -107,25 +109,25 @@ interface IDrawable
|
||||
void setScale(Vector2f scale);
|
||||
|
||||
/**
|
||||
* Set the center of the object, in coordinates relative to the
|
||||
* Set the origin of the object, in coordinates relative to the
|
||||
* top-left of the object (take 2 values).
|
||||
* The default center is (0, 0)
|
||||
* The default origin is (0, 0)
|
||||
*
|
||||
* Params:
|
||||
* centerX : X coordinate of the center
|
||||
* centerY : Y coordinate of the center
|
||||
* originX : X coordinate of the origin
|
||||
* originY : Y coordinate of the origin
|
||||
*/
|
||||
void setCenter(float centerX, float centerY);
|
||||
void setOrigin(float originX, float originY);
|
||||
|
||||
/**
|
||||
* Set the center of the object, in coordinates relative to the
|
||||
* Set the origin of the object, in coordinates relative to the
|
||||
* top-left of the object (take a 2D vector).
|
||||
* The default center is (0, 0)
|
||||
* The default origin is (0, 0)
|
||||
*
|
||||
* Params:
|
||||
* center : New center
|
||||
* origin : New origin
|
||||
*/
|
||||
void setCenter(Vector2f center);
|
||||
void setOrigin(Vector2f origin);
|
||||
|
||||
|
||||
/**
|
||||
@ -171,13 +173,13 @@ interface IDrawable
|
||||
Vector2f getScale();
|
||||
|
||||
/**
|
||||
* Get the center of the object
|
||||
* Get the origin of the object
|
||||
*
|
||||
* Returns:
|
||||
* Current position of the center
|
||||
* Current position of the origin
|
||||
*
|
||||
*/
|
||||
Vector2f getCenter();
|
||||
Vector2f getOrigin();
|
||||
|
||||
/**
|
||||
* Get the rotation angle of the object
|
||||
@ -250,7 +252,7 @@ interface IDrawable
|
||||
|
||||
/**
|
||||
* Transform a point from global coordinates into local coordinates
|
||||
* (ie it applies the inverse of object's center, translation, rotation and scale to the point)
|
||||
* (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
|
||||
*
|
||||
* Params:
|
||||
* point = Point to transform
|
||||
@ -262,7 +264,7 @@ interface IDrawable
|
||||
|
||||
/**
|
||||
* Transform a point from local coordinates into global coordinates
|
||||
* (ie it applies the inverse of object's center, translation, rotation and scale to the point)
|
||||
* (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
|
||||
*
|
||||
* Params:
|
||||
* point = Point to transform
|
||||
@ -279,6 +281,13 @@ interface IDrawable
|
||||
* window = Target into which render the object
|
||||
*/
|
||||
void render(RenderWindow window);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Render the specific geometry of the object with a shader
|
||||
*
|
||||
* Params:
|
||||
* window = Render target
|
||||
* shader = Shader to use
|
||||
*/
|
||||
void renderWithShader(RenderWindow window, Shader shader);
|
||||
}
|
@ -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
|
||||
@ -24,18 +25,15 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* TODO : FIX circular dependency with render window
|
||||
*/
|
||||
module dsfml.graphics.image;
|
||||
|
||||
import dsfml.graphics.color;
|
||||
import dsfml.graphics.rect;
|
||||
import dsfml.graphics.common,
|
||||
dsfml.graphics.color,
|
||||
dsfml.graphics.rect;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.exception;
|
||||
import dsfml.system.stringutil;
|
||||
import dsfml.system.common,
|
||||
dsfml.system.exception,
|
||||
dsfml.system.stringutil;
|
||||
|
||||
|
||||
/**
|
||||
@ -74,7 +72,7 @@ class Image : DSFMLObject
|
||||
* Throws:
|
||||
* LoadingException if filename is empty or null.
|
||||
*/
|
||||
this(char[] filename)
|
||||
this(string filename)
|
||||
{
|
||||
if (filename is null || filename.length == 0)
|
||||
throw new LoadingException("LoadingException : Filename is invalid.");
|
||||
@ -90,7 +88,7 @@ class Image : DSFMLObject
|
||||
* Throws:
|
||||
* LoadingException if data is empty or null.
|
||||
*/
|
||||
this(byte[] data)
|
||||
this(ubyte[] data)
|
||||
{
|
||||
if (data is null || data.length == 0)
|
||||
throw new LoadingException("LoadingException : Memory stream is invalid.");
|
||||
@ -131,7 +129,7 @@ class Image : DSFMLObject
|
||||
* Returns:
|
||||
* True if saving was successful
|
||||
*/
|
||||
bool saveToFile(char[] filename)
|
||||
bool saveToFile(string filename)
|
||||
{
|
||||
return cast(bool)sfImage_SaveToFile(m_ptr, toStringz(filename));
|
||||
}
|
||||
@ -304,10 +302,10 @@ private:
|
||||
typedef void* function() pf_sfImage_Create;
|
||||
typedef void* function(uint, uint, Color) pf_sfImage_CreateFromColor;
|
||||
typedef void* function(uint, uint, ubyte*) pf_sfImage_CreateFromPixels;
|
||||
typedef void* function(char*) pf_sfImage_CreateFromFile;
|
||||
typedef void* function(byte* ,size_t) pf_sfImage_CreateFromMemory;
|
||||
typedef void* function(cchar*) pf_sfImage_CreateFromFile;
|
||||
typedef void* function(ubyte* ,size_t) pf_sfImage_CreateFromMemory;
|
||||
typedef void function(void*) pf_sfImage_Destroy;
|
||||
typedef int function(void*, char*) pf_sfImage_SaveToFile;
|
||||
typedef int function(void*, cchar*) pf_sfImage_SaveToFile;
|
||||
typedef void function(void*, Color, ubyte) pf_sfImage_CreateMaskFromColor;
|
||||
typedef int function(void*, void*, sfIntRect) pf_sfImage_CopyScreen;
|
||||
typedef void function(void*, void*, uint, uint, sfIntRect) pf_sfImage_Copy;
|
||||
@ -342,7 +340,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-graphics-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfImage_Create = cast(pf_sfImage_Create)dll.getSymbol("sfImage_Create");
|
||||
sfImage_CreateFromColor = cast(pf_sfImage_CreateFromColor)dll.getSymbol("sfImage_CreateFromColor");
|
||||
|
@ -1,175 +0,0 @@
|
||||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@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.
|
||||
*/
|
||||
|
||||
module dsfml.graphics.postfx;
|
||||
|
||||
import dsfml.graphics.image;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.exception;
|
||||
import dsfml.system.stringutil;
|
||||
|
||||
|
||||
/**
|
||||
* Define loading methods for effect
|
||||
*/
|
||||
enum LoadingType
|
||||
{
|
||||
FROMFILE, /// string represents a file path
|
||||
FROMSTRING /// string represents effect code
|
||||
}
|
||||
|
||||
/**
|
||||
* PostFX is used to apply a post effect to a window
|
||||
*
|
||||
* See_Also:
|
||||
* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax.
|
||||
*/
|
||||
class PostFX : DSFMLObject
|
||||
{
|
||||
/**
|
||||
* construct the effect
|
||||
*
|
||||
* Params:
|
||||
* effect = Path of a file or string containing the effect.
|
||||
* type = type of the effect (default is FROMFILE)
|
||||
*/
|
||||
this(char[] effect, LoadingType type = LoadingType.FROMFILE)
|
||||
{
|
||||
if (effect is null || effect.length == 0)
|
||||
throw new LoadingException("LoadingException : Effect is invalid.");
|
||||
|
||||
if (type == LoadingType.FROMFILE)
|
||||
super(sfPostFX_CreateFromFile(toStringz(effect)));
|
||||
else
|
||||
super(sfPostFX_CreateFromMemory(toStringz(effect)));
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
sfPostFX_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change parameters of the effect
|
||||
*
|
||||
* Params:
|
||||
* name = Parameter name in the effect
|
||||
*/
|
||||
void setParameter(char[] name, float x)
|
||||
{
|
||||
sfPostFX_SetParameter1(m_ptr, toStringz(name), x);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(char[] name, float x, float y)
|
||||
{
|
||||
sfPostFX_SetParameter2(m_ptr, toStringz(name), x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(char[] name, float x, float y, float z)
|
||||
{
|
||||
sfPostFX_SetParameter3(m_ptr, toStringz(name), x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(char[] name, float x, float y, float z, float w)
|
||||
{
|
||||
sfPostFX_SetParameter4(m_ptr, toStringz(name), x, y, z, w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a texture parameter
|
||||
*
|
||||
* Params:
|
||||
* name = Texture name in the effect
|
||||
* texture = Image to set (pass NULL to use content of current framebuffer)
|
||||
*/
|
||||
void setTexture(char[] name, Image texture)
|
||||
{
|
||||
m_texture = texture;
|
||||
sfPostFX_SetTexture(m_ptr, toStringz(name), texture is null ? null : texture.getNativePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether or not the system supports post-effects
|
||||
*
|
||||
* Returns:
|
||||
* True if the system can use post-effects
|
||||
*/
|
||||
static bool canUsePostFX()
|
||||
{
|
||||
return cast(bool)sfPostFX_CanUsePostFX();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Image m_texture;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function(char*) pf_sfPostFX_CreateFromFile;
|
||||
typedef void* function(char*) pf_sfPostFX_CreateFromMemory;
|
||||
typedef void function(void*) pf_sfPostFX_Destroy;
|
||||
typedef void function(void*, char*, float) pf_sfPostFX_SetParameter1;
|
||||
typedef void function(void*, char*, float, float) pf_sfPostFX_SetParameter2;
|
||||
typedef void function(void*, char*, float, float, float) pf_sfPostFX_SetParameter3;
|
||||
typedef void function(void*, char*, float, float, float, float) pf_sfPostFX_SetParameter4;
|
||||
typedef void function(void*, char*, void*) pf_sfPostFX_SetTexture;
|
||||
typedef int function() pf_sfPostFX_CanUsePostFX;
|
||||
|
||||
static pf_sfPostFX_CreateFromFile sfPostFX_CreateFromFile;
|
||||
static pf_sfPostFX_CreateFromMemory sfPostFX_CreateFromMemory;
|
||||
static pf_sfPostFX_Destroy sfPostFX_Destroy;
|
||||
static pf_sfPostFX_SetParameter1 sfPostFX_SetParameter1;
|
||||
static pf_sfPostFX_SetParameter2 sfPostFX_SetParameter2;
|
||||
static pf_sfPostFX_SetParameter3 sfPostFX_SetParameter3;
|
||||
static pf_sfPostFX_SetParameter4 sfPostFX_SetParameter4;
|
||||
static pf_sfPostFX_SetTexture sfPostFX_SetTexture;
|
||||
static pf_sfPostFX_CanUsePostFX sfPostFX_CanUsePostFX;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfPostFX_CreateFromFile = cast(pf_sfPostFX_CreateFromFile)dll.getSymbol("sfPostFX_CreateFromFile");
|
||||
sfPostFX_CreateFromMemory = cast(pf_sfPostFX_CreateFromMemory)dll.getSymbol("sfPostFX_CreateFromMemory");
|
||||
sfPostFX_Destroy = cast(pf_sfPostFX_Destroy)dll.getSymbol("sfPostFX_Destroy");
|
||||
sfPostFX_SetParameter1 = cast(pf_sfPostFX_SetParameter1)dll.getSymbol("sfPostFX_SetParameter1");
|
||||
sfPostFX_SetParameter2 = cast(pf_sfPostFX_SetParameter2)dll.getSymbol("sfPostFX_SetParameter2");
|
||||
sfPostFX_SetParameter3 = cast(pf_sfPostFX_SetParameter3)dll.getSymbol("sfPostFX_SetParameter3");
|
||||
sfPostFX_SetParameter4 = cast(pf_sfPostFX_SetParameter4)dll.getSymbol("sfPostFX_SetParameter4");
|
||||
sfPostFX_SetTexture = cast(pf_sfPostFX_SetTexture)dll.getSymbol("sfPostFX_SetTexture");
|
||||
sfPostFX_CanUsePostFX = cast(pf_sfPostFX_CanUsePostFX)dll.getSymbol("sfPostFX_CanUsePostFX");
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -71,7 +72,15 @@ else
|
||||
|
||||
class Rect (T)
|
||||
{
|
||||
static if (!isIntegerType!(T) && !isRealType!(T))
|
||||
|
||||
private:
|
||||
T m_Left; // Left coordinate of the rectangle
|
||||
T m_Top; // Top coordinate of the rectangle
|
||||
T m_Right; // Right coordinate of the rectangle
|
||||
T m_Bottom; // Bottom coordinate of the rectangle
|
||||
|
||||
public:
|
||||
static if (!isIntegerType!(T) && !isRealType!(T))
|
||||
{
|
||||
static assert (0, "This type is not supported by Rectangle");
|
||||
}
|
||||
@ -273,19 +282,9 @@ package:
|
||||
{
|
||||
return sfIntRect(cast(int)m_Left, cast(int)m_Top, cast(int)m_Right, cast(int)m_Bottom);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T m_Left; // Left coordinate of the rectangle
|
||||
T m_Top; // Top coordinate of the rectangle
|
||||
T m_Right; // Right coordinate of the rectangle
|
||||
T m_Bottom; // Bottom coordinate of the rectangle
|
||||
}
|
||||
|
||||
///Alias
|
||||
alias Rect!(int) IntRect;
|
||||
///ditto
|
||||
alias Rect!(float) FloatRect;
|
||||
|
||||
|
||||
|
||||
alias Rect!(float) FloatRect;
|
@ -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
|
||||
@ -25,30 +26,38 @@
|
||||
|
||||
module dsfml.graphics.renderwindow;
|
||||
|
||||
import dsfml.graphics.color;
|
||||
import dsfml.graphics.idrawable;
|
||||
import dsfml.graphics.image;
|
||||
import dsfml.graphics.rect;
|
||||
import dsfml.graphics.postfx;
|
||||
import dsfml.graphics.view;
|
||||
import dsfml.graphics.common,
|
||||
dsfml.graphics.color,
|
||||
dsfml.graphics.sprite,
|
||||
dsfml.graphics.shape,
|
||||
dsfml.graphics.text,
|
||||
dsfml.graphics.image,
|
||||
dsfml.graphics.rect,
|
||||
dsfml.graphics.shader,
|
||||
dsfml.graphics.view,
|
||||
dsfml.graphics.idrawable;
|
||||
|
||||
import dsfml.window.event;
|
||||
import dsfml.window.input;
|
||||
import dsfml.window.videomode;
|
||||
import dsfml.window.window;
|
||||
import dsfml.window.windowhandle;
|
||||
import dsfml.window.windowsettings;
|
||||
import dsfml.window.windowstyle;
|
||||
import dsfml.window.event,
|
||||
dsfml.window.input,
|
||||
dsfml.window.videomode,
|
||||
dsfml.window.window,
|
||||
dsfml.window.windowhandle;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.stringutil;
|
||||
import dsfml.system.vector2;
|
||||
import dsfml.system.common,
|
||||
dsfml.system.stringutil,
|
||||
dsfml.system.vector2;
|
||||
|
||||
/**
|
||||
* Simple wrapper for Window that allows easy 2D rendering.
|
||||
*/
|
||||
class RenderWindow : Window
|
||||
{
|
||||
private:
|
||||
View m_view = null;
|
||||
View m_defaultView = null;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Construct the window
|
||||
*
|
||||
@ -56,11 +65,11 @@ class RenderWindow : Window
|
||||
* 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, in char[] title, ulong windowStyle = Style.RESIZE | Style.CLOSE, WindowSettings settings = WindowSettings())
|
||||
this(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, settings));
|
||||
super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings));
|
||||
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
|
||||
}
|
||||
|
||||
@ -69,11 +78,11 @@ class RenderWindow : Window
|
||||
*
|
||||
* 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(sfRenderWindow_CreateFromHandle(handle, settings));
|
||||
super(sfRenderWindow_CreateFromHandle(handle, &settings));
|
||||
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
|
||||
}
|
||||
|
||||
@ -91,15 +100,15 @@ class RenderWindow : Window
|
||||
* 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, ulong windowStyle = Style.RESIZE | Style.CLOSE, WindowSettings settings = WindowSettings())
|
||||
void create(VideoMode mode, string title, uint windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
|
||||
{
|
||||
if (m_ptr !is null)
|
||||
dispose();
|
||||
|
||||
m_ptr = sfRenderWindow_Create(mode, toStringz(title), windowStyle, settings);
|
||||
m_ptr = sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings);
|
||||
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
|
||||
}
|
||||
|
||||
@ -110,50 +119,41 @@ class RenderWindow : Window
|
||||
*
|
||||
* 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();
|
||||
|
||||
m_ptr = sfRenderWindow_CreateFromHandle(handle, settings);
|
||||
m_ptr = sfRenderWindow_CreateFromHandle(handle, &settings);
|
||||
m_input = new Input(sfRenderWindow_GetInput(m_ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a PostFX on the window
|
||||
*
|
||||
* Params:
|
||||
* postFX = PostFX to draw
|
||||
*/
|
||||
void draw(PostFX postFX)
|
||||
{
|
||||
sfRenderWindow_DrawPostFX(m_ptr, postFX.getNativePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a Sprite or a String
|
||||
/**
|
||||
* Draw a sprite, shape or text on the window with a shader
|
||||
*
|
||||
* Params:
|
||||
* drawable = IDrawable to draw
|
||||
* shader = Shader to use
|
||||
*/
|
||||
void draw(IDrawable drawable, Shader shader)
|
||||
{
|
||||
drawable.renderWithShader(this, shader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a sprite, shape or text
|
||||
*
|
||||
* Params:
|
||||
* obj = IDrawable object to draw
|
||||
* drawable = IDrawable to draw
|
||||
*/
|
||||
void draw(IDrawable obj)
|
||||
void draw(IDrawable drawable)
|
||||
{
|
||||
obj.render(this);
|
||||
}
|
||||
/**
|
||||
* Save the content of the window to an image
|
||||
*
|
||||
* Returns:
|
||||
* Image instance containing the contents of the screen
|
||||
*/
|
||||
Image capture()
|
||||
{
|
||||
return new Image(sfRenderWindow_Capture(m_ptr));
|
||||
drawable.render(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the screen with the given color.
|
||||
*
|
||||
@ -234,73 +234,4 @@ class RenderWindow : Window
|
||||
sfRenderWindow_ConvertCoords(m_ptr, windowX, windowY, &vec.x, &vec.y, targetView is null ? null : targetView.getNativePointer);
|
||||
return vec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell SFML to preserve external OpenGL states, at the expense of
|
||||
* more CPU charge. Use this function if you don't want SFML
|
||||
* to mess up your own OpenGL states (if any).
|
||||
* Don't enable state preservation if not needed, as it will allow
|
||||
* SFML to do internal optimizations and improve performances.
|
||||
* This parameter is false by default
|
||||
*
|
||||
* Params:
|
||||
* preserve = True to preserve OpenGL states, false to let SFML optimize
|
||||
*
|
||||
*/
|
||||
void preserveOpenGLStates(bool preserve)
|
||||
{
|
||||
sfRenderWindow_PreserveOpenGLStates(m_ptr, preserve);
|
||||
}
|
||||
|
||||
private:
|
||||
View m_view = null;
|
||||
View m_defaultView = null;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function(VideoMode, char*, uint, WindowSettings) pf_sfRenderWindow_Create;
|
||||
typedef void* function(WindowHandle, WindowSettings) pf_sfRenderWindow_CreateFromHandle;
|
||||
typedef void function(void*) pf_sfRenderWindow_Destroy;
|
||||
typedef void* function(void*) pf_sfRenderWindow_GetInput;
|
||||
typedef void function(void*, void*) pf_sfRenderWindow_DrawPostFX;
|
||||
typedef void* function(void*) pf_sfRenderWindow_Capture;
|
||||
typedef void function(void*, Color) pf_sfRenderWindow_Clear;
|
||||
typedef void function(void*, void*) pf_sfRenderWindow_SetView;
|
||||
typedef void* function(void*) pf_sfRenderWindow_GetView;
|
||||
typedef void* function (void*) pf_sfRenderWindow_GetDefaultView;
|
||||
typedef void function(void*, uint, uint, float*, float*, void*) pf_sfRenderWindow_ConvertCoords;
|
||||
typedef void function(void*, int) pf_sfRenderWindow_PreserveOpenGLStates;
|
||||
|
||||
static pf_sfRenderWindow_Create sfRenderWindow_Create;
|
||||
static pf_sfRenderWindow_CreateFromHandle sfRenderWindow_CreateFromHandle;
|
||||
static pf_sfRenderWindow_Destroy sfRenderWindow_Destroy;
|
||||
static pf_sfRenderWindow_GetInput sfRenderWindow_GetInput;
|
||||
static pf_sfRenderWindow_DrawPostFX sfRenderWindow_DrawPostFX;
|
||||
static pf_sfRenderWindow_Capture sfRenderWindow_Capture;
|
||||
static pf_sfRenderWindow_Clear sfRenderWindow_Clear;
|
||||
static pf_sfRenderWindow_SetView sfRenderWindow_SetView;
|
||||
static pf_sfRenderWindow_GetView sfRenderWindow_GetView;
|
||||
static pf_sfRenderWindow_GetDefaultView sfRenderWindow_GetDefaultView;
|
||||
static pf_sfRenderWindow_ConvertCoords sfRenderWindow_ConvertCoords;
|
||||
static pf_sfRenderWindow_PreserveOpenGLStates sfRenderWindow_PreserveOpenGLStates;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfRenderWindow_Create = cast(pf_sfRenderWindow_Create)dll.getSymbol("sfRenderWindow_Create");
|
||||
sfRenderWindow_CreateFromHandle = cast(pf_sfRenderWindow_CreateFromHandle)dll.getSymbol("sfRenderWindow_CreateFromHandle");
|
||||
sfRenderWindow_Destroy = cast(pf_sfRenderWindow_Destroy)dll.getSymbol("sfRenderWindow_Destroy");
|
||||
sfRenderWindow_GetInput = cast(pf_sfRenderWindow_GetInput)dll.getSymbol("sfRenderWindow_GetInput");
|
||||
sfRenderWindow_DrawPostFX = cast(pf_sfRenderWindow_DrawPostFX)dll.getSymbol("sfRenderWindow_DrawPostFX");
|
||||
sfRenderWindow_Capture = cast(pf_sfRenderWindow_Capture)dll.getSymbol("sfRenderWindow_Capture");
|
||||
sfRenderWindow_Clear = cast(pf_sfRenderWindow_Clear)dll.getSymbol("sfRenderWindow_Clear");
|
||||
sfRenderWindow_SetView = cast(pf_sfRenderWindow_SetView)dll.getSymbol("sfRenderWindow_SetView");
|
||||
sfRenderWindow_GetView = cast(pf_sfRenderWindow_GetView)dll.getSymbol("sfRenderWindow_GetView");
|
||||
sfRenderWindow_GetDefaultView = cast(pf_sfRenderWindow_GetDefaultView)dll.getSymbol("sfRenderWindow_GetDefaultView");
|
||||
sfRenderWindow_ConvertCoords = cast(pf_sfRenderWindow_ConvertCoords)dll.getSymbol("sfRenderWindow_ConvertCoords");
|
||||
sfRenderWindow_PreserveOpenGLStates = cast(pf_sfRenderWindow_PreserveOpenGLStates)dll.getSymbol("sfRenderWindow_PreserveOpenGLStates");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
139
DSFML/import/dsfml/graphics/shader.d
Normal file
139
DSFML/import/dsfml/graphics/shader.d
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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.graphics.shader;
|
||||
|
||||
import dsfml.graphics.common;
|
||||
import dsfml.graphics.image;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.exception;
|
||||
import dsfml.system.stringutil;
|
||||
|
||||
|
||||
/**
|
||||
* Define loading methods for effect
|
||||
*/
|
||||
enum LoadingType
|
||||
{
|
||||
FROMFILE, /// string represents a file path
|
||||
FROMSTRING /// string represents effect code
|
||||
}
|
||||
|
||||
/**
|
||||
* Shader is used to apply a post effect to a window
|
||||
*
|
||||
* See_Also:
|
||||
* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax.
|
||||
*/
|
||||
class Shader : DSFMLObject
|
||||
{
|
||||
/**
|
||||
* construct the effect
|
||||
*
|
||||
* Params:
|
||||
* effect = Path of a file or string containing the effect.
|
||||
* type = type of the effect (default is FROMFILE)
|
||||
*/
|
||||
this(string effect, LoadingType type = LoadingType.FROMFILE)
|
||||
{
|
||||
if (effect is null || effect.length == 0)
|
||||
throw new LoadingException("LoadingException : Effect is invalid.");
|
||||
|
||||
if (type == LoadingType.FROMFILE)
|
||||
super(sfShader_CreateFromFile(toStringz(effect)));
|
||||
else
|
||||
super(sfShader_CreateFromMemory(toStringz(effect)));
|
||||
}
|
||||
|
||||
override void dispose()
|
||||
{
|
||||
sfShader_Destroy(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change parameters of the effect
|
||||
*
|
||||
* Params:
|
||||
* name = Parameter name in the effect
|
||||
*/
|
||||
void setParameter(string name, float x)
|
||||
{
|
||||
sfShader_SetParameter1(m_ptr, toStringz(name), x);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y)
|
||||
{
|
||||
sfShader_SetParameter2(m_ptr, toStringz(name), x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y, float z)
|
||||
{
|
||||
sfShader_SetParameter3(m_ptr, toStringz(name), x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void setParameter(string name, float x, float y, float z, float w)
|
||||
{
|
||||
sfShader_SetParameter4(m_ptr, toStringz(name), x, y, z, w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a texture parameter
|
||||
*
|
||||
* Params:
|
||||
* name = Texture name in the effect
|
||||
* texture = Image to set (pass NULL to use content of current framebuffer)
|
||||
*/
|
||||
void setTexture(string name, Image texture)
|
||||
{
|
||||
m_texture = texture;
|
||||
sfShader_SetTexture(m_ptr, toStringz(name), texture is null ? null : texture.getNativePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether or not the system supports shaders
|
||||
*
|
||||
* Returns:
|
||||
* True if the system can use shaders
|
||||
*/
|
||||
static bool isAvailable()
|
||||
{
|
||||
return cast(bool)sfShader_IsAvailable();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Image m_texture;
|
||||
}
|
@ -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
|
||||
@ -312,7 +313,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-graphics-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfShape_CreateLine = cast(pf_sfShape_CreateLine)dll.getSymbol("sfShape_CreateLine");
|
||||
sfShape_CreateRectangle = cast(pf_sfShape_CreateRectangle)dll.getSymbol("sfShape_CreateRectangle");
|
||||
|
@ -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
|
||||
@ -230,7 +231,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-graphics-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfSprite_SetImage = cast(pf_sfSprite_SetImage)dll.getSymbol("sfSprite_SetImage");
|
||||
sfSprite_SetSubRect = cast(pf_sfSprite_SetSubRect)dll.getSymbol("sfSprite_SetSubRect");
|
||||
|
@ -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,7 +24,7 @@
|
||||
* source distribution.
|
||||
*/
|
||||
|
||||
module dsfml.graphics.string;
|
||||
module dsfml.graphics.text;
|
||||
|
||||
import dsfml.graphics.blendmode;
|
||||
import dsfml.graphics.color;
|
||||
@ -37,23 +38,23 @@ import dsfml.system.vector2;
|
||||
|
||||
|
||||
/**
|
||||
* String defines a graphical 2D text, that can be drawn on screen
|
||||
* Text defines a graphical 2D text, that can be drawn on screen
|
||||
*
|
||||
* All string litterals used must be prefixed with c for utf-8
|
||||
* and d for utf-32 string.
|
||||
*
|
||||
* Examples :
|
||||
* ---------------------------------------------------------------
|
||||
* String s = new String("Hello"c);
|
||||
* //this(char[], Font, float)
|
||||
* s = new String("Hello"d);
|
||||
* //this(dchar[], Font, float)
|
||||
* Text s = new Text("Hello"c);
|
||||
* //this(string, Font, float)
|
||||
* s = new Text("Hello"d);
|
||||
* //this(dstring, Font, float)
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* See_Also:
|
||||
* IDrawable
|
||||
*/
|
||||
class String : Drawableimpl!(sfString)
|
||||
class Text : Drawableimpl!(sfText)
|
||||
{
|
||||
/**
|
||||
* Construct the string from a text
|
||||
@ -65,13 +66,13 @@ class String : Drawableimpl!(sfString)
|
||||
* font = Font used to draw the string (use default font)
|
||||
* size = Characters size, in pixels (32 by default)
|
||||
*/
|
||||
this(char[] text, Font font = Font.getDefaultFont(), float size = 30.f)
|
||||
this(string text, Font font = Font.getDefaultFont(), uint size = 30)
|
||||
{
|
||||
super();
|
||||
m_font = font;
|
||||
setFont(font);
|
||||
setText(text);
|
||||
setSize(size);
|
||||
setString(text);
|
||||
setCharacterSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,13 +85,13 @@ class String : Drawableimpl!(sfString)
|
||||
* font = Font used to draw the string (use default font)
|
||||
* size = Characters size, in pixels (32 by default)
|
||||
*/
|
||||
this(dchar[] text, Font font = Font.getDefaultFont(), float size = 30.f)
|
||||
this(dstring text, Font font = Font.getDefaultFont(), uint size = 30)
|
||||
{
|
||||
super();
|
||||
m_font = font;
|
||||
setFont(font);
|
||||
setText(text);
|
||||
setSize(size);
|
||||
setString(text);
|
||||
setCharacterSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,9 +101,9 @@ class String : Drawableimpl!(sfString)
|
||||
* text = New text
|
||||
*
|
||||
*/
|
||||
void setText(char[] text)
|
||||
void setString(string text)
|
||||
{
|
||||
sfString_SetText(m_ptr,toStringz(text));
|
||||
sfText_SetString(m_ptr,toStringz(text));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,9 +112,9 @@ class String : Drawableimpl!(sfString)
|
||||
* Params:
|
||||
* text = New text
|
||||
*/
|
||||
void setText(dchar[] text)
|
||||
void setString(dstring text)
|
||||
{
|
||||
sfString_SetUnicodeText(m_ptr, toStringz(text));
|
||||
sfText_SetUnicodeString(m_ptr, toStringz(text));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +126,7 @@ class String : Drawableimpl!(sfString)
|
||||
void setFont(Font font)
|
||||
{
|
||||
m_font = font;
|
||||
sfString_SetFont(m_ptr, font.getNativePointer);
|
||||
sfText_SetFont(m_ptr, font.getNativePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,9 +135,9 @@ class String : Drawableimpl!(sfString)
|
||||
* Params:
|
||||
* size = New size, in pixels
|
||||
*/
|
||||
void setSize(float size)
|
||||
void setCharacterSize(uint size)
|
||||
{
|
||||
sfString_SetSize(m_ptr, size);
|
||||
sfText_SetCharacterSize(m_ptr, size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +150,7 @@ class String : Drawableimpl!(sfString)
|
||||
*/
|
||||
void setStyle(TextStyle style)
|
||||
{
|
||||
sfString_SetStyle(m_ptr, style);
|
||||
sfText_SetStyle(m_ptr, style);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,9 +159,9 @@ class String : Drawableimpl!(sfString)
|
||||
* Returns:
|
||||
* Text
|
||||
*/
|
||||
dchar[] getUnicodeText()
|
||||
dstring getUnicodeText()
|
||||
{
|
||||
return fromStringz(sfString_GetUnicodeText(m_ptr));
|
||||
return fromStringz(sfText_GetUnicodeString(m_ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,9 +170,9 @@ class String : Drawableimpl!(sfString)
|
||||
* Returns:
|
||||
* Text
|
||||
*/
|
||||
char[] getText()
|
||||
string getText()
|
||||
{
|
||||
return fromStringz(sfString_GetText(m_ptr));
|
||||
return fromStringz(sfText_GetString(m_ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,9 +192,9 @@ class String : Drawableimpl!(sfString)
|
||||
* Returns:
|
||||
* Size of the characters
|
||||
*/
|
||||
float getSize()
|
||||
uint getCharacterSize()
|
||||
{
|
||||
return sfString_GetSize(m_ptr);
|
||||
return sfText_GetCharacterSize(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,7 +205,7 @@ class String : Drawableimpl!(sfString)
|
||||
*/
|
||||
TextStyle getStyle()
|
||||
{
|
||||
return sfString_GetStyle(m_ptr);
|
||||
return sfText_GetStyle(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +222,7 @@ class String : Drawableimpl!(sfString)
|
||||
Vector2f getCharacterPos(size_t index)
|
||||
{
|
||||
Vector2f ret;
|
||||
sfString_GetCharacterPos(m_ptr, index, &ret.x, &ret.y);
|
||||
sfText_GetCharacterPos(m_ptr, index, &ret.x, &ret.y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -233,7 +234,7 @@ class String : Drawableimpl!(sfString)
|
||||
*/
|
||||
FloatRect getRect()
|
||||
{
|
||||
sfFloatRect sfRect = sfString_GetRect(m_ptr);
|
||||
sfFloatRect sfRect = sfText_GetRect(m_ptr);
|
||||
|
||||
return new Rect!(float)(sfRect.Left, sfRect.Top, sfRect.Right, sfRect.Bottom);
|
||||
}
|
||||
@ -243,48 +244,51 @@ private:
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void function(void*, char*) pf_sfString_SetText;
|
||||
typedef void function(void*, dchar*) pf_sfString_SetUnicodeText;
|
||||
typedef void function(void*, void*) pf_sfString_SetFont;
|
||||
typedef void function(void*, float) pf_sfString_SetSize;
|
||||
typedef void function(void*, TextStyle) pf_sfString_SetStyle;
|
||||
typedef dchar* function(void*) pf_sfString_GetUnicodeText;
|
||||
typedef char* function(void*) pf_sfString_GetText;
|
||||
typedef void* function(void*) pf_sfString_GetFont;
|
||||
typedef float function(void*) pf_sfString_GetSize;
|
||||
typedef TextStyle function (void*) pf_sfString_GetStyle;
|
||||
typedef void function(void*, size_t, float*, float*) pf_sfString_GetCharacterPos;
|
||||
typedef sfFloatRect function(void*) pf_sfString_GetRect;
|
||||
typedef void function(void*, cchar*) pf_sfText_SetString;
|
||||
typedef void function(void*, cdchar*) pf_sfText_SetUnicodeString;
|
||||
typedef void function(void*, void*) pf_sfText_SetFont;
|
||||
typedef void function(void*, uint) pf_sfText_SetCharacterSize;
|
||||
typedef void function(void*, TextStyle) pf_sfText_SetStyle;
|
||||
typedef idchar* function(void*) pf_sfText_GetUnicodeString;
|
||||
typedef ichar* function(void*) pf_sfText_GetString;
|
||||
typedef void* function(void*) pf_sfText_GetFont;
|
||||
typedef uint function(void*) pf_sfText_GetCharacterSize;
|
||||
typedef TextStyle function (void*) pf_sfText_GetStyle;
|
||||
typedef void function(void*, size_t, float*, float*) pf_sfText_GetCharacterPos;
|
||||
typedef sfFloatRect function(void*) pf_sfText_GetRect;
|
||||
|
||||
static pf_sfString_SetText sfString_SetText;
|
||||
static pf_sfString_SetUnicodeText sfString_SetUnicodeText;
|
||||
static pf_sfString_SetFont sfString_SetFont;
|
||||
static pf_sfString_SetSize sfString_SetSize;
|
||||
static pf_sfString_SetStyle sfString_SetStyle;
|
||||
static pf_sfString_GetUnicodeText sfString_GetUnicodeText;
|
||||
static pf_sfString_GetText sfString_GetText;
|
||||
static pf_sfString_GetFont sfString_GetFont;
|
||||
static pf_sfString_GetSize sfString_GetSize;
|
||||
static pf_sfString_GetStyle sfString_GetStyle;
|
||||
static pf_sfString_GetCharacterPos sfString_GetCharacterPos;
|
||||
static pf_sfString_GetRect sfString_GetRect;
|
||||
static pf_sfText_SetString sfText_SetString;
|
||||
static pf_sfText_SetUnicodeString sfText_SetUnicodeString;
|
||||
static pf_sfText_SetFont sfText_SetFont;
|
||||
static pf_sfText_SetCharacterSize sfText_SetCharacterSize;
|
||||
static pf_sfText_SetStyle sfText_SetStyle;
|
||||
static pf_sfText_GetUnicodeString sfText_GetUnicodeString;
|
||||
static pf_sfText_GetString sfText_GetString;
|
||||
static pf_sfText_GetFont sfText_GetFont;
|
||||
static pf_sfText_GetCharacterSize sfText_GetCharacterSize;
|
||||
static pf_sfText_GetStyle sfText_GetStyle;
|
||||
static pf_sfText_GetCharacterPos sfText_GetCharacterPos;
|
||||
static pf_sfText_GetRect sfText_GetRect;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-graphics-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfString_SetText = cast(pf_sfString_SetText)dll.getSymbol("sfString_SetText");
|
||||
sfString_SetUnicodeText = cast(pf_sfString_SetUnicodeText)dll.getSymbol("sfString_SetUnicodeText");
|
||||
sfString_SetFont = cast(pf_sfString_SetFont)dll.getSymbol("sfString_SetFont");
|
||||
sfString_SetSize = cast(pf_sfString_SetSize)dll.getSymbol("sfString_SetSize");
|
||||
sfString_SetStyle = cast(pf_sfString_SetStyle)dll.getSymbol("sfString_SetStyle");
|
||||
sfString_GetUnicodeText = cast(pf_sfString_GetUnicodeText)dll.getSymbol("sfString_GetUnicodeText");
|
||||
sfString_GetText = cast(pf_sfString_GetText)dll.getSymbol("sfString_GetText");
|
||||
sfString_GetFont = cast(pf_sfString_GetFont)dll.getSymbol("sfString_GetFont");
|
||||
sfString_GetSize = cast(pf_sfString_GetSize)dll.getSymbol("sfString_GetSize");
|
||||
sfString_GetStyle = cast(pf_sfString_GetStyle)dll.getSymbol("sfString_GetStyle");
|
||||
sfString_GetCharacterPos = cast(pf_sfString_GetCharacterPos)dll.getSymbol("sfString_GetCharacterPos");
|
||||
sfString_GetRect = cast(pf_sfString_GetRect)dll.getSymbol("sfString_GetRect");
|
||||
sfText_SetString = cast(pf_sfText_SetString)dll.getSymbol("sfText_SetString");
|
||||
sfText_SetUnicodeString = cast(pf_sfText_SetUnicodeString)dll.getSymbol("sfText_SetUnicodeString");
|
||||
sfText_SetFont = cast(pf_sfText_SetFont)dll.getSymbol("sfText_SetFont");
|
||||
sfText_SetCharacterSize = cast(pf_sfText_SetCharacterSize)dll.getSymbol("sfText_SetCharacterSize");
|
||||
sfText_SetStyle = cast(pf_sfText_SetStyle)dll.getSymbol("sfText_SetStyle");
|
||||
sfText_GetUnicodeString = cast(pf_sfText_GetUnicodeString)dll.getSymbol("sfText_GetUnicodeString");
|
||||
sfText_GetString = cast(pf_sfText_GetString)dll.getSymbol("sfText_GetString");
|
||||
sfText_GetFont = cast(pf_sfText_GetFont)dll.getSymbol("sfText_GetFont");
|
||||
sfText_GetCharacterSize = cast(pf_sfText_GetCharacterSize)dll.getSymbol("sfText_GetCharacterSize");
|
||||
sfText_GetStyle = cast(pf_sfText_GetStyle)dll.getSymbol("sfText_GetStyle");
|
||||
sfText_GetCharacterPos = cast(pf_sfText_GetCharacterPos)dll.getSymbol("sfText_GetCharacterPos");
|
||||
sfText_GetRect = cast(pf_sfText_GetRect)dll.getSymbol("sfText_GetRect");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -25,10 +26,11 @@
|
||||
|
||||
module dsfml.graphics.view;
|
||||
|
||||
import dsfml.graphics.rect;
|
||||
import dsfml.graphics.common,
|
||||
dsfml.graphics.rect;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.vector2;
|
||||
import dsfml.system.common,
|
||||
dsfml.system.vector2;
|
||||
|
||||
/**
|
||||
* This class defines a view (position, size and zoom) ;
|
||||
@ -36,6 +38,11 @@ import dsfml.system.vector2;
|
||||
*/
|
||||
class View : DSFMLObject
|
||||
{
|
||||
private:
|
||||
FloatRect m_viewport;
|
||||
bool m_isModified = true;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -51,11 +58,11 @@ class View : DSFMLObject
|
||||
*
|
||||
* Params:
|
||||
* center = center of the view
|
||||
* halfsize = Half-size of the view (from center to corner)
|
||||
* size = size of the view (width, height)
|
||||
*/
|
||||
this(Vector2f center, Vector2f halfsize)
|
||||
this(Vector2f center, Vector2f size)
|
||||
{
|
||||
super(sfView_CreateFromRect(sfFloatRect(center.x - halfsize.x, center.y - halfsize.y, center.x + halfsize.x, center.y + halfsize.y) ));
|
||||
super(sfView_CreateFromRect(sfFloatRect(center.x - size.x / 2, center.y - size.y / 2, center.x + size.x / 2, center.y + size.y / 2) ));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,27 +107,27 @@ class View : DSFMLObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the half-size of the view (take 2 values)
|
||||
* Change the size of the view (take 2 values)
|
||||
*
|
||||
* Params:
|
||||
* halfWidth = New half-width
|
||||
* halfHeight = New half-height
|
||||
* width = New width
|
||||
* height = New height
|
||||
*/
|
||||
void setHalfSize(float halfWidth, float HalfHeight)
|
||||
void setSize(float width, float height)
|
||||
{
|
||||
sfView_SetHalfSize(m_ptr, halfWidth, HalfHeight);
|
||||
sfView_SetSize(m_ptr, width, height);
|
||||
m_isModified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the half-size of the view (take 2 values)
|
||||
* Change the size of the view (take 2 values)
|
||||
*
|
||||
* Params:
|
||||
* helfSize = New halfsize
|
||||
* size = New size
|
||||
*/
|
||||
void setHalfSize(Vector2f halfSize)
|
||||
void setSize(Vector2f size)
|
||||
{
|
||||
sfView_SetHalfSize(m_ptr, halfSize.x, halfSize.y);
|
||||
sfView_SetSize(m_ptr, size.x, size.y);
|
||||
m_isModified = true;
|
||||
}
|
||||
|
||||
@ -128,12 +135,12 @@ class View : DSFMLObject
|
||||
* Rebuild the view from a rectangle
|
||||
*
|
||||
* Params:
|
||||
* viewRect : Rectangle defining the position and size of the view
|
||||
* viewport : Rectangle defining the position and size of the view
|
||||
*/
|
||||
void setFromRect(FloatRect viewRect)
|
||||
void setViewport(FloatRect viewport)
|
||||
{
|
||||
sfView_SetFromRect(m_ptr, viewRect.toCFloatRect());
|
||||
m_rect = viewRect;
|
||||
sfView_SetViewport(m_ptr, viewport.toCFloatRect());
|
||||
m_viewport = viewport;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,28 +155,50 @@ class View : DSFMLObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the halfsize of the view
|
||||
* Get the size of the view
|
||||
*
|
||||
* Returns:
|
||||
* Halfsize of the view
|
||||
* Returns:
|
||||
* size of the view
|
||||
*/
|
||||
Vector2f GetHalfSize()
|
||||
Vector2f getSize()
|
||||
{
|
||||
return Vector2f(sfView_GetHalfSizeX(m_ptr), sfView_GetHalfSizeY(m_ptr));
|
||||
return Vector2f(sfView_GetWidth(m_ptr), sfView_GetHeight(m_ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the view
|
||||
*
|
||||
* Returns:
|
||||
* width of the view
|
||||
*/
|
||||
float getWidth()
|
||||
{
|
||||
return sfView_GetWidth(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the view
|
||||
*
|
||||
* Returns:
|
||||
* height of the view
|
||||
*/
|
||||
float getHeight()
|
||||
{
|
||||
return sfView_GetHeight(m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bounding retangle of the view
|
||||
*/
|
||||
FloatRect getRect()
|
||||
FloatRect getViewport()
|
||||
{
|
||||
if (m_isModified)
|
||||
{
|
||||
m_isModified = false;
|
||||
sfFloatRect cRect = sfView_GetRect(m_ptr);
|
||||
m_rect = new FloatRect(cRect.Left, cRect.Top, cRect.Right, cRect.Bottom);
|
||||
sfFloatRect cViewport = sfView_GetViewport(m_ptr);
|
||||
m_viewport = new FloatRect(cViewport.Left, cViewport.Top, cViewport.Right, cViewport.Bottom);
|
||||
}
|
||||
return m_rect;
|
||||
return m_viewport;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,66 +238,44 @@ class View : DSFMLObject
|
||||
m_isModified = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the view relatively to its current orientation.
|
||||
*
|
||||
* Params:
|
||||
* angle = Angle to rotate, in degree
|
||||
*/
|
||||
void rotate(float angle)
|
||||
{
|
||||
sfView_Rotate(m_ptr, angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the orientation of the view
|
||||
* The default rotation of a view is 0 degree
|
||||
*
|
||||
* Params:
|
||||
* angle = New angle, in degrees
|
||||
*/
|
||||
void setRotation(float angle)
|
||||
{
|
||||
sfView_SetRotation(m_ptr, angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current orientation of the view
|
||||
*
|
||||
* Returns:
|
||||
* Rotation angle of the view, in degrees
|
||||
*/
|
||||
float getRotation()
|
||||
{
|
||||
return sfView_GetRotation(m_ptr);
|
||||
}
|
||||
|
||||
package:
|
||||
|
||||
this(void* ptr, bool preventDelete)
|
||||
{
|
||||
super(ptr, preventDelete);
|
||||
}
|
||||
|
||||
private:
|
||||
FloatRect m_rect;
|
||||
bool m_isModified = true;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function() pf_sfView_Create;
|
||||
typedef void* function(sfFloatRect) pf_sfView_CreateFromRect;
|
||||
typedef void function(void*) pf_sfView_Destroy;
|
||||
typedef void function(void*, float, float) pf_sfView_SetCenter;
|
||||
typedef void function(void*, float, float) pf_sfView_SetHalfSize;
|
||||
typedef void function(void*, sfFloatRect ViewRect) pf_sfView_SetFromRect;
|
||||
typedef float function(void*) pf_sfView_GetCenterX;
|
||||
typedef float function(void*) pf_sfView_GetCenterY;
|
||||
typedef float function(void*) pf_sfView_GetHalfSizeX;
|
||||
typedef float function(void*) pf_sfView_GetHalfSizeY;
|
||||
typedef sfFloatRect function(void*) pf_sfView_GetRect;
|
||||
typedef void function(void*, float, float) pf_sfView_Move;
|
||||
typedef void function(void*, float) pf_sfView_Zoom;
|
||||
|
||||
static pf_sfView_Create sfView_Create;
|
||||
static pf_sfView_CreateFromRect sfView_CreateFromRect;
|
||||
static pf_sfView_Destroy sfView_Destroy;
|
||||
static pf_sfView_SetCenter sfView_SetCenter;
|
||||
static pf_sfView_SetHalfSize sfView_SetHalfSize;
|
||||
static pf_sfView_SetFromRect sfView_SetFromRect;
|
||||
static pf_sfView_GetCenterX sfView_GetCenterX;
|
||||
static pf_sfView_GetCenterY sfView_GetCenterY;
|
||||
static pf_sfView_GetHalfSizeX sfView_GetHalfSizeX;
|
||||
static pf_sfView_GetHalfSizeY sfView_GetHalfSizeY;
|
||||
static pf_sfView_GetRect sfView_GetRect;
|
||||
static pf_sfView_Move sfView_Move;
|
||||
static pf_sfView_Zoom sfView_Zoom;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfView_Create = cast(pf_sfView_Create) dll.getSymbol("sfView_Create");
|
||||
sfView_CreateFromRect = cast(pf_sfView_CreateFromRect) dll.getSymbol("sfView_CreateFromRect");
|
||||
sfView_Destroy = cast(pf_sfView_Destroy) dll.getSymbol("sfView_Destroy");
|
||||
sfView_SetCenter = cast(pf_sfView_SetCenter) dll.getSymbol("sfView_SetCenter");
|
||||
sfView_SetHalfSize = cast(pf_sfView_SetHalfSize) dll.getSymbol("sfView_SetHalfSize");
|
||||
sfView_SetFromRect = cast(pf_sfView_SetFromRect) dll.getSymbol("sfView_SetFromRect");
|
||||
sfView_GetCenterX = cast(pf_sfView_GetCenterX) dll.getSymbol("sfView_GetCenterX");
|
||||
sfView_GetCenterY = cast(pf_sfView_GetCenterY) dll.getSymbol("sfView_GetCenterY");
|
||||
sfView_GetHalfSizeX = cast(pf_sfView_GetHalfSizeX) dll.getSymbol("sfView_GetHalfSizeX");
|
||||
sfView_GetHalfSizeY = cast(pf_sfView_GetHalfSizeY) dll.getSymbol("sfView_GetHalfSizeY");
|
||||
sfView_GetRect = cast(pf_sfView_GetRect) dll.getSymbol("sfView_GetRect");
|
||||
sfView_Move = cast(pf_sfView_Move) dll.getSymbol("sfView_Move");
|
||||
sfView_Zoom = cast(pf_sfView_Zoom) dll.getSymbol("sfView_Zoom");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this(void* ptr, bool preventDelete)
|
||||
{
|
||||
super(ptr, preventDelete);
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -155,7 +156,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* The response message
|
||||
*/
|
||||
char[] getMessage()
|
||||
string getMessage()
|
||||
{
|
||||
return fromStringz(sfFtpResponse_GetMessage(m_ptr));
|
||||
}
|
||||
@ -206,7 +207,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Directory name
|
||||
*/
|
||||
char[] getDirectory()
|
||||
string getDirectory()
|
||||
{
|
||||
return fromStringz(sfFtpDirectoryResponse_GetDirectory(m_ptr));
|
||||
}
|
||||
@ -266,7 +267,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Filename
|
||||
*/
|
||||
char[] opIndex(size_t index)
|
||||
string opIndex(size_t index)
|
||||
{
|
||||
return fromStringz(sfFtpListingResponse_GetFilename(m_ptr, index));
|
||||
}
|
||||
@ -274,7 +275,7 @@ class Ftp : DSFMLObject
|
||||
/**
|
||||
* Foreach implementation
|
||||
*/
|
||||
int opApply(int delegate(char[]) dg)
|
||||
int opApply(int delegate(string) dg)
|
||||
{
|
||||
size_t count = getCount();
|
||||
int result;
|
||||
@ -366,7 +367,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse login(char[] username, char[] password)
|
||||
FtpResponse login(string username, string password)
|
||||
{
|
||||
return new FtpResponse(sfFtp_Login(m_ptr, toStringz(username), toStringz(password)));
|
||||
}
|
||||
@ -413,7 +414,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpListingResponse getDirectoryListing(char[] directory = null)
|
||||
FtpListingResponse getDirectoryListing(string directory = null)
|
||||
{
|
||||
return new FtpListingResponse(sfFtp_GetDirectoryListing(m_ptr, toStringz(directory)));
|
||||
}
|
||||
@ -427,7 +428,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse changeDirectory(char[] directory)
|
||||
FtpResponse changeDirectory(string directory)
|
||||
{
|
||||
return new FtpResponse(sfFtp_ChangeDirectory(m_ptr, toStringz(directory)));
|
||||
}
|
||||
@ -452,7 +453,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse makeDirectory(char[] name)
|
||||
FtpResponse makeDirectory(string name)
|
||||
{
|
||||
return new FtpResponse(sfFtp_MakeDirectory(m_ptr, toStringz(name)));
|
||||
}
|
||||
@ -466,7 +467,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse deleteDirectory(char[] name)
|
||||
FtpResponse deleteDirectory(string name)
|
||||
{
|
||||
return new FtpResponse(sfFtp_DeleteDirectory(m_ptr, toStringz(name)));
|
||||
}
|
||||
@ -481,7 +482,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse renameFile(char[] name, char[] newName)
|
||||
FtpResponse renameFile(string name, string newName)
|
||||
{
|
||||
return new FtpResponse(sfFtp_RenameFile(m_ptr, toStringz(name), toStringz(newName)));
|
||||
}
|
||||
@ -495,7 +496,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse deleteFile(char[] name)
|
||||
FtpResponse deleteFile(string name)
|
||||
{
|
||||
return new FtpResponse(sfFtp_DeleteFile(m_ptr, toStringz(name)));
|
||||
}
|
||||
@ -511,7 +512,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse download(char[] distantFile, char[] destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
|
||||
FtpResponse download(string distantFile, string destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
|
||||
{
|
||||
return new FtpResponse(sfFtp_Download(m_ptr, toStringz(distantFile), toStringz(destFile), mode));
|
||||
}
|
||||
@ -526,7 +527,7 @@ class Ftp : DSFMLObject
|
||||
* Returns:
|
||||
* Server response to the request
|
||||
*/
|
||||
FtpResponse upload(char[] localFile, char[] destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
|
||||
FtpResponse upload(string localFile, string destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
|
||||
{
|
||||
return new FtpResponse(sfFtp_Upload(m_ptr, toStringz(localFile), toStringz(destFile), mode));
|
||||
}
|
||||
@ -575,7 +576,10 @@ private:
|
||||
}
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
sfFtp_Create = cast(pf_sfFtp_Create)dll.getSymbol("sfFtp_Create");
|
||||
sfFtp_Destroy = cast(pf_sfFtp_Destroy)dll.getSymbol("sfFtp_Destroy");
|
||||
|
@ -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
|
||||
@ -99,7 +100,7 @@ class Http : DSFMLObject
|
||||
* Returns:
|
||||
* Value of the field, or enpty string if not found
|
||||
*/
|
||||
char[] getField(char[] field)
|
||||
string getField(string field)
|
||||
{
|
||||
return fromStringz(sfHttpResponse_GetField(m_ptr, toStringz(field)));
|
||||
}
|
||||
@ -147,7 +148,7 @@ class Http : DSFMLObject
|
||||
* Returns:
|
||||
* the response body
|
||||
*/
|
||||
char[] getBody()
|
||||
string getBody()
|
||||
{
|
||||
return fromStringz(sfHttpResponse_GetBody(m_ptr));
|
||||
}
|
||||
@ -203,7 +204,7 @@ class Http : DSFMLObject
|
||||
* uri = Target URI ("/" by default -- index page)
|
||||
* requestBody = Content of the request's body (empty by default)
|
||||
*/
|
||||
this(HttpMethod requestMethod = HttpMethod.GET, char[] uri = "/", char[] requestBody = "")
|
||||
this(HttpMethod requestMethod = HttpMethod.GET, string uri = "/", string requestBody = "")
|
||||
{
|
||||
super(sfHttpRequest_Create());
|
||||
sfHttpRequest_SetMethod(m_ptr, requestMethod);
|
||||
@ -218,7 +219,7 @@ class Http : DSFMLObject
|
||||
* field = name of the field to set (case-insensitive)
|
||||
* value = value of the field
|
||||
*/
|
||||
void setField(char[] field, char[] value)
|
||||
void setField(string field, string value)
|
||||
{
|
||||
sfHttpRequest_SetField(m_ptr, toStringz(field), toStringz(value));
|
||||
}
|
||||
@ -241,7 +242,7 @@ class Http : DSFMLObject
|
||||
* uri = URI to request, local to the host.
|
||||
* Returns:
|
||||
*/
|
||||
void setURI(char[] uri)
|
||||
void setURI(string uri)
|
||||
{
|
||||
sfHttpRequest_SetURI(m_ptr, toStringz(uri));
|
||||
}
|
||||
@ -265,7 +266,7 @@ class Http : DSFMLObject
|
||||
* Params:
|
||||
* requestBody = Content of the request body.
|
||||
*/
|
||||
void setBody(char[] requestBody)
|
||||
void setBody(string requestBody)
|
||||
{
|
||||
sfHttpRequest_SetBody(m_ptr, toStringz(requestBody));
|
||||
}
|
||||
@ -321,7 +322,7 @@ class Http : DSFMLObject
|
||||
* host = Web server to connect to
|
||||
* port = port to use for connection (0 by default -- use the standard port of the protocol)
|
||||
*/
|
||||
this(char[] host, ushort port = 0)
|
||||
this(string host, ushort port = 0)
|
||||
{
|
||||
super(sfHttp_Create());
|
||||
sfHttp_SetHost(m_ptr, toStringz(host), port);
|
||||
@ -339,7 +340,7 @@ class Http : DSFMLObject
|
||||
* host = Web server to connect to
|
||||
* port = port to use for connection (0 by default -- use the standard port of the protocol)
|
||||
*/
|
||||
void setHost(char[] host, ushort port = 0)
|
||||
void setHost(string host, ushort port = 0)
|
||||
{
|
||||
sfHttp_SetHost(m_ptr, toStringz(host), port);
|
||||
}
|
||||
@ -384,7 +385,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
sfHttp_Create = cast(pf_sfHttp_Create)dll.getSymbol("sfHttp_Create");
|
||||
sfHttp_Destroy = cast(pf_sfHttp_Destroy)dll.getSymbol("sfHttp_Destroy");
|
||||
|
@ -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
|
||||
@ -40,7 +41,7 @@ struct IPAddress
|
||||
* address = IP address ("xxx.xxx.xxx.xxx") or network name
|
||||
*
|
||||
*/
|
||||
static IPAddress opCall(char[] address)
|
||||
static IPAddress opCall(string address)
|
||||
{
|
||||
return sfIPAddress_FromString(toStringz(address));
|
||||
}
|
||||
@ -82,7 +83,7 @@ struct IPAddress
|
||||
*/
|
||||
bool isValid()
|
||||
{
|
||||
return cast(bool)sfIPAddress_IsValid(*this);
|
||||
return cast(bool)sfIPAddress_IsValid(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,7 +153,10 @@ extern (C)
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
sfIPAddress_FromBytes = cast(pf_sfIPAddress_FromBytes)dll.getSymbol("sfIPAddress_FromBytes");
|
||||
sfIPAddress_FromString = cast(pf_sfIPAddress_FromString)dll.getSymbol("sfIPAddress_FromString");
|
||||
|
@ -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
|
||||
@ -44,12 +45,12 @@ import dsfml.system.stringutil;
|
||||
* Packet p = new Packet();
|
||||
*
|
||||
* int i = 32, j = 42;
|
||||
* char[] k = hello;
|
||||
* string k = hello;
|
||||
*
|
||||
* p.set(i, k, j); //Set the data in the packet
|
||||
*
|
||||
* int a, b;
|
||||
* char[] c;
|
||||
* string c;
|
||||
* p.get(a, c, b); //Get data from the packet
|
||||
*
|
||||
* //...
|
||||
@ -113,13 +114,13 @@ class Packet : DSFMLObject
|
||||
* ----------
|
||||
* Packet p = new Packet();
|
||||
*
|
||||
* char[] str1 = "Hi";
|
||||
* char[] str2 = "Hello";
|
||||
* string str1 = "Hi";
|
||||
* string str2 = "Hello";
|
||||
*
|
||||
* p.set(str1, str2);
|
||||
*
|
||||
* // Retrieve str1 from packet
|
||||
* char[] str3;
|
||||
* string str3;
|
||||
* p.get(str3);
|
||||
*
|
||||
* // Returns an array containing str1 and str2.
|
||||
@ -169,7 +170,7 @@ class Packet : DSFMLObject
|
||||
|
||||
/**
|
||||
* Add new variables to the packet
|
||||
* Accept (u)byte, (u)short, (u)int, float, double, char[] and wchar[] types
|
||||
* Accept (u)byte, (u)short, (u)int, float, double, string and wstring types
|
||||
*/
|
||||
Packet set(T...)(T t)
|
||||
{
|
||||
@ -180,7 +181,7 @@ class Packet : DSFMLObject
|
||||
|
||||
/**
|
||||
* Retrieve data from the packet
|
||||
* Accept (u)byte, (u)short, (u)int, float, double, char[] and wchar[] types
|
||||
* Accept (u)byte, (u)short, (u)int, float, double, string and wstring types
|
||||
*/
|
||||
Packet get(T...)(ref T t)
|
||||
{
|
||||
@ -250,18 +251,18 @@ private:
|
||||
{
|
||||
data = sfPacket_ReadDouble(m_ptr);
|
||||
}
|
||||
void internalGet(ref char[] data)
|
||||
void internalGet(ref string data)
|
||||
{
|
||||
scope char[] temp = new char[sfPacket_GetDataSize(m_ptr)];
|
||||
scope string temp = new char[sfPacket_GetDataSize(m_ptr)];
|
||||
sfPacket_ReadString(m_ptr, temp.ptr);
|
||||
size_t l = fromStringz(temp.ptr).length;
|
||||
data = new char[l];
|
||||
data[] = temp[0 .. l];
|
||||
}
|
||||
|
||||
void internalGet(ref wchar[] data)
|
||||
void internalGet(ref wstring data)
|
||||
{
|
||||
scope wchar[] temp = new wchar[sfPacket_GetDataSize(m_ptr)];
|
||||
scope wstring temp = new wchar[sfPacket_GetDataSize(m_ptr)];
|
||||
sfPacket_ReadWideString(m_ptr, temp.ptr);
|
||||
size_t l = fromStringz(temp.ptr).length;
|
||||
data = new wchar[l];
|
||||
@ -304,12 +305,12 @@ private:
|
||||
{
|
||||
sfPacket_WriteDouble(m_ptr, data);
|
||||
}
|
||||
void internalSet(char[] data)
|
||||
void internalSet(string data)
|
||||
{
|
||||
sfPacket_WriteString(m_ptr, toStringz(data));
|
||||
}
|
||||
|
||||
void internalSet(wchar[] data)
|
||||
void internalSet(wstring data)
|
||||
{
|
||||
sfPacket_WriteWideString(m_ptr, toStringz(data));
|
||||
}
|
||||
@ -379,7 +380,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
sfPacket_Append = cast(pf_sfPacket_Append)dll.getSymbol("sfPacket_Append");
|
||||
sfPacket_CanRead = cast(pf_sfPacket_CanRead)dll.getSymbol("sfPacket_CanRead");
|
||||
|
@ -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
|
||||
@ -157,15 +158,18 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
static if (is (T : SocketTCP))
|
||||
{
|
||||
char[] symbol = "sfSelectorTCP";
|
||||
string symbol = "sfSelectorTCP";
|
||||
}
|
||||
else static if (is (T : SocketUDP))
|
||||
{
|
||||
char[] symbol = "sfSelectorUDP";
|
||||
string symbol = "sfSelectorUDP";
|
||||
}
|
||||
|
||||
sfSelector_Add = cast(pf_sfSelector_Add)dll.getSymbol(symbol ~ "_Add");
|
||||
|
@ -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
|
||||
@ -252,7 +253,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
sfSocketTCP_Accept = cast(pf_sfSocketTCP_Accept)dll.getSymbol("sfSocketTCP_Accept");
|
||||
sfSocketTCP_Connect = cast(pf_sfSocketTCP_Connect)dll.getSymbol("sfSocketTCP_Connect");
|
||||
|
@ -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
|
||||
@ -228,7 +229,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-network-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-network");
|
||||
|
||||
sfSocketUDP_Bind = cast(pf_sfSocketUDP_Bind)dll.getSymbol("sfSocketUDP_Bind");
|
||||
sfSocketUDP_Create = cast(pf_sfSocketUDP_Create)dll.getSymbol("sfSocketUDP_Create");
|
||||
|
@ -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
|
||||
@ -40,6 +41,6 @@ public import
|
||||
dsfml.system.mutex,
|
||||
dsfml.system.randomizer,
|
||||
dsfml.system.sleep,
|
||||
dsfml.system.thread,
|
||||
// dsfml.system.thread, // thread isn't used anywhere in the library and D threading is nice, so the user can safely use standard threads
|
||||
dsfml.system.vector2,
|
||||
dsfml.system.vector3;
|
||||
|
@ -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
|
||||
@ -31,9 +32,10 @@ version (Tango)
|
||||
}
|
||||
else
|
||||
{
|
||||
import std.c.stdlib;
|
||||
import std.gc;
|
||||
|
||||
public import core.memory;
|
||||
}
|
||||
|
||||
/*
|
||||
struct GC
|
||||
{
|
||||
static void* malloc(uint size)
|
||||
@ -56,7 +58,8 @@ else
|
||||
std.gc.removeRange(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* Template for native non-GCed allocation for interaction between C and D threads.
|
||||
|
@ -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
|
||||
@ -85,7 +86,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
sfClock_Create = cast(pf_sfClock_Create)dll.getSymbol("sfClock_Create");
|
||||
sfClock_Destroy = cast(pf_sfClock_Destroy)dll.getSymbol("sfClock_Destroy");
|
||||
|
@ -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
|
||||
@ -27,12 +28,38 @@ module dsfml.system.common;
|
||||
|
||||
public import dsfml.system.dllloader;
|
||||
|
||||
// type aliases for D2
|
||||
package
|
||||
{
|
||||
alias const(char) cchar;
|
||||
alias const(wchar) cwchar;
|
||||
alias const(dchar) cdchar;
|
||||
alias immutable(char) ichar;
|
||||
alias immutable(wchar) iwchar;
|
||||
alias immutable(dchar) idchar;
|
||||
alias const(char)[] cstring;
|
||||
}
|
||||
|
||||
// used to mixin code function
|
||||
string loadFromSharedLib(string fname)
|
||||
{
|
||||
return fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");";
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for all DSFML classes.
|
||||
*/
|
||||
class DSFMLObject
|
||||
{
|
||||
this(void* ptr, bool preventDelete = false)
|
||||
private:
|
||||
bool m_preventDelete;
|
||||
|
||||
protected:
|
||||
void* m_ptr;
|
||||
|
||||
public:
|
||||
|
||||
this(void* ptr, bool preventDelete = false)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
}
|
||||
@ -61,10 +88,4 @@ class DSFMLObject
|
||||
{
|
||||
assert(m_ptr !is null, "Problem occurs with a null pointer in " ~ this.toString);
|
||||
}
|
||||
|
||||
protected:
|
||||
void* m_ptr;
|
||||
|
||||
private:
|
||||
bool m_preventDelete;
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -59,16 +60,16 @@ static this()
|
||||
}
|
||||
}
|
||||
|
||||
private void report(char[] msg, char[] lib, char[] symb)
|
||||
private void report(string msg, string lib, string symb)
|
||||
{
|
||||
char[] str = "Loading error. Reason : " ~ msg ~ " (library : " ~ lib ~ ", symbol : " ~ symb ~ ")";
|
||||
string str = "Loading error. Reason : " ~ msg ~ " (library : " ~ lib ~ ", symbol : " ~ symb ~ ")";
|
||||
version (Tango)
|
||||
{
|
||||
Cerr(str).newline;
|
||||
}
|
||||
else
|
||||
{
|
||||
fwritefln(stderr, str);
|
||||
stderr.writeln(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,15 +79,15 @@ private void report(char[] msg, char[] lib, char[] symb)
|
||||
*/
|
||||
class DllLoader
|
||||
{
|
||||
static DllLoader load(char[] library)
|
||||
static DllLoader load(string library)
|
||||
{
|
||||
version (Windows)
|
||||
{
|
||||
char[] libraryName = library ~ ".dll";
|
||||
string libraryName = library ~ ".dll";
|
||||
}
|
||||
version (linux)
|
||||
{
|
||||
char[] libraryName = "lib" ~ library ~ ".so";
|
||||
string libraryName = "lib" ~ library ~ ".so";
|
||||
}
|
||||
|
||||
if (libraryName in alreadyLoaded)
|
||||
@ -106,7 +107,7 @@ class DllLoader
|
||||
close();
|
||||
}
|
||||
|
||||
void* getSymbol(char[] symbolName)
|
||||
void* getSymbol(string symbolName)
|
||||
{
|
||||
void* symb;
|
||||
version (Tango)
|
||||
@ -152,7 +153,7 @@ class DllLoader
|
||||
}
|
||||
|
||||
private:
|
||||
this(char[] libraryPath)
|
||||
this(string libraryPath)
|
||||
{
|
||||
m_libPath = libraryPath;
|
||||
|
||||
@ -184,6 +185,6 @@ private:
|
||||
MODULEHANDLE m_lib;
|
||||
}
|
||||
|
||||
static DllLoader[char[]] alreadyLoaded;
|
||||
char[] m_libPath;
|
||||
static DllLoader[string] alreadyLoaded;
|
||||
string m_libPath;
|
||||
}
|
||||
|
@ -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
|
||||
@ -27,7 +28,7 @@ module dsfml.system.exception;
|
||||
|
||||
class LoadingException : Exception
|
||||
{
|
||||
this(char[] msg)
|
||||
this(string msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
@ -35,7 +36,7 @@ class LoadingException : Exception
|
||||
|
||||
class NullParameterException : Exception
|
||||
{
|
||||
this(char[] msg)
|
||||
this(string msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -84,7 +85,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
sfMutex_Create = cast(pf_sfMutex_Create)dll.getSymbol("sfMutex_Create");
|
||||
sfMutex_Destroy = cast(pf_sfMutex_Destroy)dll.getSymbol("sfMutex_Destroy");
|
||||
|
@ -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
|
||||
@ -119,7 +120,10 @@ private:
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
sfRandom_SetSeed = cast(pf_sfRandom_SetSeed)dll.getSymbol("sfRandom_SetSeed");
|
||||
sfRandom_GetSeed = cast(pf_sfRandom_GetSeed)dll.getSymbol("sfRandom_GetSeed");
|
||||
|
@ -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
|
||||
@ -36,7 +37,11 @@ extern(C)
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
|
||||
sfSleep = cast(pf_sfSleep)dll.getSymbol("sfSleep");
|
||||
}
|
||||
|
@ -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
|
||||
@ -25,12 +26,20 @@
|
||||
|
||||
module dsfml.system.stringutil;
|
||||
|
||||
// version (Tango)
|
||||
// {
|
||||
// public import tango.stdc.stringz;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
import std.traits; // for Unqual
|
||||
|
||||
/*
|
||||
version (Tango)
|
||||
{
|
||||
public import tango.stdc.stringz;
|
||||
}
|
||||
else
|
||||
{
|
||||
public import std.string;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
T* toStringz(T)(T[] str)
|
||||
{
|
||||
if (str is null)
|
||||
@ -38,14 +47,15 @@ module dsfml.system.stringutil;
|
||||
else if (str.length && str[$ - 1] is T.init)
|
||||
return str.ptr;
|
||||
|
||||
T[] ret = new T[str.length + 1];
|
||||
auto ret = new Unqual!(T)[str.length + 1];
|
||||
|
||||
ret[0 .. str.length] = str[0 .. $];
|
||||
ret[str.length] = 0;
|
||||
|
||||
return ret.ptr;
|
||||
return cast(T*) ret.ptr;
|
||||
}
|
||||
|
||||
|
||||
size_t stringLength(T)(T* p)
|
||||
{
|
||||
if (p is null || *p == T.init)
|
||||
@ -63,107 +73,10 @@ module dsfml.system.stringutil;
|
||||
|
||||
T[] fromStringz(T)(T* ptr)
|
||||
{
|
||||
T[] ret = new T[stringLength(ptr)];
|
||||
auto ret = new Unqual!(T)[stringLength(ptr)];
|
||||
ret[0..$] = ptr[0..ret.length];
|
||||
|
||||
return ret;
|
||||
return cast(T[]) ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /*
|
||||
// * Tango equivalent functions
|
||||
// *
|
||||
// * Author : Keinfarbton
|
||||
// * Licence : BSD style
|
||||
// */
|
||||
// char* toStringz(char[] s)
|
||||
// {
|
||||
// if (s.ptr)
|
||||
// if (!(s.length && s[$-1] is 0))
|
||||
// s = s ~ '\0';
|
||||
// return s.ptr;
|
||||
// }
|
||||
//
|
||||
// char[] fromStringz (char* s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// if (s)
|
||||
// while (*(s+i))
|
||||
// ++i;
|
||||
//
|
||||
// return s ? s[0 .. i] : null;
|
||||
// }
|
||||
//
|
||||
// wchar* toString16z(wchar[] s)
|
||||
// {
|
||||
// if (s.ptr)
|
||||
// if (!(s.length && s[$-1] is 0))
|
||||
// s = s ~ '\0';
|
||||
// return s.ptr;
|
||||
// }
|
||||
//
|
||||
// wchar[] fromString16z (wchar* s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// if (s)
|
||||
// while (*(s+i))
|
||||
// ++i;
|
||||
//
|
||||
// return s ? s[0 .. i] : null;
|
||||
// }
|
||||
//
|
||||
// dchar* toString32z (dchar[] s)
|
||||
// {
|
||||
// if (s.ptr)
|
||||
// if (!(s.length && s[$-1] is 0))
|
||||
// s = s ~ "\0"d;
|
||||
// return s.ptr;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// dchar[] fromString32z (dchar* s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// if (s)
|
||||
// while (*(s+i))
|
||||
// ++i;
|
||||
//
|
||||
// return s ? s[0 .. i] : null;
|
||||
// }
|
||||
// }
|
||||
version (UnitTest)
|
||||
{
|
||||
void main()
|
||||
{
|
||||
|
||||
}
|
||||
unittest
|
||||
{
|
||||
char[] str = "Test";
|
||||
char[] espaceStr = "string with espace";
|
||||
|
||||
dchar[] strW = "Test"d;
|
||||
dchar[] espaceStrW = "string with espace"d;
|
||||
|
||||
char[] empty = "";
|
||||
dchar[] emptyW = ""d;
|
||||
|
||||
char[] nullStr = null;
|
||||
dchar[] nullStrW = null;
|
||||
|
||||
assert(fromStringz(toStringz(str)) == str);
|
||||
assert(fromStringz(toStringz(espaceStr)) == espaceStr);
|
||||
assert(fromStringz(toStringz(strW)) == strW);
|
||||
assert(fromStringz(toStringz(espaceStrW)) == espaceStrW);
|
||||
|
||||
assert(fromStringz(toStringz(empty)) == empty);
|
||||
assert(fromStringz(toStringz(emptyW)) == emptyW);
|
||||
|
||||
assert(fromStringz(toStringz(nullStr)) == nullStr);
|
||||
assert(fromStringz(toStringz(nullStrW)) == nullStrW);
|
||||
}
|
||||
}
|
||||
|
@ -1,216 +0,0 @@
|
||||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@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.
|
||||
*/
|
||||
|
||||
module dsfml.system.thread;
|
||||
|
||||
version(Tango)
|
||||
{
|
||||
static import tango.core.Thread;
|
||||
alias tango.core.Thread.Thread DThread;
|
||||
}
|
||||
else
|
||||
{
|
||||
static import std.thread;
|
||||
alias std.thread.Thread DThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread defines a simple thread abstraction.
|
||||
*
|
||||
* Examples:
|
||||
* Can be a base class (you need to override void run(void) method) :
|
||||
* --------------------
|
||||
* class MyThread : Thread
|
||||
* {
|
||||
* void function()
|
||||
* {
|
||||
* this.launch();
|
||||
* }
|
||||
*
|
||||
* //Thread entry point
|
||||
* protected void run()
|
||||
* {
|
||||
* }
|
||||
* }
|
||||
* --------------------
|
||||
*
|
||||
* or
|
||||
*
|
||||
* --------------------
|
||||
* void main()
|
||||
* {
|
||||
* Thread t = new Thread(&threadStart);
|
||||
* t.launch();
|
||||
* t.wait(); //Wait the end of t thread
|
||||
* }
|
||||
*
|
||||
* //Thread entry point
|
||||
* void threadStart (void* userData)
|
||||
* {
|
||||
*
|
||||
* }
|
||||
* --------------------
|
||||
*
|
||||
* or
|
||||
*
|
||||
* --------------------
|
||||
* void main()
|
||||
* {
|
||||
* MyObject foo = new MyObject();
|
||||
* Thread t = new Thread(&foo.bar);
|
||||
* t.launch();
|
||||
* t.wait(); //Wait the end of t thread
|
||||
* }
|
||||
*
|
||||
* class MyObject
|
||||
* {
|
||||
* void bar(void* user)
|
||||
* {
|
||||
* //...
|
||||
* }
|
||||
* }
|
||||
* --------------------
|
||||
*/
|
||||
class Thread
|
||||
{
|
||||
/**
|
||||
* Construct the thread from a function pointer.
|
||||
*
|
||||
* Params:
|
||||
* func = Entry point of the thread
|
||||
* userData = Data to pass to the thread function (NULL by default)
|
||||
*
|
||||
*/
|
||||
this(void function(void*) func, void* userData = null)
|
||||
{
|
||||
m_t = new DThread(&threadStart);
|
||||
|
||||
m_func = func;
|
||||
m_userData = userData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the thread from a delegate.
|
||||
*
|
||||
* Params:
|
||||
* dg = Entry point of the thread
|
||||
* userData = Data to pass to the thread function (NULL by default)
|
||||
*
|
||||
*/
|
||||
this(void delegate(void*) dg, void* userData = null)
|
||||
{
|
||||
m_t = new DThread(&threadStart);
|
||||
|
||||
m_dg = dg;
|
||||
m_userData = userData;
|
||||
|
||||
m_isDelegate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the thread
|
||||
*/
|
||||
final void launch()
|
||||
{
|
||||
if (!m_running)
|
||||
{
|
||||
m_t.start();
|
||||
m_running = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the thread finishes
|
||||
*/
|
||||
final void wait()
|
||||
{
|
||||
if(m_running)
|
||||
{
|
||||
version (Tango)
|
||||
{
|
||||
m_t.join();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_t.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Protected constructor
|
||||
*/
|
||||
this()
|
||||
{
|
||||
m_t = new DThread(&threadStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method in class derived from Thread.
|
||||
*/
|
||||
void run()
|
||||
{
|
||||
if (m_isDelegate)
|
||||
this.m_dg(this.m_userData);
|
||||
else
|
||||
this.m_func(this.m_userData);
|
||||
}
|
||||
|
||||
private:
|
||||
DThread m_t;
|
||||
bool m_isDelegate;
|
||||
bool m_running;
|
||||
|
||||
union
|
||||
{
|
||||
void function(void*) m_func;
|
||||
void delegate(void*) m_dg;
|
||||
}
|
||||
|
||||
void* m_userData;
|
||||
|
||||
/*
|
||||
* Thread entry point
|
||||
*/
|
||||
version (Tango)
|
||||
{
|
||||
final void threadStart()
|
||||
{
|
||||
run();
|
||||
m_running = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final int threadStart()
|
||||
{
|
||||
run();
|
||||
m_running = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -56,7 +57,7 @@ struct Vector2(T)
|
||||
{
|
||||
x += other.x;
|
||||
y += other.y;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (-=) overload
|
||||
@ -64,7 +65,7 @@ struct Vector2(T)
|
||||
{
|
||||
x -= other.x;
|
||||
y -= other.y;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (+) overload
|
||||
@ -90,7 +91,7 @@ struct Vector2(T)
|
||||
{
|
||||
x *= i;
|
||||
y *= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (/) overload
|
||||
@ -104,11 +105,11 @@ struct Vector2(T)
|
||||
{
|
||||
x /= i;
|
||||
y /= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
///
|
||||
int opEquals(Vector2 other)
|
||||
const bool opEquals(ref const(Vector2) other)
|
||||
{
|
||||
return (x == other.x) && (y == other.y);
|
||||
}
|
||||
|
@ -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
|
||||
@ -59,7 +60,7 @@ struct Vector3(T)
|
||||
x += other.x;
|
||||
y += other.y;
|
||||
z += other.z;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (-=) overload
|
||||
@ -68,7 +69,7 @@ struct Vector3(T)
|
||||
x -= other.x;
|
||||
y -= other.y;
|
||||
z -= other.z;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (+) overload
|
||||
@ -95,7 +96,7 @@ struct Vector3(T)
|
||||
x *= i;
|
||||
y *= i;
|
||||
z *= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (/) overload
|
||||
@ -110,11 +111,11 @@ struct Vector3(T)
|
||||
x /= i;
|
||||
y /= i;
|
||||
z /= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
///
|
||||
int opEquals(Vector3 other)
|
||||
const bool opEquals(ref const(Vector3) other)
|
||||
{
|
||||
return (x == other.x) && (y == other.y) && (z == other.z) ;
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user