mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
* renamed SoundRecorder.canCapture to isAvailable
* some internal fixes/changes git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1352 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
8a848e3175
commit
9f1354b2a9
@ -43,7 +43,7 @@ import core.thread;
|
||||
* $(B onProcessSamples and onStop will be called by a different thread, take care of synchronization issues.)
|
||||
*
|
||||
* Examples:
|
||||
* -------
|
||||
* -------
|
||||
* class MySoundRecorder : SoundRecorder
|
||||
* {
|
||||
* this()
|
||||
@ -53,21 +53,21 @@ import core.thread;
|
||||
*
|
||||
* protected bool onStart()
|
||||
* {
|
||||
* return true;
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* protected void onStop()
|
||||
* {
|
||||
*
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* protected bool onProcessSamples(out short[])
|
||||
* {
|
||||
* // Process data here
|
||||
*
|
||||
* return true; //return true to continue capture, else return false
|
||||
* return true; //return true to continue capture, else return false
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* -------
|
||||
*/
|
||||
abstract class SoundRecorder : DSFMLObject
|
||||
@ -128,9 +128,9 @@ abstract class SoundRecorder : DSFMLObject
|
||||
* True if audio capture is supported
|
||||
*
|
||||
*/
|
||||
static bool canCapture()
|
||||
static bool isAvailable()
|
||||
{
|
||||
return cast(bool)sfSoundRecorder_CanCapture();
|
||||
return cast(bool) sfSoundRecorder_IsAvailable();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -286,38 +286,18 @@ private:
|
||||
|
||||
// External ====================================================================
|
||||
|
||||
extern (C)
|
||||
static extern (C)
|
||||
{
|
||||
typedef void* function(int function(void*), int function(short*, size_t, void*), void function(void*), void*) pf_sfSoundRecorder_Create;
|
||||
typedef void function(void*) pf_sfSoundRecorder_Destroy;
|
||||
typedef void function(void*, uint SampleRate) pf_sfSoundRecorder_Start;
|
||||
typedef void function(void*) pf_sfSoundRecorder_Stop;
|
||||
typedef uint function(void*) pf_sfSoundRecorder_GetSampleRate;
|
||||
typedef int function() pf_sfSoundRecorder_CanCapture;
|
||||
|
||||
static pf_sfSoundRecorder_Create sfSoundRecorder_Create;
|
||||
static pf_sfSoundRecorder_Destroy sfSoundRecorder_Destroy;
|
||||
static pf_sfSoundRecorder_Start sfSoundRecorder_Start;
|
||||
static pf_sfSoundRecorder_Stop sfSoundRecorder_Stop;
|
||||
static pf_sfSoundRecorder_GetSampleRate sfSoundRecorder_GetSampleRate;
|
||||
static pf_sfSoundRecorder_CanCapture sfSoundRecorder_CanCapture;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
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");
|
||||
sfSoundRecorder_Start = cast(pf_sfSoundRecorder_Start)dll.getSymbol("sfSoundRecorder_Start");
|
||||
sfSoundRecorder_Stop = cast(pf_sfSoundRecorder_Stop)dll.getSymbol("sfSoundRecorder_Stop");
|
||||
sfSoundRecorder_GetSampleRate = cast(pf_sfSoundRecorder_GetSampleRate)dll.getSymbol("sfSoundRecorder_GetSampleRate");
|
||||
sfSoundRecorder_CanCapture = cast(pf_sfSoundRecorder_CanCapture)dll.getSymbol("sfSoundRecorder_CanCapture");
|
||||
void* function(int function(void*), int function(short*, size_t, void*), void function(void*), void*) sfSoundRecorder_Create;
|
||||
void function(void*) sfSoundRecorder_Destroy;
|
||||
void function(void*, uint SampleRate) sfSoundRecorder_Start;
|
||||
void function(void*) sfSoundRecorder_Stop;
|
||||
uint function(void*) sfSoundRecorder_GetSampleRate;
|
||||
int function() sfSoundRecorder_IsAvailable;
|
||||
}
|
||||
|
||||
mixin(loadFromSharedLib2("csfml-audio", "sfSoundRecorder_Create", "sfSoundRecorder_Destroy", "sfSoundRecorder_Start",
|
||||
"sfSoundRecorder_Stop", "sfSoundRecorder_GetSampleRate", "sfSoundRecorder_IsAvailable"));
|
||||
}
|
||||
|
||||
// Use explicit alloc to allow instaciation by C thread
|
||||
@ -333,5 +313,4 @@ private class Samples
|
||||
|
||||
public short* data;
|
||||
public size_t length;
|
||||
}
|
||||
|
||||
}
|
@ -51,7 +51,7 @@ protected:
|
||||
|
||||
this(void* ptr)
|
||||
{
|
||||
super(ptr);
|
||||
super(ptr, true);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -149,7 +149,7 @@ public:
|
||||
* Returns:
|
||||
* Center of the view
|
||||
*/
|
||||
Vector2f GetCenter()
|
||||
Vector2f getCenter()
|
||||
{
|
||||
return Vector2f(sfView_GetCenterX(m_ptr), sfView_GetCenterY(m_ptr));
|
||||
}
|
||||
@ -207,10 +207,12 @@ public:
|
||||
* offsetX = Offset to move the view, on X axis
|
||||
* offsetY = Offset to move the view, on Y axis
|
||||
*/
|
||||
void move(float offsetX, float offsetY)
|
||||
View move(float offsetX, float offsetY)
|
||||
{
|
||||
sfView_Move(m_ptr, offsetX, offsetY);
|
||||
m_isModified = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,10 +221,12 @@ public:
|
||||
* Params:
|
||||
* offset = offsetto move the view
|
||||
*/
|
||||
void move(Vector2f offset)
|
||||
View move(Vector2f offset)
|
||||
{
|
||||
sfView_Move(m_ptr, offset.x, offset.y);
|
||||
m_isModified = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,11 +234,13 @@ public:
|
||||
*
|
||||
* Params:
|
||||
* factor = Zoom factor to apply, relative to the current zoom
|
||||
*/
|
||||
void zoom(float factor)
|
||||
*/
|
||||
View zoom(float factor)
|
||||
{
|
||||
sfView_Zoom(m_ptr, factor);
|
||||
m_isModified = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,9 +249,11 @@ public:
|
||||
* Params:
|
||||
* angle = Angle to rotate, in degree
|
||||
*/
|
||||
void rotate(float angle)
|
||||
View rotate(float angle)
|
||||
{
|
||||
sfView_Rotate(m_ptr, angle);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,9 +263,11 @@ public:
|
||||
* Params:
|
||||
* angle = New angle, in degrees
|
||||
*/
|
||||
void setRotation(float angle)
|
||||
View setRotation(float angle)
|
||||
{
|
||||
sfView_SetRotation(m_ptr, angle);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,6 +46,30 @@ string loadFromSharedLib(string fname)
|
||||
return fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");";
|
||||
}
|
||||
|
||||
//used to mixin code function
|
||||
string loadFromSharedLib2(S...)(string lib, S fnames)
|
||||
{
|
||||
string res = `static this()
|
||||
{
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("` ~ lib ~ `-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("` ~ lib ~ `");
|
||||
|
||||
`;
|
||||
|
||||
foreach(fname; fnames)
|
||||
{
|
||||
res ~= "\t" ~ fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");\n";
|
||||
}
|
||||
return res ~ "}\n";
|
||||
}
|
||||
|
||||
string loadDerivedFromSharedLib(string base, string fname, string derived)
|
||||
{
|
||||
return base ~ "_" ~ fname ~ " = " ~ "cast(typeof(" ~ base ~ "_" ~ fname ~ ")) dll.getSymbol(\"" ~ derived ~ "_" ~ fname ~ "\");";
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for all DSFML classes.
|
||||
*/
|
||||
|
@ -272,13 +272,11 @@ align(1) struct Event
|
||||
|
||||
struct SKey
|
||||
{
|
||||
align(4): // cause bool is size 1
|
||||
KeyCode Code;
|
||||
bool Alt;
|
||||
byte[3] Filler1;
|
||||
bool Control;
|
||||
byte[3] Filler2;
|
||||
bool Shift;
|
||||
byte[3] Filler3;
|
||||
}
|
||||
SKey Key;
|
||||
|
||||
|
@ -132,21 +132,14 @@ private:
|
||||
|
||||
// External ====================================================================
|
||||
|
||||
extern (C)
|
||||
static extern (C)
|
||||
{
|
||||
typedef int function(void*, KeyCode) pf_sfInput_IsKeyDown;
|
||||
typedef int function(void*, MouseButtons) pf_sfInput_IsMouseButtonDown;
|
||||
typedef int function(void*, uint, uint) pf_sfInput_IsJoystickButtonDown;
|
||||
typedef uint function (void*) pf_sfInput_GetMouseX;
|
||||
typedef uint function(void*) pf_sfInput_GetMouseY;
|
||||
typedef float function(void*, uint, JoyAxis) pf_sfInput_GetJoystickAxis;
|
||||
|
||||
static pf_sfInput_IsKeyDown sfInput_IsKeyDown;
|
||||
static pf_sfInput_IsMouseButtonDown sfInput_IsMouseButtonDown;
|
||||
static pf_sfInput_IsJoystickButtonDown sfInput_IsJoystickButtonDown;
|
||||
static pf_sfInput_GetMouseX sfInput_GetMouseX;
|
||||
static pf_sfInput_GetMouseY sfInput_GetMouseY;
|
||||
static pf_sfInput_GetJoystickAxis sfInput_GetJoystickAxis;
|
||||
int function(void*, KeyCode) sfInput_IsKeyDown;
|
||||
int function(void*, MouseButtons) sfInput_IsMouseButtonDown;
|
||||
int function(void*, uint, uint) sfInput_IsJoystickButtonDown;
|
||||
int function(void*) sfInput_GetMouseX;
|
||||
int function(void*) sfInput_GetMouseY;
|
||||
float function(void*, uint, JoyAxis) sfInput_GetJoystickAxis;
|
||||
}
|
||||
|
||||
static this()
|
||||
@ -156,11 +149,11 @@ private:
|
||||
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");
|
||||
sfInput_IsJoystickButtonDown = cast(pf_sfInput_IsJoystickButtonDown)dll.getSymbol("sfInput_IsJoystickButtonDown");
|
||||
sfInput_GetMouseX = cast(pf_sfInput_GetMouseX)dll.getSymbol("sfInput_GetMouseX");
|
||||
sfInput_GetMouseY = cast(pf_sfInput_GetMouseY)dll.getSymbol("sfInput_GetMouseY");
|
||||
sfInput_GetJoystickAxis = cast(pf_sfInput_GetJoystickAxis)dll.getSymbol("sfInput_GetJoystickAxis");
|
||||
mixin(loadFromSharedLib("sfInput_IsKeyDown"));
|
||||
mixin(loadFromSharedLib("sfInput_IsMouseButtonDown"));
|
||||
mixin(loadFromSharedLib("sfInput_IsJoystickButtonDown"));
|
||||
mixin(loadFromSharedLib("sfInput_GetMouseX"));
|
||||
mixin(loadFromSharedLib("sfInput_GetMouseY"));
|
||||
mixin(loadFromSharedLib("sfInput_GetJoystickAxis"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user