* D-ified property functions and used SFMLClass in:

- Window
 - RenderTargets
 - Image
 - Drawable
* fixed Image.copy -> copyImage

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1461 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
trass3r 2010-03-16 02:04:52 +00:00
parent 337448d3cb
commit dcdf39bf74
6 changed files with 844 additions and 897 deletions

View File

@ -42,7 +42,7 @@ import dsfml.graphics.idrawable,
* Package base class of all drawable. * Package base class of all drawable.
* Provide implementation of IDrawable and functions aliases. * Provide implementation of IDrawable and functions aliases.
*/ */
package class DrawableImpl(alias derivedClassName) : DSFMLObject, IDrawable package class DrawableImpl(string derivedClassName) : DSFMLObject, IDrawable
{ {
protected: protected:
this() this()
@ -50,7 +50,7 @@ protected:
super(sfDrawable_Create()); super(sfDrawable_Create());
} }
this(void* ptr) this(SFMLClass ptr)
{ {
super(ptr, true); super(ptr, true);
} }
@ -210,73 +210,51 @@ public:
private: private:
extern (C) static extern(C)
{ {
typedef void* function() pf_sfDrawable_Create; SFMLClass function() sfDrawable_Create;
typedef void function(void*) pf_sfDrawable_Destroy; void function(SFMLClass) sfDrawable_Destroy;
typedef void function(void*, float) pf_sfDrawable_SetX; void function(SFMLClass, float) sfDrawable_SetX;
typedef void function(void*, float) pf_sfDrawable_SetY; void function(SFMLClass, float) sfDrawable_SetY;
typedef void function(void*, float, float) pf_sfDrawable_SetPosition; void function(SFMLClass, float, float) sfDrawable_SetPosition;
typedef void function(void*, float) pf_sfDrawable_SetScaleX; void function(SFMLClass, float) sfDrawable_SetScaleX;
typedef void function(void*, float) pf_sfDrawable_SetScaleY; void function(SFMLClass, float) sfDrawable_SetScaleY;
typedef void function(void*, float, float) pf_sfDrawable_SetScale; void function(SFMLClass, float, float) sfDrawable_SetScale;
typedef void function(void*, float) pf_sfDrawable_SetRotation; void function(SFMLClass, float) sfDrawable_SetRotation;
typedef void function(void*, float, float) pf_sfDrawable_SetOrigin; void function(SFMLClass, float, float) sfDrawable_SetOrigin;
typedef void function(void*, Color) pf_sfDrawable_SetColor; void function(SFMLClass, Color) sfDrawable_SetColor;
typedef void function(void*, BlendMode) pf_sfDrawable_SetBlendMode; void function(SFMLClass, BlendMode) sfDrawable_SetBlendMode;
typedef float function(void*) pf_sfDrawable_GetX; float function(SFMLClass) sfDrawable_GetX;
typedef float function(void*) pf_sfDrawable_GetY; float function(SFMLClass) sfDrawable_GetY;
typedef float function(void*) pf_sfDrawable_GetScaleX; float function(SFMLClass) sfDrawable_GetScaleX;
typedef float function(void*) pf_sfDrawable_GetScaleY; float function(SFMLClass) sfDrawable_GetScaleY;
typedef float function(void*) pf_sfDrawable_GetRotation; float function(SFMLClass) sfDrawable_GetRotation;
typedef float function(void*) pf_sfDrawable_GetOriginX; float function(SFMLClass) sfDrawable_GetOriginX;
typedef float function(void*) pf_sfDrawable_GetOriginY; float function(SFMLClass) sfDrawable_GetOriginY;
typedef Color function(void*) pf_sfDrawable_GetColor; Color function(SFMLClass) sfDrawable_GetColor;
typedef BlendMode function(void*) pf_sfDrawable_GetBlendMode; BlendMode function(SFMLClass) sfDrawable_GetBlendMode;
typedef void function(void*, float, float) pf_sfDrawable_Move; void function(SFMLClass, float, float) sfDrawable_Move;
typedef void function(void*, float, float) pf_sfDrawable_Scale; void function(SFMLClass, float, float) sfDrawable_Scale;
typedef void function(void*, float) pf_sfDrawable_Rotate; void function(SFMLClass, float) sfDrawable_Rotate;
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToLocal; void function(SFMLClass, float, float, float*, float*) sfDrawable_TransformToLocal;
typedef void function(void*, float, float, float*, float*) pf_sfDrawable_TransformToGlobal; void function(SFMLClass, float, float, float*, float*) sfDrawable_TransformToGlobal;
typedef void function(void*, void*) pf_sfRenderWindow_DrawThis; typedef void function(SFMLClass, SFMLClass) pf_sfRenderWindow_DrawThis;
typedef void function(void*, void*, void*) pf_sfRenderWindow_DrawThisWithShader; typedef void function(SFMLClass, SFMLClass, SFMLClass) pf_sfRenderWindow_DrawThisWithShader;
typedef void function(void*, void*) pf_sfRenderImage_DrawThis; typedef void function(SFMLClass, SFMLClass) pf_sfRenderImage_DrawThis;
typedef void function(void*, void*, void*) pf_sfRenderImage_DrawThisWithShader; typedef void function(SFMLClass, SFMLClass, SFMLClass) pf_sfRenderImage_DrawThisWithShader;
static pf_sfDrawable_Create sfDrawable_Create; pf_sfRenderWindow_DrawThis sfRenderWindow_DrawThis;
static pf_sfDrawable_Destroy sfDrawable_Destroy; pf_sfRenderWindow_DrawThisWithShader sfRenderWindow_DrawThisWithShader;
static pf_sfDrawable_SetX sfDrawable_SetX; pf_sfRenderImage_DrawThis sfRenderImage_DrawThis;
static pf_sfDrawable_SetY sfDrawable_SetY; pf_sfRenderImage_DrawThisWithShader sfRenderImage_DrawThisWithShader;
static pf_sfDrawable_SetPosition sfDrawable_SetPosition;
static pf_sfDrawable_SetScaleX sfDrawable_SetScaleX;
static pf_sfDrawable_SetScaleY sfDrawable_SetScaleY;
static pf_sfDrawable_SetScale sfDrawable_SetScale;
static pf_sfDrawable_SetRotation sfDrawable_SetRotation;
static pf_sfDrawable_SetOrigin sfDrawable_SetOrigin;
static pf_sfDrawable_SetColor sfDrawable_SetColor;
static pf_sfDrawable_SetBlendMode sfDrawable_SetBlendMode;
static pf_sfDrawable_GetX sfDrawable_GetX;
static pf_sfDrawable_GetY sfDrawable_GetY;
static pf_sfDrawable_GetScaleX sfDrawable_GetScaleX;
static pf_sfDrawable_GetScaleY sfDrawable_GetScaleY;
static pf_sfDrawable_GetRotation sfDrawable_GetRotation;
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;
static pf_sfDrawable_Scale sfDrawable_Scale;
static pf_sfDrawable_Rotate sfDrawable_Rotate;
static pf_sfDrawable_TransformToLocal sfDrawable_TransformToLocal;
static pf_sfDrawable_TransformToGlobal sfDrawable_TransformToGlobal;
static pf_sfRenderWindow_DrawThis sfRenderWindow_DrawThis;
static pf_sfRenderWindow_DrawThisWithShader sfRenderWindow_DrawThisWithShader;
static pf_sfRenderImage_DrawThis sfRenderImage_DrawThis;
static pf_sfRenderImage_DrawThisWithShader sfRenderImage_DrawThisWithShader;
} }
mixin(loadDerivedFromSharedLib("csfml-graphics", "sfDrawable", derivedClassName,
"Create", "Destroy", "SetX", "SetY", "SetPosition", "SetScaleX", "SetScaleY", "SetScale", "SetRotation", "SetOrigin", "SetColor", "SetBlendMode",
"GetX", "GetY", "GetScaleX", "GetScaleY", "GetRotation", "GetOriginX", "GetOriginY", "GetColor", "GetBlendMode", "Move",
"Scale", "Rotate", "TransformToLocal", "TransformToGlobal"));
static this() static this()
{ {
debug debug
@ -284,33 +262,6 @@ private:
else else
DllLoader dll = DllLoader.load("csfml-graphics"); DllLoader dll = DllLoader.load("csfml-graphics");
sfDrawable_Create = cast(pf_sfDrawable_Create)dll.getSymbol(derivedClassName ~ "_Create");
sfDrawable_Destroy = cast(pf_sfDrawable_Destroy)dll.getSymbol(derivedClassName ~ "_Destroy");
sfDrawable_SetX = cast(pf_sfDrawable_SetX)dll.getSymbol(derivedClassName ~ "_SetX");
sfDrawable_SetY = cast(pf_sfDrawable_SetY)dll.getSymbol(derivedClassName ~ "_SetY");
sfDrawable_SetPosition = cast(pf_sfDrawable_SetPosition)dll.getSymbol(derivedClassName ~ "_SetPosition");
sfDrawable_SetScaleX = cast(pf_sfDrawable_SetScaleX)dll.getSymbol(derivedClassName ~ "_SetScaleX");
sfDrawable_SetScaleY = cast(pf_sfDrawable_SetScaleY)dll.getSymbol(derivedClassName ~ "_SetScaleY");
sfDrawable_SetScale = cast(pf_sfDrawable_SetScale)dll.getSymbol(derivedClassName ~ "_SetScale");
sfDrawable_SetRotation = cast(pf_sfDrawable_SetRotation)dll.getSymbol(derivedClassName ~ "_SetRotation");
sfDrawable_SetOrigin = cast(pf_sfDrawable_SetOrigin)dll.getSymbol(derivedClassName ~ "_SetOrigin");
sfDrawable_SetColor = cast(pf_sfDrawable_SetColor)dll.getSymbol(derivedClassName ~ "_SetColor");
sfDrawable_SetBlendMode = cast(pf_sfDrawable_SetBlendMode)dll.getSymbol(derivedClassName ~ "_SetBlendMode");
sfDrawable_GetX = cast(pf_sfDrawable_GetX)dll.getSymbol(derivedClassName ~ "_GetX");
sfDrawable_GetY = cast(pf_sfDrawable_GetY)dll.getSymbol(derivedClassName ~ "_GetY");
sfDrawable_GetScaleX = cast(pf_sfDrawable_GetScaleX)dll.getSymbol(derivedClassName ~ "_GetScaleX");
sfDrawable_GetScaleY = cast(pf_sfDrawable_GetScaleY)dll.getSymbol(derivedClassName ~ "_GetScaleX");
sfDrawable_GetRotation = cast(pf_sfDrawable_GetRotation)dll.getSymbol(derivedClassName ~ "_GetRotation");
sfDrawable_GetOriginX = cast(pf_sfDrawable_GetOriginX)dll.getSymbol(derivedClassName ~ "_GetOriginX");
sfDrawable_GetOriginY = cast(pf_sfDrawable_GetOriginY)dll.getSymbol(derivedClassName ~ "_GetOriginY");
sfDrawable_GetColor = cast(pf_sfDrawable_GetColor)dll.getSymbol(derivedClassName ~ "_GetColor");
sfDrawable_GetBlendMode = cast(pf_sfDrawable_GetBlendMode)dll.getSymbol(derivedClassName ~ "_GetBlendMode");
sfDrawable_Move = cast(pf_sfDrawable_Move)dll.getSymbol(derivedClassName ~ "_Move");
sfDrawable_Scale = cast(pf_sfDrawable_Scale)dll.getSymbol(derivedClassName ~ "_Scale");
sfDrawable_Rotate = cast(pf_sfDrawable_Rotate)dll.getSymbol(derivedClassName ~ "_Rotate");
sfDrawable_TransformToLocal = cast(pf_sfDrawable_TransformToLocal)dll.getSymbol(derivedClassName ~ "_TransformToLocal");
sfDrawable_TransformToGlobal= cast(pf_sfDrawable_TransformToGlobal)dll.getSymbol(derivedClassName ~ "_TransformToGlobal");
sfRenderWindow_DrawThis = cast(pf_sfRenderWindow_DrawThis)dll.getSymbol("sfRenderWindow_Draw" ~ derivedClassName[2..$]); sfRenderWindow_DrawThis = cast(pf_sfRenderWindow_DrawThis)dll.getSymbol("sfRenderWindow_Draw" ~ derivedClassName[2..$]);
sfRenderWindow_DrawThisWithShader = cast(pf_sfRenderWindow_DrawThisWithShader)dll.getSymbol("sfRenderWindow_Draw" ~ derivedClassName[2..$] ~ "WithShader"); sfRenderWindow_DrawThisWithShader = cast(pf_sfRenderWindow_DrawThisWithShader)dll.getSymbol("sfRenderWindow_Draw" ~ derivedClassName[2..$] ~ "WithShader");
sfRenderImage_DrawThis = cast(pf_sfRenderImage_DrawThis)dll.getSymbol("sfRenderImage_Draw" ~ derivedClassName[2..$]); sfRenderImage_DrawThis = cast(pf_sfRenderImage_DrawThis)dll.getSymbol("sfRenderImage_Draw" ~ derivedClassName[2..$]);

View File

@ -29,6 +29,7 @@ module dsfml.graphics.image;
import dsfml.graphics.color, import dsfml.graphics.color,
dsfml.graphics.rect; dsfml.graphics.rect;
// dsfml.graphics.renderwindow;
import dsfml.system.common, import dsfml.system.common,
dsfml.system.exception, dsfml.system.exception,
@ -42,7 +43,7 @@ import dsfml.system.common,
class Image : DSFMLObject class Image : DSFMLObject
{ {
package: package:
this(void* ptr) this(SFMLClass ptr)
{ {
super(ptr, true); super(ptr, true);
} }
@ -170,21 +171,23 @@ public:
sfImage_CreateMaskFromColor(m_ptr, colorKey, alpha); sfImage_CreateMaskFromColor(m_ptr, colorKey, alpha);
} }
// /** /+
// * Create the image from the current contents of the /**
// * given window * Create the image from the current contents of the
// * * given window
// * Params: *
// * window = Window to capture * Params:
// * sourceRect = Sub-rectangle of the screen to copy (empty by default - entire image) * window = Window to capture
// * * sourceRect = Sub-rectangle of the screen to copy (empty by default - entire image)
// * Returns: *
// * True if copy was successful * Returns:
// */ * True if copy was successful
// void copyScreen(RenderWindow window, IntRect sourceRect = IntRect()) */
// { bool copyScreen(RenderWindow window, IntRect sourceRect = IntRect())
// return cast(bool)sfImage_CopyScreen(m_ptr, window.nativePointer, sourceRect); {
// } return cast(bool)sfImage_CopyScreen(m_ptr, window.nativePointer, sourceRect);
}
+/
/** /**
* Copy pixels from another image onto this one. * Copy pixels from another image onto this one.
@ -197,9 +200,9 @@ public:
* destY = Y coordinate of the destination position * destY = Y coordinate of the destination position
* sourceRect = Sub-rectangle of the source image to copy * sourceRect = Sub-rectangle of the source image to copy
*/ */
void copy(Image source, uint destX, uint destY, IntRect sourceRect = IntRect()) void copyImage(Image source, uint destX, uint destY, IntRect sourceRect = IntRect())
{ {
sfImage_Copy(m_ptr, source.nativePointer, destX, destY, sourceRect); sfImage_CopyImage(m_ptr, source.nativePointer, destX, destY, sourceRect);
} }
/** /**
@ -241,7 +244,7 @@ public:
*/ */
ubyte[] getPixelsArray() ubyte[] getPixelsArray()
{ {
return sfImage_GetPixelsPtr(m_ptr)[0..getWidth() * getHeight() * 4]; return sfImage_GetPixelsPtr(m_ptr)[0..width() * height() * 4];
} }
/** /**
@ -252,51 +255,6 @@ public:
sfImage_Bind(m_ptr); sfImage_Bind(m_ptr);
} }
/**
* Enable or disable image smooth filter.
* This parameter is enabled by default
*
* Params:
* smooth = True to enable smoothing filter, false to disable it
*/
void setSmooth(bool smooth)
{
sfImage_SetSmooth(m_ptr, smooth);
}
/**
* Return the width of the image
*
* Returns:
* Width in pixels
*/
uint getWidth()
{
return sfImage_GetWidth(m_ptr);
}
/**
* Return the height of the image
*
* Returns:
* Height in pixels
*/
uint getHeight()
{
return sfImage_GetHeight(m_ptr);
}
/**
* Tells whether the smooth filtering is enabled or not
*
* Returns:
* True if image smoothing is enabled
*/
bool isSmooth()
{
return cast(bool)sfImage_IsSmooth(m_ptr);
}
/** /**
* Update a sub-rectangle of the image from an array of pixels * Update a sub-rectangle of the image from an array of pixels
* *
@ -314,32 +272,81 @@ public:
sfImage_UpdatePixels(m_ptr, pixels.ptr, rectangle); sfImage_UpdatePixels(m_ptr, pixels.ptr, rectangle);
} }
@property
{
/**
* Enable or disable image smooth filter.
* This parameter is enabled by default
*
* Params:
* s = True to enable smoothing filter, false to disable it
*/
void smooth(bool s)
{
sfImage_SetSmooth(m_ptr, s);
}
/**
* Return the width of the image
*
* Returns:
* Width in pixels
*/
uint width()
{
return sfImage_GetWidth(m_ptr);
}
/**
* Return the height of the image
*
* Returns:
* Height in pixels
*/
uint height()
{
return sfImage_GetHeight(m_ptr);
}
/**
* Tells whether the smooth filtering is enabled or not
*
* Returns:
* True if image smoothing is enabled
*/
bool smooth()
{
return cast(bool)sfImage_IsSmooth(m_ptr);
}
}
private: private:
static extern (C) static extern (C)
{ {
void* function() sfImage_Create; SFMLClass function() sfImage_Create;
void* function(uint, uint, Color) sfImage_CreateFromColor; SFMLClass function(uint, uint, Color) sfImage_CreateFromColor;
void* function(uint, uint, ubyte*) sfImage_CreateFromPixels; SFMLClass function(uint, uint, ubyte*) sfImage_CreateFromPixels;
void* function(cchar*) sfImage_CreateFromFile; SFMLClass function(cchar*) sfImage_CreateFromFile;
void* function(ubyte* ,size_t) sfImage_CreateFromMemory; SFMLClass function(ubyte* ,size_t) sfImage_CreateFromMemory;
void function(void*) sfImage_Destroy; void function(SFMLClass) sfImage_Destroy;
int function(void*, cchar*) sfImage_SaveToFile; int function(SFMLClass, cchar*) sfImage_SaveToFile;
void function(void*, Color, ubyte) sfImage_CreateMaskFromColor; void function(SFMLClass, Color, ubyte) sfImage_CreateMaskFromColor;
int function(void*, void*, IntRect) sfImage_CopyScreen; SFMLClass function(SFMLClass) sfImage_Copy;
void function(void*, void*, uint, uint, IntRect) sfImage_Copy; int function(SFMLClass, SFMLClass, IntRect) sfImage_CopyScreen;
void function(void*, uint, uint, Color) sfImage_SetPixel; void function(SFMLClass, SFMLClass, uint, uint, IntRect) sfImage_CopyImage;
Color function(void*, uint, uint) sfImage_GetPixel; void function(SFMLClass, uint, uint, Color) sfImage_SetPixel;
ubyte* function(void*) sfImage_GetPixelsPtr; Color function(SFMLClass, uint, uint) sfImage_GetPixel;
void function(void*) sfImage_Bind; ubyte* function(SFMLClass) sfImage_GetPixelsPtr;
void function(void*, int) sfImage_SetSmooth; void function(SFMLClass) sfImage_Bind;
uint function(void*) sfImage_GetWidth; void function(SFMLClass, int) sfImage_SetSmooth;
uint function(void*) sfImage_GetHeight; uint function(SFMLClass) sfImage_GetWidth;
int function(void*) sfImage_IsSmooth; uint function(SFMLClass) sfImage_GetHeight;
void function(void*, ubyte*, IntRect) sfImage_UpdatePixels; int function(SFMLClass) sfImage_IsSmooth;
void function(SFMLClass, ubyte*, IntRect) sfImage_UpdatePixels;
} }
mixin(loadFromSharedLib2("csfml-graphics", "sfImage", mixin(loadFromSharedLib2("csfml-graphics", "sfImage",
"Create", "CreateFromColor", "CreateFromPixels", "CreateFromFile", "CreateFromMemory", "Destroy", "SaveToFile", "Create", "CreateFromColor", "CreateFromPixels", "CreateFromFile", "CreateFromMemory", "Destroy", "SaveToFile",
"CreateMaskFromColor", "CopyScreen", "Copy", "SetPixel", "GetPixel", "GetPixelsPtr", "Bind", "SetSmooth", "GetWidth", "CreateMaskFromColor", "Copy", "CopyScreen", "CopyImage", "SetPixel", "GetPixel", "GetPixelsPtr", "Bind", "SetSmooth", "GetWidth",
"GetHeight", "IsSmooth", "UpdatePixels")); "GetHeight", "IsSmooth", "UpdatePixels"));
} }

