mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Use 'auto' where no information is lost
This commit is contained in:
parent
9a0cc4b7dc
commit
2839f6b4d2
@ -137,11 +137,11 @@ public:
|
|||||||
m_points.setPrimitiveType(sf::Points);
|
m_points.setPrimitiveType(sf::Points);
|
||||||
for (int i = 0; i < 40000; ++i)
|
for (int i = 0; i < 40000; ++i)
|
||||||
{
|
{
|
||||||
float x = static_cast<float>(std::rand() % 800);
|
auto x = static_cast<float>(std::rand() % 800);
|
||||||
float y = static_cast<float>(std::rand() % 600);
|
auto y = static_cast<float>(std::rand() % 600);
|
||||||
sf::Uint8 r = static_cast<sf::Uint8>(std::rand() % 255);
|
auto r = static_cast<sf::Uint8>(std::rand() % 255);
|
||||||
sf::Uint8 g = static_cast<sf::Uint8>(std::rand() % 255);
|
auto g = static_cast<sf::Uint8>(std::rand() % 255);
|
||||||
sf::Uint8 b = static_cast<sf::Uint8>(std::rand() % 255);
|
auto b = static_cast<sf::Uint8>(std::rand() % 255);
|
||||||
m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
|
m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ public:
|
|||||||
swapchainExtent.width = clamp<uint32_t>(window.getSize().x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width);
|
swapchainExtent.width = clamp<uint32_t>(window.getSize().x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width);
|
||||||
swapchainExtent.height = clamp<uint32_t>(window.getSize().y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height);
|
swapchainExtent.height = clamp<uint32_t>(window.getSize().y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height);
|
||||||
|
|
||||||
uint32_t imageCount = clamp<uint32_t>(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount);
|
auto imageCount = clamp<uint32_t>(2, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount);
|
||||||
|
|
||||||
VkSwapchainCreateInfoKHR swapchainCreateInfo = VkSwapchainCreateInfoKHR();
|
VkSwapchainCreateInfoKHR swapchainCreateInfo = VkSwapchainCreateInfoKHR();
|
||||||
swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||||
|
@ -656,7 +656,7 @@ Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Get the facet of the locale which deals with character conversion
|
// Get the facet of the locale which deals with character conversion
|
||||||
const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
|
const auto& facet = std::use_facet< std::ctype<wchar_t> >(locale);
|
||||||
|
|
||||||
// Use the facet to convert each character of the input string
|
// Use the facet to convert each character of the input string
|
||||||
return static_cast<Uint32>(facet.widen(input));
|
return static_cast<Uint32>(facet.widen(input));
|
||||||
@ -705,7 +705,7 @@ Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const st
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Get the facet of the locale which deals with character conversion
|
// Get the facet of the locale which deals with character conversion
|
||||||
const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
|
const auto& facet = std::use_facet< std::ctype<wchar_t> >(locale);
|
||||||
|
|
||||||
// Use the facet to convert each character of the input string
|
// Use the facet to convert each character of the input string
|
||||||
*output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);
|
*output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);
|
||||||
|
@ -71,7 +71,7 @@ bool InputSoundFile::openFromFile(const std::string& filename)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Wrap the file into a stream
|
// Wrap the file into a stream
|
||||||
FileInputStream* file = new FileInputStream;
|
auto* file = new FileInputStream;
|
||||||
m_stream = file;
|
m_stream = file;
|
||||||
m_streamOwned = true;
|
m_streamOwned = true;
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ bool InputSoundFile::openFromMemory(const void* data, std::size_t sizeInBytes)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Wrap the memory file into a stream
|
// Wrap the memory file into a stream
|
||||||
MemoryInputStream* memory = new MemoryInputStream;
|
auto* memory = new MemoryInputStream;
|
||||||
m_stream = memory;
|
m_stream = memory;
|
||||||
m_streamOwned = true;
|
m_streamOwned = true;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
|
|||||||
soundPtr->resetBuffer();
|
soundPtr->resetBuffer();
|
||||||
|
|
||||||
// Fill the buffer
|
// Fill the buffer
|
||||||
ALsizei size = static_cast<ALsizei>(m_samples.size() * sizeof(Int16));
|
auto size = static_cast<ALsizei>(m_samples.size() * sizeof(Int16));
|
||||||
alCheck(alBufferData(m_buffer, format, m_samples.data(), size, static_cast<ALsizei>(sampleRate)));
|
alCheck(alBufferData(m_buffer, format, m_samples.data(), size, static_cast<ALsizei>(sampleRate)));
|
||||||
|
|
||||||
// Compute the duration
|
// Compute the duration
|
||||||
|
@ -35,7 +35,7 @@ namespace
|
|||||||
{
|
{
|
||||||
FLAC__StreamDecoderReadStatus streamRead(const FLAC__StreamDecoder*, FLAC__byte buffer[], std::size_t* bytes, void* clientData)
|
FLAC__StreamDecoderReadStatus streamRead(const FLAC__StreamDecoder*, FLAC__byte buffer[], std::size_t* bytes, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
sf::Int64 count = data->stream->read(buffer, static_cast<sf::Int64>(*bytes));
|
sf::Int64 count = data->stream->read(buffer, static_cast<sf::Int64>(*bytes));
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
@ -55,7 +55,7 @@ namespace
|
|||||||
|
|
||||||
FLAC__StreamDecoderSeekStatus streamSeek(const FLAC__StreamDecoder*, FLAC__uint64 absoluteByteOffset, void* clientData)
|
FLAC__StreamDecoderSeekStatus streamSeek(const FLAC__StreamDecoder*, FLAC__uint64 absoluteByteOffset, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
sf::Int64 position = data->stream->seek(static_cast<sf::Int64>(absoluteByteOffset));
|
sf::Int64 position = data->stream->seek(static_cast<sf::Int64>(absoluteByteOffset));
|
||||||
if (position >= 0)
|
if (position >= 0)
|
||||||
@ -66,7 +66,7 @@ namespace
|
|||||||
|
|
||||||
FLAC__StreamDecoderTellStatus streamTell(const FLAC__StreamDecoder*, FLAC__uint64* absoluteByteOffset, void* clientData)
|
FLAC__StreamDecoderTellStatus streamTell(const FLAC__StreamDecoder*, FLAC__uint64* absoluteByteOffset, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
sf::Int64 position = data->stream->tell();
|
sf::Int64 position = data->stream->tell();
|
||||||
if (position >= 0)
|
if (position >= 0)
|
||||||
@ -82,7 +82,7 @@ namespace
|
|||||||
|
|
||||||
FLAC__StreamDecoderLengthStatus streamLength(const FLAC__StreamDecoder*, FLAC__uint64* streamLength, void* clientData)
|
FLAC__StreamDecoderLengthStatus streamLength(const FLAC__StreamDecoder*, FLAC__uint64* streamLength, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
sf::Int64 count = data->stream->getSize();
|
sf::Int64 count = data->stream->getSize();
|
||||||
if (count >= 0)
|
if (count >= 0)
|
||||||
@ -98,14 +98,14 @@ namespace
|
|||||||
|
|
||||||
FLAC__bool streamEof(const FLAC__StreamDecoder*, void* clientData)
|
FLAC__bool streamEof(const FLAC__StreamDecoder*, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
return data->stream->tell() == data->stream->getSize();
|
return data->stream->tell() == data->stream->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC__StreamDecoderWriteStatus streamWrite(const FLAC__StreamDecoder*, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* clientData)
|
FLAC__StreamDecoderWriteStatus streamWrite(const FLAC__StreamDecoder*, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
// Reserve memory if we're going to use the leftovers buffer
|
// Reserve memory if we're going to use the leftovers buffer
|
||||||
unsigned int frameSamples = frame->header.blocksize * frame->header.channels;
|
unsigned int frameSamples = frame->header.blocksize * frame->header.channels;
|
||||||
@ -158,7 +158,7 @@ namespace
|
|||||||
|
|
||||||
void streamMetadata(const FLAC__StreamDecoder*, const FLAC__StreamMetadata* meta, void* clientData)
|
void streamMetadata(const FLAC__StreamDecoder*, const FLAC__StreamMetadata* meta, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
|
|
||||||
if (meta->type == FLAC__METADATA_TYPE_STREAMINFO)
|
if (meta->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||||
{
|
{
|
||||||
@ -170,7 +170,7 @@ namespace
|
|||||||
|
|
||||||
void streamError(const FLAC__StreamDecoder*, FLAC__StreamDecoderErrorStatus, void* clientData)
|
void streamError(const FLAC__StreamDecoder*, FLAC__StreamDecoderErrorStatus, void* clientData)
|
||||||
{
|
{
|
||||||
sf::priv::SoundFileReaderFlac::ClientData* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
auto* data = static_cast<sf::priv::SoundFileReaderFlac::ClientData*>(clientData);
|
||||||
data->error = true;
|
data->error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,13 @@ namespace
|
|||||||
{
|
{
|
||||||
size_t read(void* ptr, size_t size, size_t nmemb, void* data)
|
size_t read(void* ptr, size_t size, size_t nmemb, void* data)
|
||||||
{
|
{
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(data);
|
auto* stream = static_cast<sf::InputStream*>(data);
|
||||||
return static_cast<std::size_t>(stream->read(ptr, static_cast<sf::Int64>(size * nmemb)));
|
return static_cast<std::size_t>(stream->read(ptr, static_cast<sf::Int64>(size * nmemb)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int seek(void* data, ogg_int64_t offset, int whence)
|
int seek(void* data, ogg_int64_t offset, int whence)
|
||||||
{
|
{
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(data);
|
auto* stream = static_cast<sf::InputStream*>(data);
|
||||||
switch (whence)
|
switch (whence)
|
||||||
{
|
{
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
@ -59,7 +59,7 @@ namespace
|
|||||||
|
|
||||||
long tell(void* data)
|
long tell(void* data)
|
||||||
{
|
{
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(data);
|
auto* stream = static_cast<sf::InputStream*>(data);
|
||||||
return static_cast<long>(stream->tell());
|
return static_cast<long>(stream->tell());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
|
|||||||
assert(m_stream);
|
assert(m_stream);
|
||||||
|
|
||||||
Uint64 count = 0;
|
Uint64 count = 0;
|
||||||
Uint64 startPos = static_cast<Uint64>(m_stream->tell());
|
auto startPos = static_cast<Uint64>(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.
|
||||||
|
@ -165,7 +165,7 @@ bool SoundFileWriterWav::writeHeader(unsigned int sampleRate, unsigned int chann
|
|||||||
encode(m_file, sampleRate);
|
encode(m_file, sampleRate);
|
||||||
Uint32 byteRate = sampleRate * channelCount * 2;
|
Uint32 byteRate = sampleRate * channelCount * 2;
|
||||||
encode(m_file, byteRate);
|
encode(m_file, byteRate);
|
||||||
Uint16 blockAlign = static_cast<Uint16>(channelCount * 2);
|
auto blockAlign = static_cast<Uint16>(channelCount * 2);
|
||||||
encode(m_file, blockAlign);
|
encode(m_file, blockAlign);
|
||||||
Uint16 bitsPerSample = 16;
|
Uint16 bitsPerSample = 16;
|
||||||
encode(m_file, bitsPerSample);
|
encode(m_file, bitsPerSample);
|
||||||
|
@ -452,7 +452,7 @@ bool SoundStream::fillAndPushBuffer(unsigned int bufferNum, bool immediateLoop)
|
|||||||
unsigned int buffer = m_buffers[bufferNum];
|
unsigned int buffer = m_buffers[bufferNum];
|
||||||
|
|
||||||
// Fill the buffer
|
// Fill the buffer
|
||||||
ALsizei size = static_cast<ALsizei>(data.sampleCount * sizeof(Int16));
|
auto size = static_cast<ALsizei>(data.sampleCount * sizeof(Int16));
|
||||||
alCheck(alBufferData(buffer, m_format, data.samples, size, static_cast<ALsizei>(m_sampleRate)));
|
alCheck(alBufferData(buffer, m_format, data.samples, size, static_cast<ALsizei>(m_sampleRate)));
|
||||||
|
|
||||||
// Push it into the sound queue
|
// Push it into the sound queue
|
||||||
|
@ -48,8 +48,8 @@ namespace
|
|||||||
// FreeType callbacks that operate on a sf::InputStream
|
// FreeType callbacks that operate on a sf::InputStream
|
||||||
unsigned long read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count)
|
unsigned long read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count)
|
||||||
{
|
{
|
||||||
sf::Int64 convertedOffset = static_cast<sf::Int64>(offset);
|
auto convertedOffset = static_cast<sf::Int64>(offset);
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(rec->descriptor.pointer);
|
auto* stream = static_cast<sf::InputStream*>(rec->descriptor.pointer);
|
||||||
if (stream->seek(convertedOffset) == convertedOffset)
|
if (stream->seek(convertedOffset) == convertedOffset)
|
||||||
{
|
{
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
@ -281,7 +281,7 @@ bool Font::loadFromStream(InputStream& stream)
|
|||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
|
|
||||||
// Prepare a wrapper for our stream, that we'll pass to FreeType callbacks
|
// Prepare a wrapper for our stream, that we'll pass to FreeType callbacks
|
||||||
FT_StreamRec* rec = new FT_StreamRec;
|
auto* rec = new FT_StreamRec;
|
||||||
std::memset(rec, 0, sizeof(*rec));
|
std::memset(rec, 0, sizeof(*rec));
|
||||||
rec->base = nullptr;
|
rec->base = nullptr;
|
||||||
rec->size = static_cast<unsigned long>(stream.getSize());
|
rec->size = static_cast<unsigned long>(stream.getSize());
|
||||||
@ -382,7 +382,7 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize,
|
|||||||
if (first == 0 || second == 0)
|
if (first == 0 || second == 0)
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
FT_Face face = static_cast<FT_Face>(m_face);
|
auto face = static_cast<FT_Face>(m_face);
|
||||||
|
|
||||||
if (face && setCurrentSize(characterSize))
|
if (face && setCurrentSize(characterSize))
|
||||||
{
|
{
|
||||||
@ -391,8 +391,8 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize,
|
|||||||
FT_UInt index2 = FT_Get_Char_Index(face, second);
|
FT_UInt index2 = FT_Get_Char_Index(face, second);
|
||||||
|
|
||||||
// Retrieve position compensation deltas generated by FT_LOAD_FORCE_AUTOHINT flag
|
// Retrieve position compensation deltas generated by FT_LOAD_FORCE_AUTOHINT flag
|
||||||
float firstRsbDelta = static_cast<float>(getGlyph(first, characterSize, bold).rsbDelta);
|
auto firstRsbDelta = static_cast<float>(getGlyph(first, characterSize, bold).rsbDelta);
|
||||||
float secondLsbDelta = static_cast<float>(getGlyph(second, characterSize, bold).lsbDelta);
|
auto secondLsbDelta = static_cast<float>(getGlyph(second, characterSize, bold).lsbDelta);
|
||||||
|
|
||||||
// Get the kerning vector if present
|
// Get the kerning vector if present
|
||||||
FT_Vector kerning;
|
FT_Vector kerning;
|
||||||
@ -419,7 +419,7 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize,
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
float Font::getLineSpacing(unsigned int characterSize) const
|
float Font::getLineSpacing(unsigned int characterSize) const
|
||||||
{
|
{
|
||||||
FT_Face face = static_cast<FT_Face>(m_face);
|
auto face = static_cast<FT_Face>(m_face);
|
||||||
|
|
||||||
if (face && setCurrentSize(characterSize))
|
if (face && setCurrentSize(characterSize))
|
||||||
{
|
{
|
||||||
@ -435,7 +435,7 @@ float Font::getLineSpacing(unsigned int characterSize) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
float Font::getUnderlinePosition(unsigned int characterSize) const
|
float Font::getUnderlinePosition(unsigned int characterSize) const
|
||||||
{
|
{
|
||||||
FT_Face face = static_cast<FT_Face>(m_face);
|
auto face = static_cast<FT_Face>(m_face);
|
||||||
|
|
||||||
if (face && setCurrentSize(characterSize))
|
if (face && setCurrentSize(characterSize))
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ float Font::getUnderlinePosition(unsigned int characterSize) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
float Font::getUnderlineThickness(unsigned int characterSize) const
|
float Font::getUnderlineThickness(unsigned int characterSize) const
|
||||||
{
|
{
|
||||||
FT_Face face = static_cast<FT_Face>(m_face);
|
auto face = static_cast<FT_Face>(m_face);
|
||||||
|
|
||||||
if (face && setCurrentSize(characterSize))
|
if (face && setCurrentSize(characterSize))
|
||||||
{
|
{
|
||||||
@ -573,7 +573,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
|||||||
Glyph glyph;
|
Glyph glyph;
|
||||||
|
|
||||||
// First, transform our ugly void* to a FT_Face
|
// First, transform our ugly void* to a FT_Face
|
||||||
FT_Face face = static_cast<FT_Face>(m_face);
|
auto face = static_cast<FT_Face>(m_face);
|
||||||
if (!face)
|
if (!face)
|
||||||
return glyph;
|
return glyph;
|
||||||
|
|
||||||
@ -600,13 +600,13 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
|||||||
{
|
{
|
||||||
if (bold)
|
if (bold)
|
||||||
{
|
{
|
||||||
FT_OutlineGlyph outlineGlyph = reinterpret_cast<FT_OutlineGlyph>(glyphDesc);
|
auto outlineGlyph = reinterpret_cast<FT_OutlineGlyph>(glyphDesc);
|
||||||
FT_Outline_Embolden(&outlineGlyph->outline, weight);
|
FT_Outline_Embolden(&outlineGlyph->outline, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outlineThickness != 0)
|
if (outlineThickness != 0)
|
||||||
{
|
{
|
||||||
FT_Stroker stroker = static_cast<FT_Stroker>(m_stroker);
|
auto stroker = static_cast<FT_Stroker>(m_stroker);
|
||||||
|
|
||||||
FT_Stroker_Set(stroker, static_cast<FT_Fixed>(outlineThickness * static_cast<float>(1 << 6)), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
|
FT_Stroker_Set(stroker, static_cast<FT_Fixed>(outlineThickness * static_cast<float>(1 << 6)), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
|
||||||
FT_Glyph_Stroke(&glyphDesc, stroker, true);
|
FT_Glyph_Stroke(&glyphDesc, stroker, true);
|
||||||
@ -617,7 +617,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
|||||||
// Warning! After this line, do not read any data from glyphDesc directly, use
|
// Warning! After this line, do not read any data from glyphDesc directly, use
|
||||||
// bitmapGlyph.root to access the FT_Glyph data.
|
// bitmapGlyph.root to access the FT_Glyph data.
|
||||||
FT_Glyph_To_Bitmap(&glyphDesc, FT_RENDER_MODE_NORMAL, 0, 1);
|
FT_Glyph_To_Bitmap(&glyphDesc, FT_RENDER_MODE_NORMAL, 0, 1);
|
||||||
FT_BitmapGlyph bitmapGlyph = reinterpret_cast<FT_BitmapGlyph>(glyphDesc);
|
auto bitmapGlyph = reinterpret_cast<FT_BitmapGlyph>(glyphDesc);
|
||||||
FT_Bitmap& bitmap = bitmapGlyph->bitmap;
|
FT_Bitmap& bitmap = bitmapGlyph->bitmap;
|
||||||
|
|
||||||
// Apply bold if necessary -- fallback technique using bitmap (lower quality)
|
// Apply bold if necessary -- fallback technique using bitmap (lower quality)
|
||||||
@ -805,7 +805,7 @@ bool Font::setCurrentSize(unsigned int characterSize) const
|
|||||||
// FT_Set_Pixel_Sizes is an expensive function, so we must call it
|
// FT_Set_Pixel_Sizes is an expensive function, so we must call it
|
||||||
// only when necessary to avoid killing performances
|
// only when necessary to avoid killing performances
|
||||||
|
|
||||||
FT_Face face = static_cast<FT_Face>(m_face);
|
auto face = static_cast<FT_Face>(m_face);
|
||||||
FT_UShort currentSize = face->size->metrics.x_ppem;
|
FT_UShort currentSize = face->size->metrics.x_ppem;
|
||||||
|
|
||||||
if (currentSize != characterSize)
|
if (currentSize != characterSize)
|
||||||
|
@ -211,8 +211,8 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then find the valid bounds of the destination rectangle
|
// Then find the valid bounds of the destination rectangle
|
||||||
unsigned int width = static_cast<unsigned int>(srcRect.width);
|
auto width = static_cast<unsigned int>(srcRect.width);
|
||||||
unsigned int height = static_cast<unsigned int>(srcRect.height);
|
auto height = static_cast<unsigned int>(srcRect.height);
|
||||||
if (destX + width > m_size.x) width = m_size.x - destX;
|
if (destX + width > m_size.x) width = m_size.x - destX;
|
||||||
if (destY + height > m_size.y) height = m_size.y - destY;
|
if (destY + height > m_size.y) height = m_size.y - destY;
|
||||||
|
|
||||||
|
@ -50,25 +50,25 @@ namespace
|
|||||||
// stb_image callbacks that operate on a sf::InputStream
|
// stb_image callbacks that operate on a sf::InputStream
|
||||||
int read(void* user, char* data, int size)
|
int read(void* user, char* data, int size)
|
||||||
{
|
{
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(user);
|
auto* stream = static_cast<sf::InputStream*>(user);
|
||||||
return static_cast<int>(stream->read(data, size));
|
return static_cast<int>(stream->read(data, size));
|
||||||
}
|
}
|
||||||
void skip(void* user, int size)
|
void skip(void* user, int size)
|
||||||
{
|
{
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(user);
|
auto* stream = static_cast<sf::InputStream*>(user);
|
||||||
stream->seek(stream->tell() + size);
|
stream->seek(stream->tell() + size);
|
||||||
}
|
}
|
||||||
int eof(void* user)
|
int eof(void* user)
|
||||||
{
|
{
|
||||||
sf::InputStream* stream = static_cast<sf::InputStream*>(user);
|
auto* stream = static_cast<sf::InputStream*>(user);
|
||||||
return stream->tell() >= stream->getSize();
|
return stream->tell() >= stream->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// stb_image callback for constructing a buffer
|
// stb_image callback for constructing a buffer
|
||||||
void bufferFromCallback(void* context, void* data, int size)
|
void bufferFromCallback(void* context, void* data, int size)
|
||||||
{
|
{
|
||||||
sf::Uint8* source = static_cast<sf::Uint8*>(data);
|
auto* source = static_cast<sf::Uint8*>(data);
|
||||||
std::vector<sf::Uint8>* dest = static_cast<std::vector<sf::Uint8>*>(context);
|
auto* dest = static_cast<std::vector<sf::Uint8>*>(context);
|
||||||
std::copy(source, source + size, std::back_inserter(*dest));
|
std::copy(source, source + size, std::back_inserter(*dest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, st
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
int channels = 0;
|
int channels = 0;
|
||||||
const unsigned char* buffer = static_cast<const unsigned char*>(data);
|
const auto* buffer = static_cast<const unsigned char*>(data);
|
||||||
unsigned char* ptr = stbi_load_from_memory(buffer, static_cast<int>(dataSize), &width, &height, &channels, STBI_rgb_alpha);
|
unsigned char* ptr = stbi_load_from_memory(buffer, static_cast<int>(dataSize), &width, &height, &channels, STBI_rgb_alpha);
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
|
@ -66,7 +66,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (it->first == contextId)
|
if (it->first == contextId)
|
||||||
{
|
{
|
||||||
GLuint frameBuffer = static_cast<GLuint>(it->second);
|
auto frameBuffer = static_cast<GLuint>(it->second);
|
||||||
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
||||||
|
|
||||||
staleFrameBuffers.erase(it++);
|
staleFrameBuffers.erase(it++);
|
||||||
|
@ -968,7 +968,7 @@ void Shader::bindTextures() const
|
|||||||
auto it = m_textures.begin();
|
auto it = m_textures.begin();
|
||||||
for (std::size_t i = 0; i < m_textures.size(); ++i)
|
for (std::size_t i = 0; i < m_textures.size(); ++i)
|
||||||
{
|
{
|
||||||
GLint index = static_cast<GLsizei>(i + 1);
|
auto index = static_cast<GLsizei>(i + 1);
|
||||||
glCheck(GLEXT_glUniform1i(it->first, index));
|
glCheck(GLEXT_glUniform1i(it->first, index));
|
||||||
glCheck(GLEXT_glActiveTexture(GLEXT_GL_TEXTURE0 + static_cast<GLenum>(index)));
|
glCheck(GLEXT_glActiveTexture(GLEXT_GL_TEXTURE0 + static_cast<GLenum>(index)));
|
||||||
Texture::bind(it->second);
|
Texture::bind(it->second);
|
||||||
|
@ -237,7 +237,7 @@ void Shape::updateFillColors()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Shape::updateTexCoords()
|
void Shape::updateTexCoords()
|
||||||
{
|
{
|
||||||
FloatRect convertedTextureRect = FloatRect(m_textureRect);
|
FloatRect convertedTextureRect(m_textureRect);
|
||||||
|
|
||||||
for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i)
|
for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -124,8 +124,8 @@ const Color& Sprite::getColor() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
FloatRect Sprite::getLocalBounds() const
|
FloatRect Sprite::getLocalBounds() const
|
||||||
{
|
{
|
||||||
float width = static_cast<float>(std::abs(m_textureRect.width));
|
auto width = static_cast<float>(std::abs(m_textureRect.width));
|
||||||
float height = static_cast<float>(std::abs(m_textureRect.height));
|
auto height = static_cast<float>(std::abs(m_textureRect.height));
|
||||||
|
|
||||||
return FloatRect(0.f, 0.f, width, height);
|
return FloatRect(0.f, 0.f, width, height);
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ void Sprite::updatePositions()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Sprite::updateTexCoords()
|
void Sprite::updateTexCoords()
|
||||||
{
|
{
|
||||||
FloatRect convertedTextureRect = FloatRect(m_textureRect);
|
FloatRect convertedTextureRect(m_textureRect);
|
||||||
|
|
||||||
float left = convertedTextureRect.left;
|
float left = convertedTextureRect.left;
|
||||||
float right = left + convertedTextureRect.width;
|
float right = left + convertedTextureRect.width;
|
||||||
|
@ -434,11 +434,11 @@ void Text::ensureGeometryUpdate() const
|
|||||||
whitespaceWidth += letterSpacing;
|
whitespaceWidth += letterSpacing;
|
||||||
float lineSpacing = m_font->getLineSpacing(m_characterSize) * m_lineSpacingFactor;
|
float lineSpacing = m_font->getLineSpacing(m_characterSize) * m_lineSpacingFactor;
|
||||||
float x = 0.f;
|
float x = 0.f;
|
||||||
float y = static_cast<float>(m_characterSize);
|
auto y = static_cast<float>(m_characterSize);
|
||||||
|
|
||||||
// Create one quad for each character
|
// Create one quad for each character
|
||||||
float minX = static_cast<float>(m_characterSize);
|
auto minX = static_cast<float>(m_characterSize);
|
||||||
float minY = static_cast<float>(m_characterSize);
|
auto minY = static_cast<float>(m_characterSize);
|
||||||
float maxX = 0.f;
|
float maxX = 0.f;
|
||||||
float maxY = 0.f;
|
float maxY = 0.f;
|
||||||
Uint32 prevChar = 0;
|
Uint32 prevChar = 0;
|
||||||
|
@ -412,7 +412,7 @@ Packet& Packet::operator <<(Uint8 data)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Packet& Packet::operator <<(Int16 data)
|
Packet& Packet::operator <<(Int16 data)
|
||||||
{
|
{
|
||||||
Int16 toWrite = static_cast<Int16>(htons(static_cast<uint16_t>(data)));
|
auto toWrite = static_cast<Int16>(htons(static_cast<uint16_t>(data)));
|
||||||
append(&toWrite, sizeof(toWrite));
|
append(&toWrite, sizeof(toWrite));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ Packet& Packet::operator <<(double data)
|
|||||||
Packet& Packet::operator <<(const char* data)
|
Packet& Packet::operator <<(const char* data)
|
||||||
{
|
{
|
||||||
// First insert string length
|
// First insert string length
|
||||||
Uint32 length = static_cast<Uint32>(std::strlen(data));
|
auto length = static_cast<Uint32>(std::strlen(data));
|
||||||
*this << length;
|
*this << length;
|
||||||
|
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
@ -521,7 +521,7 @@ Packet& Packet::operator <<(const char* data)
|
|||||||
Packet& Packet::operator <<(const std::string& data)
|
Packet& Packet::operator <<(const std::string& data)
|
||||||
{
|
{
|
||||||
// First insert string length
|
// First insert string length
|
||||||
Uint32 length = static_cast<Uint32>(data.size());
|
auto length = static_cast<Uint32>(data.size());
|
||||||
*this << length;
|
*this << length;
|
||||||
|
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
@ -536,7 +536,7 @@ Packet& Packet::operator <<(const std::string& data)
|
|||||||
Packet& Packet::operator <<(const wchar_t* data)
|
Packet& Packet::operator <<(const wchar_t* data)
|
||||||
{
|
{
|
||||||
// First insert string length
|
// First insert string length
|
||||||
Uint32 length = static_cast<Uint32>(std::wcslen(data));
|
auto length = static_cast<Uint32>(std::wcslen(data));
|
||||||
*this << length;
|
*this << length;
|
||||||
|
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
@ -551,7 +551,7 @@ Packet& Packet::operator <<(const wchar_t* data)
|
|||||||
Packet& Packet::operator <<(const std::wstring& data)
|
Packet& Packet::operator <<(const std::wstring& data)
|
||||||
{
|
{
|
||||||
// First insert string length
|
// First insert string length
|
||||||
Uint32 length = static_cast<Uint32>(data.size());
|
auto length = static_cast<Uint32>(data.size());
|
||||||
*this << length;
|
*this << length;
|
||||||
|
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
@ -569,7 +569,7 @@ Packet& Packet::operator <<(const std::wstring& data)
|
|||||||
Packet& Packet::operator <<(const String& data)
|
Packet& Packet::operator <<(const String& data)
|
||||||
{
|
{
|
||||||
// First insert the string length
|
// First insert the string length
|
||||||
Uint32 length = static_cast<Uint32>(data.getSize());
|
auto length = static_cast<Uint32>(data.getSize());
|
||||||
*this << length;
|
*this << length;
|
||||||
|
|
||||||
// Then insert characters
|
// Then insert characters
|
||||||
|
@ -83,7 +83,7 @@ private:
|
|||||||
if (pbase() != pptr())
|
if (pbase() != pptr())
|
||||||
{
|
{
|
||||||
// Print the contents of the write buffer into the standard error output
|
// Print the contents of the write buffer into the standard error output
|
||||||
std::size_t size = static_cast<std::size_t>(pptr() - pbase());
|
auto size = static_cast<std::size_t>(pptr() - pbase());
|
||||||
fwrite(pbase(), 1, size, stderr);
|
fwrite(pbase(), 1, size, stderr);
|
||||||
|
|
||||||
// Reset the pointer position to the beginning of the write buffer
|
// Reset the pointer position to the beginning of the write buffer
|
||||||
|
@ -76,7 +76,7 @@ void ThreadImpl::terminate()
|
|||||||
void* ThreadImpl::entryPoint(void* userData)
|
void* ThreadImpl::entryPoint(void* userData)
|
||||||
{
|
{
|
||||||
// The Thread instance is stored in the user data
|
// The Thread instance is stored in the user data
|
||||||
Thread* owner = static_cast<Thread*>(userData);
|
auto* owner = static_cast<Thread*>(userData);
|
||||||
|
|
||||||
#ifndef SFML_SYSTEM_ANDROID
|
#ifndef SFML_SYSTEM_ANDROID
|
||||||
// Tell the thread to handle cancel requests immediately
|
// Tell the thread to handle cancel requests immediately
|
||||||
|
@ -77,7 +77,7 @@ void ThreadImpl::terminate()
|
|||||||
unsigned int __stdcall ThreadImpl::entryPoint(void* userData)
|
unsigned int __stdcall ThreadImpl::entryPoint(void* userData)
|
||||||
{
|
{
|
||||||
// The Thread instance is stored in the user data
|
// The Thread instance is stored in the user data
|
||||||
Thread* owner = static_cast<Thread*>(userData);
|
auto* owner = static_cast<Thread*>(userData);
|
||||||
|
|
||||||
// Forward to the owner
|
// Forward to the owner
|
||||||
owner->run();
|
owner->run();
|
||||||
|
@ -239,9 +239,9 @@ namespace
|
|||||||
{
|
{
|
||||||
extensions.clear();
|
extensions.clear();
|
||||||
|
|
||||||
glGetErrorFuncType glGetErrorFunc = reinterpret_cast<glGetErrorFuncType>(sf::priv::GlContext::getFunction("glGetError"));
|
auto glGetErrorFunc = reinterpret_cast<glGetErrorFuncType>(sf::priv::GlContext::getFunction("glGetError"));
|
||||||
glGetIntegervFuncType glGetIntegervFunc = reinterpret_cast<glGetIntegervFuncType>(sf::priv::GlContext::getFunction("glGetIntegerv"));
|
auto glGetIntegervFunc = reinterpret_cast<glGetIntegervFuncType>(sf::priv::GlContext::getFunction("glGetIntegerv"));
|
||||||
glGetStringFuncType glGetStringFunc = reinterpret_cast<glGetStringFuncType>(sf::priv::GlContext::getFunction("glGetString"));
|
auto glGetStringFunc = reinterpret_cast<glGetStringFuncType>(sf::priv::GlContext::getFunction("glGetString"));
|
||||||
|
|
||||||
if (!glGetErrorFunc || !glGetIntegervFunc || !glGetStringFunc)
|
if (!glGetErrorFunc || !glGetIntegervFunc || !glGetStringFunc)
|
||||||
return;
|
return;
|
||||||
@ -250,7 +250,7 @@ namespace
|
|||||||
int majorVersion = 0;
|
int majorVersion = 0;
|
||||||
glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion);
|
glGetIntegervFunc(GL_MAJOR_VERSION, &majorVersion);
|
||||||
|
|
||||||
glGetStringiFuncType glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(sf::priv::GlContext::getFunction("glGetStringi"));
|
auto glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(sf::priv::GlContext::getFunction("glGetStringi"));
|
||||||
|
|
||||||
if (glGetErrorFunc() == GL_INVALID_ENUM || !glGetStringiFunc)
|
if (glGetErrorFunc() == GL_INVALID_ENUM || !glGetStringiFunc)
|
||||||
{
|
{
|
||||||
@ -754,11 +754,11 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
int minorVersion = 0;
|
int minorVersion = 0;
|
||||||
|
|
||||||
// Try the new way first
|
// Try the new way first
|
||||||
glGetIntegervFuncType glGetIntegervFunc = reinterpret_cast<glGetIntegervFuncType>(getFunction("glGetIntegerv"));
|
auto glGetIntegervFunc = reinterpret_cast<glGetIntegervFuncType>(getFunction("glGetIntegerv"));
|
||||||
glGetErrorFuncType glGetErrorFunc = reinterpret_cast<glGetErrorFuncType>(getFunction("glGetError"));
|
auto glGetErrorFunc = reinterpret_cast<glGetErrorFuncType>(getFunction("glGetError"));
|
||||||
glGetStringFuncType glGetStringFunc = reinterpret_cast<glGetStringFuncType>(getFunction("glGetString"));
|
auto glGetStringFunc = reinterpret_cast<glGetStringFuncType>(getFunction("glGetString"));
|
||||||
glEnableFuncType glEnableFunc = reinterpret_cast<glEnableFuncType>(getFunction("glEnable"));
|
auto glEnableFunc = reinterpret_cast<glEnableFuncType>(getFunction("glEnable"));
|
||||||
glIsEnabledFuncType glIsEnabledFunc = reinterpret_cast<glIsEnabledFuncType>(getFunction("glIsEnabled"));
|
auto glIsEnabledFunc = reinterpret_cast<glIsEnabledFuncType>(getFunction("glIsEnabled"));
|
||||||
|
|
||||||
if (!glGetIntegervFunc || !glGetErrorFunc || !glGetStringFunc || !glEnableFunc || !glIsEnabledFunc)
|
if (!glGetIntegervFunc || !glGetErrorFunc || !glGetStringFunc || !glEnableFunc || !glIsEnabledFunc)
|
||||||
{
|
{
|
||||||
@ -837,7 +837,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
|
|||||||
{
|
{
|
||||||
m_settings.attributeFlags |= ContextSettings::Core;
|
m_settings.attributeFlags |= ContextSettings::Core;
|
||||||
|
|
||||||
glGetStringiFuncType glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(getFunction("glGetStringi"));
|
auto glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(getFunction("glGetStringi"));
|
||||||
|
|
||||||
if (glGetStringiFunc)
|
if (glGetStringiFunc)
|
||||||
{
|
{
|
||||||
@ -901,7 +901,7 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings)
|
|||||||
{
|
{
|
||||||
// Perform checks to inform the user if they are getting a context they might not have expected
|
// Perform checks to inform the user if they are getting a context they might not have expected
|
||||||
|
|
||||||
glGetStringFuncType glGetStringFunc = reinterpret_cast<glGetStringFuncType>(getFunction("glGetString"));
|
auto glGetStringFunc = reinterpret_cast<glGetStringFuncType>(getFunction("glGetString"));
|
||||||
|
|
||||||
if (!glGetStringFunc)
|
if (!glGetStringFunc)
|
||||||
{
|
{
|
||||||
|
@ -201,7 +201,7 @@ bool VulkanImplX11::createVulkanSurface(const VkInstance& instance, WindowHandle
|
|||||||
// Make a copy of the instance handle since we get it passed as a reference
|
// Make a copy of the instance handle since we get it passed as a reference
|
||||||
VkInstance inst = instance;
|
VkInstance inst = instance;
|
||||||
|
|
||||||
PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = reinterpret_cast<PFN_vkCreateXlibSurfaceKHR>(wrapper.vkGetInstanceProcAddr(inst, "vkCreateXlibSurfaceKHR"));
|
auto vkCreateXlibSurfaceKHR = reinterpret_cast<PFN_vkCreateXlibSurfaceKHR>(wrapper.vkGetInstanceProcAddr(inst, "vkCreateXlibSurfaceKHR"));
|
||||||
|
|
||||||
if (!vkCreateXlibSurfaceKHR)
|
if (!vkCreateXlibSurfaceKHR)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1002,7 +1002,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
|||||||
{
|
{
|
||||||
// X11 wants BGRA pixels: swap red and blue channels
|
// X11 wants BGRA pixels: swap red and blue channels
|
||||||
// Note: this memory will be freed by XDestroyImage
|
// Note: this memory will be freed by XDestroyImage
|
||||||
Uint8* iconPixels = static_cast<Uint8*>(std::malloc(width * height * 4));
|
auto* iconPixels = static_cast<Uint8*>(std::malloc(width * height * 4));
|
||||||
for (std::size_t i = 0; i < width * height; ++i)
|
for (std::size_t i = 0; i < width * height; ++i)
|
||||||
{
|
{
|
||||||
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
iconPixels[i * 4 + 0] = pixels[i * 4 + 2];
|
||||||
@ -1013,7 +1013,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
|||||||
|
|
||||||
// Create the icon pixmap
|
// Create the icon pixmap
|
||||||
Visual* defVisual = DefaultVisual(m_display, m_screen);
|
Visual* defVisual = DefaultVisual(m_display, m_screen);
|
||||||
unsigned int defDepth = static_cast<unsigned int>(DefaultDepth(m_display, m_screen));
|
auto defDepth = static_cast<unsigned int>(DefaultDepth(m_display, m_screen));
|
||||||
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), width, height, 32, 0);
|
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, reinterpret_cast<char*>(iconPixels), width, height, 32, 0);
|
||||||
if (!iconImage)
|
if (!iconImage)
|
||||||
{
|
{
|
||||||
|
@ -404,7 +404,7 @@ void JoystickImpl::initializeDInput()
|
|||||||
{
|
{
|
||||||
// Try to get the address of the DirectInput8Create entry point
|
// Try to get the address of the DirectInput8Create entry point
|
||||||
using DirectInput8CreateFunc = HRESULT (*)(HINSTANCE, DWORD, const IID &, LPVOID *, LPUNKNOWN);
|
using DirectInput8CreateFunc = HRESULT (*)(HINSTANCE, DWORD, const IID &, LPVOID *, LPUNKNOWN);
|
||||||
DirectInput8CreateFunc directInput8Create = reinterpret_cast<DirectInput8CreateFunc>(reinterpret_cast<void*>(GetProcAddress(dinput8dll, "DirectInput8Create")));
|
auto directInput8Create = reinterpret_cast<DirectInput8CreateFunc>(reinterpret_cast<void*>(GetProcAddress(dinput8dll, "DirectInput8Create")));
|
||||||
|
|
||||||
if (directInput8Create)
|
if (directInput8Create)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ bool VulkanImplWin32::createVulkanSurface(const VkInstance& instance, WindowHand
|
|||||||
// Make a copy of the instance handle since we get it passed as a reference
|
// Make a copy of the instance handle since we get it passed as a reference
|
||||||
VkInstance inst = instance;
|
VkInstance inst = instance;
|
||||||
|
|
||||||
PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = reinterpret_cast<PFN_vkCreateWin32SurfaceKHR>(wrapper.vkGetInstanceProcAddr(inst, "vkCreateWin32SurfaceKHR"));
|
auto vkCreateWin32SurfaceKHR = reinterpret_cast<PFN_vkCreateWin32SurfaceKHR>(wrapper.vkGetInstanceProcAddr(inst, "vkCreateWin32SurfaceKHR"));
|
||||||
|
|
||||||
if (!vkCreateWin32SurfaceKHR)
|
if (!vkCreateWin32SurfaceKHR)
|
||||||
return false;
|
return false;
|
||||||
|
@ -192,12 +192,12 @@ WglContext::~WglContext()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlFunctionPointer WglContext::getFunction(const char* name)
|
GlFunctionPointer WglContext::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
GlFunctionPointer address = reinterpret_cast<GlFunctionPointer>(wglGetProcAddress(reinterpret_cast<LPCSTR>(name)));
|
auto address = reinterpret_cast<GlFunctionPointer>(wglGetProcAddress(reinterpret_cast<LPCSTR>(name)));
|
||||||
|
|
||||||
if (address)
|
if (address)
|
||||||
{
|
{
|
||||||
// Test whether the returned value is a valid error code
|
// Test whether the returned value is a valid error code
|
||||||
ptrdiff_t errorCode = reinterpret_cast<ptrdiff_t>(address);
|
auto errorCode = reinterpret_cast<ptrdiff_t>(address);
|
||||||
|
|
||||||
if ((errorCode != -1) && (errorCode != 1) && (errorCode != 2) && (errorCode != 3))
|
if ((errorCode != -1) && (errorCode != 1) && (errorCode != 2) && (errorCode != 3))
|
||||||
return address;
|
return address;
|
||||||
|
@ -86,7 +86,7 @@ namespace
|
|||||||
};
|
};
|
||||||
|
|
||||||
using SetProcessDpiAwarenessFuncType = HRESULT (*)(ProcessDpiAwareness);
|
using SetProcessDpiAwarenessFuncType = HRESULT (*)(ProcessDpiAwareness);
|
||||||
SetProcessDpiAwarenessFuncType SetProcessDpiAwarenessFunc = reinterpret_cast<SetProcessDpiAwarenessFuncType>(reinterpret_cast<void*>(GetProcAddress(shCoreDll, "SetProcessDpiAwareness")));
|
auto SetProcessDpiAwarenessFunc = reinterpret_cast<SetProcessDpiAwarenessFuncType>(reinterpret_cast<void*>(GetProcAddress(shCoreDll, "SetProcessDpiAwareness")));
|
||||||
|
|
||||||
if (SetProcessDpiAwarenessFunc)
|
if (SetProcessDpiAwarenessFunc)
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ namespace
|
|||||||
if (user32Dll)
|
if (user32Dll)
|
||||||
{
|
{
|
||||||
using SetProcessDPIAwareFuncType = BOOL (*)();
|
using SetProcessDPIAwareFuncType = BOOL (*)();
|
||||||
SetProcessDPIAwareFuncType SetProcessDPIAwareFunc = reinterpret_cast<SetProcessDPIAwareFuncType>(reinterpret_cast<void*>(GetProcAddress(user32Dll, "SetProcessDPIAware")));
|
auto SetProcessDPIAwareFunc = reinterpret_cast<SetProcessDPIAwareFuncType>(reinterpret_cast<void*>(GetProcAddress(user32Dll, "SetProcessDPIAware")));
|
||||||
|
|
||||||
if (SetProcessDPIAwareFunc)
|
if (SetProcessDPIAwareFunc)
|
||||||
{
|
{
|
||||||
@ -658,7 +658,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
// We override the returned information to remove the default limit
|
// We override the returned information to remove the default limit
|
||||||
// (the OS doesn't allow windows bigger than the desktop by default)
|
// (the OS doesn't allow windows bigger than the desktop by default)
|
||||||
MINMAXINFO* info = reinterpret_cast<MINMAXINFO*>(lParam);
|
auto* info = reinterpret_cast<MINMAXINFO*>(lParam);
|
||||||
info->ptMaxTrackSize.x = 50000;
|
info->ptMaxTrackSize.x = 50000;
|
||||||
info->ptMaxTrackSize.y = 50000;
|
info->ptMaxTrackSize.y = 50000;
|
||||||
break;
|
break;
|
||||||
@ -694,7 +694,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
if (m_keyRepeatEnabled || ((lParam & (1 << 30)) == 0))
|
if (m_keyRepeatEnabled || ((lParam & (1 << 30)) == 0))
|
||||||
{
|
{
|
||||||
// Get the code of the typed character
|
// Get the code of the typed character
|
||||||
Uint32 character = static_cast<Uint32>(wParam);
|
auto character = static_cast<Uint32>(wParam);
|
||||||
|
|
||||||
// Check if it is the first part of a surrogate pair, or a regular character
|
// Check if it is the first part of a surrogate pair, or a regular character
|
||||||
if ((character >= 0xD800) && (character <= 0xDBFF))
|
if ((character >= 0xD800) && (character <= 0xDBFF))
|
||||||
@ -765,7 +765,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
position.y = static_cast<Int16>(HIWORD(lParam));
|
position.y = static_cast<Int16>(HIWORD(lParam));
|
||||||
ScreenToClient(m_handle, &position);
|
ScreenToClient(m_handle, &position);
|
||||||
|
|
||||||
Int16 delta = static_cast<Int16>(HIWORD(wParam));
|
auto delta = static_cast<Int16>(HIWORD(wParam));
|
||||||
|
|
||||||
Event event;
|
Event event;
|
||||||
|
|
||||||
@ -793,7 +793,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
position.y = static_cast<Int16>(HIWORD(lParam));
|
position.y = static_cast<Int16>(HIWORD(lParam));
|
||||||
ScreenToClient(m_handle, &position);
|
ScreenToClient(m_handle, &position);
|
||||||
|
|
||||||
Int16 delta = static_cast<Int16>(HIWORD(wParam));
|
auto delta = static_cast<Int16>(HIWORD(wParam));
|
||||||
|
|
||||||
Event event;
|
Event event;
|
||||||
event.type = Event::MouseWheelScrolled;
|
event.type = Event::MouseWheelScrolled;
|
||||||
@ -991,7 +991,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
if ((wParam == DBT_DEVICEARRIVAL) || (wParam == DBT_DEVICEREMOVECOMPLETE))
|
if ((wParam == DBT_DEVICEARRIVAL) || (wParam == DBT_DEVICEREMOVECOMPLETE))
|
||||||
{
|
{
|
||||||
// Some sort of device change has happened, update joystick connections if it is a device interface
|
// Some sort of device change has happened, update joystick connections if it is a device interface
|
||||||
DEV_BROADCAST_HDR* deviceBroadcastHeader = reinterpret_cast<DEV_BROADCAST_HDR*>(lParam);
|
auto* deviceBroadcastHeader = reinterpret_cast<DEV_BROADCAST_HDR*>(lParam);
|
||||||
|
|
||||||
if (deviceBroadcastHeader && (deviceBroadcastHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE))
|
if (deviceBroadcastHeader && (deviceBroadcastHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE))
|
||||||
JoystickImpl::updateConnections();
|
JoystickImpl::updateConnections();
|
||||||
@ -1131,7 +1131,7 @@ LRESULT CALLBACK WindowImplWin32::globalOnEvent(HWND handle, UINT message, WPARA
|
|||||||
if (message == WM_CREATE)
|
if (message == WM_CREATE)
|
||||||
{
|
{
|
||||||
// Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow)
|
// Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow)
|
||||||
LONG_PTR window = reinterpret_cast<LONG_PTR>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
|
auto window = reinterpret_cast<LONG_PTR>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
|
||||||
|
|
||||||
// Set as the "user data" parameter of the window
|
// Set as the "user data" parameter of the window
|
||||||
SetWindowLongPtrW(handle, GWLP_USERDATA, window);
|
SetWindowLongPtrW(handle, GWLP_USERDATA, window);
|
||||||
|
@ -205,7 +205,7 @@ void WindowImpl::processJoystickEvents()
|
|||||||
{
|
{
|
||||||
if (caps.axes[j])
|
if (caps.axes[j])
|
||||||
{
|
{
|
||||||
Joystick::Axis axis = static_cast<Joystick::Axis>(j);
|
auto axis = static_cast<Joystick::Axis>(j);
|
||||||
float prevPos = m_previousAxes[i][axis];
|
float prevPos = m_previousAxes[i][axis];
|
||||||
float currPos = m_joystickStates[i].axes[axis];
|
float currPos = m_joystickStates[i].axes[axis];
|
||||||
if (std::abs(currPos - prevPos) >= m_joystickThreshold)
|
if (std::abs(currPos - prevPos) >= m_joystickThreshold)
|
||||||
@ -250,7 +250,7 @@ void WindowImpl::processSensorEvents()
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < Sensor::Count; ++i)
|
for (unsigned int i = 0; i < Sensor::Count; ++i)
|
||||||
{
|
{
|
||||||
Sensor::Type sensor = static_cast<Sensor::Type>(i);
|
auto sensor = static_cast<Sensor::Type>(i);
|
||||||
|
|
||||||
// Only process enabled sensors
|
// Only process enabled sensors
|
||||||
if (SensorManager::getInstance().isEnabled(sensor))
|
if (SensorManager::getInstance().isEnabled(sensor))
|
||||||
|
Loading…
Reference in New Issue
Block a user