Replace sf::Uint64 with std::uint64_t

This commit is contained in:
Chris Thrasher 2022-09-12 15:54:03 -06:00 committed by Vittorio Romeo
parent 05690b963d
commit 3a3935d005
52 changed files with 183 additions and 186 deletions

View File

@ -188,7 +188,7 @@ GLADapiproc getVulkanFunction(const char* name)
VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback( VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
VkDebugReportFlagsEXT, VkDebugReportFlagsEXT,
VkDebugReportObjectTypeEXT, VkDebugReportObjectTypeEXT,
uint64_t, std::uint64_t,
std::size_t, std::size_t,
std::int32_t, std::int32_t,
const char*, const char*,
@ -393,7 +393,7 @@ public:
{ {
// Swapchain teardown procedure // Swapchain teardown procedure
for (VkFence fence : fences) for (VkFence fence : fences)
vkWaitForFences(device, 1, &fence, VK_TRUE, std::numeric_limits<uint64_t>::max()); vkWaitForFences(device, 1, &fence, VK_TRUE, std::numeric_limits<std::uint64_t>::max());
if (commandBuffers.size()) if (commandBuffers.size())
vkFreeCommandBuffers(device, commandPool, static_cast<std::uint32_t>(commandBuffers.size()), commandBuffers.data()); vkFreeCommandBuffers(device, commandPool, static_cast<std::uint32_t>(commandBuffers.size()), commandBuffers.data());
@ -2483,13 +2483,13 @@ public:
std::uint32_t imageIndex = 0; std::uint32_t imageIndex = 0;
// If the objects we need to submit this frame are still pending, wait here // If the objects we need to submit this frame are still pending, wait here
vkWaitForFences(device, 1, &fences[currentFrame], VK_TRUE, std::numeric_limits<uint64_t>::max()); vkWaitForFences(device, 1, &fences[currentFrame], VK_TRUE, std::numeric_limits<std::uint64_t>::max());
{ {
// Get the next image in the swapchain // Get the next image in the swapchain
VkResult result = vkAcquireNextImageKHR(device, VkResult result = vkAcquireNextImageKHR(device,
swapchain, swapchain,
std::numeric_limits<uint64_t>::max(), std::numeric_limits<std::uint64_t>::max(),
imageAvailableSemaphores[currentFrame], imageAvailableSemaphores[currentFrame],
VK_NULL_HANDLE, VK_NULL_HANDLE,
&imageIndex); &imageIndex);

View File

@ -124,7 +124,7 @@ public:
/// \return Number of samples /// \return Number of samples
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 getSampleCount() const; std::uint64_t getSampleCount() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the number of channels used by the sound /// \brief Get the number of channels used by the sound
@ -167,7 +167,7 @@ public:
/// \return Sample position /// \return Sample position
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 getSampleOffset() const; std::uint64_t getSampleOffset() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the current read position to the given sample offset /// \brief Change the current read position to the given sample offset
@ -186,7 +186,7 @@ public:
/// \param sampleOffset Index of the sample to jump to, relative to the beginning /// \param sampleOffset Index of the sample to jump to, relative to the beginning
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void seek(Uint64 sampleOffset); void seek(std::uint64_t sampleOffset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the current read position to the given time offset /// \brief Change the current read position to the given time offset
@ -211,7 +211,7 @@ public:
/// \return Number of samples actually read (may be less than \a maxCount) /// \return Number of samples actually read (may be less than \a maxCount)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount); [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Close the current file /// \brief Close the current file
@ -242,8 +242,8 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::unique_ptr<SoundFileReader> m_reader; //!< Reader that handles I/O on the file's format std::unique_ptr<SoundFileReader> m_reader; //!< Reader that handles I/O on the file's format
std::unique_ptr<InputStream, StreamDeleter> m_stream; //!< Input stream used to access the file's data std::unique_ptr<InputStream, StreamDeleter> m_stream; //!< Input stream used to access the file's data
Uint64 m_sampleOffset; //!< Sample Read Position std::uint64_t m_sampleOffset; //!< Sample Read Position
Uint64 m_sampleCount; //!< Total number of samples in the file std::uint64_t m_sampleCount; //!< Total number of samples in the file
unsigned int m_channelCount; //!< Number of channels of the sound unsigned int m_channelCount; //!< Number of channels of the sound
unsigned int m_sampleRate; //!< Number of samples per second unsigned int m_sampleRate; //!< Number of samples per second
}; };
@ -280,7 +280,7 @@ private:
/// ///
/// // Read and process batches of samples until the end of file is reached /// // Read and process batches of samples until the end of file is reached
/// std::int16_t samples[1024]; /// std::int16_t samples[1024];
/// sf::Uint64 count; /// std::uint64_t count;
/// do /// do
/// { /// {
/// count = file.read(samples, 1024); /// count = file.read(samples, 1024);

View File

@ -256,7 +256,7 @@ private:
/// \return The number of samples elapsed at the given time /// \return The number of samples elapsed at the given time
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 timeToSamples(Time position) const; std::uint64_t timeToSamples(Time position) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Helper to convert a sample position to an sf::Time /// \brief Helper to convert a sample position to an sf::Time
@ -266,7 +266,7 @@ private:
/// \return The Time position of the given sample /// \return The Time position of the given sample
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Time samplesToTime(Uint64 samples) const; Time samplesToTime(std::uint64_t samples) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
@ -274,7 +274,7 @@ private:
InputSoundFile m_file; //!< The streamed music file InputSoundFile m_file; //!< The streamed music file
std::vector<std::int16_t> m_samples; //!< Temporary buffer of samples std::vector<std::int16_t> m_samples; //!< Temporary buffer of samples
std::recursive_mutex m_mutex; //!< Mutex protecting the data std::recursive_mutex m_mutex; //!< Mutex protecting the data
Span<Uint64> m_loopSpan; //!< Loop Range Specifier Span<std::uint64_t> m_loopSpan; //!< Loop Range Specifier
}; };
} // namespace sf } // namespace sf

View File

@ -93,7 +93,7 @@ public:
/// \param count Number of samples to write /// \param count Number of samples to write
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void write(const std::int16_t* samples, Uint64 count); void write(const std::int16_t* samples, std::uint64_t count);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Close the current file /// \brief Close the current file

View File

@ -134,7 +134,7 @@ public:
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] bool loadFromSamples(const std::int16_t* samples, [[nodiscard]] bool loadFromSamples(const std::int16_t* samples,
Uint64 sampleCount, std::uint64_t sampleCount,
unsigned int channelCount, unsigned int channelCount,
unsigned int sampleRate); unsigned int sampleRate);
@ -178,7 +178,7 @@ public:
/// \see getSamples /// \see getSamples
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 getSampleCount() const; std::uint64_t getSampleCount() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the sample rate of the sound /// \brief Get the sample rate of the sound