View File

@ -59,58 +59,6 @@ interface IRenderTarget
*/ */
void draw(IDrawable object, Shader shader); void draw(IDrawable object, Shader shader);
/**
* Get the width of the rendering region of the target
*
* \return Width in pixels
*
*/
uint getWidth();
/**
* Get the height of the rendering region of the target
*
* \return Height in pixels
*
*/
uint getHeight();
/**
* Change the current active view.
*
* \param view : New view to use (pass GetDefaultView() to set the default view)
*
*/
void setView(View view);
/**
* Get the current view
*
* \return Current view active in the window
*
*/
View getView();
/**
* Get the default view of the window
*
* \return Default view
*
*/
View getDefaultView();
/**
* Get the viewport of a view applied to this target
*
* \param view Target view
*
* \return Viewport rectangle, expressed in pixels in the current target
*
*/
IntRect getViewport(View view);
/** /**
* Convert a point in target coordinates into view coordinates * Convert a point in target coordinates into view coordinates
* *
@ -134,4 +82,57 @@ interface IRenderTarget
* *
*/ */
void restoreGLStates(); void restoreGLStates();
@property
{
/**
* Get the width of the rendering region of the target
*
* \return Width in pixels
*
*/
uint width();
/**
* Get the height of the rendering region of the target
*
* \return Height in pixels
*
*/
uint height();
/**
* Change the current active view.
*
* \param view : New view to use (pass GetDefaultView() to set the default view)
*
*/
void view(View view);
/**
* Get the current view
*
* \return Current view active in the window
*
*/
View view();
/**
* Get the default view of the window
*
* \return Default view
*
*/
View defaultView();
/**
* Get the viewport of a view applied to this target
*
* \param view Target view
*
* \return Viewport rectangle, expressed in pixels in the current target
*
*/
IntRect viewport(View view);
}
} }

