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
+12 -6
View File
@@ -97,9 +97,12 @@ sfBool sfMusic_GetLoop(const sfMusic* music)
////////////////////////////////////////////////////////////
sfUint32 sfMusic_GetDuration(const sfMusic* music)
sfTime sfMusic_GetDuration(const sfMusic* music)
{
CSFML_CALL_RETURN(music, GetDuration(), 0);
CSFML_CHECK_RETURN(music, sfTimeZero);
sf::Time time = music->This.GetDuration();
return sfMicroseconds(time.AsMicroseconds());
}
@@ -148,9 +151,12 @@ sfSoundStatus sfMusic_GetStatus(const sfMusic* music)
////////////////////////////////////////////////////////////
sfUint32 sfMusic_GetPlayingOffset(const sfMusic* music)
sfTime sfMusic_GetPlayingOffset(const sfMusic* music)
{
CSFML_CALL_RETURN(music, GetPlayingOffset(), 0);
CSFML_CHECK_RETURN(music, sfTimeZero);
sf::Time time = music->This.GetPlayingOffset();
return sfMicroseconds(time.AsMicroseconds());
}
@@ -197,9 +203,9 @@ void sfMusic_SetAttenuation(sfMusic* music, float attenuation)
////////////////////////////////////////////////////////////
void sfMusic_SetPlayingOffset(sfMusic* music, sfUint32 timeOffset)
void sfMusic_SetPlayingOffset(sfMusic* music, sfTime timeOffset)
{
CSFML_CALL(music, SetPlayingOffset(timeOffset));
CSFML_CALL(music, SetPlayingOffset(sf::Microseconds(timeOffset.Microseconds)));
}
+7 -4
View File
@@ -160,9 +160,9 @@ void sfSound_SetAttenuation(sfSound* sound, float attenuation)
////////////////////////////////////////////////////////////
void sfSound_SetPlayingOffset(sfSound* sound, sfUint32 timeOffset)
void sfSound_SetPlayingOffset(sfSound* sound, sfTime timeOffset)
{
CSFML_CALL(sound, SetPlayingOffset(timeOffset));
CSFML_CALL(sound, SetPlayingOffset(sf::Microseconds(timeOffset.Microseconds)));
}
@@ -214,7 +214,10 @@ float sfSound_GetAttenuation(const sfSound* sound)
////////////////////////////////////////////////////////////
sfUint32 sfSound_GetPlayingOffset(const sfSound* sound)
sfTime sfSound_GetPlayingOffset(const sfSound* sound)
{
CSFML_CALL_RETURN(sound, GetPlayingOffset(), 0)
CSFML_CHECK_RETURN(sound, sfTimeZero)
sf::Time time = sound->This.GetPlayingOffset();
return sfMicroseconds(time.AsMicroseconds());
}
+5 -2
View File
@@ -146,7 +146,10 @@ unsigned int sfSoundBuffer_GetChannelCount(const sfSoundBuffer* soundBuffer)
////////////////////////////////////////////////////////////
sfUint32 sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer)
sfTime sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer)
{
CSFML_CALL_RETURN(soundBuffer, GetDuration(), 0)
CSFML_CHECK_RETURN(soundBuffer, sfTimeZero)
sf::Time duration = soundBuffer->This.GetDuration();
return sfMicroseconds(duration.AsMicroseconds());
}
+7 -4
View File
@@ -135,9 +135,9 @@ void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation)
////////////////////////////////////////////////////////////
void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfUint32 timeOffset)
void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset)
{
CSFML_CALL(soundStream, SetPlayingOffset(timeOffset));
CSFML_CALL(soundStream, SetPlayingOffset(sf::Microseconds(timeOffset.Microseconds)));
}
@@ -203,7 +203,10 @@ sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream)
////////////////////////////////////////////////////////////
sfUint32 sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream)
sfTime sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream)
{
CSFML_CALL_RETURN(soundStream, GetPlayingOffset(), 0);
CSFML_CHECK_RETURN(soundStream, sfTimeZero);
sf::Time offset = soundStream->This.GetPlayingOffset();
return sfMicroseconds(offset.AsMicroseconds());
}
+2 -2
View File
@@ -64,10 +64,10 @@ private :
return ok;
}
virtual void OnSeek(sfUint32 timeOffset)
virtual void OnSeek(sf::Time timeOffset)
{
if (mySeekCallback)
mySeekCallback(timeOffset, myUserData);
mySeekCallback(sfMicroseconds(timeOffset.AsMicroseconds()), myUserData);
}
sfSoundStreamGetDataCallback myGetDataCallback;
-19
View File
@@ -248,25 +248,6 @@ sfBool sfTexture_IsRepeated(const sfTexture* texture)
}
////////////////////////////////////////////////////////////
sfFloatRect sfTexture_GetTexCoords(const sfTexture* texture, sfIntRect rectangle)
{
sfFloatRect result = {0, 0, 0, 0};
CSFML_CHECK_RETURN(texture, result);
CSFML_CHECK_RETURN(texture->This, result);
sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height);
sf::FloatRect sfmlResult = texture->This->GetTexCoords(rect);
result.Left = sfmlResult.Left;
result.Top = sfmlResult.Top;
result.Width = sfmlResult.Width;
result.Height = sfmlResult.Height;
return result;
}
////////////////////////////////////////////////////////////
unsigned int sfTexture_GetMaximumSize()
{
+3 -1
View File
@@ -38,7 +38,7 @@ sfVertexArray* sfVertexArray_Create(void)
////////////////////////////////////////////////////////////
sfVertexArray* sfTransform_Copy(sfVertexArray* vertexArray)
sfVertexArray* sfVertexArray_Copy(sfVertexArray* vertexArray)
{
CSFML_CHECK_RETURN(vertexArray, NULL);
@@ -118,4 +118,6 @@ sfFloatRect sfVertexArray_GetBounds(sfVertexArray* vertexArray)
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
+2 -2
View File
@@ -169,13 +169,13 @@ void sfFtp_Destroy(sfFtp* ftp)
////////////////////////////////////////////////////////////
sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfUint32 timeout)
sfFtpResponse* sfFtp_Connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout)
{
CSFML_CHECK_RETURN(ftp, NULL);
sf::IpAddress SFMLServer(server.Address);
return new sfFtpResponse(ftp->This.Connect(SFMLServer, port, timeout));
return new sfFtpResponse(ftp->This.Connect(SFMLServer, port, sf::Microseconds(timeout.Microseconds)));
}
+2 -2
View File
@@ -153,13 +153,13 @@ void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short port)
////////////////////////////////////////////////////////////
sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfUint32 timeout)
sfHttpResponse* sfHttp_SendRequest(sfHttp* http, const sfHttpRequest* request, sfTime timeout)
{
CSFML_CHECK_RETURN(http, NULL);
CSFML_CHECK_RETURN(request, NULL);
sfHttpResponse* response = new sfHttpResponse;
response->This = http->This.SendRequest(request->This, timeout);
response->This = http->This.SendRequest(request->This, sf::Microseconds(timeout.Microseconds));
return response;
}
+2 -2
View File
@@ -93,9 +93,9 @@ sfIpAddress sfIpAddress_GetLocalAddress(void)
////////////////////////////////////////////////////////////
sfIpAddress sfIpAddress_GetPublicAddress(sfUint32 timeout)
sfIpAddress sfIpAddress_GetPublicAddress(sfTime timeout)
{
return FromSFMLAddress(sf::IpAddress::GetPublicAddress(timeout));
return FromSFMLAddress(sf::IpAddress::GetPublicAddress(sf::Microseconds(timeout.Microseconds)));
}
+2 -2
View File
@@ -100,9 +100,9 @@ void sfSocketSelector_Clear(sfSocketSelector* selector)
////////////////////////////////////////////////////////////
sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfUint32 timeout)
sfBool sfSocketSelector_Wait(sfSocketSelector* selector, sfTime timeout)
{
CSFML_CALL_RETURN(selector, Wait(timeout), sfFalse);
CSFML_CALL_RETURN(selector, Wait(sf::Microseconds(timeout.Microseconds)), sfFalse);
}
+2 -2
View File
@@ -89,13 +89,13 @@ unsigned short sfTcpSocket_GetRemotePort(const sfTcpSocket* socket)
////////////////////////////////////////////////////////////
sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfUint32 timeout)
sfSocketStatus sfTcpSocket_Connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfTime timeout)
{
sf::IpAddress address(host.Address);
CSFML_CHECK_RETURN(socket, sfSocketError);
return static_cast<sfSocketStatus>(socket->This.Connect(address, port, timeout));
return static_cast<sfSocketStatus>(socket->This.Connect(address, port, sf::Microseconds(timeout.Microseconds)));
}
+2
View File
@@ -16,6 +16,8 @@ set(SRC
${SRCROOT}/Thread.cpp
${SRCROOT}/ThreadStruct.h
${INCROOT}/Thread.h
${SRCROOT}/Time.cpp
${INCROOT}/Time.h
${INCROOT}/Types.h
)
+10 -4
View File
@@ -54,14 +54,20 @@ void sfClock_Destroy(sfClock* clock)
////////////////////////////////////////////////////////////
sfUint32 sfClock_GetTime(const sfClock* clock)
sfTime sfClock_GetElapsedTime(const sfClock* clock)
{
CSFML_CALL_RETURN(clock, GetElapsedTime(), 0)
CSFML_CHECK_RETURN(clock, sfTimeZero);
sf::Time time = clock->This.GetElapsedTime();
return sfMicroseconds(time.AsMicroseconds());
}
////////////////////////////////////////////////////////////
void sfClock_Reset(sfClock* clock)
sfTime sfClock_Restart(sfClock* clock)
{
CSFML_CALL(clock, Reset())
CSFML_CHECK_RETURN(clock, sfTimeZero);
sf::Time time = clock->This.Restart();
return sfMicroseconds(time.AsMicroseconds());
}
+2 -2
View File
@@ -31,7 +31,7 @@
////////////////////////////////////////////////////////////
void sfSleep(sfUint32 Duration)
void sfSleep(sfTime duration)
{
sf::Sleep(Duration);
sf::Sleep(sf::Microseconds(duration.Microseconds));
}
+80
View File
@@ -0,0 +1,80 @@
////////////////////////////////////////////////////////////
//
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Time.h>
////////////////////////////////////////////////////////////
sfTime sfTimeZero = {0};
////////////////////////////////////////////////////////////
float sfTime_AsSeconds(sfTime time)
{
return time.Microseconds / 1000000.f;
}
////////////////////////////////////////////////////////////
sfInt32 sfTime_AsMilliseconds(sfTime time)
{
return static_cast<sfUint32>(time.Microseconds / 1000);
}
////////////////////////////////////////////////////////////
sfInt64 sfTime_AsMicroseconds(sfTime time)
{
return time.Microseconds;
}
////////////////////////////////////////////////////////////
sfTime sfSeconds(float amount)
{
sfTime time;
time.Microseconds = static_cast<sfUint64>(amount * 1000000);
return time;
}
////////////////////////////////////////////////////////////
sfTime sfMilliseconds(sfInt32 amount)
{
sfTime time;
time.Microseconds = static_cast<sfUint64>(amount) * 1000;
return time;
}
////////////////////////////////////////////////////////////
sfTime sfMicroseconds(sfInt64 amount)
{
sfTime time;
time.Microseconds = amount;
return time;
}