View File

@ -30,6 +30,8 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp> #include <SFML/Audio/Export.hpp>
#include <cstdint>
namespace sf namespace sf
{ {
@ -48,7 +50,7 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct Info struct Info
{ {
Uint64 sampleCount; //!< Total number of samples in the file std::uint64_t sampleCount; //!< Total number of samples in the file
unsigned int channelCount; //!< Number of channels of the sound unsigned int channelCount; //!< Number of channels of the sound
unsigned int sampleRate; //!< Samples rate of the sound, in samples per second unsigned int sampleRate; //!< Samples rate of the sound, in samples per second
}; };
@ -89,7 +91,7 @@ public:
/// \param sampleOffset Index of the sample to jump to, relative to the beginning /// \param sampleOffset Index of the sample to jump to, relative to the beginning
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
virtual void seek(Uint64 sampleOffset) = 0; virtual void seek(std::uint64_t sampleOffset) = 0;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Read audio samples from the open file /// \brief Read audio samples from the open file
@ -100,7 +102,7 @@ public:
/// \return Number of samples actually read (may be less than \a maxCount) /// \return Number of samples actually read (may be less than \a maxCount)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] virtual Uint64 read(std::int16_t* samples, Uint64 maxCount) = 0; [[nodiscard]] virtual std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) = 0;
}; };
} // namespace sf } // namespace sf
@ -143,13 +145,13 @@ public:
/// // return true on success /// // return true on success
/// } /// }
/// ///
/// void seek(sf::Uint64 sampleOffset) override /// void seek(std::uint64_t sampleOffset) override
/// { /// {
/// // advance to the sampleOffset-th sample from the beginning of the /// // advance to the sampleOffset-th sample from the beginning of the
/// sound /// sound
/// } /// }
/// ///
/// sf::Uint64 read(std::int16_t* samples, sf::Uint64 maxCount) override /// std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) override
/// { /// {
/// // read up to 'maxCount' samples into the 'samples' array, /// // read up to 'maxCount' samples into the 'samples' array,
/// // convert them (for example from normalized float) if they are not stored /// // convert them (for example from normalized float) if they are not stored

View File

@ -72,7 +72,7 @@ public:
/// \param count Number of samples to write /// \param count Number of samples to write
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
virtual void write(const std::int16_t* samples, Uint64 count) = 0; virtual void write(const std::int16_t* samples, std::uint64_t count) = 0;
}; };
} // namespace sf } // namespace sf
@ -115,7 +115,7 @@ public:
/// // return true on success /// // return true on success
/// } /// }
/// ///
/// void write(const std::int16_t* samples, sf::Uint64 count) override /// void write(const std::int16_t* samples, std::uint64_t count) override
/// { /// {
/// // write 'count' samples stored at address 'samples', /// // write 'count' samples stored at address 'samples',
/// // convert them (for example to normalized float) if the format requires it /// // convert them (for example to normalized float) if the format requires it

View File

@ -346,7 +346,7 @@ private:
unsigned int m_sampleRate; //!< Frequency (samples / second) unsigned int m_sampleRate; //!< Frequency (samples / second)
std::int32_t m_format; //!< Format of the internal sound buffers std::int32_t m_format; //!< Format of the internal sound buffers
bool m_loop; //!< Loop flag (true to loop, false to play once) bool m_loop; //!< Loop flag (true to loop, false to play once)
Uint64 m_samplesProcessed; //!< Number of samples processed since beginning of the stream std::uint64_t m_samplesProcessed; //!< Number of samples processed since beginning of the stream
std::int64_t m_bufferSeeks[BufferCount]; //!< If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation. std::int64_t m_bufferSeeks[BufferCount]; //!< If buffer is an "end buffer", holds next seek position, else NoLoop. For play offset calculation.
Time m_processingInterval; //!< Interval for checking and filling the internal sound buffers. Time m_processingInterval; //!< Interval for checking and filling the internal sound buffers.
}; };

View File

@ -26,12 +26,6 @@
#define SFML_CONFIG_HPP #define SFML_CONFIG_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <cstdint>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Define the SFML version // Define the SFML version
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -162,15 +156,4 @@
#endif #endif
////////////////////////////////////////////////////////////
// Define portable fixed-size types
////////////////////////////////////////////////////////////
namespace sf
{
// 64 bits integer types
using Uint64 = std::uint64_t;
} // namespace sf
#endif // SFML_CONFIG_HPP #endif // SFML_CONFIG_HPP

View File

@ -30,6 +30,8 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp> #include <SFML/Graphics/Export.hpp>
#include <cstdint>
namespace sf namespace sf
{ {

View File

@ -348,7 +348,7 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Types // Types
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
using GlyphTable = std::unordered_map<Uint64, Glyph>; //!< Table mapping a codepoint to its glyph using GlyphTable = std::unordered_map<std::uint64_t, Glyph>; //!< Table mapping a codepoint to its glyph
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Structure defining a page of glyphs /// \brief Structure defining a page of glyphs

View File

@ -489,7 +489,7 @@ private:
bool glStatesSet; //!< Are our internal GL states set yet? bool glStatesSet; //!< Are our internal GL states set yet?
bool viewChanged; //!< Has the current view changed since last draw? bool viewChanged; //!< Has the current view changed since last draw?
BlendMode lastBlendMode; //!< Cached blending mode BlendMode lastBlendMode; //!< Cached blending mode
Uint64 lastTextureId; //!< Cached texture std::uint64_t lastTextureId; //!< Cached texture
bool texCoordsArrayEnabled; //!< Is GL_TEXTURE_COORD_ARRAY client state enabled? bool texCoordsArrayEnabled; //!< Is GL_TEXTURE_COORD_ARRAY client state enabled?
bool useVertexCache; //!< Did we previously use the vertex cache? bool useVertexCache; //!< Did we previously use the vertex cache?
Vertex vertexCache[VertexCacheSize]; //!< Pre-transformed vertices cache Vertex vertexCache[VertexCacheSize]; //!< Pre-transformed vertices cache
@ -501,7 +501,7 @@ private:
View m_defaultView; //!< Default view View m_defaultView; //!< Default view
View m_view; //!< Current view View m_view; //!< Current view
StatesCache m_cache; //!< Render states cache StatesCache m_cache; //!< Render states cache
Uint64 m_id; //!< Unique number that identifies the RenderTarget std::uint64_t m_id; //!< Unique number that identifies the RenderTarget
}; };
} // namespace sf } // namespace sf

View File

@ -441,7 +441,7 @@ private:
mutable VertexArray m_outlineVertices; //!< Vertex array containing the outline geometry mutable VertexArray m_outlineVertices; //!< Vertex array containing the outline geometry
mutable FloatRect m_bounds; //!< Bounding rectangle of the text (in local coordinates) mutable FloatRect m_bounds; //!< Bounding rectangle of the text (in local coordinates)
mutable bool m_geometryNeedUpdate; //!< Does the geometry need to be recomputed? mutable bool m_geometryNeedUpdate; //!< Does the geometry need to be recomputed?
mutable Uint64 m_fontTextureId; //!< The font texture id mutable std::uint64_t m_fontTextureId; //!< The font texture id
}; };
} // namespace sf } // namespace sf

View File

@ -620,7 +620,7 @@ private:
mutable bool m_pixelsFlipped; //!< To work around the inconsistency in Y orientation mutable bool m_pixelsFlipped; //!< To work around the inconsistency in Y orientation
bool m_fboAttachment; //!< Is this texture owned by a framebuffer object? bool m_fboAttachment; //!< Is this texture owned by a framebuffer object?
bool m_hasMipmap; //!< Has the mipmap been generated? bool m_hasMipmap; //!< Has the mipmap been generated?
Uint64 m_cacheId; //!< Unique number that identifies the texture to the render target's cache std::uint64_t m_cacheId; //!< Unique number that identifies the texture to the render target's cache
}; };
} // namespace sf } // namespace sf

View File