View File

@ -51,11 +51,16 @@ private:
View _defaultView = null; View _defaultView = null;
package: package:
this(void* ptr) this(SFMLClass ptr)
{ {
super(ptr, true); super(ptr, true);
} }
override void dispose()
{
sfRenderImage_Destroy(m_ptr);
}
public: public:
/** /**
@ -71,46 +76,6 @@ public:
super(sfRenderImage_Create(width, height, depthBuffer)); super(sfRenderImage_Create(width, height, depthBuffer));
} }
override void dispose()
{
sfRenderImage_Destroy(m_ptr);
}
/**
* Return the width of the rendering region of a renderimage
*
* Returns:
* Width in pixels
*/
uint getWidth()
{
return sfRenderImage_GetWidth(m_ptr);
}
/**
* Return the height of the rendering region of a renderimage
*
* Returns:
* Height in pixels
*/
uint getHeight()
{
return sfRenderImage_GetHeight(m_ptr);
}
/**
* Activate or deactivate a renderimage as the current target for rendering
*
* Params:
* active = true to activate, false to deactivate
* Returns:
* true if operation was successful, false otherwise
*/
bool setActive(bool active)
{
return sfRenderImage_SetActive(m_ptr, active);
}
/** /**
* Update the contents of the target image * Update the contents of the target image
*/ */
@ -152,63 +117,6 @@ public:
sfRenderImage_Clear(m_ptr, color); sfRenderImage_Clear(m_ptr, color);
} }
/**
* Change the current active view of a renderimage
*
* Params:
* view = Pointer to the new view
*/
void setView(View view)
{
if (_view !is null)
{
_view.setHandled(false);
}
sfRenderImage_SetView(m_ptr, view.nativePointer);
_view = view;
_view.setHandled(true);
}
/**
* Get the current active view rectangle
*
* Returns:
* current view rectangle, in global coordinates
*/
View getView()
{
if (_view is null)
{
void* cView = sfRenderImage_GetView(m_ptr);
_view = new View(cView, true);
}
return _view;
}
/**
* Get the default view
*
* Returns:
* default view
*/
View getDefaultView()
{
if (_defaultView is null)
{
void* cView = sfRenderImage_GetDefaultView(m_ptr);
_defaultView = new View(cView, true);
}
return _defaultView;
}
IntRect getViewport(View view = null) // TODO: is there a need to accept other Views than the currently assigned one?
{
return sfRenderImage_GetViewport(m_ptr, view is null ? _view.nativePointer : view.nativePointer);
}
/** /**
* Convert a point in image coordinates into view coordinates * Convert a point in image coordinates into view coordinates
* *
@ -227,32 +135,7 @@ public:
return vec; return vec;
} }
/**
* Get the target image
*
* Returns:
* target image
*/
Image getImage()
{
if (_image is null)
{
void* cImage = sfRenderImage_GetImage(m_ptr);
_image = new Image(cImage);
}
return _image;
}
/**
* Check whether the system supports render images or not
*
* Returns:
* true if the RenderImage class can be used
*/
bool isAvailable()
{
return sfRenderImage_IsAvailable();
}
/** /**
* Save the current OpenGL render states and matrices * Save the current OpenGL render states and matrices
@ -270,36 +153,158 @@ public:
sfRenderImage_RestoreGLStates(m_ptr); sfRenderImage_RestoreGLStates(m_ptr);
} }
@property
{
/**
* Return the width of the rendering region of a renderimage
*
* Returns:
* Width in pixels
*/
uint width()
{
return sfRenderImage_GetWidth(m_ptr);
}
/**
* Return the height of the rendering region of a renderimage
*
* Returns:
* Height in pixels
*/
uint height()
{
return sfRenderImage_GetHeight(m_ptr);
}
/**
* Activate or deactivate a renderimage as the current target for rendering
*
* Params:
* active = true to activate, false to deactivate
* Returns:
* true if operation was successful, false otherwise
*/
bool active(bool activ)
{
return sfRenderImage_SetActive(m_ptr, activ);
}
/**
* Change the current active view of a renderimage
*
* Params:
* view = Pointer to the new view
*/
void view(View v)
{
if (_view !is null)
{
_view.setHandled(false);
}
sfRenderImage_SetView(m_ptr, v.nativePointer);
_view = v;
_view.setHandled(true);
}
/**
* Get the current active view rectangle
*
* Returns:
* current view rectangle, in global coordinates
*/
View view()
{
if (_view is null)
{
SFMLClass cView = sfRenderImage_GetView(m_ptr);
_view = new View(cView, true);
}
return _view;
}
/**
* Get the default view
*
* Returns:
* default view
*/
View defaultView()
{
if (_defaultView is null)
{
SFMLClass cView = sfRenderImage_GetDefaultView(m_ptr);
_defaultView = new View(cView, true);
}
return _defaultView;
}
IntRect viewport(View v = null) // TODO: is there a need to accept other Views than the currently assigned one?
{
return sfRenderImage_GetViewport(m_ptr, v is null ? _view.nativePointer : v.nativePointer);
}
/**
* Get the target image
*
* Returns:
* target image
*/
Image image()
{
if (_image is null)
{
SFMLClass cImage = sfRenderImage_GetImage(m_ptr);
_image = new Image(cImage);
}
return _image;
}
/**
* Check whether the system supports render images or not
*
* Returns:
* true if the RenderImage class can be used
*/
bool isAvailable()
{
return sfRenderImage_IsAvailable();
}
}
private: private:
static extern(C) static extern(C)
{ {
void* function(uint, uint, bool) sfRenderImage_Create; SFMLClass function(uint, uint, bool) sfRenderImage_Create;
void function(void*) sfRenderImage_Destroy; void function(SFMLClass) sfRenderImage_Destroy;
uint function(void*) sfRenderImage_GetWidth; uint function(SFMLClass) sfRenderImage_GetWidth;
uint function(void*) sfRenderImage_GetHeight; uint function(SFMLClass) sfRenderImage_GetHeight;
bool function(void*, bool) sfRenderImage_SetActive; bool function(SFMLClass, bool) sfRenderImage_SetActive;
void function(void*) sfRenderImage_Display; void function(SFMLClass) sfRenderImage_Display;
void function(void*, void*) sfRenderImage_DrawSprite; void function(SFMLClass, void*) sfRenderImage_DrawSprite;
void function(void*, void*) sfRenderImage_DrawShape; void function(SFMLClass, void*) sfRenderImage_DrawShape;
void function(void*, void*) sfRenderImage_DrawText; void function(SFMLClass, void*) sfRenderImage_DrawText;
void function(void*, void*, void*) sfRenderImage_DrawSpriteWithShader; void function(SFMLClass, void*, void*) sfRenderImage_DrawSpriteWithShader;
void function(void*, void*, void*) sfRenderImage_DrawShapeWithShader; void function(SFMLClass, void*, void*) sfRenderImage_DrawShapeWithShader;
void function(void*, void*, void*) sfRenderImage_DrawTextWithShader; void function(SFMLClass, void*, void*) sfRenderImage_DrawTextWithShader;
void function(void*, Color) sfRenderImage_Clear; void function(SFMLClass, Color) sfRenderImage_Clear;
void function(void*, void*) sfRenderImage_SetView; void function(SFMLClass, SFMLClass) sfRenderImage_SetView;
void* function(void*) sfRenderImage_GetView; SFMLClass function(SFMLClass) sfRenderImage_GetView;
void* function(void*) sfRenderImage_GetDefaultView; SFMLClass function(SFMLClass) sfRenderImage_GetDefaultView;
IntRect function(void*, void*) sfRenderImage_GetViewport; IntRect function(SFMLClass, SFMLClass) sfRenderImage_GetViewport;
void function(void*, uint, uint, float*, float*, void*) sfRenderImage_ConvertCoords; void function(SFMLClass, uint, uint, float*, float*, SFMLClass) sfRenderImage_ConvertCoords;
void* function(void*) sfRenderImage_GetImage; SFMLClass function(SFMLClass) sfRenderImage_GetImage;
bool function() sfRenderImage_IsAvailable; bool function() sfRenderImage_IsAvailable;
// DSFML2 // DSFML2
void function(void*) sfRenderImage_SaveGLStates; void function(SFMLClass) sfRenderImage_SaveGLStates;
void function(void*) sfRenderImage_RestoreGLStates; void function(SFMLClass) sfRenderImage_RestoreGLStates;
} }
mixin(loadFromSharedLib2("csfml-graphics", "sfRenderImage", "Create", "Destroy", "GetWidth", "GetHeight", mixin(loadFromSharedLib2("csfml-graphics", "sfRenderImage", "Create", "Destroy", "GetWidth", "GetHeight",

View File

@ -30,7 +30,6 @@ import dsfml.graphics.color,
dsfml.graphics.sprite, dsfml.graphics.sprite,
dsfml.graphics.shape, dsfml.graphics.shape,
dsfml.graphics.text, dsfml.graphics.text,
dsfml.graphics.image,
dsfml.graphics.rect, dsfml.graphics.rect,
dsfml.graphics.shader, dsfml.graphics.shader,
dsfml.graphics.view, dsfml.graphics.view,
@ -67,7 +66,7 @@ public:
* windowStyle = Window style (Resize | Close by default) * windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values) * settings = Context settings (default is default ContextSettings values)
*/ */
this(VideoMode mode, string title, uint windowStyle = Style.Default, ContextSettings settings = ContextSettings()) this(VideoMode mode, string title, Style windowStyle = Style.Default, 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)); m_input = new Input(sfRenderWindow_GetInput(m_ptr));
@ -103,7 +102,7 @@ public:
* settings = Context settings (default is default ContextSettings values) * settings = Context settings (default is default ContextSettings values)
* *
*/ */
void create(VideoMode mode, string title, uint windowStyle = Style.Default, ContextSettings settings = ContextSettings()) override void create(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings())
{ {
if (m_ptr !is null) if (m_ptr !is null)
dispose(); dispose();
@ -122,7 +121,7 @@ public:
* settings = Context settings (default is default ContextSettings values) * settings = Context settings (default is default ContextSettings values)
* *
*/ */
void create(WindowHandle handle, ContextSettings settings = ContextSettings()) override void create(WindowHandle handle, ContextSettings settings = ContextSettings())
{ {
if (m_ptr !is null) if (m_ptr !is null)
dispose(); dispose();
@ -165,57 +164,7 @@ public:
sfRenderWindow_Clear(m_ptr, col); sfRenderWindow_Clear(m_ptr, col);
} }
/**
* Change the current active view.
* The current view is defined with the initial size of the window
*
* Params:
* newView = Pointer to the new view (pass getDefaultView to set the default view)
*/
void setView(View newView)
{
if (m_view !is null)
{
m_view.setHandled(false);
}
sfRenderWindow_SetView(m_ptr, newView.nativePointer);
m_view = newView;
m_view.setHandled(true);
}
/**
* Get the current view rectangle
*
* Returns:
* current view rectangle, in global coordinates
*/
View getView()
{
if (m_view is null)
{
void* cView = sfRenderWindow_GetView(m_ptr);
m_view = new View(cView, true);
}
return m_view;
}
/**
* Get the default view
*
* Returns:
* default view
*/
View getDefaultView()
{
if (m_defaultView is null)
{
void* cView = sfRenderWindow_GetDefaultView(m_ptr);
m_defaultView = new View(cView, true);
}
return m_defaultView;
}
/** /**
* Convert a point in window coordinates into view coordinates * Convert a point in window coordinates into view coordinates
@ -251,6 +200,59 @@ public:
sfRenderWindow_RestoreGLStates(m_ptr); sfRenderWindow_RestoreGLStates(m_ptr);
} }
@property
{
/**
* Change the current active view.
* The current view is defined with the initial size of the window
*
* Params:
* newView = Pointer to the new view (pass getDefaultView to set the default view)
*/
void view(View newView)
{
if (m_view !is null)
{
m_view.setHandled(false);
}
sfRenderWindow_SetView(m_ptr, newView.nativePointer);
m_view = newView;
m_view.setHandled(true);
}
/**
* Get the current view rectangle
*
* Returns:
* current view rectangle, in global coordinates
*/
View view()
{
if (m_view is null)
{
SFMLClass cView = sfRenderWindow_GetView(m_ptr);
m_view = new View(cView, true);
}
return m_view;
}
/**
* Get the default view
*
* Returns:
* default view
*/
View defaultView()
{
if (m_defaultView is null)
{
SFMLClass cView = sfRenderWindow_GetDefaultView(m_ptr);
m_defaultView = new View(cView, true);
}
return m_defaultView;
}
/** /**
* Return the width of the rendering region of a renderwindow * Return the width of the rendering region of a renderwindow
@ -258,7 +260,7 @@ public:
* Returns: * Returns:
* Width in pixels * Width in pixels
*/ */
uint getWidth() override uint width()
{ {
return sfRenderWindow_GetWidth(m_ptr); return sfRenderWindow_GetWidth(m_ptr);
} }
@ -269,49 +271,58 @@ public:
* Returns: * Returns:
* Height in pixels * Height in pixels
*/ */
uint getHeight() override uint height()
{ {
return sfRenderWindow_GetHeight(m_ptr); return sfRenderWindow_GetHeight(m_ptr);
} }
IntRect getViewport(View view = null) // TODO: is there a need to accept other Views than the currently assigned one? /**
* Get the viewport of a view applied to this target
*
* Params:
* view = Target view
* Returns:
* Viewport rectangle, expressed in pixels in the current target
*/
IntRect viewport(View v = null) // TODO: is there a need to accept other Views than the currently assigned one?
{ {
return sfRenderWindow_GetViewport(m_ptr, view is null ? m_view.nativePointer : view.nativePointer); return sfRenderWindow_GetViewport(m_ptr, v is null ? m_view.nativePointer : v.nativePointer);
}
} }
private: private:
static extern(C) static extern(C)
{ {
void* function(VideoMode, cchar*, uint, ContextSettings*) sfRenderWindow_Create; SFMLClass function(VideoMode, cchar*, Style, ContextSettings*)sfRenderWindow_Create;
void* function(WindowHandle, ContextSettings*) sfRenderWindow_CreateFromHandle; SFMLClass function(WindowHandle, ContextSettings*) sfRenderWindow_CreateFromHandle;
void function(void*) sfRenderWindow_Destroy; void function(SFMLClass) sfRenderWindow_Destroy;
void* function(void*) sfRenderWindow_GetInput; SFMLClass function(SFMLClass) sfRenderWindow_GetInput;
bool function(void*) sfRenderWindow_IsOpened; bool function(SFMLClass) sfRenderWindow_IsOpened;
uint function(void*) sfRenderWindow_GetWidth; uint function(SFMLClass) sfRenderWindow_GetWidth;
uint function(void*) sfRenderWindow_GetHeight; uint function(SFMLClass) sfRenderWindow_GetHeight;
/* /*
void function(void*, void*) sfRenderWindow_DrawSprite; void function(SFMLClass, SFMLClass) sfRenderWindow_DrawSprite;
void function(void*, void*) sfRenderWindow_DrawShape; void function(SFMLClass, SFMLClass) sfRenderWindow_DrawShape;
void function(void*, void*) sfRenderWindow_DrawText; void function(SFMLClass, SFMLClass) sfRenderWindow_DrawText;
void function(void*, void*, void*) sfRenderWindow_DrawSpriteWithShader; void function(SFMLClass, SFMLClass, SFMLClass) sfRenderWindow_DrawSpriteWithShader;
void function(void*, void*, void*) sfRenderWindow_DrawShapeWithShader; void function(SFMLClass, SFMLClass, SFMLClass) sfRenderWindow_DrawShapeWithShader;
void function(void*, void*, void*) sfRenderWindow_DrawTextWithShader; void function(SFMLClass, SFMLClass, SFMLClass) sfRenderWindow_DrawTextWithShader;
*/ */
void* function(void*) sfRenderWindow_Capture; SFMLClass function(SFMLClass) sfRenderWindow_Capture;
void function(void*, Color) sfRenderWindow_Clear; void function(SFMLClass, Color) sfRenderWindow_Clear;
void function(void*, void*) sfRenderWindow_SetView; void function(SFMLClass, SFMLClass) sfRenderWindow_SetView;
void* function(void*) sfRenderWindow_GetView; SFMLClass function(SFMLClass) sfRenderWindow_GetView;
void* function (void*) sfRenderWindow_GetDefaultView; SFMLClass function(SFMLClass) sfRenderWindow_GetDefaultView;
void function(void*, uint, uint, float*, float*, void*) sfRenderWindow_ConvertCoords; void function(SFMLClass, uint, uint, float*, float*, SFMLClass) sfRenderWindow_ConvertCoords;
// DSFML2 // DSFML2
void function(void*) sfRenderWindow_SaveGLStates; void function(SFMLClass) sfRenderWindow_SaveGLStates;
void function(void*) sfRenderWindow_RestoreGLStates; void function(SFMLClass) sfRenderWindow_RestoreGLStates;
IntRect function(void*, void*) sfRenderWindow_GetViewport; IntRect function(SFMLClass, SFMLClass) sfRenderWindow_GetViewport;
} }
mixin(loadFromSharedLib2("csfml-graphics", "sfRenderWindow", "Create", "CreateFromHandle", mixin(loadFromSharedLib2("csfml-graphics", "sfRenderWindow", "Create", "CreateFromHandle",

View File

@ -38,7 +38,7 @@ import dsfml.system.stringutil;
/** /**
* Window style * Window style
*/ */
enum Style enum Style : uint
{ {
None = 0, /// No border / title bar (this flag and all others are mutually exclusive) None = 0, /// No border / title bar (this flag and all others are mutually exclusive)
Titlebar = 1 << 0, /// Title bar + fixed border Titlebar = 1 << 0, /// Title bar + fixed border
@ -70,13 +70,19 @@ struct ContextSettings
class Window : DSFMLObject class Window : DSFMLObject
{ {
protected: protected:
this(void* ptr) this(SFMLClass ptr)
{ {
super(ptr); super(ptr);
} }
Input m_input; Input m_input;
override void dispose()
{
m_input = null;
sfWindow_Destroy(m_ptr);
}
public: public:
/** /**
* Construct a new window * Construct a new window
@ -89,7 +95,7 @@ public:
*/ */
this(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) this(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings())
{ {
super(sfWindow_Create(mode, toStringz(title), windowStyle, settings)); super(sfWindow_Create(mode, toStringz(title), windowStyle, &settings));
} }
/** /**
@ -101,13 +107,7 @@ public:
*/ */
this(WindowHandle handle, ContextSettings settings = ContextSettings()) this(WindowHandle handle, ContextSettings settings = ContextSettings())
{ {
super(sfWindow_CreateFromHandle(handle, settings)); super(sfWindow_CreateFromHandle(handle, &settings));
}
override void dispose()
{
m_input = null;
sfWindow_Destroy(m_ptr);
} }
/** /**
@ -126,7 +126,7 @@ public:
if (m_ptr !is null) if (m_ptr !is null)
dispose(); dispose();
m_ptr = sfWindow_Create(mode, toStringz(title), windowStyle, settings); m_ptr = sfWindow_Create(mode, toStringz(title), windowStyle, &settings);
} }
/** /**
@ -143,7 +143,7 @@ public:
if (m_ptr !is null) if (m_ptr !is null)
dispose(); dispose();
m_ptr = sfWindow_CreateFromHandle(handle, settings); m_ptr = sfWindow_CreateFromHandle(handle, &settings);
} }
/** /**
@ -155,6 +155,62 @@ public:
sfWindow_Close(m_ptr); sfWindow_Close(m_ptr);
} }
/**
* Get the event on top of events stack, if any, and pop it
*
* Params:
* eventReceived = Event to fill, if any
*
* Returns:
* True if an event was returned, false if events stack was empty
*/
bool getEvent(out Event eventReceived)
{
return cast(bool) sfWindow_GetEvent(m_ptr, &eventReceived);
}
/**
* Wait for an event and return it
*
* This function is blocking: if there's no pending event then it will wait until an event is received.
* After this function returns (and no error occured), the \a event object is always valid and filled properly.
* This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread
* sleep as long as no new event is received.
*
* Params:
* e Event to be returned
*
* Returns:
* false if any error occured
*/
bool waitEvent(out Event e)
{
return sfWindow_WaitEvent(m_ptr, &e);
}
/**
* Show or hide the window
*
* Params:
* state = True to show, false to hide
*
*/
void show(bool state)
{
sfWindow_Show(m_ptr, state);
}
/**
* Display the window on screen
*/
void display()
{
sfWindow_Display(m_ptr);
}
@property
{
/** /**
* Tell whether or not a window is opened * Tell whether or not a window is opened
* *
@ -171,7 +227,7 @@ public:
* Returns: * Returns:
* Width in pixels * Width in pixels
*/ */
uint getWidth() uint width()
{ {
return sfWindow_GetWidth(m_ptr); return sfWindow_GetWidth(m_ptr);
} }
@ -182,7 +238,7 @@ public:
* Returns: * Returns:
* Height in pixels * Height in pixels
*/ */
uint getHeight() uint height()
{ {
return sfWindow_GetHeight(m_ptr); return sfWindow_GetHeight(m_ptr);
} }
@ -193,26 +249,11 @@ public:
* Returns: * Returns:
* Settings used to create the window * Settings used to create the window
*/ */
ContextSettings getSettings() ContextSettings settings()
{ {
return sfWindow_GetSettings(m_ptr); return sfWindow_GetSettings(m_ptr);
} }
/**
* Get the event on top of events stack, if any, and pop it
*
* Params:
* eventReceived = Event to fill, if any
*
* Returns:
* True if an event was returned, false if events stack was empty
*/
bool getEvent(out Event eventReceived)
{
return cast(bool) sfWindow_GetEvent(m_ptr, &eventReceived);
}
/** /**
* Enable / disable vertical synchronization * Enable / disable vertical synchronization
* *
@ -235,6 +276,81 @@ public:
sfWindow_ShowMouseCursor(m_ptr, show); sfWindow_ShowMouseCursor(m_ptr, show);
} }
/**
* Enable or disable automatic key-repeat for keydown events.
* Automatic key-repeat is enabled by default.
*
* Params:
* enabled = true to enable, false to disable
*/
void enableKeyRepeat(bool enabled)
{
sfWindow_EnableKeyRepeat(m_ptr, enabled);
}
/**
* Set the window as the current target for rendering
*
* Params:
* active = True to activate, false to deactivate
* Returns:
* True if operation was successful, false otherwise
*/
bool active(bool active)
{
return cast(bool)sfWindow_SetActive(m_ptr, active);
}
/**
* Get the input manager of the window
*
* Returns:
* An input manager
* See_Also :
* Input
*/
Input input()
{
if (m_input is null)
m_input = new Input(sfWindow_GetInput(m_ptr));
return m_input;
}
/**
* Limit the framerate to a maximum fixed frequency
*
* Params:
* limit : Framerate limit, in frames per seconds (use 0 to disable limit)
*/
void framerateLimit(uint limit)
{
sfWindow_SetFramerateLimit(m_ptr, limit);
}
/**
* Get the time the last frame took
*
* Returns:
* time in seconds
*/
float frameTime()
{
return sfWindow_GetFrameTime(m_ptr);
}
/**
* Change the joystick threshold, ie. the value below which
* no move event will be generated
*
* Params:
* threshold : New threshold, in range [0, 100]
*/
void joystickThreshold(float threshold)
{
sfWindow_SetJoystickThreshold(m_ptr, threshold);
}
}
/** /**
* Change the position of the mouse cursor * Change the position of the mouse cursor
* *
@ -272,30 +388,6 @@ public:
sfWindow_SetSize(m_ptr, width, height); sfWindow_SetSize(m_ptr, width, height);
} }
/**
* Show or hide the window
*
* Params:
* state = True to show, false to hide
*
*/
void show(bool state)
{
sfWindow_Show(m_ptr, state);
}
/**
* Enable or disable automatic key-repeat for keydown events.
* Automatic key-repeat is enabled by default.
*
* Params:
* enabled = true to enable, false to disable
*/
void enableKeyRepeat(bool enabled)
{
sfWindow_EnableKeyRepeat(m_ptr, enabled);
}
/** /**
* Change the window's icon * Change the window's icon
* *
@ -310,161 +402,41 @@ public:
sfWindow_SetIcon(m_ptr, width, height, data.ptr); sfWindow_SetIcon(m_ptr, width, height, data.ptr);
} }
/**
* Set the window as the current target for rendering
*
* Params:
* active = True to activate, false to deactivate
* Returns:
* True if operation was successful, false otherwise
*/
bool setActive(bool active = true)
{
return cast(bool)sfWindow_SetActive(m_ptr, active);
}
/**
* Display the window on screen
*/
void display()
{
sfWindow_Display(m_ptr);
}
/**
* Get the input manager of the window
*
* Returns:
* An input manager
* See_Also :
* Input
*/
Input getInput()
{
if (m_input is null)
m_input = new Input(sfWindow_GetInput(m_ptr));
return m_input;
}
/**
* Limit the framerate to a maximum fixed frequency
*
* Params:
* limit : Framerate limit, in frames per seconds (use 0 to disable limit)
*/
void setFramerateLimit(uint limit)
{
sfWindow_SetFramerateLimit(m_ptr, limit);
}
/**
* Get the time the last frame took
*
* Returns:
* time in seconds
*/
float getFrameTime()
{
return sfWindow_GetFrameTime(m_ptr);
}
/**
* Change the joystick threshold, ie. the value below which
* no move event will be generated
*
* Params:
* threshold : New threshold, in range [0, 100]
*/
void setJoystickThreshold(float threshold)
{
sfWindow_SetJoystickThreshold(m_ptr, threshold);
}
/**
* Wait for an event and return it
*
* This function is blocking: if there's no pending event then it will wait until an event is received.
* After this function returns (and no error occured), the \a event object is always valid and filled properly.
* This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread
* sleep as long as no new event is received.
*
* Params:
* e Event to be returned
*
* Returns:
* false if any error occured
*/
bool waitEvent(out Event e)
{
return sfWindow_WaitEvent(m_ptr, &e);
}
private: private:
// External ==================================================================== // External ====================================================================
extern (C) static extern(C)
{ {
static SFMLClass function(VideoMode, cchar*, Style, ContextSettings*)sfWindow_Create;
{ SFMLClass function(WindowHandle, ContextSettings*) sfWindow_CreateFromHandle;
void* function(VideoMode, cchar*, uint, ContextSettings) sfWindow_Create; void function(SFMLClass) sfWindow_Destroy;
void* function(WindowHandle, ContextSettings) sfWindow_CreateFromHandle; void function(SFMLClass) sfWindow_Close;
void function(void*) sfWindow_Destroy; int function(SFMLClass) sfWindow_IsOpened;
void function(void*) sfWindow_Close; uint function(SFMLClass) sfWindow_GetWidth;
int function(void*) sfWindow_IsOpened; uint function(SFMLClass) sfWindow_GetHeight;
uint function(void*) sfWindow_GetWidth; ContextSettings function(SFMLClass Window) sfWindow_GetSettings;
uint function(void*) sfWindow_GetHeight; int function(SFMLClass, Event*) sfWindow_GetEvent;
ContextSettings function(void* Window) sfWindow_GetSettings; void function(SFMLClass, int) sfWindow_UseVerticalSync;
int function(void*, Event*) sfWindow_GetEvent; void function(SFMLClass, int) sfWindow_ShowMouseCursor;
void function(void*, int) sfWindow_UseVerticalSync; void function(SFMLClass, uint, uint) sfWindow_SetCursorPosition;
void function(void*, int) sfWindow_ShowMouseCursor; void function(SFMLClass, int, int) sfWindow_SetPosition;
void function(void*, uint, uint) sfWindow_SetCursorPosition; void function(SFMLClass, uint, uint) sfWindow_SetSize;
void function(void*, int, int) sfWindow_SetPosition; void function(SFMLClass, int) sfWindow_Show;
void function(void*, uint, uint) sfWindow_SetSize; void function(SFMLClass, int) sfWindow_EnableKeyRepeat;
void function(void*, int) sfWindow_Show; void function(SFMLClass, size_t, size_t, ubyte*) sfWindow_SetIcon;
void function(void*, int) sfWindow_EnableKeyRepeat; int function(SFMLClass, int) sfWindow_SetActive;
void function(void*, size_t, size_t, ubyte*) sfWindow_SetIcon; void function(SFMLClass) sfWindow_Display;
int function(void*, int) sfWindow_SetActive; SFMLClass function(SFMLClass) sfWindow_GetInput;
void function(void*) sfWindow_Display; void function(SFMLClass, uint) sfWindow_SetFramerateLimit;
void* function(void*) sfWindow_GetInput; float function(SFMLClass) sfWindow_GetFrameTime;
void function(void*, uint) sfWindow_SetFramerateLimit; void function(SFMLClass, float) sfWindow_SetJoystickThreshold;
float function(void*) sfWindow_GetFrameTime;
void function(void*, float) sfWindow_SetJoystickThreshold;
// DSFML2 // DSFML2
bool function(void*, void*) sfWindow_WaitEvent; bool function(SFMLClass, void*) sfWindow_WaitEvent;
}
} }
static this() mixin(loadFromSharedLib2("csfml-window", "sfWindow",
{ "Create", "CreateFromHandle", "Destroy", "Close", "IsOpened", "GetWidth", "GetHeight", "GetSettings", "GetEvent", "UseVerticalSync",
debug "ShowMouseCursor", "SetCursorPosition", "SetPosition", "SetSize", "Show", "EnableKeyRepeat", "SetIcon", "SetActive", "Display",
DllLoader dll = DllLoader.load("csfml-window-d"); "GetInput", "SetFramerateLimit", "GetFrameTime", "SetJoystickThreshold", "WaitEvent"));
else
DllLoader dll = DllLoader.load("csfml-window");
mixin(loadFromSharedLib("sfWindow_Create"));
mixin(loadFromSharedLib("sfWindow_CreateFromHandle"));
mixin(loadFromSharedLib("sfWindow_Destroy"));
mixin(loadFromSharedLib("sfWindow_Close"));
mixin(loadFromSharedLib("sfWindow_IsOpened"));
mixin(loadFromSharedLib("sfWindow_GetWidth"));
mixin(loadFromSharedLib("sfWindow_GetHeight"));
mixin(loadFromSharedLib("sfWindow_GetSettings"));
mixin(loadFromSharedLib("sfWindow_GetEvent"));
mixin(loadFromSharedLib("sfWindow_UseVerticalSync"));
mixin(loadFromSharedLib("sfWindow_ShowMouseCursor"));
mixin(loadFromSharedLib("sfWindow_SetCursorPosition"));
mixin(loadFromSharedLib("sfWindow_SetPosition"));
mixin(loadFromSharedLib("sfWindow_SetSize"));
mixin(loadFromSharedLib("sfWindow_Show"));
mixin(loadFromSharedLib("sfWindow_EnableKeyRepeat"));
mixin(loadFromSharedLib("sfWindow_SetIcon"));
mixin(loadFromSharedLib("sfWindow_SetActive"));
mixin(loadFromSharedLib("sfWindow_Display"));
mixin(loadFromSharedLib("sfWindow_GetInput"));
mixin(loadFromSharedLib("sfWindow_SetFramerateLimit"));
mixin(loadFromSharedLib("sfWindow_GetFrameTime"));
mixin(loadFromSharedLib("sfWindow_SetJoystickThreshold"));
mixin(loadFromSharedLib("sfWindow_WaitEvent"));
}
} }