Updated to the new time API (sfTime)

This commit is contained in:
Laurent Gomila committed 2012-02-02 21:22:49 +01:00
1 parent 44d4c4e707
commit 7615382a68
28 files changed
+293 -95

No files matched your search

+5 -4
View File
@@ -32,6 +32,7 @@
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Time.h>
#include <stddef.h>
@@ -121,10 +122,10 @@ CSFML_API sfBool sfMusic_GetLoop(const sfMusic* music);
///
/// \param music Music object
///
/// \return Music duration, in milliseconds
/// \return Music duration
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfMusic_GetDuration(const sfMusic* music);
CSFML_API sfTime sfMusic_GetDuration(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Start or resume playing a music
@@ -203,10 +204,10 @@ CSFML_API sfSoundStatus sfMusic_GetStatus(const sfMusic* music);
///
/// \param music Music object
///
/// \return Current playing position, in milliseconds
/// \return Current playing position
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music);
CSFML_API sfTime sfMusic_GetPlayingOffset(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Set the pitch of a music
+5 -4
View File
@@ -31,6 +31,7 @@
#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -251,10 +252,10 @@ CSFML_API void sfSound_SetAttenuation(sfSound* sound, float attenuation);
/// either paused or playing.
///
/// \param sound Sound object
/// \param timeOffset New playing position, in milliseconds
/// \param timeOffset New playing position
///
////////////////////////////////////////////////////////////
CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset);
CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, sfTime timeOffset);
////////////////////////////////////////////////////////////
/// \brief Get the pitch of a sound
@@ -323,10 +324,10 @@ CSFML_API float sfSound_GetAttenuation(const sfSound* sound);
///
/// \param sound Sound object
///
/// \return Current playing position, in milliseconds
/// \return Current playing position
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfSound_GetPlayingOffset(const sfSound* sound);
CSFML_API sfTime sfSound_GetPlayingOffset(const sfSound* sound);
#endif // SFML_SOUND_H
+3 -2
View File
@@ -31,6 +31,7 @@
#include <SFML/Config.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Time.h>
#include <stddef.h>
@@ -185,10 +186,10 @@ CSFML_API unsigned int sfSoundBuffer_GetChannelCount(const sfSoundBuffer* soundB
///
/// \param soundBuffer Sound buffer object
///
/// \return Sound duration, in milliseconds
/// \return Sound duration
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer);
CSFML_API sfTime sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer);
#endif // SFML_SOUNDBUFFER_H
+6 -5
View File
@@ -31,6 +31,7 @@
#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -44,7 +45,7 @@ typedef struct
} sfSoundStreamChunk;
typedef sfBool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); ///< Type of the callback used to get a sound stream data
typedef void (*sfSoundStreamSeekCallback)(sfUint32, void*); ///< Type of the callback used to seek in a sound stream
typedef void (*sfSoundStreamSeekCallback)(sfTime, void*); ///< Type of the callback used to seek in a sound stream
////////////////////////////////////////////////////////////
@@ -243,10 +244,10 @@ CSFML_API void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float at
/// either paused or playing.
///
/// \param soundStream Sound stream object
/// \param timeOffset New playing position, in milliseconds
/// \param timeOffset New playing position
///
////////////////////////////////////////////////////////////
CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset);
CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset);
////////////////////////////////////////////////////////////
/// \brief Set whether or not a sound stream should loop after reaching the end
@@ -339,10 +340,10 @@ CSFML_API sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream);
///
/// \param soundStream Sound stream object
///
/// \return Current playing position, in milliseconds
/// \return Current playing position
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream);
CSFML_API sfTime sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream);
#endif // SFML_SOUNDSTREAM_H
-11
View File
@@ -246,17 +246,6 @@ CSFML_API void sfTexture_SetRepeated(sfTexture* texture, sfBool repeated);
////////////////////////////////////////////////////////////
CSFML_API sfBool sfTexture_IsRepeated(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Convert a rectangle of pixels into texture coordinates
///
/// \param texture Texture to use for conversion
/// \param rectangle Rectangle to convert
///
/// \return Texture coordinates corresponding to \a rectangle
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfTexture_GetTexCoords(const sfTexture* texture, sfIntRect rectangle);
////////////////////////////////////////////////////////////
/// \brief Get the maximum texture size allowed
///
+3 -2
View File
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Network/Types.h>
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -285,12 +286,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, in milliseconds
/// \param timeout Maximum time to wait
///
/// \return Server's response
///
////////////////////////////////////////////////////////////
CSFML_API sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout);
CSFML_API sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfTime timeout);
#endif // SFML_HTTP_H
+3 -2
View File
@@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -146,12 +147,12 @@ CSFML_API sfIpAddress sfIpAddress_GetLocalAddress(void);
/// to be possibly stuck waiting in case there is a problem; use
/// 0 to deactivate this limit.
///
/// \param timeout Maximum time to wait, in milliseconds
/// \param timeout Maximum time to wait
///
/// \return Public IP address of the computer
///
////////////////////////////////////////////////////////////
CSFML_API sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout);
CSFML_API sfIpAddress sfIpAddress_GetPublicAddress(sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Get the empty/invalid address
+3 -2
View File
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Network/Types.h>
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -109,12 +110,12 @@ CSFML_API void sfSocketSelector_Clear(sfSocketSelector* selector);
/// is over, the function returns sfFalse.
///
/// \param selector Socket selector object
/// \param timeout Maximum time to wait, in milliseconds (use 0 for infinity)
/// \param timeout Maximum time to wait (use sfTimeZero for infinity)
///
/// \return sfTrue if there are sockets ready, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout);
CSFML_API sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Test a socket to know if it is ready to receive data
+3 -2
View File
@@ -32,6 +32,7 @@
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/SocketStatus.h>
#include <SFML/Network/Types.h>
#include <SFML/System/Time.h>
#include <stddef.h>
@@ -128,12 +129,12 @@ CSFML_API unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket);
/// \param socket TCP socket object
/// \param remoteAddress Address of the remote peer
/// \param remotePort Port of the remote peer
/// \param timeout Maximum time to wait, in milliseconds
/// \param timeout Maximum time to wait
///
/// \return Status code
///
////////////////////////////////////////////////////////////
CSFML_API sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout);
CSFML_API sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Disconnect a TCP socket from its remote peer
+9 -5
View File
@@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/System/Time.h>
#include <SFML/System/Types.h>
@@ -62,25 +63,28 @@ CSFML_API void sfClock_Destroy(sfClock* clock);
/// \brief Get the time elapsed in a clock
///
/// This function returns the time elapsed since the last call
/// to sfClock_Reset (or the construction of the object if
/// sfClock_Reset has not been called).
/// to sfClock_Restart (or the construction of the object if
/// sfClock_Restart has not been called).
///
/// \param clock Clock object
///
/// \return Time elapsed, in milliseconds
/// \return Time elapsed
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfClock_GetTime(const sfClock* clock);
CSFML_API sfTime sfClock_GetElapsedTime(const sfClock* clock);
////////////////////////////////////////////////////////////
/// \brief Restart a clock
///
/// This function puts the time counter back to zero.
/// It also returns the time elapsed since the clock was started.
///
/// \param clock Clock object
///
/// \return Time elapsed
///
////////////////////////////////////////////////////////////
CSFML_API void sfClock_Reset(sfClock* clock);
CSFML_API sfTime sfClock_Restart(sfClock* clock);
#endif // SFML_CLOCK_H
+3 -2
View File
@@ -29,6 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -37,10 +38,10 @@
/// sfSleep 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 milliseconds
/// \param duration Time to sleep
///
////////////////////////////////////////////////////////////
CSFML_API void sfSleep(sfUint32 duration);
CSFML_API void sfSleep(sfTime duration);
#endif // SFML_SLEEP_H
+110
View File
@@ -0,0 +1,110 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_TIME_H
#define SFML_TIME_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Represents a time value
///
////////////////////////////////////////////////////////////
typedef struct
{
sfInt64 Microseconds;
} sfTime;
////////////////////////////////////////////////////////////
/// \brief Predefined "zero" time value
///
////////////////////////////////////////////////////////////
CSFML_API sfTime sfTimeZero;
////////////////////////////////////////////////////////////
/// \brief Return a time value as a number of seconds
///
/// \param time Time value
///
/// \return Time in seconds
///
////////////////////////////////////////////////////////////
CSFML_API float sfTime_AsSeconds(sfTime time);
////////////////////////////////////////////////////////////
/// \brief Return a time value as a number of milliseconds
///
/// \param time Time value
///
/// \return Time in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfInt32 sfTime_AsMilliseconds(sfTime time);
////////////////////////////////////////////////////////////
/// \brief Return a time value as a number of microseconds
///
/// \param time Time value
///
/// \return Time in microseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfInt64 sfTime_AsMicroseconds(sfTime time);
////////////////////////////////////////////////////////////
/// \brief Construct a time value from a number of seconds
///
/// \param amount Number of seconds
///
/// \return Time value constructed from the amount of seconds
///
////////////////////////////////////////////////////////////
CSFML_API sfTime sfSeconds(float amount);
////////////////////////////////////////////////////////////
/// \brief Construct a time value from a number of milliseconds
///
/// \param amount Number of milliseconds
///
/// \return Time value constructed from the amount of milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfTime sfMilliseconds(sfInt32 amount);
////////////////////////////////////////////////////////////
/// \brief Construct a time value from a number of microseconds
///
/// \param amount Number of microseconds
///
/// \return Time value constructed from the amount of microseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfTime sfMicroseconds(sfInt64 amount);
#endif // SFML_TIME_H