mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
sync with sfml:
+ SoundStream.setPlayingOffset * Listener.getTarget -> getDirection git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1349 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
06d91c6020
commit
1c3cdd5058
@ -109,44 +109,41 @@ class Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the orientation of the listener (the point
|
* Change the orientation of the listener
|
||||||
* he must look at).
|
* The default direction is (0, 0, -1)
|
||||||
* The default target is (0, 0, -1)
|
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* targetX = X position of the point the listener must look at
|
* directionX = X component of the listener's direction
|
||||||
* targetY = X position of the point the listener must look at
|
* directionY = Y component of the listener's direction
|
||||||
* targetZ = X position of the point the listener must look at
|
* directionZ = Z component of the listener's direction
|
||||||
*/
|
*/
|
||||||
static void setTarget(float targetX, float targetY, float targetZ)
|
static void setDirection(float directionX, float directionY, float directionZ)
|
||||||
{
|
{
|
||||||
sfListener_SetTarget(targetX, targetY, targetZ);
|
sfListener_SetDirection(directionX, directionY, directionZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the orientation of the listener (the point
|
* Change the orientation of the listener
|
||||||
* he must look at).
|
* The default direction is (0, 0, -1)
|
||||||
* The default target is (0, 0, -1)
|
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* target = Position of the point the listener must look at
|
* direction = Position of the point the listener must look at
|
||||||
*/
|
*/
|
||||||
static void setTarget(Vector3f position)
|
static void setDirection(Vector3f position)
|
||||||
{
|
{
|
||||||
sfListener_SetTarget(position.x, position.y, position.z);
|
sfListener_SetDirection(position.x, position.y, position.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current orientation of the listener (the point
|
* Get the current orientation of the listener
|
||||||
* he's looking at)
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* Position of the point the listener is looking at
|
* Position of the point the listener is looking at
|
||||||
*/
|
*/
|
||||||
static Vector3f getTarget()
|
static Vector3f getDirection()
|
||||||
{
|
{
|
||||||
Vector3f ret;
|
Vector3f ret;
|
||||||
sfListener_GetTarget(&ret.x, &ret.y, &ret.z);
|
sfListener_GetDirection(&ret.x, &ret.y, &ret.z);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,15 +157,15 @@ private:
|
|||||||
typedef float function() pf_sfListener_GetGlobalVolume;
|
typedef float function() pf_sfListener_GetGlobalVolume;
|
||||||
typedef void function(float, float, float) pf_sfListener_SetPosition;
|
typedef void function(float, float, float) pf_sfListener_SetPosition;
|
||||||
typedef void function(float*, float*, float*) pf_sfListener_GetPosition;
|
typedef void function(float*, float*, float*) pf_sfListener_GetPosition;
|
||||||
typedef void function(float, float, float) pf_sfListener_SetTarget;
|
typedef void function(float, float, float) pf_sfListener_SetDirection;
|
||||||
typedef void function(float*, float*, float*) pf_sfListener_GetTarget;
|
typedef void function(float*, float*, float*) pf_sfListener_GetDirection;
|
||||||
|
|
||||||
static pf_sfListener_SetGlobalVolume sfListener_SetGlobalVolume;
|
static pf_sfListener_SetGlobalVolume sfListener_SetGlobalVolume;
|
||||||
static pf_sfListener_GetGlobalVolume sfListener_GetGlobalVolume;
|
static pf_sfListener_GetGlobalVolume sfListener_GetGlobalVolume;
|
||||||
static pf_sfListener_SetPosition sfListener_SetPosition;
|
static pf_sfListener_SetPosition sfListener_SetPosition;
|
||||||
static pf_sfListener_GetPosition sfListener_GetPosition;
|
static pf_sfListener_GetPosition sfListener_GetPosition;
|
||||||
static pf_sfListener_SetTarget sfListener_SetTarget;
|
static pf_sfListener_SetDirection sfListener_SetDirection;
|
||||||
static pf_sfListener_GetTarget sfListener_GetTarget;
|
static pf_sfListener_GetDirection sfListener_GetDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
static this()
|
static this()
|
||||||
@ -182,7 +179,7 @@ private:
|
|||||||
sfListener_GetGlobalVolume = cast(pf_sfListener_GetGlobalVolume)dll.getSymbol("sfListener_GetGlobalVolume");
|
sfListener_GetGlobalVolume = cast(pf_sfListener_GetGlobalVolume)dll.getSymbol("sfListener_GetGlobalVolume");
|
||||||
sfListener_SetPosition = cast(pf_sfListener_SetPosition)dll.getSymbol("sfListener_SetPosition");
|
sfListener_SetPosition = cast(pf_sfListener_SetPosition)dll.getSymbol("sfListener_SetPosition");
|
||||||
sfListener_GetPosition = cast(pf_sfListener_GetPosition)dll.getSymbol("sfListener_GetPosition");
|
sfListener_GetPosition = cast(pf_sfListener_GetPosition)dll.getSymbol("sfListener_GetPosition");
|
||||||
sfListener_SetTarget = cast(pf_sfListener_SetTarget)dll.getSymbol("sfListener_SetTarget");
|
sfListener_SetDirection = cast(pf_sfListener_SetDirection)dll.getSymbol("sfListener_SetDirection");
|
||||||
sfListener_GetTarget = cast(pf_sfListener_GetTarget)dll.getSymbol("sfListener_GetTarget");
|
sfListener_GetDirection = cast(pf_sfListener_GetDirection)dll.getSymbol("sfListener_GetDirection");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,17 @@ abstract class SoundStream : SoundSource!("sfSoundStream")
|
|||||||
return sfSoundStream_GetPlayingOffset(m_ptr);
|
return sfSoundStream_GetPlayingOffset(m_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current playing position of a music
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
* timeOffset = New playing position, expressed in seconds
|
||||||
|
*/
|
||||||
|
void setPlayingOffset(float timeOffset)
|
||||||
|
{
|
||||||
|
sfSoundStream_SetPlayingOffset(m_ptr, timeOffset);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell whether or not the stream is looping
|
* Tell whether or not the stream is looping
|
||||||
*
|
*
|
||||||
@ -188,7 +199,7 @@ protected:
|
|||||||
m_channelsCount = channelsCount;
|
m_channelsCount = channelsCount;
|
||||||
m_sampleRate = sampleRate;
|
m_sampleRate = sampleRate;
|
||||||
|
|
||||||
m_ptr = sfSoundStream_Create(&externalOnStart, &externalOnGetData, channelsCount, sampleRate, &m_id); // TODO: hack
|
m_ptr = sfSoundStream_Create(&externalOnGetData, &externalOnSeek, channelsCount, sampleRate, &m_id); // TODO: hack
|
||||||
|
|
||||||
m_mutex = new Mutex();
|
m_mutex = new Mutex();
|
||||||
|
|
||||||
@ -222,7 +233,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// Called sync when user calling play()
|
// Called sync when user calling play()
|
||||||
extern(C) static int externalOnStart(void* user)
|
// FIXME: this needs to be transformed from OnStart to OnSeek
|
||||||
|
extern(C) static void externalOnSeek(float t, void* user)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
if ((id = *cast(int*) user) in s_instances)
|
if ((id = *cast(int*) user) in s_instances)
|
||||||
@ -230,7 +242,7 @@ private:
|
|||||||
SoundStream temp = s_instances[id];
|
SoundStream temp = s_instances[id];
|
||||||
return (temp.m_flag = temp.onStart());
|
return (temp.m_flag = temp.onStart());
|
||||||
}
|
}
|
||||||
return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// C Thread callback (no allocation can be done)
|
// C Thread callback (no allocation can be done)
|
||||||
@ -324,10 +336,10 @@ private:
|
|||||||
{
|
{
|
||||||
struct sfSoundStreamChunk{ short* Samples; uint NbSamples; }
|
struct sfSoundStreamChunk{ short* Samples; uint NbSamples; }
|
||||||
|
|
||||||
alias int function(void*) sfSoundStreamStartCallback;
|
alias void function(float, void*) sfSoundStreamSeekCallback;
|
||||||
alias int function (sfSoundStreamChunk*, void*) sfSoundStreamGetDataCallback;
|
alias int function (sfSoundStreamChunk*, void*) sfSoundStreamGetDataCallback;
|
||||||
|
|
||||||
alias void* function(sfSoundStreamStartCallback, sfSoundStreamGetDataCallback, uint, uint, void*) pf_sfSoundStream_Create;
|
alias void* function(sfSoundStreamGetDataCallback, sfSoundStreamSeekCallback, uint, uint, void*) pf_sfSoundStream_Create;
|
||||||
alias void function(void*) pf_sfSoundStream_Destroy;
|
alias void function(void*) pf_sfSoundStream_Destroy;
|
||||||
alias void function(void*) pf_sfSoundStream_Play;
|
alias void function(void*) pf_sfSoundStream_Play;
|
||||||
alias void function(void*) pf_sfSoundStream_Pause;
|
alias void function(void*) pf_sfSoundStream_Pause;
|
||||||
@ -335,6 +347,7 @@ private:
|
|||||||
alias uint function(void*) pf_sfSoundStream_GetChannelsCount;
|
alias uint function(void*) pf_sfSoundStream_GetChannelsCount;
|
||||||
alias uint function(void*) pf_sfSoundStream_GetSampleRate;
|
alias uint function(void*) pf_sfSoundStream_GetSampleRate;
|
||||||
alias float function(void*) pf_sfSoundStream_GetPlayingOffset;
|
alias float function(void*) pf_sfSoundStream_GetPlayingOffset;
|
||||||
|
alias void function(void*, float) pf_sfSoundStream_SetPlayingOffset;
|
||||||
alias int function(void*) pf_sfSoundStream_GetLoop;
|
alias int function(void*) pf_sfSoundStream_GetLoop;
|
||||||
alias void function(void*, int) pf_sfSoundStream_SetLoop;
|
alias void function(void*, int) pf_sfSoundStream_SetLoop;
|
||||||
|
|
||||||
@ -347,6 +360,7 @@ private:
|
|||||||
static pf_sfSoundStream_GetChannelsCount sfSoundStream_GetChannelsCount;
|
static pf_sfSoundStream_GetChannelsCount sfSoundStream_GetChannelsCount;
|
||||||
static pf_sfSoundStream_GetSampleRate sfSoundStream_GetSampleRate;
|
static pf_sfSoundStream_GetSampleRate sfSoundStream_GetSampleRate;
|
||||||
static pf_sfSoundStream_GetPlayingOffset sfSoundStream_GetPlayingOffset;
|
static pf_sfSoundStream_GetPlayingOffset sfSoundStream_GetPlayingOffset;
|
||||||
|
static pf_sfSoundStream_SetPlayingOffset sfSoundStream_SetPlayingOffset;
|
||||||
static pf_sfSoundStream_GetLoop sfSoundStream_GetLoop;
|
static pf_sfSoundStream_GetLoop sfSoundStream_GetLoop;
|
||||||
static pf_sfSoundStream_SetLoop sfSoundStream_SetLoop;
|
static pf_sfSoundStream_SetLoop sfSoundStream_SetLoop;
|
||||||
}
|
}
|
||||||
@ -366,6 +380,7 @@ private:
|
|||||||
sfSoundStream_GetChannelsCount = cast(pf_sfSoundStream_GetChannelsCount)dll.getSymbol("sfSoundStream_GetChannelsCount");
|
sfSoundStream_GetChannelsCount = cast(pf_sfSoundStream_GetChannelsCount)dll.getSymbol("sfSoundStream_GetChannelsCount");
|
||||||
sfSoundStream_GetSampleRate = cast(pf_sfSoundStream_GetSampleRate)dll.getSymbol("sfSoundStream_GetSampleRate");
|
sfSoundStream_GetSampleRate = cast(pf_sfSoundStream_GetSampleRate)dll.getSymbol("sfSoundStream_GetSampleRate");
|
||||||
sfSoundStream_GetPlayingOffset = cast(pf_sfSoundStream_GetPlayingOffset)dll.getSymbol("sfSoundStream_GetPlayingOffset");
|
sfSoundStream_GetPlayingOffset = cast(pf_sfSoundStream_GetPlayingOffset)dll.getSymbol("sfSoundStream_GetPlayingOffset");
|
||||||
|
sfSoundStream_SetPlayingOffset = cast(pf_sfSoundStream_SetPlayingOffset)dll.getSymbol("sfSoundStream_SetPlayingOffset");
|
||||||
sfSoundStream_GetLoop = cast(pf_sfSoundStream_GetLoop)dll.getSymbol("sfSoundStream_GetLoop");
|
sfSoundStream_GetLoop = cast(pf_sfSoundStream_GetLoop)dll.getSymbol("sfSoundStream_GetLoop");
|
||||||
sfSoundStream_SetLoop = cast(pf_sfSoundStream_SetLoop)dll.getSymbol("sfSoundStream_SetLoop");
|
sfSoundStream_SetLoop = cast(pf_sfSoundStream_SetLoop)dll.getSymbol("sfSoundStream_SetLoop");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user