Replaced &container[0] with container.data() wherever applicable.
This commit is contained in:
parent
1df71a356e
commit
e1d3eff587
|
@ -89,7 +89,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill audio data to pass to the stream
|
// Fill audio data to pass to the stream
|
||||||
data.samples = &m_tempBuffer[0];
|
data.samples = m_tempBuffer.data();
|
||||||
data.sampleCount = m_tempBuffer.size();
|
data.sampleCount = m_tempBuffer.size();
|
||||||
|
|
||||||
// Update the playing offset
|
// Update the playing offset
|
||||||
|
|
|
@ -113,8 +113,8 @@ bool Music::onGetData(SoundStream::Chunk& data)
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
// Fill the chunk parameters
|
// Fill the chunk parameters
|
||||||
data.samples = &m_samples[0];
|
data.samples = m_samples.data();
|
||||||
data.sampleCount = static_cast<std::size_t>(m_file.read(&m_samples[0], m_samples.size()));
|
data.sampleCount = static_cast<std::size_t>(m_file.read(m_samples.data(), m_samples.size()));
|
||||||
|
|
||||||
// Check if we have stopped obtaining samples or reached the end of the audio file
|
// Check if we have stopped obtaining samples or reached the end of the audio file
|
||||||
return (data.sampleCount != 0) && (m_file.getSampleOffset() < m_file.getSampleCount());
|
return (data.sampleCount != 0) && (m_file.getSampleOffset() < m_file.getSampleCount());
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool SoundBuffer::saveToFile(const std::string& filename) const
|
||||||
if (file.openFromFile(filename, getSampleRate(), getChannelCount()))
|
if (file.openFromFile(filename, getSampleRate(), getChannelCount()))
|
||||||
{
|
{
|
||||||
// Write the samples to the opened file
|
// Write the samples to the opened file
|
||||||
file.write(&m_samples[0], m_samples.size());
|
file.write(m_samples.data(), m_samples.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ bool SoundBuffer::saveToFile(const std::string& filename) const
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const Int16* SoundBuffer::getSamples() const
|
const Int16* SoundBuffer::getSamples() const
|
||||||
{
|
{
|
||||||
return m_samples.empty() ? NULL : &m_samples[0];
|
return m_samples.empty() ? NULL : m_samples.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ bool SoundBuffer::initialize(InputSoundFile& file)
|
||||||
|
|
||||||
// Read the samples from the provided file
|
// Read the samples from the provided file
|
||||||
m_samples.resize(static_cast<std::size_t>(sampleCount));
|
m_samples.resize(static_cast<std::size_t>(sampleCount));
|
||||||
if (file.read(&m_samples[0], sampleCount) == sampleCount)
|
if (file.read(m_samples.data(), sampleCount) == sampleCount)
|
||||||
{
|
{
|
||||||
// Update the internal buffer with the new samples
|
// Update the internal buffer with the new samples
|
||||||
return update(channelCount, sampleRate);
|
return update(channelCount, sampleRate);
|
||||||
|
@ -262,7 +262,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
|
||||||
|
|
||||||
// Fill the buffer
|
// Fill the buffer
|
||||||
ALsizei size = static_cast<ALsizei>(m_samples.size()) * sizeof(Int16);
|
ALsizei size = static_cast<ALsizei>(m_samples.size()) * sizeof(Int16);
|
||||||
alCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate));
|
alCheck(alBufferData(m_buffer, format, m_samples.data(), size, sampleRate));
|
||||||
|
|
||||||
// Compute the duration
|
// Compute the duration
|
||||||
m_duration = seconds(static_cast<float>(m_samples.size()) / sampleRate / channelCount);
|
m_duration = seconds(static_cast<float>(m_samples.size()) / sampleRate / channelCount);
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool SoundBufferRecorder::onProcessSamples(const Int16* samples, std::size_t sam
|
||||||
void SoundBufferRecorder::onStop()
|
void SoundBufferRecorder::onStop()
|
||||||
{
|
{
|
||||||
if (!m_samples.empty())
|
if (!m_samples.empty())
|
||||||
m_buffer.loadFromSamples(&m_samples[0], m_samples.size(), getChannelCount(), getSampleRate());
|
m_buffer.loadFromSamples(m_samples.data(), m_samples.size(), getChannelCount(), getSampleRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ void SoundFileWriterFlac::write(const Int16* samples, Uint64 count)
|
||||||
m_samples32.assign(samples, samples + frames * m_channelCount);
|
m_samples32.assign(samples, samples + frames * m_channelCount);
|
||||||
|
|
||||||
// Write them to the FLAC stream
|
// Write them to the FLAC stream
|
||||||
FLAC__stream_encoder_process_interleaved(m_encoder, &m_samples32[0], frames);
|
FLAC__stream_encoder_process_interleaved(m_encoder, m_samples32.data(), frames);
|
||||||
|
|
||||||
// Next chunk
|
// Next chunk
|
||||||
count -= m_samples32.size();
|
count -= m_samples32.size();
|
||||||
|
|
|
@ -310,10 +310,10 @@ void SoundRecorder::processCapturedSamples()
|
||||||
{
|
{
|
||||||
// Get the recorded samples
|
// Get the recorded samples
|
||||||
m_samples.resize(samplesAvailable * getChannelCount());
|
m_samples.resize(samplesAvailable * getChannelCount());
|
||||||
alcCaptureSamples(captureDevice, &m_samples[0], samplesAvailable);
|
alcCaptureSamples(captureDevice, m_samples.data(), samplesAvailable);
|
||||||
|
|
||||||
// Forward them to the derived class
|
// Forward them to the derived class
|
||||||
if (!onProcessSamples(&m_samples[0], m_samples.size()))
|
if (!onProcessSamples(m_samples.data(), m_samples.size()))
|
||||||
{
|
{
|
||||||
// The user wants to stop the capture
|
// The user wants to stop the capture
|
||||||
m_isCapturing = false;
|
m_isCapturing = false;
|
||||||
|
|
|
@ -585,7 +585,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
||||||
// Resize the pixel buffer to the new size and fill it with transparent white pixels
|
// Resize the pixel buffer to the new size and fill it with transparent white pixels
|
||||||
m_pixelBuffer.resize(width * height * 4);
|
m_pixelBuffer.resize(width * height * 4);
|
||||||
|
|
||||||
Uint8* current = &m_pixelBuffer[0];
|
Uint8* current = m_pixelBuffer.data();
|
||||||
Uint8* end = current + width * height * 4;
|
Uint8* end = current + width * height * 4;
|
||||||
|
|
||||||
while (current != end)
|
while (current != end)
|
||||||
|
@ -632,7 +632,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f
|
||||||
unsigned int y = glyph.textureRect.top - padding;
|
unsigned int y = glyph.textureRect.top - padding;
|
||||||
unsigned int w = glyph.textureRect.width + 2 * padding;
|
unsigned int w = glyph.textureRect.width + 2 * padding;
|
||||||
unsigned int h = glyph.textureRect.height + 2 * padding;
|
unsigned int h = glyph.textureRect.height + 2 * padding;
|
||||||
page.texture.update(&m_pixelBuffer[0], w, h, x, y);
|
page.texture.update(m_pixelBuffer.data(), w, h, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the FT glyph
|
// Delete the FT glyph
|
||||||
|
|
|
@ -57,7 +57,7 @@ void Image::create(unsigned int width, unsigned int height, const Color& color)
|
||||||
std::vector<Uint8> newPixels(width * height * 4);
|
std::vector<Uint8> newPixels(width * height * 4);
|
||||||
|
|
||||||
// Fill it with the specified color
|
// Fill it with the specified color
|
||||||
Uint8* ptr = &newPixels[0];
|
Uint8* ptr = newPixels.data();
|
||||||
Uint8* end = ptr + newPixels.size();
|
Uint8* end = ptr + newPixels.size();
|
||||||
while (ptr < end)
|
while (ptr < end)
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,7 @@ void Image::createMaskFromColor(const Color& color, Uint8 alpha)
|
||||||
if (!m_pixels.empty())
|
if (!m_pixels.empty())
|
||||||
{
|
{
|
||||||
// Replace the alpha of the pixels that match the transparent color
|
// Replace the alpha of the pixels that match the transparent color
|
||||||
Uint8* ptr = &m_pixels[0];
|
Uint8* ptr = m_pixels.data();
|
||||||
Uint8* end = ptr + m_pixels.size();
|
Uint8* end = ptr + m_pixels.size();
|
||||||
while (ptr < end)
|
while (ptr < end)
|
||||||
{
|
{
|
||||||
|
@ -215,8 +215,8 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co
|
||||||
int rows = height;
|
int rows = height;
|
||||||
int srcStride = source.m_size.x * 4;
|
int srcStride = source.m_size.x * 4;
|
||||||
int dstStride = m_size.x * 4;
|
int dstStride = m_size.x * 4;
|
||||||
const Uint8* srcPixels = &source.m_pixels[0] + (srcRect.left + srcRect.top * source.m_size.x) * 4;
|
const Uint8* srcPixels = source.m_pixels.data() + (srcRect.left + srcRect.top * source.m_size.x) * 4;
|
||||||
Uint8* dstPixels = &m_pixels[0] + (destX + destY * m_size.x) * 4;
|
Uint8* dstPixels = m_pixels.data() + (destX + destY * m_size.x) * 4;
|
||||||
|
|
||||||
// Copy the pixels
|
// Copy the pixels
|
||||||
if (applyAlpha)
|
if (applyAlpha)
|
||||||
|
@ -279,7 +279,7 @@ const Uint8* Image::getPixelsPtr() const
|
||||||
{
|
{
|
||||||
if (!m_pixels.empty())
|
if (!m_pixels.empty())
|
||||||
{
|
{
|
||||||
return &m_pixels[0];
|
return m_pixels.data();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool ImageLoader::loadImageFromFile(const std::string& filename, std::vector<Uin
|
||||||
{
|
{
|
||||||
// Copy the loaded pixels to the pixel buffer
|
// Copy the loaded pixels to the pixel buffer
|
||||||
pixels.resize(width * height * 4);
|
pixels.resize(width * height * 4);
|
||||||
memcpy(&pixels[0], ptr, pixels.size());
|
memcpy(pixels.data(), ptr, pixels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the loaded pixels (they are now in our own pixel buffer)
|
// Free the loaded pixels (they are now in our own pixel buffer)
|
||||||
|
@ -162,7 +162,7 @@ bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, st
|
||||||
{
|
{
|
||||||
// Copy the loaded pixels to the pixel buffer
|
// Copy the loaded pixels to the pixel buffer
|
||||||
pixels.resize(width * height * 4);
|
pixels.resize(width * height * 4);
|
||||||
memcpy(&pixels[0], ptr, pixels.size());
|
memcpy(pixels.data(), ptr, pixels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the loaded pixels (they are now in our own pixel buffer)
|
// Free the loaded pixels (they are now in our own pixel buffer)
|
||||||
|
@ -217,7 +217,7 @@ bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector<Uint8>& p
|
||||||
{
|
{
|
||||||
// Copy the loaded pixels to the pixel buffer
|
// Copy the loaded pixels to the pixel buffer
|
||||||
pixels.resize(width * height * 4);
|
pixels.resize(width * height * 4);
|
||||||
memcpy(&pixels[0], ptr, pixels.size());
|
memcpy(pixels.data(), ptr, pixels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free the loaded pixels (they are now in our own pixel buffer)
|
// Free the loaded pixels (they are now in our own pixel buffer)
|
||||||
|
@ -250,19 +250,19 @@ bool ImageLoader::saveImageToFile(const std::string& filename, const std::vector
|
||||||
if (extension == "bmp")
|
if (extension == "bmp")
|
||||||
{
|
{
|
||||||
// BMP format
|
// BMP format
|
||||||
if (stbi_write_bmp(filename.c_str(), size.x, size.y, 4, &pixels[0]))
|
if (stbi_write_bmp(filename.c_str(), size.x, size.y, 4, pixels.data()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (extension == "tga")
|
else if (extension == "tga")
|
||||||
{
|
{
|
||||||
// TGA format
|
// TGA format
|
||||||
if (stbi_write_tga(filename.c_str(), size.x, size.y, 4, &pixels[0]))
|
if (stbi_write_tga(filename.c_str(), size.x, size.y, 4, pixels.data()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (extension == "png")
|
else if (extension == "png")
|
||||||
{
|
{
|
||||||
// PNG format
|
// PNG format
|
||||||
if (stbi_write_png(filename.c_str(), size.x, size.y, 4, &pixels[0], 0))
|
if (stbi_write_png(filename.c_str(), size.x, size.y, 4, pixels.data(), 0))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (extension == "jpg" || extension == "jpeg")
|
else if (extension == "jpg" || extension == "jpeg")
|
||||||
|
@ -309,7 +309,7 @@ bool ImageLoader::writeJpg(const std::string& filename, const std::vector<Uint8>
|
||||||
buffer[i * 3 + 1] = pixels[i * 4 + 1];
|
buffer[i * 3 + 1] = pixels[i * 4 + 1];
|
||||||
buffer[i * 3 + 2] = pixels[i * 4 + 2];
|
buffer[i * 3 + 2] = pixels[i * 4 + 2];
|
||||||
}
|
}
|
||||||
Uint8* ptr = &buffer[0];
|
Uint8* ptr = buffer.data();
|
||||||
|
|
||||||
// Start compression
|
// Start compression
|
||||||
jpeg_start_compress(&compressInfos, TRUE);
|
jpeg_start_compress(&compressInfos, TRUE);
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace
|
||||||
{
|
{
|
||||||
file.seekg(0, std::ios_base::beg);
|
file.seekg(0, std::ios_base::beg);
|
||||||
buffer.resize(static_cast<std::size_t>(size));
|
buffer.resize(static_cast<std::size_t>(size));
|
||||||
file.read(&buffer[0], size);
|
file.read(buffer.data(), size);
|
||||||
}
|
}
|
||||||
buffer.push_back('\0');
|
buffer.push_back('\0');
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,7 +86,7 @@ namespace
|
||||||
{
|
{
|
||||||
buffer.resize(static_cast<std::size_t>(size));
|
buffer.resize(static_cast<std::size_t>(size));
|
||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
sf::Int64 read = stream.read(&buffer[0], size);
|
sf::Int64 read = stream.read(buffer.data(), size);
|
||||||
success = (read == size);
|
success = (read == size);
|
||||||
}
|
}
|
||||||
buffer.push_back('\0');
|
buffer.push_back('\0');
|
||||||
|
@ -228,11 +228,11 @@ bool Shader::loadFromFile(const std::string& filename, Type type)
|
||||||
|
|
||||||
// Compile the shader program
|
// Compile the shader program
|
||||||
if (type == Vertex)
|
if (type == Vertex)
|
||||||
return compile(&shader[0], NULL, NULL);
|
return compile(shader.data(), NULL, NULL);
|
||||||
else if (type == Geometry)
|
else if (type == Geometry)
|
||||||
return compile(NULL, &shader[0], NULL);
|
return compile(NULL, shader.data(), NULL);
|
||||||
else
|
else
|
||||||
return compile(NULL, NULL, &shader[0]);
|
return compile(NULL, NULL, shader.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the shader program
|
// Compile the shader program
|
||||||
return compile(&vertexShader[0], NULL, &fragmentShader[0]);
|
return compile(vertexShader.data(), NULL, fragmentShader.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the shader program
|
// Compile the shader program
|
||||||
return compile(&vertexShader[0], &geometryShader[0], &fragmentShader[0]);
|
return compile(vertexShader.data(), geometryShader.data(), fragmentShader.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,11 +334,11 @@ bool Shader::loadFromStream(InputStream& stream, Type type)
|
||||||
|
|
||||||
// Compile the shader program
|
// Compile the shader program
|
||||||
if (type == Vertex)
|
if (type == Vertex)
|
||||||
return compile(&shader[0], NULL, NULL);
|
return compile(shader.data(), NULL, NULL);
|
||||||
else if (type == Geometry)
|
else if (type == Geometry)
|
||||||
return compile(NULL, &shader[0], NULL);
|
return compile(NULL, shader.data(), NULL);
|
||||||
else
|
else
|
||||||
return compile(NULL, NULL, &shader[0]);
|
return compile(NULL, NULL, shader.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& fragme
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the shader program
|
// Compile the shader program
|
||||||
return compile(&vertexShader[0], NULL, &fragmentShader[0]);
|
return compile(vertexShader.data(), NULL, fragmentShader.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& geomet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the shader program
|
// Compile the shader program
|
||||||
return compile(&vertexShader[0], &geometryShader[0], &fragmentShader[0]);
|
return compile(vertexShader.data(), geometryShader.data(), fragmentShader.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec2* vectorAr
|
||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniform2fv(binder.location, length, &contiguous[0]));
|
glCheck(GLEXT_glUniform2fv(binder.location, length, contiguous.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec3* vectorAr
|
||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniform3fv(binder.location, length, &contiguous[0]));
|
glCheck(GLEXT_glUniform3fv(binder.location, length, contiguous.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -610,7 +610,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec4* vectorAr
|
||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniform4fv(binder.location, length, &contiguous[0]));
|
glCheck(GLEXT_glUniform4fv(binder.location, length, contiguous.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat3* matrixAr
|
||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniformMatrix3fv(binder.location, length, GL_FALSE, &contiguous[0]));
|
glCheck(GLEXT_glUniformMatrix3fv(binder.location, length, GL_FALSE, contiguous.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixAr
|
||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, &contiguous[0]));
|
glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, contiguous.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ Image Texture::copyToImage() const
|
||||||
|
|
||||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer));
|
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer));
|
||||||
glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0));
|
glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0));
|
||||||
glCheck(glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]));
|
glCheck(glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()));
|
||||||
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
||||||
|
|
||||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer));
|
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer));
|
||||||
|
@ -349,7 +349,7 @@ Image Texture::copyToImage() const
|
||||||
{
|
{
|
||||||
// Texture is not padded nor flipped, we can use a direct copy
|
// Texture is not padded nor flipped, we can use a direct copy
|
||||||
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
||||||
glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]));
|
glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -358,11 +358,11 @@ Image Texture::copyToImage() const
|
||||||
// All the pixels will first be copied to a temporary array
|
// All the pixels will first be copied to a temporary array
|
||||||
std::vector<Uint8> allPixels(m_actualSize.x * m_actualSize.y * 4);
|
std::vector<Uint8> allPixels(m_actualSize.x * m_actualSize.y * 4);
|
||||||
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
|
||||||
glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &allPixels[0]));
|
glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, allPixels.data()));
|
||||||
|
|
||||||
// Then we copy the useful pixels from the temporary array to the final one
|
// Then we copy the useful pixels from the temporary array to the final one
|
||||||
const Uint8* src = &allPixels[0];
|
const Uint8* src = allPixels.data();
|
||||||
Uint8* dst = &pixels[0];
|
Uint8* dst = pixels.data();
|
||||||
int srcPitch = m_actualSize.x * 4;
|
int srcPitch = m_actualSize.x * 4;
|
||||||
int dstPitch = m_size.x * 4;
|
int dstPitch = m_size.x * 4;
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ Image Texture::copyToImage() const
|
||||||
|
|
||||||
// Create the image
|
// Create the image
|
||||||
Image image;
|
Image image;
|
||||||
image.create(m_size.x, m_size.y, &pixels[0]);
|
image.create(m_size.x, m_size.y, pixels.data());
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ FloatRect VertexArray::getBounds() const
|
||||||
void VertexArray::draw(RenderTarget& target, RenderStates states) const
|
void VertexArray::draw(RenderTarget& target, RenderStates states) const
|
||||||
{
|
{
|
||||||
if (!m_vertices.empty())
|
if (!m_vertices.empty())
|
||||||
target.draw(&m_vertices[0], m_vertices.size(), m_primitiveType, states);
|
target.draw(m_vertices.data(), m_vertices.size(), m_primitiveType, states);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
|
|
@ -75,7 +75,7 @@ void Packet::clear()
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const void* Packet::getData() const
|
const void* Packet::getData() const
|
||||||
{
|
{
|
||||||
return !m_data.empty() ? &m_data[0] : NULL;
|
return !m_data.empty() ? m_data.data() : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -317,13 +317,13 @@ Socket::Status TcpSocket::send(Packet& packet)
|
||||||
std::vector<char> blockToSend(sizeof(packetSize) + size);
|
std::vector<char> blockToSend(sizeof(packetSize) + size);
|
||||||
|
|
||||||
// Copy the packet size and data into the block to send
|
// Copy the packet size and data into the block to send
|
||||||
std::memcpy(&blockToSend[0], &packetSize, sizeof(packetSize));
|
std::memcpy(blockToSend.data(), &packetSize, sizeof(packetSize));
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
std::memcpy(&blockToSend[0] + sizeof(packetSize), data, size);
|
std::memcpy(blockToSend.data() + sizeof(packetSize), data, size);
|
||||||
|
|
||||||
// Send the data block
|
// Send the data block
|
||||||
std::size_t sent;
|
std::size_t sent;
|
||||||
Status status = send(&blockToSend[0] + packet.m_sendPos, blockToSend.size() - packet.m_sendPos, sent);
|
Status status = send(blockToSend.data() + packet.m_sendPos, blockToSend.size() - packet.m_sendPos, sent);
|
||||||
|
|
||||||
// In the case of a partial send, record the location to resume from
|
// In the case of a partial send, record the location to resume from
|
||||||
if (status == Partial)
|
if (status == Partial)
|
||||||
|
@ -385,14 +385,14 @@ Socket::Status TcpSocket::receive(Packet& packet)
|
||||||
if (received > 0)
|
if (received > 0)
|
||||||
{
|
{
|
||||||
m_pendingPacket.Data.resize(m_pendingPacket.Data.size() + received);
|
m_pendingPacket.Data.resize(m_pendingPacket.Data.size() + received);
|
||||||
char* begin = &m_pendingPacket.Data[0] + m_pendingPacket.Data.size() - received;
|
char* begin = m_pendingPacket.Data.data() + m_pendingPacket.Data.size() - received;
|
||||||
std::memcpy(begin, buffer, received);
|
std::memcpy(begin, buffer, received);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have received all the packet data: we can copy it to the user packet
|
// We have received all the packet data: we can copy it to the user packet
|
||||||
if (!m_pendingPacket.Data.empty())
|
if (!m_pendingPacket.Data.empty())
|
||||||
packet.onReceive(&m_pendingPacket.Data[0], m_pendingPacket.Data.size());
|
packet.onReceive(m_pendingPacket.Data.data(), m_pendingPacket.Data.size());
|
||||||
|
|
||||||
// Clear the pending packet data
|
// Clear the pending packet data
|
||||||
m_pendingPacket = PendingPacket();
|
m_pendingPacket = PendingPacket();
|
||||||
|
|
|
@ -183,12 +183,12 @@ Socket::Status UdpSocket::receive(Packet& packet, IpAddress& remoteAddress, unsi
|
||||||
|
|
||||||
// Receive the datagram
|
// Receive the datagram
|
||||||
std::size_t received = 0;
|
std::size_t received = 0;
|
||||||
Status status = receive(&m_buffer[0], m_buffer.size(), received, remoteAddress, remotePort);
|
Status status = receive(m_buffer.data(), m_buffer.size(), received, remoteAddress, remotePort);
|
||||||
|
|
||||||
// If we received valid data, we can copy it to the user packet
|
// If we received valid data, we can copy it to the user packet
|
||||||
packet.clear();
|
packet.clear();
|
||||||
if ((status == Done) && (received > 0))
|
if ((status == Done) && (received > 0))
|
||||||
packet.onReceive(&m_buffer[0], received);
|
packet.onReceive(m_buffer.data(), received);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
JoystickState JoystickImpl::JoystickImpl::update()
|
JoystickState JoystickImpl::JoystickImpl::update()
|
||||||
{
|
{
|
||||||
while (read(m_file, &m_buffer[0], m_length) == m_length)
|
while (read(m_file, m_buffer.data(), m_length) == m_length)
|
||||||
{
|
{
|
||||||
hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id);
|
hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id);
|
||||||
|
|
||||||
|
@ -312,11 +312,11 @@ JoystickState JoystickImpl::JoystickImpl::update()
|
||||||
|
|
||||||
if (usage == HUP_BUTTON)
|
if (usage == HUP_BUTTON)
|
||||||
{
|
{
|
||||||
m_state.buttons[buttonIndex++] = hid_get_data(&m_buffer[0], &item);
|
m_state.buttons[buttonIndex++] = hid_get_data(m_buffer.data(), &item);
|
||||||
}
|
}
|
||||||
else if (usage == HUP_GENERIC_DESKTOP)
|
else if (usage == HUP_GENERIC_DESKTOP)
|
||||||
{
|
{
|
||||||
int value = hid_get_data(&m_buffer[0], &item);
|
int value = hid_get_data(m_buffer.data(), &item);
|
||||||
int axis = usageToAxis(usage);
|
int axis = usageToAxis(usage);
|
||||||
|
|
||||||
if (usage == HUG_HAT_SWITCH)
|
if (usage == HUG_HAT_SWITCH)
|
||||||
|
|
|
@ -45,8 +45,8 @@ namespace
|
||||||
CFIndex length = CFStringGetLength(cfString);
|
CFIndex length = CFStringGetLength(cfString);
|
||||||
std::vector<char> str(length);
|
std::vector<char> str(length);
|
||||||
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
||||||
CFStringGetCString(cfString, &str[0], maxSize, kCFStringEncodingUTF8);
|
CFStringGetCString(cfString, str.data(), maxSize, kCFStringEncodingUTF8);
|
||||||
return &str[0];
|
return str.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get HID device property key as a string
|
// Get HID device property key as a string
|
||||||
|
|
|
@ -258,7 +258,7 @@ void SFContext::createContext(SFContext* shared,
|
||||||
m_settings.sRgbCapable = true;
|
m_settings.sRgbCapable = true;
|
||||||
|
|
||||||
// Create the pixel format.
|
// Create the pixel format.
|
||||||
NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attrs[0]];
|
NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.data()];
|
||||||
|
|
||||||
if (pixFmt == nil)
|
if (pixFmt == nil)
|
||||||
{
|
{
|
||||||
|
|
|
@ -701,7 +701,7 @@ void GlxContext::createContext(GlxContext* shared)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, &attributes[0]);
|
m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, attributes.data());
|
||||||
|
|
||||||
if (!m_context)
|
if (!m_context)
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace
|
||||||
buffer[offset] = 0;
|
buffer[offset] = 0;
|
||||||
|
|
||||||
// Remove the path to keep the executable name only
|
// Remove the path to keep the executable name only
|
||||||
return basename(&buffer[0]);
|
return basename(buffer.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default fallback name
|
// Default fallback name
|
||||||
|
@ -581,7 +581,7 @@ m_lastInputTime (0)
|
||||||
std::string executableName = findExecutableName();
|
std::string executableName = findExecutableName();
|
||||||
std::vector<char> windowInstance(executableName.size() + 1, 0);
|
std::vector<char> windowInstance(executableName.size() + 1, 0);
|
||||||
std::copy(executableName.begin(), executableName.end(), windowInstance.begin());
|
std::copy(executableName.begin(), executableName.end(), windowInstance.begin());
|
||||||
hint->res_name = &windowInstance[0];
|
hint->res_name = windowInstance.data();
|
||||||
|
|
||||||
// The class name identifies a class of windows that
|
// The class name identifies a class of windows that
|
||||||
// "are of the same type". We simply use the initial window name as
|
// "are of the same type". We simply use the initial window name as
|
||||||
|
@ -589,7 +589,7 @@ m_lastInputTime (0)
|
||||||
std::string ansiTitle = title.toAnsiString();
|
std::string ansiTitle = title.toAnsiString();
|
||||||
std::vector<char> windowClass(ansiTitle.size() + 1, 0);
|
std::vector<char> windowClass(ansiTitle.size() + 1, 0);
|
||||||
std::copy(ansiTitle.begin(), ansiTitle.end(), windowClass.begin());
|
std::copy(ansiTitle.begin(), ansiTitle.end(), windowClass.begin());
|
||||||
hint->res_class = &windowClass[0];
|
hint->res_class = windowClass.data();
|
||||||
|
|
||||||
XSetClassHint(m_display, m_window, hint);
|
XSetClassHint(m_display, m_window, hint);
|
||||||
|
|
||||||
|
@ -822,7 +822,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, (char*)&maskPixels[0], width, height, 1, 0, 1);
|
m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, reinterpret_cast<char*>(maskPixels.data()), width, height, 1, 0, 1);
|
||||||
|
|
||||||
// Send our new icon to the window through the WMHints
|
// Send our new icon to the window through the WMHints
|
||||||
XWMHints* hints = XAllocWMHints();
|
XWMHints* hints = XAllocWMHints();
|
||||||
|
@ -835,7 +835,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||||
// ICCCM wants BGRA pixels: swap red and blue channels
|
// ICCCM wants BGRA pixels: swap red and blue channels
|
||||||
// ICCCM also wants the first 2 unsigned 32-bit values to be width and height
|
// ICCCM also wants the first 2 unsigned 32-bit values to be width and height
|
||||||
std::vector<unsigned long> icccmIconPixels(2 + width * height, 0);
|
std::vector<unsigned long> icccmIconPixels(2 + width * height, 0);
|
||||||
unsigned long* ptr = &icccmIconPixels[0];
|
unsigned long* ptr = icccmIconPixels.data();
|
||||||
|
|
||||||
*ptr++ = width;
|
*ptr++ = width;
|
||||||
*ptr++ = height;
|
*ptr++ = height;
|
||||||
|
@ -856,7 +856,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
|
||||||
XA_CARDINAL,
|
XA_CARDINAL,
|
||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
reinterpret_cast<const unsigned char*>(&icccmIconPixels[0]),
|
reinterpret_cast<const unsigned char*>(icccmIconPixels.data()),
|
||||||
2 + width * height);
|
2 + width * height);
|
||||||
|
|
||||||
XFlush(m_display);
|
XFlush(m_display);
|
||||||
|
@ -1249,7 +1249,7 @@ void WindowImplX11::setProtocols()
|
||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
reinterpret_cast<const unsigned char*>(&atoms[0]),
|
reinterpret_cast<const unsigned char*>(atoms.data()),
|
||||||
atoms.size());
|
atoms.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -649,7 +649,7 @@ void WglContext::createContext(WglContext* shared)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, &attributes[0]);
|
m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, attributes.data());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -364,7 +364,7 @@ void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the icon from the pixel array
|
// Create the icon from the pixel array
|
||||||
m_icon = CreateIcon(GetModuleHandleW(NULL), width, height, 1, 32, NULL, &iconPixels[0]);
|
m_icon = CreateIcon(GetModuleHandleW(NULL), width, height, 1, 32, NULL, iconPixels.data());
|
||||||
|
|
||||||
// Set it as both big and small icon of the window
|
// Set it as both big and small icon of the window
|
||||||
if (m_icon)
|
if (m_icon)
|
||||||
|
|
Loading…
Reference in a new issue