diff --git a/bindings/c/include/SFML/Audio/Music.h b/bindings/c/include/SFML/Audio/Music.h index 30f48ad05..6077bb3d7 100644 --- a/bindings/c/include/SFML/Audio/Music.h +++ b/bindings/c/include/SFML/Audio/Music.h @@ -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 diff --git a/bindings/c/include/SFML/Audio/Sound.h b/bindings/c/include/SFML/Audio/Sound.h index c7a76b6a0..3c24b6838 100644 --- a/bindings/c/include/SFML/Audio/Sound.h +++ b/bindings/c/include/SFML/Audio/Sound.h @@ -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 diff --git a/bindings/c/include/SFML/Audio/SoundBuffer.h b/bindings/c/include/SFML/Audio/SoundBuffer.h index e72920b53..1b1926268 100644 --- a/bindings/c/include/SFML/Audio/SoundBuffer.h +++ b/bindings/c/include/SFML/Audio/SoundBuffer.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 diff --git a/bindings/c/include/SFML/Audio/SoundStream.h b/bindings/c/include/SFML/Audio/SoundStream.h index e96a6c930..8e2c68118 100644 --- a/bindings/c/include/SFML/Audio/SoundStream.h +++ b/bindings/c/include/SFML/Audio/SoundStream.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 diff --git a/bindings/c/include/SFML/Graphics/RenderWindow.h b/bindings/c/include/SFML/Graphics/RenderWindow.h index e17e81db8..775fa5a6c 100644 --- a/bindings/c/include/SFML/Graphics/RenderWindow.h +++ b/bindings/c/include/SFML/Graphics/RenderWindow.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 diff --git a/bindings/c/include/SFML/Network/Ftp.h b/bindings/c/include/SFML/Network/Ftp.h index f5603c8e4..b784e23bf 100644 --- a/bindings/c/include/SFML/Network/Ftp.h +++ b/bindings/c/include/SFML/Network/Ftp.h @@ -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 diff --git a/bindings/c/include/SFML/Network/Http.h b/bindings/c/include/SFML/Network/Http.h index f8faa6442..773819aa7 100644 --- a/bindings/c/include/SFML/Network/Http.h +++ b/bindings/c/include/SFML/Network/Http.h @@ -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 diff --git a/bindings/c/include/SFML/Network/IpAddress.h b/bindings/c/include/SFML/Network/IpAddress.h index d6417ae05..719564478 100644 --- a/bindings/c/include/SFML/Network/IpAddress.h +++ b/bindings/c/include/SFML/Network/IpAddress.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 diff --git a/bindings/c/include/SFML/Network/SocketSelector.h b/bindings/c/include/SFML/Network/SocketSelector.h index 77479d0d1..53ddbffc2 100644 --- a/bindings/c/include/SFML/Network/SocketSelector.h +++ b/bindings/c/include/SFML/Network/SocketSelector.h @@ -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 diff --git a/bindings/c/include/SFML/Network/TcpSocket.h b/bindings/c/include/SFML/Network/TcpSocket.h index ac3fab4a2..71ea12f7e 100644 --- a/bindings/c/include/SFML/Network/TcpSocket.h +++ b/bindings/c/include/SFML/Network/TcpSocket.h @@ -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 diff --git a/bindings/c/include/SFML/System/Clock.h b/bindings/c/include/SFML/System/Clock.h index 6f4a31cbb..2f30da29e 100644 --- a/bindings/c/include/SFML/System/Clock.h +++ b/bindings/c/include/SFML/System/Clock.h @@ -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 diff --git a/bindings/c/include/SFML/System/Sleep.h b/bindings/c/include/SFML/System/Sleep.h index 6177a6c9e..783365a07 100644 --- a/bindings/c/include/SFML/System/Sleep.h +++ b/bindings/c/include/SFML/System/Sleep.h @@ -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 diff --git a/bindings/c/include/SFML/Window/Window.h b/bindings/c/include/SFML/Window/Window.h index b2dd42c91..a3754eabf 100644 --- a/bindings/c/include/SFML/Window/Window.h +++ b/bindings/c/include/SFML/Window/Window.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 diff --git a/bindings/c/src/SFML/Audio/Music.cpp b/bindings/c/src/SFML/Audio/Music.cpp index 9f513716d..0022562d9 100644 --- a/bindings/c/src/SFML/Audio/Music.cpp +++ b/bindings/c/src/SFML/Audio/Music.cpp @@ -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)); } diff --git a/bindings/c/src/SFML/Audio/Sound.cpp b/bindings/c/src/SFML/Audio/Sound.cpp index aafd251d5..f7b95c5c9 100644 --- a/bindings/c/src/SFML/Audio/Sound.cpp +++ b/bindings/c/src/SFML/Audio/Sound.cpp @@ -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) } diff --git a/bindings/c/src/SFML/Audio/SoundBuffer.cpp b/bindings/c/src/SFML/Audio/SoundBuffer.cpp index c5348e5d5..13157bfdd 100644 --- a/bindings/c/src/SFML/Audio/SoundBuffer.cpp +++ b/bindings/c/src/SFML/Audio/SoundBuffer.cpp @@ -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) } diff --git a/bindings/c/src/SFML/Audio/SoundStream.cpp b/bindings/c/src/SFML/Audio/SoundStream.cpp index 4295f4544..6b152f9bb 100644 --- a/bindings/c/src/SFML/Audio/SoundStream.cpp +++ b/bindings/c/src/SFML/Audio/SoundStream.cpp @@ -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); } diff --git a/bindings/c/src/SFML/Audio/SoundStreamStruct.h b/bindings/c/src/SFML/Audio/SoundStreamStruct.h index bef7f83b4..dba54774e 100644 --- a/bindings/c/src/SFML/Audio/SoundStreamStruct.h +++ b/bindings/c/src/SFML/Audio/SoundStreamStruct.h @@ -64,7 +64,7 @@ private : return Continue; } - virtual void OnSeek(float TimeOffset) + virtual void OnSeek(sfUint32 TimeOffset) { if (mySeekCallback) mySeekCallback(TimeOffset, myUserData); diff --git a/bindings/c/src/SFML/Graphics/RenderWindow.cpp b/bindings/c/src/SFML/Graphics/RenderWindow.cpp index 866d9ce26..e76a0cc0a 100644 --- a/bindings/c/src/SFML/Graphics/RenderWindow.cpp +++ b/bindings/c/src/SFML/Graphics/RenderWindow.cpp @@ -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); } diff --git a/bindings/c/src/SFML/Network/Ftp.cpp b/bindings/c/src/SFML/Network/Ftp.cpp index 6c44c90c7..2a282ca26 100644 --- a/bindings/c/src/SFML/Network/Ftp.cpp +++ b/bindings/c/src/SFML/Network/Ftp.cpp @@ -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); diff --git a/bindings/c/src/SFML/Network/Http.cpp b/bindings/c/src/SFML/Network/Http.cpp index e5ab75fb8..7c1d784f2 100644 --- a/bindings/c/src/SFML/Network/Http.cpp +++ b/bindings/c/src/SFML/Network/Http.cpp @@ -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); diff --git a/bindings/c/src/SFML/Network/IpAddress.cpp b/bindings/c/src/SFML/Network/IpAddress.cpp index 341ab2a9f..985a9a212 100644 --- a/bindings/c/src/SFML/Network/IpAddress.cpp +++ b/bindings/c/src/SFML/Network/IpAddress.cpp @@ -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)); } diff --git a/bindings/c/src/SFML/Network/SocketSelector.cpp b/bindings/c/src/SFML/Network/SocketSelector.cpp index c09851343..7418b9d47 100644 --- a/bindings/c/src/SFML/Network/SocketSelector.cpp +++ b/bindings/c/src/SFML/Network/SocketSelector.cpp @@ -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); } diff --git a/bindings/c/src/SFML/Network/TcpSocket.cpp b/bindings/c/src/SFML/Network/TcpSocket.cpp index 09bbc5aeb..9cba5b82d 100644 --- a/bindings/c/src/SFML/Network/TcpSocket.cpp +++ b/bindings/c/src/SFML/Network/TcpSocket.cpp @@ -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); diff --git a/bindings/c/src/SFML/System/Clock.cpp b/bindings/c/src/SFML/System/Clock.cpp index 383565342..69667612b 100644 --- a/bindings/c/src/SFML/System/Clock.cpp +++ b/bindings/c/src/SFML/System/Clock.cpp @@ -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) } diff --git a/bindings/c/src/SFML/System/Sleep.cpp b/bindings/c/src/SFML/System/Sleep.cpp index 74fc9c45b..8d8f9fc53 100644 --- a/bindings/c/src/SFML/System/Sleep.cpp +++ b/bindings/c/src/SFML/System/Sleep.cpp @@ -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); } diff --git a/bindings/c/src/SFML/Window/Window.cpp b/bindings/c/src/SFML/Window/Window.cpp index 3b9cf86d1..d3e9fe4e3 100644 --- a/bindings/c/src/SFML/Window/Window.cpp +++ b/bindings/c/src/SFML/Window/Window.cpp @@ -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) } diff --git a/bindings/dotnet/examples/opengl/OpenGL.cs b/bindings/dotnet/examples/opengl/OpenGL.cs index 39af5e750..7167a45b3 100644 --- a/bindings/dotnet/examples/opengl/OpenGL.cs +++ b/bindings/dotnet/examples/opengl/OpenGL.cs @@ -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); diff --git a/bindings/dotnet/examples/visualbasic/OpenGL.vb b/bindings/dotnet/examples/visualbasic/OpenGL.vb index d9b73ca4e..849664810 100644 --- a/bindings/dotnet/examples/visualbasic/OpenGL.vb +++ b/bindings/dotnet/examples/visualbasic/OpenGL.vb @@ -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) diff --git a/bindings/dotnet/examples/window/Window.cs b/bindings/dotnet/examples/window/Window.cs index 2e74dd708..eece87eb1 100644 --- a/bindings/dotnet/examples/window/Window.cs +++ b/bindings/dotnet/examples/window/Window.cs @@ -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); diff --git a/bindings/dotnet/extlibs/x64/csfml-audio-2.dll b/bindings/dotnet/extlibs/x64/csfml-audio-2.dll index a07fdb931..e40d615f7 100644 Binary files a/bindings/dotnet/extlibs/x64/csfml-audio-2.dll and b/bindings/dotnet/extlibs/x64/csfml-audio-2.dll differ diff --git a/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll b/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll index d1c366213..caaf5c43c 100644 Binary files a/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll and b/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll differ diff --git a/bindings/dotnet/extlibs/x64/csfml-window-2.dll b/bindings/dotnet/extlibs/x64/csfml-window-2.dll index 253d1763c..3f82d4f8e 100644 Binary files a/bindings/dotnet/extlibs/x64/csfml-window-2.dll and b/bindings/dotnet/extlibs/x64/csfml-window-2.dll differ diff --git a/bindings/dotnet/extlibs/x86/csfml-audio-2.dll b/bindings/dotnet/extlibs/x86/csfml-audio-2.dll index 458ca4ae9..b36224e34 100644 Binary files a/bindings/dotnet/extlibs/x86/csfml-audio-2.dll and b/bindings/dotnet/extlibs/x86/csfml-audio-2.dll differ diff --git a/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll b/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll index 228044258..42ec9953a 100644 Binary files a/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll and b/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll differ diff --git a/bindings/dotnet/extlibs/x86/csfml-window-2.dll b/bindings/dotnet/extlibs/x86/csfml-window-2.dll index e4f4e44c7..5df7ff826 100644 Binary files a/bindings/dotnet/extlibs/x86/csfml-window-2.dll and b/bindings/dotnet/extlibs/x86/csfml-window-2.dll differ diff --git a/bindings/dotnet/src/Audio/Music.cs b/bindings/dotnet/src/Audio/Music.cs index 7ea1c7975..b7e4b6712 100644 --- a/bindings/dotnet/src/Audio/Music.cs +++ b/bindings/dotnet/src/Audio/Music.cs @@ -113,10 +113,10 @@ namespace SFML //////////////////////////////////////////////////////////// /// - /// Total duration of the music, in seconds + /// Total duration of the music, in milliseconds /// //////////////////////////////////////////////////////////// - public float Duration + public uint Duration { get {return sfMusic_GetDuration(This);} } @@ -206,10 +206,10 @@ namespace SFML //////////////////////////////////////////////////////////// /// - /// Current playing position, in seconds + /// Current playing position, in milliseconds /// //////////////////////////////////////////////////////////// - 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 } } diff --git a/bindings/dotnet/src/Audio/Sound.cs b/bindings/dotnet/src/Audio/Sound.cs index eb02808c6..f42f41969 100644 --- a/bindings/dotnet/src/Audio/Sound.cs +++ b/bindings/dotnet/src/Audio/Sound.cs @@ -151,10 +151,10 @@ namespace SFML //////////////////////////////////////////////////////////// /// - /// Current playing position of the sound, in seconds + /// Current playing position of the sound, in milliseconds /// //////////////////////////////////////////////////////////// - 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 } } diff --git a/bindings/dotnet/src/Audio/SoundBuffer.cs b/bindings/dotnet/src/Audio/SoundBuffer.cs index c7501216a..acf4f6c6f 100644 --- a/bindings/dotnet/src/Audio/SoundBuffer.cs +++ b/bindings/dotnet/src/Audio/SoundBuffer.cs @@ -122,10 +122,10 @@ namespace SFML //////////////////////////////////////////////////////////// /// - /// Total duration of the buffer, in seconds + /// Total duration of the buffer, in milliseconds /// //////////////////////////////////////////////////////////// - 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 } } diff --git a/bindings/dotnet/src/Audio/SoundStream.cs b/bindings/dotnet/src/Audio/SoundStream.cs index 65429817c..999ad1435 100644 --- a/bindings/dotnet/src/Audio/SoundStream.cs +++ b/bindings/dotnet/src/Audio/SoundStream.cs @@ -171,10 +171,10 @@ namespace SFML //////////////////////////////////////////////////////////// /// - /// Current playing position, in seconds + /// Current playing position, in milliseconds /// //////////////////////////////////////////////////////////// - public float PlayingOffset + public uint PlayingOffset { get {return sfSoundStream_GetPlayingOffset(This);} set {sfSoundStream_SetPlayingOffset(This, value);} @@ -229,9 +229,9 @@ namespace SFML /// /// Virtual function called to seek into the stream /// - /// New position, expressed in seconds + /// New position, in milliseconds //////////////////////////////////////////////////////////// - protected abstract void OnSeek(float timeOffset); + protected abstract void OnSeek(uint timeOffset); //////////////////////////////////////////////////////////// /// @@ -289,11 +289,11 @@ namespace SFML /// /// Called to seek in the stream /// - /// New position, expressed in seconds + /// New position, in milliseconds /// User data -- unused /// If false is returned, the playback is aborted //////////////////////////////////////////////////////////// - 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 } } diff --git a/bindings/dotnet/src/Graphics/RenderWindow.cs b/bindings/dotnet/src/Graphics/RenderWindow.cs index 709572f83..7e0a23aa6 100644 --- a/bindings/dotnet/src/Graphics/RenderWindow.cs +++ b/bindings/dotnet/src/Graphics/RenderWindow.cs @@ -288,7 +288,7 @@ namespace SFML /// /// Time elapsed, in seconds //////////////////////////////////////////////////////////// - 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); diff --git a/bindings/dotnet/src/Window/Window.cs b/bindings/dotnet/src/Window/Window.cs index ce428a00b..e430eaf08 100644 --- a/bindings/dotnet/src/Window/Window.cs +++ b/bindings/dotnet/src/Window/Window.cs @@ -333,9 +333,9 @@ namespace SFML /// /// Get time elapsed since last frame /// - /// Time elapsed, in seconds + /// Time elapsed, in milliseconds //////////////////////////////////////////////////////////// - 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); diff --git a/examples/opengl/OpenGL.cpp b/examples/opengl/OpenGL.cpp index 367b6b03a..33cfd837e 100644 --- a/examples/opengl/OpenGL.cpp +++ b/examples/opengl/OpenGL.cpp @@ -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; diff --git a/examples/pong/Pong.cpp b/examples/pong/Pong.cpp index a33c0b0d3..84020e2fb 100644 --- a/examples/pong/Pong.cpp +++ b/examples/pong/Pong.cpp @@ -17,7 +17,7 @@ //////////////////////////////////////////////////////////// int main() { - std::srand(std::time(NULL)); + std::srand(static_cast(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 diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp index a145c0874..cf7c0ea40 100644 --- a/examples/shader/Shader.cpp +++ b/examples/shader/Shader.cpp @@ -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(); diff --git a/examples/sound/Sound.cpp b/examples/sound/Sound.cpp index 6a8a46a98..8215d48bd 100644 --- a/examples/sound/Sound.cpp +++ b/examples/sound/Sound.cpp @@ -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 "; diff --git a/examples/sound_capture/SoundCapture.cpp b/examples/sound_capture/SoundCapture.cpp index 6da3354c9..83e850095 100644 --- a/examples/sound_capture/SoundCapture.cpp +++ b/examples/sound_capture/SoundCapture.cpp @@ -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); } } diff --git a/examples/voip/Server.cpp b/examples/voip/Server.cpp index d8c3a4051..7b527216d 100644 --- a/examples/voip/Server.cpp +++ b/examples/voip/Server.cpp @@ -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(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); } } diff --git a/examples/win32/Win32.cpp b/examples/win32/Win32.cpp index 60b9ec246..705f482f6 100644 --- a/examples/win32/Win32.cpp +++ b/examples/win32/Win32.cpp @@ -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 diff --git a/examples/window/Window.cpp b/examples/window/Window.cpp index 304fffcb6..7a0d94149 100644 --- a/examples/window/Window.cpp +++ b/examples/window/Window.cpp @@ -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); diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp index efd769c31..423c359aa 100644 --- a/include/SFML/Audio/Music.hpp +++ b/include/SFML/Audio/Music.hpp @@ -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 mySamples; ///< Temporary buffer of samples Mutex myMutex; ///< Mutex protecting the data }; diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index 304a9e0e4..efa928ee7 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -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) diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp index d738294fb..f06841ad2 100644 --- a/include/SFML/Audio/SoundBuffer.hpp +++ b/include/SFML/Audio/SoundBuffer.hpp @@ -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 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 }; diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 2717ce2b8..300ea9424 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -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 /// ... diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 5b628a776..7162aae3c 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -134,44 +134,31 @@ //////////////////////////////////////////////////////////// // Define portable fixed-size types //////////////////////////////////////////////////////////// -#include - 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 diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp index a28331e8b..ad0905a72 100644 --- a/include/SFML/Network/Ftp.hpp +++ b/include/SFML/Network/Ftp.hpp @@ -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 diff --git a/include/SFML/Network/Http.hpp b/include/SFML/Network/Http.hpp index 033d37b43..93c3ed55d 100644 --- a/include/SFML/Network/Http.hpp +++ b/include/SFML/Network/Http.hpp @@ -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 : diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp index ace8bc5e0..a2a6a1caa 100644 --- a/include/SFML/Network/IpAddress.hpp +++ b/include/SFML/Network/IpAddress.hpp @@ -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 diff --git a/include/SFML/Network/SocketSelector.hpp b/include/SFML/Network/SocketSelector.hpp index 9c505492a..3f3747f2a 100644 --- a/include/SFML/Network/SocketSelector.hpp +++ b/include/SFML/Network/SocketSelector.hpp @@ -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 diff --git a/include/SFML/Network/TcpSocket.hpp b/include/SFML/Network/TcpSocket.hpp index 424304e8c..ebe1f60b0 100644 --- a/include/SFML/Network/TcpSocket.hpp +++ b/include/SFML/Network/TcpSocket.hpp @@ -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 diff --git a/include/SFML/System/Clock.hpp b/include/SFML/System/Clock.hpp index 69000653b..19784ac39 100644 --- a/include/SFML/System/Clock.hpp +++ b/include/SFML/System/Clock.hpp @@ -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 /// //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/Sleep.hpp b/include/SFML/System/Sleep.hpp index 208b5a4e9..ff07549f2 100644 --- a/include/SFML/System/Sleep.hpp +++ b/include/SFML/System/Sleep.hpp @@ -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 diff --git a/include/SFML/Window/Input.hpp b/include/SFML/Window/Input.hpp index 03cbce58e..161cb6781 100644 --- a/include/SFML/Window/Input.hpp +++ b/include/SFML/Window/Input.hpp @@ -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); diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 0a28d1494..99750317d 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -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 diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index 2e89b8217..5b8be796e 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -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(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount(); + myDuration = static_cast(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(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount(); + myDuration = static_cast(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); diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp index f1c59ddb1..2fc609a45 100644 --- a/src/SFML/Audio/Sound.cpp +++ b/src/SFML/Audio/Sound.cpp @@ -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(seconds * 1000); } diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index 792a8018b..74764afe8 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -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(mySamples.size()) / sampleRate / channelsCount; + myDuration = static_cast(1000 * mySamples.size() / sampleRate / channelsCount); return true; } diff --git a/src/SFML/Audio/SoundFile.cpp b/src/SFML/Audio/SoundFile.cpp index 3f3d2ae56..23908ce0e 100644 --- a/src/SFML/Audio/SoundFile.cpp +++ b/src/SFML/Audio/SoundFile.cpp @@ -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(timeOffset * mySampleRate); + sf_count_t frameOffset = timeOffset * mySampleRate / 1000; sf_seek(myFile, frameOffset, SEEK_SET); } } diff --git a/src/SFML/Audio/SoundFile.hpp b/src/SFML/Audio/SoundFile.hpp index b30891d17..0451a3457 100644 --- a/src/SFML/Audio/SoundFile.hpp +++ b/src/SFML/Audio/SoundFile.hpp @@ -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 : diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index 10c6be56c..ce1014545 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -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 diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 7db02a4cb..eb4edf377 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -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(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(mySamplesProcessed) / mySampleRate / myChannelsCount; + return static_cast(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 diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index e38a34cb2..b0c29a502 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -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) diff --git a/src/SFML/Network/Http.cpp b/src/SFML/Network/Http.cpp index e221d07ae..d845eba5b 100644 --- a/src/SFML/Network/Http.cpp +++ b/src/SFML/Network/Http.cpp @@ -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); diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index 39c04d7bc..73cf6a1e2 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -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. diff --git a/src/SFML/Network/SocketSelector.cpp b/src/SFML/Network/SocketSelector.cpp index bbb311751..295ea7406 100644 --- a/src/SFML/Network/SocketSelector.cpp +++ b/src/SFML/Network/SocketSelector.cpp @@ -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(timeout); - time.tv_usec = (static_cast(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; } diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index 200270ee2..8e68e5a8a 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -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(timeout); - time.tv_usec = (static_cast(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(GetHandle() + 1), NULL, &selector, NULL, &time) > 0) diff --git a/src/SFML/System/Clock.cpp b/src/SFML/System/Clock.cpp index b4cd9a099..5a5bf8ca5 100644 --- a/src/SFML/System/Clock.cpp +++ b/src/SFML/System/Clock.cpp @@ -39,9 +39,9 @@ Clock::Clock() //////////////////////////////////////////////////////////// -float Clock::GetElapsedTime() const +Uint32 Clock::GetElapsedTime() const { - return static_cast(priv::Platform::GetSystemTime() - myStartTime); + return static_cast(priv::Platform::GetSystemTime() - myStartTime); } diff --git a/src/SFML/System/Sleep.cpp b/src/SFML/System/Sleep.cpp index bdbd8497c..588d629d3 100644 --- a/src/SFML/System/Sleep.cpp +++ b/src/SFML/System/Sleep.cpp @@ -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 diff --git a/src/SFML/System/Unix/Platform.cpp b/src/SFML/System/Unix/Platform.cpp index a75469767..ffd2edea5 100644 --- a/src/SFML/System/Unix/Platform.cpp +++ b/src/SFML/System/Unix/Platform.cpp @@ -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(time * 1000000)); + usleep(time * 1000); } } // namespace priv diff --git a/src/SFML/System/Unix/Platform.hpp b/src/SFML/System/Unix/Platform.hpp index 0173e64bc..abd4e1957 100644 --- a/src/SFML/System/Unix/Platform.hpp +++ b/src/SFML/System/Unix/Platform.hpp @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include 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 diff --git a/src/SFML/System/Win32/Platform.cpp b/src/SFML/System/Win32/Platform.cpp index a3b0e768b..f99671167 100644 --- a/src/SFML/System/Win32/Platform.cpp +++ b/src/SFML/System/Win32/Platform.cpp @@ -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(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(time * 1000)); + ::Sleep(time); } } // namespace priv diff --git a/src/SFML/System/Win32/Platform.hpp b/src/SFML/System/Win32/Platform.hpp index 8c56074f6..84162b685 100644 --- a/src/SFML/System/Win32/Platform.hpp +++ b/src/SFML/System/Win32/Platform.hpp @@ -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 diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 7e7912cee..21421b599 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -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();