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
83 changed files with 250 additions and 262 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue