mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Times in SFML are now Uint32 milliseconds instead of float seconds
Added the sf::Uint64 and sf::Int64 types
This commit is contained in:
parent
c1ce16f4d6
commit
e4c6c30e0b
@ -86,10 +86,10 @@ CSFML_API sfBool sfMusic_GetLoop(const sfMusic* music);
|
||||
///
|
||||
/// \param music : Music to get the duration from
|
||||
///
|
||||
/// \return Music duration, in seconds
|
||||
/// \return Music duration, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfMusic_GetDuration(const sfMusic* music);
|
||||
CSFML_API sfUint32 sfMusic_GetDuration(const sfMusic* music);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Start playing a music
|
||||
@ -150,10 +150,10 @@ CSFML_API sfSoundStatus sfMusic_GetStatus(const sfMusic* music);
|
||||
///
|
||||
/// \param music : Music to get the position from
|
||||
///
|
||||
/// \return Current playing position, expressed in seconds
|
||||
/// \return Current playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfMusic_GetPlayingOffset(const sfMusic* music);
|
||||
CSFML_API sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the pitch of a music
|
||||
@ -221,10 +221,10 @@ CSFML_API void sfMusic_SetAttenuation(sfMusic* music, float attenuation);
|
||||
/// Set the current playing position of a music
|
||||
///
|
||||
/// \param music : Music to modify
|
||||
/// \param timeOffset : New playing position, expressed in seconds
|
||||
/// \param timeOffset : New playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfMusic_SetPlayingOffset(sfMusic* music, float timeOffset);
|
||||
CSFML_API void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the pitch of a music
|
||||
|
@ -197,10 +197,10 @@ CSFML_API void sfSound_SetAttenuation(sfSound* sound, float attenuation);
|
||||
/// Set the current playing position of a sound
|
||||
///
|
||||
/// \param sound : Sound to modify
|
||||
/// \param timeOffset : New playing position, expressed in seconds
|
||||
/// \param timeOffset : New playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, float timeOffset);
|
||||
CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the pitch of a sound
|
||||
@ -269,10 +269,10 @@ CSFML_API float sfSound_GetAttenuation(const sfSound* sound);
|
||||
///
|
||||
/// \param sound : Sound to get the position from
|
||||
///
|
||||
/// \return Current playing position, expressed in seconds
|
||||
/// \return Current playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfSound_GetPlayingOffset(const sfSound* sound);
|
||||
CSFML_API sfUint32 sfSound_GetPlayingOffset(const sfSound* sound);
|
||||
|
||||
|
||||
#endif // SFML_SOUND_H
|
||||
|
@ -142,10 +142,10 @@ CSFML_API unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* sound
|
||||
///
|
||||
/// \param soundBuffer : Sound buffer to get duration from
|
||||
///
|
||||
/// \return Sound duration, in seconds
|
||||
/// \return Sound duration, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer);
|
||||
CSFML_API sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer);
|
||||
|
||||
|
||||
#endif // SFML_SOUNDBUFFER_H
|
||||
|
@ -44,7 +44,7 @@ typedef struct
|
||||
} sfSoundStreamChunk;
|
||||
|
||||
typedef sfBool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); ///< Type of the callback used to get a sound stream data
|
||||
typedef void (*sfSoundStreamSeekCallback)(float, void*); ///< Type of the callback used to seek in a sound stream
|
||||
typedef void (*sfSoundStreamSeekCallback)(sfUint32, void*); ///< Type of the callback used to seek in a sound stream
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -194,10 +194,10 @@ CSFML_API void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float at
|
||||
/// Set the current playing position of a stream
|
||||
///
|
||||
/// \param soundStream : Sound stream to modify
|
||||
/// \param timeOffset : New playing position, expressed in seconds
|
||||
/// \param timeOffset : New playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, float timeOffset);
|
||||
CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set a stream loop state
|
||||
@ -285,10 +285,10 @@ CSFML_API sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream);
|
||||
///
|
||||
/// \param soundStream : Sound stream to get the position from
|
||||
///
|
||||
/// \return Current playing position, expressed in seconds
|
||||
/// \return Current playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream);
|
||||
CSFML_API sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream);
|
||||
|
||||
|
||||
#endif // SFML_SOUNDSTREAM_H
|
||||
|
@ -281,10 +281,10 @@ CSFML_API void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, un
|
||||
///
|
||||
/// \param renderWindow : Renderwindow object
|
||||
///
|
||||
/// \return Time elapsed, in seconds
|
||||
/// \return Time elapsed, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow);
|
||||
CSFML_API sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the joystick threshold, ie. the value below which
|
||||
|
@ -282,12 +282,12 @@ CSFML_API void sfFtp_Destroy(sfFtp* ftp);
|
||||
/// \param ftp : Ftp instance
|
||||
/// \param server : FTP server to connect to
|
||||
/// \param port : Port used for connection (21 by default, standard FTP port)
|
||||
/// \param timeout : Maximum time to wait (0 to use no timeout)
|
||||
/// \param timeout : Maximum time to wait, in milliseconds (0 to use no timeout)
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, float timeout);
|
||||
CSFML_API sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfUint32 timeout);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Log in using anonymous account
|
||||
|
@ -246,12 +246,12 @@ CSFML_API void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short por
|
||||
///
|
||||
/// \param http : Http object
|
||||
/// \param request : Request to send
|
||||
/// \param timeout : Maximum time to wait (0 to use no timeout)
|
||||
/// \param timeout : Maximum time to wait, in milliseconds (0 to use no timeout)
|
||||
///
|
||||
/// \return Server's response, or NULL if request is invalid
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, float timeout);
|
||||
CSFML_API sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout);
|
||||
|
||||
|
||||
#endif // SFML_HTTP_H
|
||||
|
@ -104,12 +104,12 @@ CSFML_API sfIpAddress sfIpAddress_GetLocalAddress(void);
|
||||
/// distant website ; as a consequence, this function may be
|
||||
/// very slow -- use it as few as possible !
|
||||
///
|
||||
/// \param timeout : Maximum time to wait, in seconds (use 0 for no timeout)
|
||||
/// \param timeout : Maximum time to wait, in milliseconds (use 0 for no timeout)
|
||||
///
|
||||
/// \return Public IP address
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfIpAddress sfIpAddress_GetPublicAddress(float timeout);
|
||||
CSFML_API sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the computer's loopback address
|
||||
|
@ -94,12 +94,12 @@ CSFML_API void sfSocketSelector_Clear(sfSocketSelector* selector);
|
||||
/// is ready, or when the given timeout is over
|
||||
///
|
||||
/// \param selector : Selector to check
|
||||
/// \param timeout : Maximum time to wait, in seconds (0 to disable timeout)
|
||||
/// \param timeout : Maximum time to wait, in milliseconds (0 to disable timeout)
|
||||
///
|
||||
/// \return sfTrue if there are sockets ready, sfFalse otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfBool sfSocketSelector_Wait(sfSocketSelector* selector, float timeout);
|
||||
CSFML_API sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Test a socket to know if it is ready to receive data
|
||||
|
@ -106,12 +106,12 @@ CSFML_API unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket);
|
||||
/// \param socket : Socket to connect
|
||||
/// \param host : IP Address of the host to connect to
|
||||
/// \param port : Port to use for transfers (warning : ports < 1024 are reserved)
|
||||
/// \param timeout : Maximum time to wait (0 to use no timeout)
|
||||
/// \param timeout : Maximum time to wait, in milliseconds (0 to use no timeout)
|
||||
///
|
||||
/// \return sfTrue if operation has been successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, float timeout);
|
||||
CSFML_API sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Disconnect a connect from its remote peer
|
||||
|
@ -63,8 +63,10 @@ CSFML_API void sfClock_Destroy(sfClock* clock);
|
||||
///
|
||||
/// \param clock : Clock to get time from
|
||||
///
|
||||
/// \return Elapsed time, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfClock_GetTime(const sfClock* clock);
|
||||
CSFML_API sfUint32 sfClock_GetTime(const sfClock* clock);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Restart a clock
|
||||
|
@ -32,12 +32,12 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make the current thread sleep for a given time
|
||||
/// Make the current thread sleep for a given duration
|
||||
///
|
||||
/// \param duration : Time to sleep, in seconds
|
||||
/// \param duration : Time to sleep, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfSleep(float duration);
|
||||
CSFML_API void sfSleep(sfUint32 duration);
|
||||
|
||||
|
||||
#endif // SFML_SLEEP_H
|
||||
|
@ -290,10 +290,10 @@ CSFML_API void sfWindow_SetFramerateLimit(sfWindow* window, unsigned int limit);
|
||||
///
|
||||
/// \param window : Window object
|
||||
///
|
||||
/// \return Time elapsed, in seconds
|
||||
/// \return Time elapsed, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API float sfWindow_GetFrameTime(const sfWindow* window);
|
||||
CSFML_API sfUint32 sfWindow_GetFrameTime(const sfWindow* window);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the joystick threshold, ie. the value below which
|
||||
|
@ -94,9 +94,9 @@ sfBool sfMusic_GetLoop(const sfMusic* music)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a music duration
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfMusic_GetDuration(const sfMusic* music)
|
||||
sfUint32 sfMusic_GetDuration(const sfMusic* music)
|
||||
{
|
||||
CSFML_CALL_RETURN(music, GetDuration(), 0.f);
|
||||
CSFML_CALL_RETURN(music, GetDuration(), 0);
|
||||
}
|
||||
|
||||
|
||||
@ -159,9 +159,9 @@ sfSoundStatus sfMusic_GetStatus(const sfMusic* music)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current playing position of a music
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfMusic_GetPlayingOffset(const sfMusic* music)
|
||||
sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music)
|
||||
{
|
||||
CSFML_CALL_RETURN(music, GetPlayingOffset(), 0.f);
|
||||
CSFML_CALL_RETURN(music, GetPlayingOffset(), 0);
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ void sfMusic_SetAttenuation(sfMusic* music, float attenuation)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the current playing position of a stream
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfMusic_SetPlayingOffset(sfMusic* music, float timeOffset)
|
||||
void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset)
|
||||
{
|
||||
CSFML_CALL(music, SetPlayingOffset(timeOffset));
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void sfSound_SetAttenuation(sfSound* sound, float attenuation)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the current playing position of a sound
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSound_SetPlayingOffset(sfSound* sound, float timeOffset)
|
||||
void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset)
|
||||
{
|
||||
CSFML_CALL(sound, SetPlayingOffset(timeOffset));
|
||||
}
|
||||
@ -271,7 +271,7 @@ float sfSound_GetAttenuation(const sfSound* sound)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current playing position of a sound
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfSound_GetPlayingOffset(const sfSound* sound)
|
||||
sfUint32 sfSound_GetPlayingOffset(const sfSound* sound)
|
||||
{
|
||||
CSFML_CALL_RETURN(sound, GetPlayingOffset(), 0.f)
|
||||
CSFML_CALL_RETURN(sound, GetPlayingOffset(), 0)
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the duration of a sound buffer
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer)
|
||||
sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer)
|
||||
{
|
||||
CSFML_CALL_RETURN(soundBuffer, GetDuration(), 0.f)
|
||||
CSFML_CALL_RETURN(soundBuffer, GetDuration(), 0)
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the current playing position of a stream
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, float timeOffset)
|
||||
void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset)
|
||||
{
|
||||
CSFML_CALL(soundStream, SetPlayingOffset(timeOffset));
|
||||
}
|
||||
@ -259,7 +259,7 @@ sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current playing position of a sound stream
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream)
|
||||
sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream)
|
||||
{
|
||||
CSFML_CALL_RETURN(soundStream, GetPlayingOffset(), 0.f);
|
||||
CSFML_CALL_RETURN(soundStream, GetPlayingOffset(), 0);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ private :
|
||||
return Continue;
|
||||
}
|
||||
|
||||
virtual void OnSeek(float TimeOffset)
|
||||
virtual void OnSeek(sfUint32 TimeOffset)
|
||||
{
|
||||
if (mySeekCallback)
|
||||
mySeekCallback(TimeOffset, myUserData);
|
||||
|
@ -343,9 +343,9 @@ void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get time elapsed since last frame of a window
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow)
|
||||
sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow)
|
||||
{
|
||||
CSFML_CALL_RETURN(renderWindow, GetFrameTime(), 0.f);
|
||||
CSFML_CALL_RETURN(renderWindow, GetFrameTime(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -208,7 +208,7 @@ void sfFtp_Destroy(sfFtp* ftp)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Connect to the specified FTP server
|
||||
////////////////////////////////////////////////////////////
|
||||
sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, float timeout)
|
||||
sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfUint32 timeout)
|
||||
{
|
||||
CSFML_CHECK_RETURN(ftp, NULL);
|
||||
|
||||
|
@ -201,7 +201,7 @@ void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short port)
|
||||
/// not return instantly; use a thread if you don't want to block your
|
||||
/// application.
|
||||
////////////////////////////////////////////////////////////
|
||||
sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, float timeout)
|
||||
sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout)
|
||||
{
|
||||
CSFML_CHECK_RETURN(http, NULL);
|
||||
CSFML_CHECK_RETURN(request, NULL);
|
||||
|
@ -114,7 +114,7 @@ sfIpAddress sfIpAddress_GetLocalAddress(void)
|
||||
/// distant website ; as a consequence, this function may be
|
||||
/// very slow -- use it as few as possible !
|
||||
////////////////////////////////////////////////////////////
|
||||
sfIpAddress sfIpAddress_GetPublicAddress(float timeout)
|
||||
sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout)
|
||||
{
|
||||
return FromSFMLAddress(sf::IpAddress::GetPublicAddress(timeout));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void sfSocketSelector_Clear(sfSocketSelector* selector)
|
||||
/// This functions will return either when at least one socket
|
||||
/// is ready, or when the given timeout is over
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBool sfSocketSelector_Wait(sfSocketSelector* selector, float timeout)
|
||||
sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout)
|
||||
{
|
||||
CSFML_CALL_RETURN(selector, Wait(timeout), sfFalse);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Connect a TCP socket to another computer on a specified port
|
||||
////////////////////////////////////////////////////////////
|
||||
sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, float timeout)
|
||||
sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout)
|
||||
{
|
||||
sf::IpAddress address(host.Address);
|
||||
|
||||
|
@ -62,9 +62,9 @@ void sfClock_Destroy(sfClock* clock)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the time elapsed for a clock
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfClock_GetTime(const sfClock* clock)
|
||||
sfUint32 sfClock_GetTime(const sfClock* clock)
|
||||
{
|
||||
CSFML_CALL_RETURN(clock, GetElapsedTime(), 0.f)
|
||||
CSFML_CALL_RETURN(clock, GetElapsedTime(), 0)
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,9 +31,9 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make the current thread sleep for a given time
|
||||
/// Make the current thread sleep for a given duration
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSleep(float Duration)
|
||||
void sfSleep(sfUint32 Duration)
|
||||
{
|
||||
sf::Sleep(Duration);
|
||||
}
|
||||
|
@ -317,9 +317,9 @@ void sfWindow_SetFramerateLimit(sfWindow* window, unsigned int limit)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get time elapsed since last frame of a window
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfWindow_GetFrameTime(const sfWindow* window)
|
||||
sfUint32 sfWindow_GetFrameTime(const sfWindow* window)
|
||||
{
|
||||
CSFML_CALL_RETURN(window, GetFrameTime(), 0.f)
|
||||
CSFML_CALL_RETURN(window, GetFrameTime(), 0)
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace opengl
|
||||
float y = -window.Input.GetMouseY() * 200.0F / window.Height + 100.0F;
|
||||
|
||||
// Apply some transformations
|
||||
time += window.GetFrameTime();
|
||||
time += window.GetFrameTime() / 1000.0F;
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glLoadIdentity();
|
||||
Gl.glTranslatef(x, y, -100.0F);
|
||||
|
@ -74,7 +74,7 @@ Module OpenGL
|
||||
Dim y = -window.Input.GetMouseY() * 200.0F / window.Height + 100.0F
|
||||
|
||||
' Apply some transformations
|
||||
time += window.GetFrameTime()
|
||||
time += window.GetFrameTime() / 1000.0F
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW)
|
||||
Gl.glLoadIdentity()
|
||||
Gl.glTranslatef(x, y, -100.0F)
|
||||
|
@ -50,7 +50,7 @@ namespace window
|
||||
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Apply some transformations
|
||||
time += window.GetFrameTime();
|
||||
time += window.GetFrameTime() / 1000.0F;
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glLoadIdentity();
|
||||
Gl.glTranslatef(0.0F, 0.0F, -200.0F);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -113,10 +113,10 @@ namespace SFML
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Total duration of the music, in seconds
|
||||
/// Total duration of the music, in milliseconds
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public float Duration
|
||||
public uint Duration
|
||||
{
|
||||
get {return sfMusic_GetDuration(This);}
|
||||
}
|
||||
@ -206,10 +206,10 @@ namespace SFML
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Current playing position, in seconds
|
||||
/// Current playing position, in milliseconds
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public float PlayingOffset
|
||||
public uint PlayingOffset
|
||||
{
|
||||
get {return sfMusic_GetPlayingOffset(This);}
|
||||
set {sfMusic_SetPlayingOffset(This, value);}
|
||||
@ -272,7 +272,7 @@ namespace SFML
|
||||
static extern SoundStatus sfMusic_GetStatus(IntPtr Music);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfMusic_GetDuration(IntPtr Music);
|
||||
static extern uint sfMusic_GetDuration(IntPtr Music);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern uint sfMusic_GetChannelsCount(IntPtr Music);
|
||||
@ -302,7 +302,7 @@ namespace SFML
|
||||
static extern void sfMusic_SetAttenuation(IntPtr Music, float Attenuation);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfMusic_SetPlayingOffset(IntPtr Music, float TimeOffset);
|
||||
static extern void sfMusic_SetPlayingOffset(IntPtr Music, uint TimeOffset);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern bool sfMusic_GetLoop(IntPtr Music);
|
||||
@ -326,7 +326,7 @@ namespace SFML
|
||||
static extern float sfMusic_GetAttenuation(IntPtr Music);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfMusic_GetPlayingOffset(IntPtr Music);
|
||||
static extern uint sfMusic_GetPlayingOffset(IntPtr Music);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -151,10 +151,10 @@ namespace SFML
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Current playing position of the sound, in seconds
|
||||
/// Current playing position of the sound, in milliseconds
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public float PlayingOffset
|
||||
public uint PlayingOffset
|
||||
{
|
||||
get {return sfSound_GetPlayingOffset(This);}
|
||||
set {sfSound_SetPlayingOffset(This, value);}
|
||||
@ -297,7 +297,7 @@ namespace SFML
|
||||
static extern void sfSound_SetAttenuation(IntPtr Sound, float Attenuation);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfSound_SetPlayingOffset(IntPtr Sound, float TimeOffset);
|
||||
static extern void sfSound_SetPlayingOffset(IntPtr Sound, uint TimeOffset);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfSound_GetPitch(IntPtr Sound);
|
||||
@ -318,7 +318,7 @@ namespace SFML
|
||||
static extern float sfSound_GetAttenuation(IntPtr Sound);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfSound_GetPlayingOffset(IntPtr Sound);
|
||||
static extern uint sfSound_GetPlayingOffset(IntPtr Sound);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -122,10 +122,10 @@ namespace SFML
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Total duration of the buffer, in seconds
|
||||
/// Total duration of the buffer, in milliseconds
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public float Duration
|
||||
public uint Duration
|
||||
{
|
||||
get {return sfSoundBuffer_GetDuration(This);}
|
||||
}
|
||||
@ -202,7 +202,7 @@ namespace SFML
|
||||
static extern uint sfSoundBuffer_GetChannelsCount(IntPtr SoundBuffer);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfSoundBuffer_GetDuration(IntPtr SoundBuffer);
|
||||
static extern uint sfSoundBuffer_GetDuration(IntPtr SoundBuffer);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -171,10 +171,10 @@ namespace SFML
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Current playing position, in seconds
|
||||
/// Current playing position, in milliseconds
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public float PlayingOffset
|
||||
public uint PlayingOffset
|
||||
{
|
||||
get {return sfSoundStream_GetPlayingOffset(This);}
|
||||
set {sfSoundStream_SetPlayingOffset(This, value);}
|
||||
@ -229,9 +229,9 @@ namespace SFML
|
||||
/// <summary>
|
||||
/// Virtual function called to seek into the stream
|
||||
/// </summary>
|
||||
/// <param name="timeOffset">New position, expressed in seconds</param>
|
||||
/// <param name="timeOffset">New position, in milliseconds</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
protected abstract void OnSeek(float timeOffset);
|
||||
protected abstract void OnSeek(uint timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
@ -289,11 +289,11 @@ namespace SFML
|
||||
/// <summary>
|
||||
/// Called to seek in the stream
|
||||
/// </summary>
|
||||
/// <param name="timeOffset">New position, expressed in seconds</param>
|
||||
/// <param name="timeOffset">New position, in milliseconds</param>
|
||||
/// <param name="userData">User data -- unused</param>
|
||||
/// <returns>If false is returned, the playback is aborted</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
private void Seek(float timeOffset, IntPtr userData)
|
||||
private void Seek(uint timeOffset, IntPtr userData)
|
||||
{
|
||||
OnSeek(timeOffset);
|
||||
}
|
||||
@ -302,7 +302,7 @@ namespace SFML
|
||||
private delegate bool GetDataCallbackType(ref Chunk dataChunk, IntPtr UserData);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate void SeekCallbackType(float timeOffset, IntPtr UserData);
|
||||
private delegate void SeekCallbackType(uint timeOffset, IntPtr UserData);
|
||||
|
||||
private GetDataCallbackType myGetDataCallback;
|
||||
private SeekCallbackType mySeekCallback;
|
||||
@ -355,7 +355,7 @@ namespace SFML
|
||||
static extern void sfSoundStream_SetAttenuation(IntPtr SoundStream, float Attenuation);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfSoundStream_SetPlayingOffset(IntPtr SoundStream, float TimeOffset);
|
||||
static extern void sfSoundStream_SetPlayingOffset(IntPtr SoundStream, uint TimeOffset);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern bool sfSoundStream_GetLoop(IntPtr SoundStream);
|
||||
@ -379,7 +379,7 @@ namespace SFML
|
||||
static extern float sfSoundStream_GetAttenuation(IntPtr SoundStream);
|
||||
|
||||
[DllImport("csfml-audio-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfSoundStream_GetPlayingOffset(IntPtr SoundStream);
|
||||
static extern uint sfSoundStream_GetPlayingOffset(IntPtr SoundStream);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ namespace SFML
|
||||
/// </summary>
|
||||
/// <returns>Time elapsed, in seconds</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public override float GetFrameTime()
|
||||
public override uint GetFrameTime()
|
||||
{
|
||||
return sfRenderWindow_GetFrameTime(This);
|
||||
}
|
||||
@ -605,7 +605,7 @@ namespace SFML
|
||||
static extern void sfRenderWindow_SetFramerateLimit(IntPtr This, uint Limit);
|
||||
|
||||
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfRenderWindow_GetFrameTime(IntPtr This);
|
||||
static extern uint sfRenderWindow_GetFrameTime(IntPtr This);
|
||||
|
||||
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfRenderWindow_SetJoystickThreshold(IntPtr This, float Threshold);
|
||||
|
@ -333,9 +333,9 @@ namespace SFML
|
||||
/// <summary>
|
||||
/// Get time elapsed since last frame
|
||||
/// </summary>
|
||||
/// <returns>Time elapsed, in seconds</returns>
|
||||
/// <returns>Time elapsed, in milliseconds</returns>
|
||||
////////////////////////////////////////////////////////////
|
||||
public virtual float GetFrameTime()
|
||||
public virtual uint GetFrameTime()
|
||||
{
|
||||
return sfWindow_GetFrameTime(This);
|
||||
}
|
||||
@ -662,7 +662,7 @@ namespace SFML
|
||||
static extern void sfWindow_SetFramerateLimit(IntPtr This, uint Limit);
|
||||
|
||||
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern float sfWindow_GetFrameTime(IntPtr This);
|
||||
static extern uint sfWindow_GetFrameTime(IntPtr This);
|
||||
|
||||
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||
static extern void sfWindow_SetJoystickThreshold(IntPtr This, float Threshold);
|
||||
|
@ -97,9 +97,9 @@ int main()
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(x, y, -100.f);
|
||||
glRotatef(clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.05f, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.03f, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.09f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Draw a cube
|
||||
float size = 20.f;
|
||||
|
@ -17,7 +17,7 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
std::srand(std::time(NULL));
|
||||
std::srand(static_cast<unsigned int>(std::time(NULL)));
|
||||
|
||||
// Defines PI
|
||||
const float PI = 3.14159f;
|
||||
@ -100,15 +100,15 @@ int main()
|
||||
{
|
||||
// Move the player's paddle
|
||||
if (window.GetInput().IsKeyDown(sf::Key::Up) && (leftPaddle.GetPosition().y > 5.f))
|
||||
leftPaddle.Move(0.f, -leftPaddleSpeed * window.GetFrameTime());
|
||||
leftPaddle.Move(0.f, -leftPaddleSpeed * window.GetFrameTime() / 1000.f);
|
||||
if (window.GetInput().IsKeyDown(sf::Key::Down) && (leftPaddle.GetPosition().y < window.GetView().GetSize().y - leftPaddle.GetSize().y - 5.f))
|
||||
leftPaddle.Move(0.f, leftPaddleSpeed * window.GetFrameTime());
|
||||
leftPaddle.Move(0.f, leftPaddleSpeed * window.GetFrameTime() / 1000.f);
|
||||
|
||||
// Move the computer's paddle
|
||||
if (((rightPaddleSpeed < 0.f) && (rightPaddle.GetPosition().y > 5.f)) ||
|
||||
((rightPaddleSpeed > 0.f) && (rightPaddle.GetPosition().y < window.GetView().GetSize().y - rightPaddle.GetSize().y - 5.f)))
|
||||
{
|
||||
rightPaddle.Move(0.f, rightPaddleSpeed * window.GetFrameTime());
|
||||
rightPaddle.Move(0.f, rightPaddleSpeed * window.GetFrameTime() / 1000.f);
|
||||
}
|
||||
|
||||
// Update the computer's paddle direction according to the ball position
|
||||
@ -122,7 +122,7 @@ int main()
|
||||
}
|
||||
|
||||
// Move the ball
|
||||
float factor = ballSpeed * window.GetFrameTime();
|
||||
float factor = ballSpeed * window.GetFrameTime() / 1000.f;
|
||||
ball.Move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
||||
|
||||
// Check collisions between the ball and the screen
|
||||
|
@ -214,10 +214,10 @@ test.Create(800, 600);
|
||||
globalShader.Update(mouseX, mouseY);
|
||||
|
||||
// Animate the entity
|
||||
float entityX = (cos(clock.GetElapsedTime() * 1.3f) + 1.2f) * 300;
|
||||
float entityY = (cos(clock.GetElapsedTime() * 0.8f) + 1.2f) * 200;
|
||||
float entityX = (cos(clock.GetElapsedTime() * 0.0013f) + 1.2f) * 300;
|
||||
float entityY = (cos(clock.GetElapsedTime() * 0.0008f) + 1.2f) * 200;
|
||||
entity.SetPosition(entityX, entityY);
|
||||
entity.Rotate(window.GetFrameTime() * 100);
|
||||
entity.Rotate(window.GetFrameTime() * 0.1f);
|
||||
|
||||
// Draw the background and the moving entity to the render image
|
||||
image.Clear();
|
||||
|
@ -20,9 +20,9 @@ void PlaySound()
|
||||
|
||||
// Display sound informations
|
||||
std::cout << "canary.wav :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() << " sec" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
|
||||
// Create a sound instance and play it
|
||||
sf::Sound sound(buffer);
|
||||
@ -32,7 +32,7 @@ void PlaySound()
|
||||
while (sound.GetStatus() == sf::Sound::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.GetPlayingOffset() << " sec ";
|
||||
@ -54,9 +54,9 @@ void PlayMusic()
|
||||
|
||||
// Display music informations
|
||||
std::cout << "orchestral.ogg :" << std::endl;
|
||||
std::cout << " " << music.GetDuration() << " sec" << std::endl;
|
||||
std::cout << " " << music.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << music.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << music.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.GetChannelsCount() << " channels" << std::endl;
|
||||
|
||||
// Play it
|
||||
music.Play();
|
||||
@ -65,7 +65,7 @@ void PlayMusic()
|
||||
while (music.GetStatus() == sf::Music::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.GetPlayingOffset() << " sec ";
|
||||
|
@ -46,9 +46,9 @@ int main()
|
||||
|
||||
// Display captured sound informations
|
||||
std::cout << "Sound information :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
|
||||
// Choose what to do with the recorded sound data
|
||||
char choice;
|
||||
@ -79,7 +79,7 @@ int main()
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.GetPlayingOffset() << " sec";
|
||||
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ private :
|
||||
|
||||
// No new data has arrived since last update : wait until we get some
|
||||
while ((myOffset >= mySamples.size()) && !myHasFinished)
|
||||
sf::Sleep(0.01f);
|
||||
sf::Sleep(10);
|
||||
|
||||
// Copy samples into a local buffer to avoid synchronization problems
|
||||
// (don't forget that we run in two separate threads)
|
||||
@ -101,9 +101,9 @@ private :
|
||||
/// /see SoundStream::OnSeek
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(float timeOffset)
|
||||
virtual void OnSeek(sf::Uint32 timeOffset)
|
||||
{
|
||||
myOffset = static_cast<std::size_t>(timeOffset * GetSampleRate() * GetChannelsCount());
|
||||
myOffset = timeOffset * GetSampleRate() * GetChannelsCount() / 1000;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -179,7 +179,7 @@ void DoServer(unsigned short port)
|
||||
while (audioStream.GetStatus() != sf::SoundStream::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
}
|
||||
|
||||
std::cin.ignore(10000, '\n');
|
||||
@ -195,6 +195,6 @@ void DoServer(unsigned short port)
|
||||
while (audioStream.GetStatus() != sf::SoundStream::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
}
|
||||
}
|
||||
|
@ -105,11 +105,11 @@ INT WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
|
||||
SFMLView2.Clear();
|
||||
|
||||
// Draw sprite 1 on view 1
|
||||
sprite1.SetRotation(clock.GetElapsedTime() * 100);
|
||||
sprite1.SetRotation(clock.GetElapsedTime() * 0.1f);
|
||||
SFMLView1.Draw(sprite1);
|
||||
|
||||
// Draw sprite 2 on view 2
|
||||
sprite2.SetX(cos(clock.GetElapsedTime()) * 100);
|
||||
sprite2.SetX(cos(clock.GetElapsedTime() * 0.001f) * 100.f);
|
||||
SFMLView2.Draw(sprite2);
|
||||
|
||||
// Display each view on screen
|
||||
|
@ -65,9 +65,9 @@ int main()
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.f, 0.f, -200.f);
|
||||
glRotatef(clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.05f, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.03f, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.09f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Draw a cube
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -101,10 +101,10 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total duration of the music
|
||||
///
|
||||
/// \return Music duration, in seconds
|
||||
/// \return Music duration, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetDuration() const;
|
||||
Uint32 GetDuration() const;
|
||||
|
||||
protected :
|
||||
|
||||
@ -124,10 +124,10 @@ protected :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current playing position in the stream source
|
||||
///
|
||||
/// \param timeOffset New playing position, in seconds
|
||||
/// \param timeOffset New playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(float timeOffset);
|
||||
virtual void OnSeek(Uint32 timeOffset);
|
||||
|
||||
private :
|
||||
|
||||
@ -135,7 +135,7 @@ private :
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::SoundFile* myFile; ///< Sound file
|
||||
float myDuration; ///< Music duration, in seconds
|
||||
Uint32 myDuration; ///< Music duration, in milliseconds
|
||||
std::vector<Int16> mySamples; ///< Temporary buffer of samples
|
||||
Mutex myMutex; ///< Mutex protecting the data
|
||||
};
|
||||
|
@ -149,12 +149,12 @@ public :
|
||||
/// The playing position can be changed when the sound is
|
||||
/// either paused or playing.
|
||||
///
|
||||
/// \param timeOffset New playing position, in seconds
|
||||
/// \param timeOffset New playing position, in milliseconds
|
||||
///
|
||||
/// \see GetPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPlayingOffset(float timeOffset);
|
||||
void SetPlayingOffset(Uint32 timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the audio buffer attached to the sound
|
||||
@ -177,12 +177,12 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current playing position of the sound
|
||||
///
|
||||
/// \return Current playing position, in seconds
|
||||
/// \return Current playing position, in milliseconds
|
||||
///
|
||||
/// \see SetPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetPlayingOffset() const;
|
||||
Uint32 GetPlayingOffset() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current status of the sound (stopped, paused, playing)
|
||||
|
@ -191,12 +191,12 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total duration of the sound
|
||||
///
|
||||
/// \return Sound duration, in seconds
|
||||
/// \return Sound duration, in milliseconds
|
||||
///
|
||||
/// \see GetSampleRate, GetChannelsCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetDuration() const;
|
||||
Uint32 GetDuration() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
@ -249,7 +249,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int myBuffer; ///< OpenAL buffer identifier
|
||||
std::vector<Int16> mySamples; ///< Samples buffer
|
||||
float myDuration; ///< Sound duration, in seconds
|
||||
Uint32 myDuration; ///< Sound duration, in milliseconds
|
||||
mutable SoundList mySounds; ///< List of sounds that are using this buffer
|
||||
};
|
||||
|
||||
|
@ -131,22 +131,22 @@ public :
|
||||
/// The playing position can be changed when the stream is
|
||||
/// either paused or playing.
|
||||
///
|
||||
/// \param timeOffset New playing position, in seconds
|
||||
/// \param timeOffset New playing position, in milliseconds
|
||||
///
|
||||
/// \see GetPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPlayingOffset(float timeOffset);
|
||||
void SetPlayingOffset(Uint32 timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current playing position of the stream
|
||||
///
|
||||
/// \return Current playing position, in seconds
|
||||
/// \return Current playing position, in milliseconds
|
||||
///
|
||||
/// \see SetPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetPlayingOffset() const;
|
||||
Uint32 GetPlayingOffset() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set whether or not the stream should loop after reaching the end
|
||||
@ -232,10 +232,10 @@ private :
|
||||
/// This function must be overriden by derived classes to
|
||||
/// allow random seeking into the stream source.
|
||||
///
|
||||
/// \param timeOffset New playing position, in seconds
|
||||
/// \param timeOffset New playing position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(float timeOffset) = 0;
|
||||
virtual void OnSeek(Uint32 timeOffset) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Fill a new buffer with audio samples, and append
|
||||
@ -357,7 +357,7 @@ private :
|
||||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// virtual void OnSeek(float timeOffset)
|
||||
/// virtual void OnSeek(Uint32 timeOffset)
|
||||
/// {
|
||||
/// // Change the current position in the stream source
|
||||
/// ...
|
||||
|
@ -134,44 +134,31 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Define portable fixed-size types
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <climits>
|
||||
|
||||
namespace sf
|
||||
{
|
||||
// All "common" platforms use the same size for char, short and int
|
||||
// (basically there are 3 types for 3 sizes, so no other match is possible),
|
||||
// we can use them without doing any kind of check
|
||||
|
||||
// 8 bits integer types
|
||||
#if UCHAR_MAX == 0xFF
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char Uint8;
|
||||
#else
|
||||
#error No 8 bits integer type for this platform
|
||||
#endif
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char Uint8;
|
||||
|
||||
// 16 bits integer types
|
||||
#if USHRT_MAX == 0xFFFF
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short Uint16;
|
||||
#elif UINT_MAX == 0xFFFF
|
||||
typedef signed int Int16;
|
||||
typedef unsigned int Uint16;
|
||||
#elif ULONG_MAX == 0xFFFF
|
||||
typedef signed long Int16;
|
||||
typedef unsigned long Uint16;
|
||||
#else
|
||||
#error No 16 bits integer type for this platform
|
||||
#endif
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short Uint16;
|
||||
|
||||
// 32 bits integer types
|
||||
#if USHRT_MAX == 0xFFFFFFFF
|
||||
typedef signed short Int32;
|
||||
typedef unsigned short Uint32;
|
||||
#elif UINT_MAX == 0xFFFFFFFF
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int Uint32;
|
||||
#elif ULONG_MAX == 0xFFFFFFFF
|
||||
typedef signed long Int32;
|
||||
typedef unsigned long Uint32;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int Uint32;
|
||||
|
||||
// 64 bits integer types
|
||||
#if defined(_MSC_VER)
|
||||
typedef signed __int64 Int64;
|
||||
typedef unsigned __int64 Uint64;
|
||||
#else
|
||||
#error No 32 bits integer type for this platform
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long Uint64;
|
||||
#endif
|
||||
|
||||
} // namespace sf
|
||||
|
@ -269,14 +269,14 @@ public :
|
||||
///
|
||||
/// \param server Name or address of the FTP server to connect to
|
||||
/// \param port Port used for the connection
|
||||
/// \param timeout Maximum time to wait, in seconds
|
||||
/// \param timeout Maximum time to wait, in milliseconds
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Disconnect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Connect(const IpAddress& server, unsigned short port = 21, float timeout = 0.f);
|
||||
Response Connect(const IpAddress& server, unsigned short port = 21, Uint32 timeout = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the connection with the server
|
||||
|
@ -381,12 +381,12 @@ public :
|
||||
/// (which is usually pretty long).
|
||||
///
|
||||
/// \param request Request to send
|
||||
/// \param timeout Maximum time to wait, in seconds
|
||||
/// \param timeout Maximum time to wait, in milliseconds
|
||||
///
|
||||
/// \return Server's response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response SendRequest(const Request& request, float timeout = 0.f);
|
||||
Response SendRequest(const Request& request, Uint32 timeout = 0);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -168,14 +168,14 @@ public :
|
||||
/// to be possibly stuck waiting in case there is a problem; this
|
||||
/// limit is deactivated by default.
|
||||
///
|
||||
/// \param timeout Maximum time to wait, in seconds
|
||||
/// \param timeout Maximum time to wait, in milliseconds
|
||||
///
|
||||
/// \return Public IP address of the computer
|
||||
///
|
||||
/// \see GetLocalAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static IpAddress GetPublicAddress(float timeout = 0.f);
|
||||
static IpAddress GetPublicAddress(Uint32 timeout = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static member data
|
||||
|
@ -111,14 +111,14 @@ public :
|
||||
/// If you use a timeout and no socket is ready before the timeout
|
||||
/// is over, the function returns false.
|
||||
///
|
||||
/// \param timeout Maximum time to wait (use 0 for infinity)
|
||||
/// \param timeout Maximum time to wait, in milliseconds (use 0 for infinity)
|
||||
///
|
||||
/// \return True if there are sockets ready, false otherwise
|
||||
///
|
||||
/// \see IsReady
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Wait(float timeout = 0.f);
|
||||
bool Wait(Uint32 timeout = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Test a socket to know if it is ready to receive data
|
||||
|
@ -99,14 +99,14 @@ public :
|
||||
///
|
||||
/// \param remoteAddress Address of the remote peer
|
||||
/// \param remotePort Port of the remote peer
|
||||
/// \param timeout Optional maximum time to wait, in seconds
|
||||
/// \param timeout Optional maximum time to wait, in milliseconds
|
||||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Disconnect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, float timeout = 0.f);
|
||||
Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, Uint32 timeout = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Disconnect the connect from its remote peer
|
||||
|
@ -54,12 +54,12 @@ public :
|
||||
///
|
||||
/// This function returns the time elapsed since the last call
|
||||
/// to Reset() (or the construction of the instance if Reset()
|
||||
/// has not been called) in seconds.
|
||||
/// has not been called).
|
||||
///
|
||||
/// \return Time elapsed, in seconds
|
||||
/// \return Time elapsed, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetElapsedTime() const;
|
||||
Uint32 GetElapsedTime() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Restart the timer
|
||||
@ -74,7 +74,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
double myStartTime; ///< Time of last reset
|
||||
Uint64 myStartTime; ///< Time of last reset
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
@ -95,10 +95,10 @@ private :
|
||||
/// \code
|
||||
/// sf::Clock clock;
|
||||
/// ...
|
||||
/// float time1 = clock.GetElapsedTime();
|
||||
/// Uint32 time1 = clock.GetElapsedTime();
|
||||
/// clock.Reset();
|
||||
/// ...
|
||||
/// float time2 = clock.GetElapsedTime();
|
||||
/// Uint32 time2 = clock.GetElapsedTime();
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -35,15 +35,15 @@ namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \ingroup system
|
||||
/// \brief Make the current thread sleep for a given time
|
||||
/// \brief Make the current thread sleep for a given duration
|
||||
///
|
||||
/// sf::Sleep is the best way to block a program or one of its
|
||||
/// threads, as it doesn't consume any CPU power.
|
||||
///
|
||||
/// \param duration Time to sleep, in seconds (must be positive)
|
||||
/// \param duration Time to sleep, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SFML_API Sleep(float duration);
|
||||
void SFML_API Sleep(Uint32 duration);
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
@ -188,7 +188,7 @@ private :
|
||||
/// const sf::Input& input = window.GetInput();
|
||||
///
|
||||
/// // Move an entity according to the current keys state
|
||||
/// float offset = 5 * window.GetFrameTime(); // 5 pixels/sec
|
||||
/// float offset = 5.f * window.GetFrameTime(); // 5 pixels/sec
|
||||
/// if (input.IsKeyDown(sf::Key::Left)) entity.Move(-offset, 0);
|
||||
/// if (input.IsKeyDown(sf::Key::Right)) entity.Move( offset, 0);
|
||||
/// if (input.IsKeyDown(sf::Key::Up)) entity.Move(0, -offset);
|
||||
|
@ -415,10 +415,10 @@ public :
|
||||
/// This can be useful for calculating the framerate, or for
|
||||
/// updating the application's objects.
|
||||
///
|
||||
/// \return Time elapsed in last frame, in seconds
|
||||
/// \return Time elapsed in last frame, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetFrameTime() const;
|
||||
Uint32 GetFrameTime() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the joystick threshold
|
||||
@ -495,7 +495,7 @@ private :
|
||||
priv::GlContext* myContext; ///< Platform-specific implementation of the OpenGL context
|
||||
Input myInput; ///< Input manager connected to window
|
||||
Clock myClock; ///< Clock for measuring the elapsed time between frames
|
||||
float myLastFrameTime; ///< Time elapsed since last frame
|
||||
Uint32 myLastFrameTime; ///< Time elapsed since last frame
|
||||
unsigned int myFramerateLimit; ///< Current framerate limit
|
||||
int mySetCursorPosX; ///< X coordinate passed to the last call to SetCursorPosition
|
||||
int mySetCursorPosY; ///< Y coordinate passed to the last call to SetCursorPosition
|
||||
|
@ -38,7 +38,7 @@ namespace sf
|
||||
////////////////////////////////////////////////////////////
|
||||
Music::Music() :
|
||||
myFile (new priv::SoundFile),
|
||||
myDuration(0.f)
|
||||
myDuration(0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -68,7 +68,7 @@ bool Music::OpenFromFile(const std::string& filename)
|
||||
}
|
||||
|
||||
// Compute the duration
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
|
||||
myDuration = static_cast<Uint32>(1000 * myFile->GetSamplesCount() / myFile->GetSampleRate() / myFile->GetChannelsCount());
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
|
||||
@ -94,7 +94,7 @@ bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
}
|
||||
|
||||
// Compute the duration
|
||||
myDuration = static_cast<float>(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
|
||||
myDuration = static_cast<Uint32>(1000 * myFile->GetSamplesCount() / myFile->GetSampleRate() / myFile->GetChannelsCount());
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
|
||||
@ -107,7 +107,7 @@ bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float Music::GetDuration() const
|
||||
Uint32 Music::GetDuration() const
|
||||
{
|
||||
return myDuration;
|
||||
}
|
||||
@ -130,7 +130,7 @@ bool Music::OnGetData(SoundStream::Chunk& data)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see SoundStream::OnSeek
|
||||
////////////////////////////////////////////////////////////
|
||||
void Music::OnSeek(float timeOffset)
|
||||
void Music::OnSeek(Uint32 timeOffset)
|
||||
{
|
||||
Lock lock(myMutex);
|
||||
|
||||
|
@ -116,9 +116,9 @@ void Sound::SetLoop(bool Loop)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetPlayingOffset(float timeOffset)
|
||||
void Sound::SetPlayingOffset(Uint32 timeOffset)
|
||||
{
|
||||
ALCheck(alSourcef(mySource, AL_SEC_OFFSET, timeOffset));
|
||||
ALCheck(alSourcef(mySource, AL_SEC_OFFSET, timeOffset / 1000.f));
|
||||
}
|
||||
|
||||
|
||||
@ -140,12 +140,12 @@ bool Sound::GetLoop() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sound::GetPlayingOffset() const
|
||||
Uint32 Sound::GetPlayingOffset() const
|
||||
{
|
||||
ALfloat seconds = 0.f;
|
||||
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
|
||||
|
||||
return seconds;
|
||||
return static_cast<Uint32>(seconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace sf
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundBuffer::SoundBuffer() :
|
||||
myBuffer (0),
|
||||
myDuration(0.f)
|
||||
myDuration(0)
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
|
||||
@ -219,7 +219,7 @@ unsigned int SoundBuffer::GetChannelsCount() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundBuffer::GetDuration() const
|
||||
Uint32 SoundBuffer::GetDuration() const
|
||||
{
|
||||
return myDuration;
|
||||
}
|
||||
@ -261,7 +261,7 @@ bool SoundBuffer::Update(unsigned int channelsCount, unsigned int sampleRate)
|
||||
ALCheck(alBufferData(myBuffer, format, &mySamples[0], size, sampleRate));
|
||||
|
||||
// Compute the duration
|
||||
myDuration = static_cast<float>(mySamples.size()) / sampleRate / channelsCount;
|
||||
myDuration = static_cast<Uint32>(1000 * mySamples.size() / sampleRate / channelsCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -195,11 +195,11 @@ void SoundFile::Write(const Int16* data, std::size_t nbSamples)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundFile::Seek(float timeOffset)
|
||||
void SoundFile::Seek(Uint32 timeOffset)
|
||||
{
|
||||
if (myFile)
|
||||
{
|
||||
sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset * mySampleRate);
|
||||
sf_count_t frameOffset = timeOffset * mySampleRate / 1000;
|
||||
sf_seek(myFile, frameOffset, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position in the file
|
||||
///
|
||||
/// \param timeOffset New read position, in seconds
|
||||
/// \param timeOffset New read position, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Seek(float timeOffset);
|
||||
void Seek(Uint32 timeOffset);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -155,7 +155,7 @@ void SoundRecorder::Record()
|
||||
ProcessCapturedSamples();
|
||||
|
||||
// Don't bother the CPU while waiting for more captured data
|
||||
Sleep(0.1f);
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
// Capture is finished : clean up everything
|
||||
|
@ -150,7 +150,7 @@ SoundStream::Status SoundStream::GetStatus() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::SetPlayingOffset(float timeOffset)
|
||||
void SoundStream::SetPlayingOffset(Uint32 timeOffset)
|
||||
{
|
||||
// Stop the stream
|
||||
Stop();
|
||||
@ -159,19 +159,19 @@ void SoundStream::SetPlayingOffset(float timeOffset)
|
||||
OnSeek(timeOffset);
|
||||
|
||||
// Restart streaming
|
||||
mySamplesProcessed = static_cast<unsigned int>(timeOffset * mySampleRate * myChannelsCount);
|
||||
mySamplesProcessed = timeOffset * mySampleRate * myChannelsCount / 1000;
|
||||
myIsStreaming = true;
|
||||
myThread.Launch();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundStream::GetPlayingOffset() const
|
||||
Uint32 SoundStream::GetPlayingOffset() const
|
||||
{
|
||||
ALfloat seconds = 0.f;
|
||||
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
|
||||
|
||||
return seconds + static_cast<float>(mySamplesProcessed) / mySampleRate / myChannelsCount;
|
||||
return static_cast<Uint32>(1000 * seconds) + 1000 * mySamplesProcessed / mySampleRate / myChannelsCount;
|
||||
}
|
||||
|
||||
|
||||
@ -264,7 +264,7 @@ void SoundStream::Stream()
|
||||
|
||||
// Leave some time for the other threads if the stream is still playing
|
||||
if (SoundSource::GetStatus() != Stopped)
|
||||
Sleep(0.01f);
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
// Stop the playback
|
||||
|
@ -146,7 +146,7 @@ Ftp::~Ftp()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Ftp::Response Ftp::Connect(const IpAddress& server, unsigned short port, float timeout)
|
||||
Ftp::Response Ftp::Connect(const IpAddress& server, unsigned short port, Uint32 timeout)
|
||||
{
|
||||
// Connect to the server
|
||||
if (myCommandSocket.Connect(server, port, timeout) != Socket::Done)
|
||||
|
@ -310,7 +310,7 @@ void Http::SetHost(const std::string& host, unsigned short port)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Http::Response Http::SendRequest(const Http::Request& request, float timeout)
|
||||
Http::Response Http::SendRequest(const Http::Request& request, Uint32 timeout)
|
||||
{
|
||||
// First make sure that the request is valid -- add missing mandatory fields
|
||||
Request toSend(request);
|
||||
|
@ -165,7 +165,7 @@ IpAddress IpAddress::GetLocalAddress()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
IpAddress IpAddress::GetPublicAddress(float timeout)
|
||||
IpAddress IpAddress::GetPublicAddress(Uint32 timeout)
|
||||
{
|
||||
// The trick here is more complicated, because the only way
|
||||
// to get our public IP address is to get it from a distant computer.
|
||||
|
@ -100,18 +100,18 @@ void SocketSelector::Clear()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SocketSelector::Wait(float timeout)
|
||||
bool SocketSelector::Wait(Uint32 timeout)
|
||||
{
|
||||
// Setup the timeout
|
||||
timeval time;
|
||||
time.tv_sec = static_cast<long>(timeout);
|
||||
time.tv_usec = (static_cast<long>(timeout * 1000) % 1000) * 1000;
|
||||
time.tv_sec = timeout / 1000;
|
||||
time.tv_usec = (timeout - time.tv_sec * 1000) * 1000;
|
||||
|
||||
// Initialize the set that will contain the sockets that are ready
|
||||
myImpl->SocketsReady = myImpl->AllSockets;
|
||||
|
||||
// Wait until one of the sockets is ready for reading, or timeout is reached
|
||||
int count = select(myImpl->MaxSocket + 1, &myImpl->SocketsReady, NULL, NULL, timeout > 0 ? &time : NULL);
|
||||
int count = select(myImpl->MaxSocket + 1, &myImpl->SocketsReady, NULL, NULL, timeout != 0 ? &time : NULL);
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ unsigned short TcpSocket::GetRemotePort() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short remotePort, float timeout)
|
||||
Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short remotePort, Uint32 timeout)
|
||||
{
|
||||
// Create the internal socket if it doesn't exist
|
||||
Create();
|
||||
@ -114,7 +114,7 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short
|
||||
// Create the remote address
|
||||
sockaddr_in address = priv::SocketImpl::CreateAddress(remoteAddress.ToInteger(), remotePort);
|
||||
|
||||
if (timeout <= 0)
|
||||
if (timeout == 0)
|
||||
{
|
||||
// ----- We're not using a timeout: just try to connect -----
|
||||
|
||||
@ -160,8 +160,8 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short
|
||||
|
||||
// Setup the timeout
|
||||
timeval time;
|
||||
time.tv_sec = static_cast<long>(timeout);
|
||||
time.tv_usec = (static_cast<long>(timeout * 1000) % 1000) * 1000;
|
||||
time.tv_sec = timeout / 1000;
|
||||
time.tv_usec = (timeout - time.tv_sec * 1000) * 1000;
|
||||
|
||||
// Wait for something to write on our socket (which means that the connection request has returned)
|
||||
if (select(static_cast<int>(GetHandle() + 1), NULL, &selector, NULL, &time) > 0)
|
||||
|
@ -39,9 +39,9 @@ Clock::Clock()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float Clock::GetElapsedTime() const
|
||||
Uint32 Clock::GetElapsedTime() const
|
||||
{
|
||||
return static_cast<float>(priv::Platform::GetSystemTime() - myStartTime);
|
||||
return static_cast<Uint32>(priv::Platform::GetSystemTime() - myStartTime);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,10 +32,9 @@
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sleep(float duration)
|
||||
void Sleep(Uint32 duration)
|
||||
{
|
||||
if (duration >= 0)
|
||||
priv::Platform::Sleep(duration);
|
||||
priv::Platform::Sleep(duration);
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
@ -35,19 +35,19 @@ namespace sf
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
double Platform::GetSystemTime()
|
||||
Uint64 Platform::GetSystemTime()
|
||||
{
|
||||
timeval time = {0, 0};
|
||||
gettimeofday(&time, NULL);
|
||||
|
||||
return time.tv_sec + time.tv_usec / 1000000.;
|
||||
return time.tv_sec * 1000 + time.tv_usec / 1000;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Platform::Sleep(float time)
|
||||
void Platform::Sleep(Uint32 time)
|
||||
{
|
||||
usleep(static_cast<unsigned long>(time * 1000000));
|
||||
usleep(time * 1000);
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
@ -29,7 +29,6 @@
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace sf
|
||||
@ -38,6 +37,7 @@ namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to some system-specific low-level functions
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class Platform
|
||||
{
|
||||
@ -46,18 +46,18 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current system time
|
||||
///
|
||||
/// \return System time, in seconds
|
||||
/// \return System time, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static double GetSystemTime();
|
||||
static Uint64 GetSystemTime();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Suspend the execution of the current thread for a specified time
|
||||
/// \brief Suspend the execution of the current thread for a specified duration
|
||||
///
|
||||
/// \param time Time to sleep, in seconds
|
||||
/// \param time Time to sleep, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void Sleep(float time);
|
||||
static void Sleep(Uint32 time);
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
@ -34,7 +34,7 @@ namespace sf
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
double Platform::GetSystemTime()
|
||||
Uint64 Platform::GetSystemTime()
|
||||
{
|
||||
static LARGE_INTEGER frequency;
|
||||
static BOOL useHighPerformanceTimer = QueryPerformanceFrequency(&frequency);
|
||||
@ -45,20 +45,20 @@ double Platform::GetSystemTime()
|
||||
LARGE_INTEGER currentTime;
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
|
||||
return static_cast<double>(currentTime.QuadPart) / frequency.QuadPart;
|
||||
return currentTime.QuadPart * 1000 / frequency.QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
// High performance counter not available: use GetTickCount (less accurate)
|
||||
return GetTickCount() * 0.001;
|
||||
return GetTickCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Platform::Sleep(float time)
|
||||
void Platform::Sleep(Uint32 time)
|
||||
{
|
||||
::Sleep(static_cast<DWORD>(time * 1000));
|
||||
::Sleep(time);
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
@ -47,18 +47,18 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current system time
|
||||
///
|
||||
/// \return System time, in seconds
|
||||
/// \return System time, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static double GetSystemTime();
|
||||
static Uint64 GetSystemTime();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Suspend the execution of the current thread for a specified time
|
||||
/// \brief Suspend the execution of the current thread for a specified duration
|
||||
///
|
||||
/// \param time Time to sleep, in seconds
|
||||
/// \param time Time to sleep, in milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void Sleep(float time);
|
||||
static void Sleep(Uint32 time);
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
@ -47,7 +47,7 @@ namespace sf
|
||||
Window::Window() :
|
||||
myWindow (NULL),
|
||||
myContext (NULL),
|
||||
myLastFrameTime (0.f),
|
||||
myLastFrameTime (0),
|
||||
myFramerateLimit(0),
|
||||
mySetCursorPosX (0xFFFF),
|
||||
mySetCursorPosY (0xFFFF)
|
||||
@ -60,7 +60,7 @@ mySetCursorPosY (0xFFFF)
|
||||
Window::Window(VideoMode mode, const std::string& title, unsigned long style, const ContextSettings& settings) :
|
||||
myWindow (NULL),
|
||||
myContext (NULL),
|
||||
myLastFrameTime (0.f),
|
||||
myLastFrameTime (0),
|
||||
myFramerateLimit(0),
|
||||
mySetCursorPosX (0xFFFF),
|
||||
mySetCursorPosY (0xFFFF)
|
||||
@ -73,7 +73,7 @@ mySetCursorPosY (0xFFFF)
|
||||
Window::Window(WindowHandle handle, const ContextSettings& settings) :
|
||||
myWindow (NULL),
|
||||
myContext (NULL),
|
||||
myLastFrameTime (0.f),
|
||||
myLastFrameTime (0),
|
||||
myFramerateLimit(0),
|
||||
mySetCursorPosX (0xFFFF),
|
||||
mySetCursorPosY (0xFFFF)
|
||||
@ -337,7 +337,7 @@ void Window::Display()
|
||||
// Limit the framerate if needed
|
||||
if (myFramerateLimit > 0)
|
||||
{
|
||||
float remainingTime = 1.f / myFramerateLimit - myClock.GetElapsedTime();
|
||||
Int32 remainingTime = 1000 / myFramerateLimit - myClock.GetElapsedTime();
|
||||
if (remainingTime > 0)
|
||||
Sleep(remainingTime);
|
||||
}
|
||||
@ -367,7 +367,7 @@ void Window::SetFramerateLimit(unsigned int limit)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float Window::GetFrameTime() const
|
||||
Uint32 Window::GetFrameTime() const
|
||||
{
|
||||
return myLastFrameTime;
|
||||
}
|
||||
@ -437,7 +437,7 @@ void Window::Initialize()
|
||||
|
||||
// Reset frame time
|
||||
myClock.Reset();
|
||||
myLastFrameTime = 0.f;
|
||||
myLastFrameTime = 0;
|
||||
|
||||
// Activate the window
|
||||
SetActive();
|
||||
|
Loading…
Reference in New Issue
Block a user