@ -248,7 +248,7 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& operator>>(Uint64& data); Packet& operator>>(std::uint64_t& data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
@ -329,7 +329,7 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& operator<<(Uint64 data); Packet& operator<<(std::uint64_t data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \overload /// \overload

View File

@ -32,6 +32,8 @@
#include <SFML/System/Export.hpp> #include <SFML/System/Export.hpp>
#include <cstdint>
namespace sf namespace sf
{ {

View File

@ -33,6 +33,7 @@
#include <SFML/System/Vector2.hpp> #include <SFML/System/Vector2.hpp>
#include <SFML/Window/GlResource.hpp> #include <SFML/Window/GlResource.hpp>
#include <cstdint>
#include <memory> #include <memory>
@ -145,7 +146,7 @@ public:
/// \return The active context's ID or 0 if no context is currently active /// \return The active context's ID or 0 if no context is currently active
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Uint64 getActiveContextId(); static std::uint64_t getActiveContextId();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a in-memory context /// \brief Construct a in-memory context

View File

@ -27,6 +27,8 @@
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
#include <cstdint>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -32,6 +32,7 @@
#include <SFML/System/Vector2.hpp> #include <SFML/System/Vector2.hpp>
#include <cstdint>
#include <memory> #include <memory>
namespace sf namespace sf

View File

@ -189,7 +189,7 @@ bool InputSoundFile::openFromStream(InputStream& stream)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 InputSoundFile::getSampleCount() const std::uint64_t InputSoundFile::getSampleCount() const
{ {
return m_sampleCount; return m_sampleCount;
} }
@ -234,14 +234,14 @@ Time InputSoundFile::getTimeOffset() const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 InputSoundFile::getSampleOffset() const std::uint64_t InputSoundFile::getSampleOffset() const
{ {
return m_sampleOffset; return m_sampleOffset;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void InputSoundFile::seek(Uint64 sampleOffset) void InputSoundFile::seek(std::uint64_t sampleOffset)
{ {
if (m_reader && m_channelCount != 0) if (m_reader && m_channelCount != 0)
{ {
@ -256,14 +256,14 @@ void InputSoundFile::seek(Uint64 sampleOffset)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void InputSoundFile::seek(Time timeOffset) void InputSoundFile::seek(Time timeOffset)
{ {
seek(static_cast<Uint64>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate)) * m_channelCount); seek(static_cast<std::uint64_t>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate)) * m_channelCount);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 InputSoundFile::read(std::int16_t* samples, Uint64 maxCount) std::uint64_t InputSoundFile::read(std::int16_t* samples, std::uint64_t maxCount)
{ {
Uint64 readSamples = 0; std::uint64_t readSamples = 0;
if (m_reader && samples && maxCount) if (m_reader && samples && maxCount)
readSamples = m_reader->read(samples, maxCount); readSamples = m_reader->read(samples, maxCount);
m_sampleOffset += readSamples; m_sampleOffset += readSamples;

View File

@ -123,7 +123,7 @@ Music::TimeSpan Music::getLoopPoints() const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Music::setLoopPoints(TimeSpan timePoints) void Music::setLoopPoints(TimeSpan timePoints)
{ {
Span<Uint64> samplePoints(timeToSamples(timePoints.offset), timeToSamples(timePoints.length)); Span<std::uint64_t> samplePoints(timeToSamples(timePoints.offset), timeToSamples(timePoints.length));
// Check our state. This averts a divide-by-zero. GetChannelCount() is cheap enough to use often // Check our state. This averts a divide-by-zero. GetChannelCount() is cheap enough to use often
if (getChannelCount() == 0 || m_file.getSampleCount() == 0) if (getChannelCount() == 0 || m_file.getSampleCount() == 0)
@ -185,8 +185,8 @@ bool Music::onGetData(SoundStream::Chunk& data)
std::scoped_lock lock(m_mutex); std::scoped_lock lock(m_mutex);
std::size_t toFill = m_samples.size(); std::size_t toFill = m_samples.size();
Uint64 currentOffset = m_file.getSampleOffset(); std::uint64_t currentOffset = m_file.getSampleOffset();
Uint64 loopEnd = m_loopSpan.offset + m_loopSpan.length; std::uint64_t loopEnd = m_loopSpan.offset + m_loopSpan.length;
// If the loop end is enabled and imminent, request less data. // If the loop end is enabled and imminent, request less data.
// This will trip an "onLoop()" call from the underlying SoundStream, // This will trip an "onLoop()" call from the underlying SoundStream,
@ -218,7 +218,7 @@ std::int64_t Music::onLoop()
{ {
// Called by underlying SoundStream so we can determine where to loop. // Called by underlying SoundStream so we can determine where to loop.
std::scoped_lock lock(m_mutex); std::scoped_lock lock(m_mutex);
Uint64 currentOffset = m_file.getSampleOffset(); std::uint64_t currentOffset = m_file.getSampleOffset();
if (getLoop() && (m_loopSpan.length != 0) && (currentOffset == m_loopSpan.offset + m_loopSpan.length)) if (getLoop() && (m_loopSpan.length != 0) && (currentOffset == m_loopSpan.offset + m_loopSpan.length))
{ {
// Looping is enabled, and either we're at the loop end, or we're at the EOF // Looping is enabled, and either we're at the loop end, or we're at the EOF
@ -251,18 +251,18 @@ void Music::initialize()
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 Music::timeToSamples(Time position) const std::uint64_t Music::timeToSamples(Time position) const
{ {
// Always ROUND, no unchecked truncation, hence the addition in the numerator. // Always ROUND, no unchecked truncation, hence the addition in the numerator.
// This avoids most precision errors arising from "samples => Time => samples" conversions // This avoids most precision errors arising from "samples => Time => samples" conversions
// Original rounding calculation is ((Micros * Freq * Channels) / 1000000) + 0.5 // Original rounding calculation is ((Micros * Freq * Channels) / 1000000) + 0.5
// We refactor it to keep std::int64_t as the data type throughout the whole operation. // We refactor it to keep std::int64_t as the data type throughout the whole operation.
return ((static_cast<Uint64>(position.asMicroseconds()) * getSampleRate() * getChannelCount()) + 500000) / 1000000; return ((static_cast<std::uint64_t>(position.asMicroseconds()) * getSampleRate() * getChannelCount()) + 500000) / 1000000;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Time Music::samplesToTime(Uint64 samples) const Time Music::samplesToTime(std::uint64_t samples) const
{ {
Time position = Time::Zero; Time position = Time::Zero;

View File

@ -69,7 +69,7 @@ bool OutputSoundFile::openFromFile(const std::filesystem::path& filename, unsign
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void OutputSoundFile::write(const std::int16_t* samples, Uint64 count) void OutputSoundFile::write(const std::int16_t* samples, std::uint64_t count)
{ {
if (m_writer && samples && count) if (m_writer && samples && count)
m_writer->write(samples, count); m_writer->write(samples, count);

View File

@ -120,7 +120,10 @@ bool SoundBuffer::loadFromStream(InputStream& stream)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool SoundBuffer::loadFromSamples(const std::int16_t* samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate) bool SoundBuffer::loadFromSamples(const std::int16_t* samples,
std::uint64_t sampleCount,
unsigned int channelCount,
unsigned int sampleRate)
{ {
if (samples && sampleCount && channelCount && sampleRate) if (samples && sampleCount && channelCount && sampleRate)
{ {
@ -171,7 +174,7 @@ const std::int16_t* SoundBuffer::getSamples() const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 SoundBuffer::getSampleCount() const std::uint64_t SoundBuffer::getSampleCount() const
{ {
return m_samples.size(); return m_samples.size();
} }
@ -222,7 +225,7 @@ SoundBuffer& SoundBuffer::operator=(const SoundBuffer& right)
bool SoundBuffer::initialize(InputSoundFile& file) bool SoundBuffer::initialize(InputSoundFile& file)
{ {
// Retrieve the sound parameters // Retrieve the sound parameters
Uint64 sampleCount = file.getSampleCount(); std::uint64_t sampleCount = file.getSampleCount();
unsigned int channelCount = file.getChannelCount(); unsigned int channelCount = file.getChannelCount();
unsigned int sampleRate = file.getSampleRate(); unsigned int sampleRate = file.getSampleRate();

View File

@ -271,7 +271,7 @@ bool SoundFileReaderFlac::open(InputStream& stream, Info& info)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileReaderFlac::seek(Uint64 sampleOffset) void SoundFileReaderFlac::seek(std::uint64_t sampleOffset)
{ {
assert(m_decoder); assert(m_decoder);
@ -300,7 +300,7 @@ void SoundFileReaderFlac::seek(Uint64 sampleOffset)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 SoundFileReaderFlac::read(std::int16_t* samples, Uint64 maxCount) std::uint64_t SoundFileReaderFlac::read(std::int16_t* samples, std::uint64_t maxCount)
{ {
assert(m_decoder); assert(m_decoder);

View File

@ -90,7 +90,7 @@ public:
/// \param sampleOffset Index of the sample to jump to, relative to the beginning /// \param sampleOffset Index of the sample to jump to, relative to the beginning
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void seek(Uint64 sampleOffset) override; void seek(std::uint64_t sampleOffset) override;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Read audio samples from the open file /// \brief Read audio samples from the open file
@ -101,7 +101,7 @@ public:
/// \return Number of samples actually read (may be less than \a maxCount) /// \return Number of samples actually read (may be less than \a maxCount)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override; [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) override;
public: public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -113,7 +113,7 @@ public:
InputStream* stream; InputStream* stream;
SoundFileReader::Info info; SoundFileReader::Info info;
std::int16_t* buffer; std::int16_t* buffer;
Uint64 remaining; std::uint64_t remaining;
std::vector<std::int16_t> leftovers; std::vector<std::int16_t> leftovers;
bool error; bool error;
}; };

View File

@ -136,7 +136,7 @@ bool SoundFileReaderMp3::open(InputStream& stream, Info& info)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileReaderMp3::seek(Uint64 sampleOffset) void SoundFileReaderMp3::seek(std::uint64_t sampleOffset)
{ {
m_position = std::min(sampleOffset, m_numSamples); m_position = std::min(sampleOffset, m_numSamples);
mp3dec_ex_seek(&m_decoder, m_position); mp3dec_ex_seek(&m_decoder, m_position);
@ -144,10 +144,10 @@ void SoundFileReaderMp3::seek(Uint64 sampleOffset)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 SoundFileReaderMp3::read(std::int16_t* samples, Uint64 maxCount) std::uint64_t SoundFileReaderMp3::read(std::int16_t* samples, std::uint64_t maxCount)
{ {
Uint64 toRead = std::min(maxCount, m_numSamples - m_position); std::uint64_t toRead = std::min(maxCount, m_numSamples - m_position);
toRead = static_cast<Uint64>(mp3dec_ex_read(&m_decoder, samples, static_cast<std::size_t>(toRead))); toRead = static_cast<std::uint64_t>(mp3dec_ex_read(&m_decoder, samples, static_cast<std::size_t>(toRead)));
m_position += toRead; m_position += toRead;
return toRead; return toRead;
} }

View File

@ -110,7 +110,7 @@ public:
/// \param sampleOffset Index of the sample to jump to, relative to the beginning /// \param sampleOffset Index of the sample to jump to, relative to the beginning
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void seek(Uint64 sampleOffset) override; void seek(std::uint64_t sampleOffset) override;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Read audio samples from the open file /// \brief Read audio samples from the open file
@ -121,7 +121,7 @@ public:
/// \return Number of samples actually read (may be less than \a maxCount) /// \return Number of samples actually read (may be less than \a maxCount)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override; [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) override;
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -129,8 +129,8 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
mp3dec_io_t m_io; mp3dec_io_t m_io;
mp3dec_ex_t m_decoder; mp3dec_ex_t m_decoder;
Uint64 m_numSamples; // Decompressed audio storage size std::uint64_t m_numSamples; // Decompressed audio storage size
Uint64 m_position; // Position in decompressed audio buffer std::uint64_t m_position; // Position in decompressed audio buffer
}; };
} // namespace priv } // namespace priv

View File

@ -126,7 +126,7 @@ bool SoundFileReaderOgg::open(InputStream& stream, Info& info)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileReaderOgg::seek(Uint64 sampleOffset) void SoundFileReaderOgg::seek(std::uint64_t sampleOffset)
{ {
assert(m_vorbis.datasource); assert(m_vorbis.datasource);
@ -135,12 +135,12 @@ void SoundFileReaderOgg::seek(Uint64 sampleOffset)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 SoundFileReaderOgg::read(std::int16_t* samples, Uint64 maxCount) std::uint64_t SoundFileReaderOgg::read(std::int16_t* samples, std::uint64_t maxCount)
{ {
assert(m_vorbis.datasource); assert(m_vorbis.datasource);
// Try to read the requested number of samples, stop only on error or end of file // Try to read the requested number of samples, stop only on error or end of file
Uint64 count = 0; std::uint64_t count = 0;
while (count < maxCount) while (count < maxCount)
{ {
int bytesToRead = static_cast<int>(maxCount - count) * static_cast<int>(sizeof(std::int16_t)); int bytesToRead = static_cast<int>(maxCount - count) * static_cast<int>(sizeof(std::int16_t));
@ -148,7 +148,7 @@ Uint64 SoundFileReaderOgg::read(std::int16_t* samples, Uint64 maxCount)
if (bytesRead > 0) if (bytesRead > 0)
{ {
long samplesRead = bytesRead / static_cast<long>(sizeof(std::int16_t)); long samplesRead = bytesRead / static_cast<long>(sizeof(std::int16_t));
count += static_cast<Uint64>(samplesRead); count += static_cast<std::uint64_t>(samplesRead);
samples += samplesRead; samples += samplesRead;
} }
else else

View File

@ -91,7 +91,7 @@ public:
/// \param sampleOffset Index of the sample to jump to, relative to the beginning /// \param sampleOffset Index of the sample to jump to, relative to the beginning
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void seek(Uint64 sampleOffset) override; void seek(std::uint64_t sampleOffset) override;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Read audio samples from the open file /// \brief Read audio samples from the open file
@ -102,7 +102,7 @@ public:
/// \return Number of samples actually read (may be less than \a maxCount) /// \return Number of samples actually read (may be less than \a maxCount)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override; [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) override;
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -90,7 +90,7 @@ bool decode(sf::InputStream& stream, std::uint32_t& value)
return true; return true;
} }
const sf::Uint64 mainChunkSize = 12; const std::uint64_t mainChunkSize = 12;
const std::uint16_t waveFormatPcm = 1; const std::uint16_t waveFormatPcm = 1;
@ -139,7 +139,7 @@ bool SoundFileReaderWav::open(InputStream& stream, Info& info)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileReaderWav::seek(Uint64 sampleOffset) void SoundFileReaderWav::seek(std::uint64_t sampleOffset)
{ {
assert(m_stream); assert(m_stream);
@ -149,12 +149,12 @@ void SoundFileReaderWav::seek(Uint64 sampleOffset)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 SoundFileReaderWav::read(std::int16_t* samples, Uint64 maxCount) std::uint64_t SoundFileReaderWav::read(std::int16_t* samples, std::uint64_t maxCount)
{ {
assert(m_stream); assert(m_stream);
Uint64 count = 0; std::uint64_t count = 0;
auto startPos = static_cast<Uint64>(m_stream->tell()); auto startPos = static_cast<std::uint64_t>(m_stream->tell());
// Tracking of m_dataEnd is important to prevent sf::Music from reading // Tracking of m_dataEnd is important to prevent sf::Music from reading
// data until EOF, as WAV files may have metadata at the end. // data until EOF, as WAV files may have metadata at the end.
@ -341,7 +341,7 @@ bool SoundFileReaderWav::parseHeader(Info& info)
info.sampleCount = subChunkSize / m_bytesPerSample; info.sampleCount = subChunkSize / m_bytesPerSample;
// Store the start and end position of samples in the file // Store the start and end position of samples in the file
m_dataStart = static_cast<Uint64>(subChunkStart); m_dataStart = static_cast<std::uint64_t>(subChunkStart);
m_dataEnd = m_dataStart + info.sampleCount * m_bytesPerSample; m_dataEnd = m_dataStart + info.sampleCount * m_bytesPerSample;
dataChunkFound = true; dataChunkFound = true;

View File

@ -81,7 +81,7 @@ public:
/// \param sampleOffset Index of the sample to jump to, relative to the beginning /// \param sampleOffset Index of the sample to jump to, relative to the beginning
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void seek(Uint64 sampleOffset) override; void seek(std::uint64_t sampleOffset) override;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Read audio samples from the open file /// \brief Read audio samples from the open file
@ -92,7 +92,7 @@ public:
/// \return Number of samples actually read (may be less than \a maxCount) /// \return Number of samples actually read (may be less than \a maxCount)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] Uint64 read(std::int16_t* samples, Uint64 maxCount) override; [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) override;
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -110,8 +110,8 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
InputStream* m_stream; //!< Source stream to read from InputStream* m_stream; //!< Source stream to read from
unsigned int m_bytesPerSample; //!< Size of a sample, in bytes unsigned int m_bytesPerSample; //!< Size of a sample, in bytes
Uint64 m_dataStart; //!< Starting position of the audio data in the open file std::uint64_t m_dataStart; //!< Starting position of the audio data in the open file
Uint64 m_dataEnd; //!< Position one byte past the end of the audio data in the open file std::uint64_t m_dataEnd; //!< Position one byte past the end of the audio data in the open file
}; };
} // namespace priv } // namespace priv

View File

@ -93,7 +93,7 @@ bool SoundFileWriterFlac::open(const std::filesystem::path& filename, unsigned i
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileWriterFlac::write(const std::int16_t* samples, Uint64 count) void SoundFileWriterFlac::write(const std::int16_t* samples, std::uint64_t count)
{ {
while (count > 0) while (count > 0)
{ {

View File

@ -88,7 +88,7 @@ public:
/// \param count Number of samples to write /// \param count Number of samples to write
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void write(const std::int16_t* samples, Uint64 count) override; void write(const std::int16_t* samples, std::uint64_t count) override;
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -125,7 +125,7 @@ bool SoundFileWriterOgg::open(const std::filesystem::path& filename, unsigned in
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileWriterOgg::write(const std::int16_t* samples, Uint64 count) void SoundFileWriterOgg::write(const std::int16_t* samples, std::uint64_t count)
{ {
// Vorbis has issues with buffers that are too large, so we ask for 64K // Vorbis has issues with buffers that are too large, so we ask for 64K
constexpr int bufferSize = 65536; constexpr int bufferSize = 65536;

View File

@ -89,7 +89,7 @@ public:
/// \param count Number of samples to write /// \param count Number of samples to write
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void write(const std::int16_t* samples, Uint64 count) override; void write(const std::int16_t* samples, std::uint64_t count) override;
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -109,7 +109,7 @@ bool SoundFileWriterWav::open(const std::filesystem::path& filename, unsigned in
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SoundFileWriterWav::write(const std::int16_t* samples, Uint64 count) void SoundFileWriterWav::write(const std::int16_t* samples, std::uint64_t count)
{ {
assert(m_file.good()); assert(m_file.good());

View File

@ -87,7 +87,7 @@ public:
/// \param count Number of samples to write /// \param count Number of samples to write
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void write(const std::int16_t* samples, Uint64 count) override; void write(const std::int16_t* samples, std::uint64_t count) override;
private: private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -218,7 +218,8 @@ void SoundStream::setPlayingOffset(Time timeOffset)
onSeek(timeOffset); onSeek(timeOffset);
// Restart streaming // Restart streaming
m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate)) * m_channelCount; m_samplesProcessed = static_cast<std::uint64_t>(timeOffset.asSeconds() * static_cast<float>(m_sampleRate)) *
m_channelCount;
if (oldStatus == Stopped) if (oldStatus == Stopped)
return; return;
@ -354,7 +355,7 @@ void SoundStream::streamData()
if (m_bufferSeeks[bufferNum] != NoLoop) if (m_bufferSeeks[bufferNum] != NoLoop)
{ {
// This was the last buffer before EOF or Loop End: reset the sample count // This was the last buffer before EOF or Loop End: reset the sample count
m_samplesProcessed = static_cast<Uint64>(m_bufferSeeks[bufferNum]); m_samplesProcessed = static_cast<std::uint64_t>(m_bufferSeeks[bufferNum]);
m_bufferSeeks[bufferNum] = NoLoop; m_bufferSeeks[bufferNum] = NoLoop;
} }
else else
@ -377,7 +378,7 @@ void SoundStream::streamData()
} }
else else
{ {
m_samplesProcessed += static_cast<Uint64>(size / (bits / 8)); m_samplesProcessed += static_cast<std::uint64_t>(size / (bits / 8));
} }
} }
@ -449,7 +450,7 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop)
if (immediateLoop && (m_bufferSeeks[bufferNum] != NoLoop)) if (immediateLoop && (m_bufferSeeks[bufferNum] != NoLoop))
{ {
// We just tried to begin preloading at EOF or Loop End: reset the sample count // We just tried to begin preloading at EOF or Loop End: reset the sample count
m_samplesProcessed = static_cast<Uint64>(m_bufferSeeks[bufferNum]); m_samplesProcessed = static_cast<std::uint64_t>(m_bufferSeeks[bufferNum]);
m_bufferSeeks[bufferNum] = NoLoop; m_bufferSeeks[bufferNum] = NoLoop;
} }

View File

@ -80,10 +80,10 @@ inline T reinterpret(const U& input)
} }
// Combine outline thickness, boldness and font glyph index into a single 64-bit key // Combine outline thickness, boldness and font glyph index into a single 64-bit key
sf::Uint64 combine(float outlineThickness, bool bold, std::uint32_t index) std::uint64_t combine(float outlineThickness, bool bold, std::uint32_t index)
{ {
return (static_cast<sf::Uint64>(reinterpret<std::uint32_t>(outlineThickness)) << 32) | return (static_cast<std::uint64_t>(reinterpret<std::uint32_t>(outlineThickness)) << 32) |
(static_cast<sf::Uint64>(bold) << 31) | index; (static_cast<std::uint64_t>(bold) << 31) | index;
} }
} // namespace } // namespace
@ -357,7 +357,7 @@ const Glyph& Font::getGlyph(std::uint32_t codePoint, unsigned int characterSize,
GlyphTable& glyphs = loadPage(characterSize).glyphs; GlyphTable& glyphs = loadPage(characterSize).glyphs;
// Build the key by combining the glyph index (based on code point), bold flag, and outline thickness // Build the key by combining the glyph index (based on code point), bold flag, and outline thickness
Uint64 key = combine(outlineThickness, std::uint64_t key = combine(outlineThickness,
bold, bold,
FT_Get_Char_Index(m_fontHandles ? m_fontHandles->face.get() : nullptr, codePoint)); FT_Get_Char_Index(m_fontHandles ? m_fontHandles->face.get() : nullptr, codePoint));

View File

@ -53,22 +53,22 @@ std::recursive_mutex mutex;
// Unique identifier, used for identifying RenderTargets when // Unique identifier, used for identifying RenderTargets when
// tracking the currently active RenderTarget within a given context // tracking the currently active RenderTarget within a given context
sf::Uint64 getUniqueId() std::uint64_t getUniqueId()
{ {
std::scoped_lock lock(mutex); std::scoped_lock lock(mutex);
static sf::Uint64 id = 1; // start at 1, zero is "no RenderTarget" static std::uint64_t id = 1; // start at 1, zero is "no RenderTarget"
return id++; return id++;
} }
// Map to help us detect whether a different RenderTarget // Map to help us detect whether a different RenderTarget
// has been activated within a single context // has been activated within a single context
using ContextRenderTargetMap = std::unordered_map<sf::Uint64, sf::Uint64>; using ContextRenderTargetMap = std::unordered_map<std::uint64_t, std::uint64_t>;
ContextRenderTargetMap contextRenderTargetMap; ContextRenderTargetMap contextRenderTargetMap;
// Check if a RenderTarget with the given ID is active in the current context // Check if a RenderTarget with the given ID is active in the current context
bool isActive(sf::Uint64 id) bool isActive(std::uint64_t id)
{ {
auto it = contextRenderTargetMap.find(sf::Context::getActiveContextId()); auto it = contextRenderTargetMap.find(sf::Context::getActiveContextId());
@ -397,7 +397,7 @@ bool RenderTarget::setActive(bool active)
{ {
std::scoped_lock lock(RenderTargetImpl::mutex); std::scoped_lock lock(RenderTargetImpl::mutex);
Uint64 contextId = Context::getActiveContextId(); std::uint64_t contextId = Context::getActiveContextId();
using RenderTargetImpl::contextRenderTargetMap; using RenderTargetImpl::contextRenderTargetMap;
auto it = contextRenderTargetMap.find(contextId); auto it = contextRenderTargetMap.find(contextId);
@ -709,7 +709,7 @@ void RenderTarget::setupDraw(bool useVertexCache, const RenderStates& states)
} }
else else
{ {
Uint64 textureId = states.texture ? states.texture->m_cacheId : 0; std::uint64_t textureId = states.texture ? states.texture->m_cacheId : 0;
if (textureId != m_cache.lastTextureId) if (textureId != m_cache.lastTextureId)
applyTexture(states.texture); applyTexture(states.texture);
} }

View File

@ -45,7 +45,7 @@ namespace
// Set to track all active FBO mappings // Set to track all active FBO mappings
// This is used to free active FBOs while their owning // This is used to free active FBOs while their owning
// RenderTextureImplFBO is still alive // RenderTextureImplFBO is still alive
std::unordered_set<std::unordered_map<sf::Uint64, unsigned int>*> frameBuffers; std::unordered_set<std::unordered_map<std::uint64_t, unsigned int>*> frameBuffers;
// Set to track all stale FBOs // Set to track all stale FBOs
// This is used to free stale FBOs after their owning // This is used to free stale FBOs after their owning
@ -53,7 +53,7 @@ std::unordered_set<std::unordered_map<sf::Uint64, unsigned int>*> frameBuffers;
// An FBO cannot be destroyed until it's containing context // An FBO cannot be destroyed until it's containing context
// becomes active, so the destruction of the RenderTextureImplFBO // becomes active, so the destruction of the RenderTextureImplFBO
// has to be decoupled from the destruction of the FBOs themselves // has to be decoupled from the destruction of the FBOs themselves
std::set<std::pair<sf::Uint64, unsigned int>> staleFrameBuffers; std::set<std::pair<std::uint64_t, unsigned int>> staleFrameBuffers;
// Mutex to protect both active and stale frame buffer sets // Mutex to protect both active and stale frame buffer sets
std::recursive_mutex mutex; std::recursive_mutex mutex;
@ -63,7 +63,7 @@ std::recursive_mutex mutex;
// might trigger deletion of its contained stale FBOs // might trigger deletion of its contained stale FBOs
void destroyStaleFBOs() void destroyStaleFBOs()
{ {
sf::Uint64 contextId = sf::Context::getActiveContextId(); std::uint64_t contextId = sf::Context::getActiveContextId();
for (auto it = staleFrameBuffers.begin(); it != staleFrameBuffers.end();) for (auto it = staleFrameBuffers.begin(); it != staleFrameBuffers.end();)
{ {
@ -86,7 +86,7 @@ void contextDestroyCallback(void* /*arg*/)
{ {
std::scoped_lock lock(mutex); std::scoped_lock lock(mutex);
sf::Uint64 contextId = sf::Context::getActiveContextId(); std::uint64_t contextId = sf::Context::getActiveContextId();
// Destroy active frame buffer objects // Destroy active frame buffer objects
for (auto* frameBuffer : frameBuffers) for (auto* frameBuffer : frameBuffers)
@ -552,7 +552,7 @@ bool RenderTextureImplFBO::activate(bool active)
return true; return true;
} }
Uint64 contextId = Context::getActiveContextId(); std::uint64_t contextId = Context::getActiveContextId();
// In the odd case we have to activate and there is no active // In the odd case we have to activate and there is no active
// context yet, we have to create one // context yet, we have to create one
@ -582,7 +582,7 @@ bool RenderTextureImplFBO::activate(bool active)
{ {
std::scoped_lock lock(mutex); std::scoped_lock lock(mutex);
std::unordered_map<Uint64, unsigned int>::iterator it; std::unordered_map<std::uint64_t, unsigned int>::iterator it;
if (m_multisample) if (m_multisample)
{ {
@ -632,7 +632,7 @@ void RenderTextureImplFBO::updateTexture(unsigned int)
// are already available within the current context // are already available within the current context
if (m_multisample && m_size.x && m_size.y && activate(true)) if (m_multisample && m_size.x && m_size.y && activate(true))
{ {
Uint64 contextId = Context::getActiveContextId(); std::uint64_t contextId = Context::getActiveContextId();
std::scoped_lock lock(mutex); std::scoped_lock lock(mutex);

View File

@ -137,8 +137,8 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::unordered_map<Uint64, unsigned int> m_frameBuffers; //!< OpenGL frame buffer objects per context std::unordered_map<std::uint64_t, unsigned int> m_frameBuffers; //!< OpenGL frame buffer objects per context
std::unordered_map<Uint64, unsigned int> m_multisampleFrameBuffers; //!< Optional per-context OpenGL frame buffer objects with multisample attachments std::unordered_map<std::uint64_t, unsigned int> m_multisampleFrameBuffers; //!< Optional per-context OpenGL frame buffer objects with multisample attachments
unsigned int m_depthStencilBuffer; //!< Optional depth/stencil buffer attached to the frame buffer unsigned int m_depthStencilBuffer; //!< Optional depth/stencil buffer attached to the frame buffer
unsigned int m_colorBuffer; //!< Optional multisample color buffer attached to the frame buffer unsigned int m_colorBuffer; //!< Optional multisample color buffer attached to the frame buffer
Vector2u m_size; //!< Width and height of the attachments Vector2u m_size; //!< Width and height of the attachments

View File

@ -50,11 +50,11 @@ std::recursive_mutex maximumSizeMutex;
// Thread-safe unique identifier generator, // Thread-safe unique identifier generator,
// is used for states cache (see RenderTarget) // is used for states cache (see RenderTarget)
sf::Uint64 getUniqueId() std::uint64_t getUniqueId()
{ {
std::scoped_lock lock(idMutex); std::scoped_lock lock(idMutex);
static sf::Uint64 id = 1; // start at 1, zero is "no texture" static std::uint64_t id = 1; // start at 1, zero is "no texture"
return id++; return id++;
} }

View File

@ -233,7 +233,7 @@ Packet& Packet::operator>>(std::int64_t& data)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& Packet::operator>>(Uint64& data) Packet& Packet::operator>>(std::uint64_t& data)
{ {
if (checkSize(sizeof(data))) if (checkSize(sizeof(data)))
{ {
@ -242,10 +242,10 @@ Packet& Packet::operator>>(Uint64& data)
std::uint8_t bytes[sizeof(data)]; std::uint8_t bytes[sizeof(data)];
std::memcpy(bytes, &m_data[m_readPos], sizeof(data)); std::memcpy(bytes, &m_data[m_readPos], sizeof(data));
data = (static_cast<Uint64>(bytes[0]) << 56) | (static_cast<Uint64>(bytes[1]) << 48) | data = (static_cast<std::uint64_t>(bytes[0]) << 56) | (static_cast<std::uint64_t>(bytes[1]) << 48) |
(static_cast<Uint64>(bytes[2]) << 40) | (static_cast<Uint64>(bytes[3]) << 32) | (static_cast<std::uint64_t>(bytes[2]) << 40) | (static_cast<std::uint64_t>(bytes[3]) << 32) |
(static_cast<Uint64>(bytes[4]) << 24) | (static_cast<Uint64>(bytes[5]) << 16) | (static_cast<std::uint64_t>(bytes[4]) << 24) | (static_cast<std::uint64_t>(bytes[5]) << 16) |
(static_cast<Uint64>(bytes[6]) << 8) | (static_cast<Uint64>(bytes[7])); (static_cast<std::uint64_t>(bytes[6]) << 8) | (static_cast<std::uint64_t>(bytes[7]));
m_readPos += sizeof(data); m_readPos += sizeof(data);
} }
@ -472,7 +472,7 @@ Packet& Packet::operator<<(std::int64_t data)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet& Packet::operator<<(Uint64 data) Packet& Packet::operator<<(std::uint64_t data)
{ {
// Since htonll is not available everywhere, we have to convert // Since htonll is not available everywhere, we have to convert
// to network byte order (big endian) manually // to network byte order (big endian) manually

View File

@ -31,6 +31,7 @@
#include <SFML/Network/Socket.hpp> #include <SFML/Network/Socket.hpp>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <cstdint>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>

View File

@ -31,6 +31,7 @@
#include <SFML/Network/Socket.hpp> #include <SFML/Network/Socket.hpp>
#include <SFML/System/Win32/WindowsHeader.hpp> #include <SFML/System/Win32/WindowsHeader.hpp>
#include <cstdint>
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>

View File

@ -97,7 +97,7 @@ const Context* Context::getActiveContext()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 Context::getActiveContextId() std::uint64_t Context::getActiveContextId()
{ {
return priv::GlContext::getActiveContextId(); return priv::GlContext::getActiveContextId();
} }

View File

@ -180,7 +180,7 @@ thread_local sf::priv::GlContext* currentContext(nullptr);
std::unique_ptr<ContextType> sharedContext; std::unique_ptr<ContextType> sharedContext;
// Unique identifier, used for identifying contexts when managing unshareable OpenGL resources // Unique identifier, used for identifying contexts when managing unshareable OpenGL resources
sf::Uint64 id = 1; // start at 1, zero is "no context" std::uint64_t id = 1; // start at 1, zero is "no context"
// Set containing callback functions to be called whenever a // Set containing callback functions to be called whenever a
// context is going to be destroyed // context is going to be destroyed
@ -601,7 +601,7 @@ const GlContext* GlContext::getActiveContext()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint64 GlContext::getActiveContextId() std::uint64_t GlContext::getActiveContextId()
{ {
using GlContextImpl::currentContext; using GlContextImpl::currentContext;
return currentContext ? currentContext->m_id : 0; return currentContext ? currentContext->m_id : 0;

View File

@ -34,6 +34,7 @@
#include <SFML/Window/ContextSettings.hpp> #include <SFML/Window/ContextSettings.hpp>
#include <SFML/Window/GlResource.hpp> #include <SFML/Window/GlResource.hpp>
#include <cstdint>
#include <memory> #include <memory>
@ -174,7 +175,7 @@ public:
/// \return The active context's ID or 0 if no context is currently active /// \return The active context's ID or 0 if no context is currently active
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Uint64 getActiveContextId(); static std::uint64_t getActiveContextId();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Destructor /// \brief Destructor
@ -319,7 +320,7 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Uint64 m_id; //!< Unique number that identifies the context const std::uint64_t m_id; //!< Unique number that identifies the context
}; };
} // namespace priv } // namespace priv

View File

@ -29,6 +29,7 @@
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include <cstdint>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Extends NSImage with a convenience method to load images /// Extends NSImage with a convenience method to load images

View File

@ -31,6 +31,7 @@
#include <SFML/Window/WindowHandle.hpp> #include <SFML/Window/WindowHandle.hpp>
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include <cstdint>
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"

View File

@ -11,9 +11,4 @@ TEST_CASE("SFML/Config.hpp")
CHECK(SFML_VERSION_PATCH == EXPECTED_SFML_VERSION_PATCH); CHECK(SFML_VERSION_PATCH == EXPECTED_SFML_VERSION_PATCH);
CHECK(SFML_VERSION_IS_RELEASE == EXPECTED_SFML_VERSION_IS_RELEASE); CHECK(SFML_VERSION_IS_RELEASE == EXPECTED_SFML_VERSION_IS_RELEASE);
} }
SUBCASE("Fixed width types")
{
CHECK(sizeof(sf::Uint64) == 8);
}
} }