Changed the naming convention for member variables (prefix changed from "my" to "m_")

This commit is contained in:
Laurent Gomila 2012-03-09 01:22:47 +01:00
parent 15e9d999b3
commit ff5b69d312
124 changed files with 1889 additions and 1889 deletions

View file

@ -37,8 +37,8 @@ namespace sf
{
////////////////////////////////////////////////////////////
Music::Music() :
myFile (new priv::SoundFile),
myDuration()
m_file (new priv::SoundFile),
m_duration()
{
}
@ -50,7 +50,7 @@ Music::~Music()
// We must stop before destroying the file :)
Stop();
delete myFile;
delete m_file;
}
@ -61,7 +61,7 @@ bool Music::OpenFromFile(const std::string& filename)
Stop();
// Open the underlying sound file
if (!myFile->OpenRead(filename))
if (!m_file->OpenRead(filename))
return false;
// Perform common initializations
@ -78,7 +78,7 @@ bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes)
Stop();
// Open the underlying sound file
if (!myFile->OpenRead(data, sizeInBytes))
if (!m_file->OpenRead(data, sizeInBytes))
return false;
// Perform common initializations
@ -95,7 +95,7 @@ bool Music::OpenFromStream(InputStream& stream)
Stop();
// Open the underlying sound file
if (!myFile->OpenRead(stream))
if (!m_file->OpenRead(stream))
return false;
// Perform common initializations
@ -108,30 +108,30 @@ bool Music::OpenFromStream(InputStream& stream)
////////////////////////////////////////////////////////////
Time Music::GetDuration() const
{
return myDuration;
return m_duration;
}
////////////////////////////////////////////////////////////
bool Music::OnGetData(SoundStream::Chunk& data)
{
Lock lock(myMutex);
Lock lock(m_mutex);
// Fill the chunk parameters
data.Samples = &mySamples[0];
data.SampleCount = myFile->Read(&mySamples[0], mySamples.size());
data.Samples = &m_samples[0];
data.SampleCount = m_file->Read(&m_samples[0], m_samples.size());
// Check if we have reached the end of the audio file
return data.SampleCount == mySamples.size();
return data.SampleCount == m_samples.size();
}
////////////////////////////////////////////////////////////
void Music::OnSeek(Time timeOffset)
{
Lock lock(myMutex);
Lock lock(m_mutex);
myFile->Seek(timeOffset);
m_file->Seek(timeOffset);
}
@ -139,13 +139,13 @@ void Music::OnSeek(Time timeOffset)
void Music::Initialize()
{
// Compute the music duration
myDuration = Seconds(static_cast<float>(myFile->GetSampleCount()) / myFile->GetSampleRate() / myFile->GetChannelCount());
m_duration = Seconds(static_cast<float>(m_file->GetSampleCount()) / m_file->GetSampleRate() / m_file->GetChannelCount());
// Resize the internal buffer so that it can contain 1 second of audio samples
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelCount());
m_samples.resize(m_file->GetSampleRate() * m_file->GetChannelCount());
// Initialize the stream
SoundStream::Initialize(myFile->GetChannelCount(), myFile->GetSampleRate());
SoundStream::Initialize(m_file->GetChannelCount(), m_file->GetSampleRate());
}
} // namespace sf

View file

@ -34,14 +34,14 @@ namespace sf
{
////////////////////////////////////////////////////////////
Sound::Sound() :
myBuffer(NULL)
m_buffer(NULL)
{
}
////////////////////////////////////////////////////////////
Sound::Sound(const SoundBuffer& buffer) :
myBuffer(NULL)
m_buffer(NULL)
{
SetBuffer(buffer);
}
@ -50,10 +50,10 @@ myBuffer(NULL)
////////////////////////////////////////////////////////////
Sound::Sound(const Sound& copy) :
SoundSource(copy),
myBuffer (NULL)
m_buffer (NULL)
{
if (copy.myBuffer)
SetBuffer(*copy.myBuffer);
if (copy.m_buffer)
SetBuffer(*copy.m_buffer);
SetLoop(copy.GetLoop());
}
@ -62,29 +62,29 @@ myBuffer (NULL)
Sound::~Sound()
{
Stop();
if (myBuffer)
myBuffer->DetachSound(this);
if (m_buffer)
m_buffer->DetachSound(this);
}
////////////////////////////////////////////////////////////
void Sound::Play()
{
ALCheck(alSourcePlay(mySource));
ALCheck(alSourcePlay(m_source));
}
////////////////////////////////////////////////////////////
void Sound::Pause()
{
ALCheck(alSourcePause(mySource));
ALCheck(alSourcePause(m_source));
}
////////////////////////////////////////////////////////////
void Sound::Stop()
{
ALCheck(alSourceStop(mySource));
ALCheck(alSourceStop(m_source));
}
@ -92,37 +92,37 @@ void Sound::Stop()
void Sound::SetBuffer(const SoundBuffer& buffer)
{
// First detach from the previous buffer
if (myBuffer)
if (m_buffer)
{
Stop();
myBuffer->DetachSound(this);
m_buffer->DetachSound(this);
}
// Assign and use the new buffer
myBuffer = &buffer;
myBuffer->AttachSound(this);
ALCheck(alSourcei(mySource, AL_BUFFER, myBuffer->myBuffer));
m_buffer = &buffer;
m_buffer->AttachSound(this);
ALCheck(alSourcei(m_source, AL_BUFFER, m_buffer->m_buffer));
}
////////////////////////////////////////////////////////////
void Sound::SetLoop(bool Loop)
{
ALCheck(alSourcei(mySource, AL_LOOPING, Loop));
ALCheck(alSourcei(m_source, AL_LOOPING, Loop));
}
////////////////////////////////////////////////////////////
void Sound::SetPlayingOffset(Time timeOffset)
{
ALCheck(alSourcef(mySource, AL_SEC_OFFSET, timeOffset.AsSeconds()));
ALCheck(alSourcef(m_source, AL_SEC_OFFSET, timeOffset.AsSeconds()));
}
////////////////////////////////////////////////////////////
const SoundBuffer* Sound::GetBuffer() const
{
return myBuffer;
return m_buffer;
}
@ -130,7 +130,7 @@ const SoundBuffer* Sound::GetBuffer() const
bool Sound::GetLoop() const
{
ALint loop;
ALCheck(alGetSourcei(mySource, AL_LOOPING, &loop));
ALCheck(alGetSourcei(m_source, AL_LOOPING, &loop));
return loop != 0;
}
@ -140,7 +140,7 @@ bool Sound::GetLoop() const
Time Sound::GetPlayingOffset() const
{
ALfloat seconds = 0.f;
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
ALCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &seconds));
return Seconds(seconds);
}
@ -160,16 +160,16 @@ Sound& Sound::operator =(const Sound& right)
// the list of sound instances contained in the buffers
// Detach the sound instance from the previous buffer (if any)
if (myBuffer)
if (m_buffer)
{
Stop();
myBuffer->DetachSound(this);
myBuffer = NULL;
m_buffer->DetachSound(this);
m_buffer = NULL;
}
// Copy the sound attributes
if (right.myBuffer)
SetBuffer(*right.myBuffer);
if (right.m_buffer)
SetBuffer(*right.m_buffer);
SetLoop(right.GetLoop());
SetPitch(right.GetPitch());
SetVolume(right.GetVolume());
@ -189,8 +189,8 @@ void Sound::ResetBuffer()
Stop();
// Detach the buffer
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
myBuffer = NULL;
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
m_buffer = NULL;
}
} // namespace sf

View file

@ -38,25 +38,25 @@ namespace sf
{
////////////////////////////////////////////////////////////
SoundBuffer::SoundBuffer() :
myBuffer (0),
myDuration()
m_buffer (0),
m_duration()
{
priv::EnsureALInit();
// Create the buffer
ALCheck(alGenBuffers(1, &myBuffer));
ALCheck(alGenBuffers(1, &m_buffer));
}
////////////////////////////////////////////////////////////
SoundBuffer::SoundBuffer(const SoundBuffer& copy) :
myBuffer (0),
mySamples (copy.mySamples),
myDuration(copy.myDuration),
mySounds () // don't copy the attached sounds
m_buffer (0),
m_samples (copy.m_samples),
m_duration(copy.m_duration),
m_sounds () // don't copy the attached sounds
{
// Create the buffer
ALCheck(alGenBuffers(1, &myBuffer));
ALCheck(alGenBuffers(1, &m_buffer));
// Update the internal buffer with the new samples
Update(copy.GetChannelCount(), copy.GetSampleRate());
@ -67,12 +67,12 @@ mySounds () // don't copy the attached sounds
SoundBuffer::~SoundBuffer()
{
// First detach the buffer from the sounds that use it (to avoid OpenAL errors)
for (SoundList::const_iterator it = mySounds.begin(); it != mySounds.end(); ++it)
for (SoundList::const_iterator it = m_sounds.begin(); it != m_sounds.end(); ++it)
(*it)->ResetBuffer();
// Destroy the buffer
if (myBuffer)
ALCheck(alDeleteBuffers(1, &myBuffer));
if (m_buffer)
ALCheck(alDeleteBuffers(1, &m_buffer));
}
@ -115,7 +115,7 @@ bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t sampleCount,
if (samples && sampleCount && channelCount && sampleRate)
{
// Copy the new audio samples
mySamples.assign(samples, samples + sampleCount);
m_samples.assign(samples, samples + sampleCount);
// Update the internal buffer with the new samples
return Update(channelCount, sampleRate);
@ -143,7 +143,7 @@ bool SoundBuffer::SaveToFile(const std::string& filename) const
if (file.OpenWrite(filename, GetChannelCount(), GetSampleRate()))
{
// Write the samples to the opened file
file.Write(&mySamples[0], mySamples.size());
file.Write(&m_samples[0], m_samples.size());
return true;
}
@ -157,14 +157,14 @@ bool SoundBuffer::SaveToFile(const std::string& filename) const
////////////////////////////////////////////////////////////
const Int16* SoundBuffer::GetSamples() const
{
return mySamples.empty() ? NULL : &mySamples[0];
return m_samples.empty() ? NULL : &m_samples[0];
}
////////////////////////////////////////////////////////////
std::size_t SoundBuffer::GetSampleCount() const
{
return mySamples.size();
return m_samples.size();
}
@ -172,7 +172,7 @@ std::size_t SoundBuffer::GetSampleCount() const
unsigned int SoundBuffer::GetSampleRate() const
{
ALint sampleRate;
ALCheck(alGetBufferi(myBuffer, AL_FREQUENCY, &sampleRate));
ALCheck(alGetBufferi(m_buffer, AL_FREQUENCY, &sampleRate));
return sampleRate;
}
@ -182,7 +182,7 @@ unsigned int SoundBuffer::GetSampleRate() const
unsigned int SoundBuffer::GetChannelCount() const
{
ALint channelCount;
ALCheck(alGetBufferi(myBuffer, AL_CHANNELS, &channelCount));
ALCheck(alGetBufferi(m_buffer, AL_CHANNELS, &channelCount));
return channelCount;
}
@ -191,7 +191,7 @@ unsigned int SoundBuffer::GetChannelCount() const
////////////////////////////////////////////////////////////
Time SoundBuffer::GetDuration() const
{
return myDuration;
return m_duration;
}
@ -200,10 +200,10 @@ SoundBuffer& SoundBuffer::operator =(const SoundBuffer& right)
{
SoundBuffer temp(right);
std::swap(mySamples, temp.mySamples);
std::swap(myBuffer, temp.myBuffer);
std::swap(myDuration, temp.myDuration);
std::swap(mySounds, temp.mySounds); // swap sounds too, so that they are detached when temp is destroyed
std::swap(m_samples, temp.m_samples);
std::swap(m_buffer, temp.m_buffer);
std::swap(m_duration, temp.m_duration);
std::swap(m_sounds, temp.m_sounds); // swap sounds too, so that they are detached when temp is destroyed
return *this;
}
@ -218,8 +218,8 @@ bool SoundBuffer::Initialize(priv::SoundFile& file)
unsigned int sampleRate = file.GetSampleRate();
// Read the samples from the provided file
mySamples.resize(sampleCount);
if (file.Read(&mySamples[0], sampleCount) == sampleCount)
m_samples.resize(sampleCount);
if (file.Read(&m_samples[0], sampleCount) == sampleCount)
{
// Update the internal buffer with the new samples
return Update(channelCount, sampleRate);
@ -235,7 +235,7 @@ bool SoundBuffer::Initialize(priv::SoundFile& file)
bool SoundBuffer::Update(unsigned int channelCount, unsigned int sampleRate)
{
// Check parameters
if (!channelCount || !sampleRate || mySamples.empty())
if (!channelCount || !sampleRate || m_samples.empty())
return false;
// Find the good format according to the number of channels
@ -249,11 +249,11 @@ bool SoundBuffer::Update(unsigned int channelCount, unsigned int sampleRate)
}
// Fill the buffer
ALsizei size = static_cast<ALsizei>(mySamples.size()) * sizeof(Int16);
ALCheck(alBufferData(myBuffer, format, &mySamples[0], size, sampleRate));
ALsizei size = static_cast<ALsizei>(m_samples.size()) * sizeof(Int16);
ALCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate));
// Compute the duration
myDuration = Milliseconds(1000 * mySamples.size() / sampleRate / channelCount);
m_duration = Milliseconds(1000 * m_samples.size() / sampleRate / channelCount);
return true;
}
@ -262,14 +262,14 @@ bool SoundBuffer::Update(unsigned int channelCount, unsigned int sampleRate)
////////////////////////////////////////////////////////////
void SoundBuffer::AttachSound(Sound* sound) const
{
mySounds.insert(sound);
m_sounds.insert(sound);
}
////////////////////////////////////////////////////////////
void SoundBuffer::DetachSound(Sound* sound) const
{
mySounds.erase(sound);
m_sounds.erase(sound);
}
} // namespace sf

View file

@ -35,8 +35,8 @@ namespace sf
////////////////////////////////////////////////////////////
bool SoundBufferRecorder::OnStart()
{
mySamples.clear();
myBuffer = SoundBuffer();
m_samples.clear();
m_buffer = SoundBuffer();
return true;
}
@ -45,7 +45,7 @@ bool SoundBufferRecorder::OnStart()
////////////////////////////////////////////////////////////
bool SoundBufferRecorder::OnProcessSamples(const Int16* samples, std::size_t sampleCount)
{
std::copy(samples, samples + sampleCount, std::back_inserter(mySamples));
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
return true;
}
@ -54,15 +54,15 @@ bool SoundBufferRecorder::OnProcessSamples(const Int16* samples, std::size_t sam
////////////////////////////////////////////////////////////
void SoundBufferRecorder::OnStop()
{
if (!mySamples.empty())
myBuffer.LoadFromSamples(&mySamples[0], mySamples.size(), 1, GetSampleRate());
if (!m_samples.empty())
m_buffer.LoadFromSamples(&m_samples[0], m_samples.size(), 1, GetSampleRate());
}
////////////////////////////////////////////////////////////
const SoundBuffer& SoundBufferRecorder::GetBuffer() const
{
return myBuffer;
return m_buffer;
}
} // namespace sf

View file

@ -50,10 +50,10 @@ namespace priv
{
////////////////////////////////////////////////////////////
SoundFile::SoundFile() :
myFile (NULL),
mySampleCount (0),
myChannelCount(0),
mySampleRate (0)
m_file (NULL),
m_sampleCount (0),
m_channelCount(0),
m_sampleRate (0)
{
}
@ -62,29 +62,29 @@ mySampleRate (0)
////////////////////////////////////////////////////////////
SoundFile::~SoundFile()
{
if (myFile)
sf_close(myFile);
if (m_file)
sf_close(m_file);
}
////////////////////////////////////////////////////////////
std::size_t SoundFile::GetSampleCount() const
{
return mySampleCount;
return m_sampleCount;
}
////////////////////////////////////////////////////////////
unsigned int SoundFile::GetChannelCount() const
{
return myChannelCount;
return m_channelCount;
}
////////////////////////////////////////////////////////////
unsigned int SoundFile::GetSampleRate() const
{
return mySampleRate;
return m_sampleRate;
}
@ -92,22 +92,22 @@ unsigned int SoundFile::GetSampleRate() const
bool SoundFile::OpenRead(const std::string& filename)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
if (m_file)
sf_close(m_file);
// Open the sound file
SF_INFO fileInfos;
myFile = sf_open(filename.c_str(), SFM_READ, &fileInfos);
if (!myFile)
m_file = sf_open(filename.c_str(), SFM_READ, &fileInfos);
if (!m_file)
{
Err() << "Failed to open sound file \"" << filename << "\" (" << sf_strerror(myFile) << ")" << std::endl;
Err() << "Failed to open sound file \"" << filename << "\" (" << sf_strerror(m_file) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelCount = fileInfos.channels;
mySampleRate = fileInfos.samplerate;
mySampleCount = static_cast<std::size_t>(fileInfos.frames) * myChannelCount;
m_channelCount = fileInfos.channels;
m_sampleRate = fileInfos.samplerate;
m_sampleCount = static_cast<std::size_t>(fileInfos.frames) * m_channelCount;
return true;
}
@ -117,8 +117,8 @@ bool SoundFile::OpenRead(const std::string& filename)
bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
if (m_file)
sf_close(m_file);
// Prepare the memory I/O structure
SF_VIRTUAL_IO io;
@ -128,23 +128,23 @@ bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
io.tell = &Memory::Tell;
// Initialize the memory data
myMemory.DataStart = static_cast<const char*>(data);
myMemory.DataPtr = myMemory.DataStart;
myMemory.TotalSize = sizeInBytes;
m_memory.DataStart = static_cast<const char*>(data);
m_memory.DataPtr = m_memory.DataStart;
m_memory.TotalSize = sizeInBytes;
// Open the sound file
SF_INFO fileInfos;
myFile = sf_open_virtual(&io, SFM_READ, &fileInfos, &myMemory);
if (!myFile)
m_file = sf_open_virtual(&io, SFM_READ, &fileInfos, &m_memory);
if (!m_file)
{
Err() << "Failed to open sound file from memory (" << sf_strerror(myFile) << ")" << std::endl;
Err() << "Failed to open sound file from memory (" << sf_strerror(m_file) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelCount = fileInfos.channels;
mySampleRate = fileInfos.samplerate;
mySampleCount = static_cast<std::size_t>(fileInfos.frames) * myChannelCount;
m_channelCount = fileInfos.channels;
m_sampleRate = fileInfos.samplerate;
m_sampleCount = static_cast<std::size_t>(fileInfos.frames) * m_channelCount;
return true;
}
@ -154,8 +154,8 @@ bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
bool SoundFile::OpenRead(InputStream& stream)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
if (m_file)
sf_close(m_file);
// Prepare the memory I/O structure
SF_VIRTUAL_IO io;
@ -166,17 +166,17 @@ bool SoundFile::OpenRead(InputStream& stream)
// Open the sound file
SF_INFO fileInfos;
myFile = sf_open_virtual(&io, SFM_READ, &fileInfos, &stream);
if (!myFile)
m_file = sf_open_virtual(&io, SFM_READ, &fileInfos, &stream);
if (!m_file)
{
Err() << "Failed to open sound file from stream (" << sf_strerror(myFile) << ")" << std::endl;
Err() << "Failed to open sound file from stream (" << sf_strerror(m_file) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelCount = fileInfos.channels;
mySampleRate = fileInfos.samplerate;
mySampleCount = static_cast<std::size_t>(fileInfos.frames) * myChannelCount;
m_channelCount = fileInfos.channels;
m_sampleRate = fileInfos.samplerate;
m_sampleCount = static_cast<std::size_t>(fileInfos.frames) * m_channelCount;
return true;
}
@ -186,8 +186,8 @@ bool SoundFile::OpenRead(InputStream& stream)
bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
if (m_file)
sf_close(m_file);
// Find the right format according to the file extension
int format = GetFormatFromFilename(filename);
@ -205,17 +205,17 @@ bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount
fileInfos.format = format | (format == SF_FORMAT_OGG ? SF_FORMAT_VORBIS : SF_FORMAT_PCM_16);
// Open the sound file for writing
myFile = sf_open(filename.c_str(), SFM_WRITE, &fileInfos);
if (!myFile)
m_file = sf_open(filename.c_str(), SFM_WRITE, &fileInfos);
if (!m_file)
{
Err() << "Failed to create sound file \"" << filename << "\" (" << sf_strerror(myFile) << ")" << std::endl;
Err() << "Failed to create sound file \"" << filename << "\" (" << sf_strerror(m_file) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelCount = channelCount;
mySampleRate = sampleRate;
mySampleCount = 0;
m_channelCount = channelCount;
m_sampleRate = sampleRate;
m_sampleCount = 0;
return true;
}
@ -224,8 +224,8 @@ bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount
////////////////////////////////////////////////////////////
std::size_t SoundFile::Read(Int16* data, std::size_t sampleCount)
{
if (myFile && data && sampleCount)
return static_cast<std::size_t>(sf_read_short(myFile, data, sampleCount));
if (m_file && data && sampleCount)
return static_cast<std::size_t>(sf_read_short(m_file, data, sampleCount));
else
return 0;
}
@ -234,14 +234,14 @@ std::size_t SoundFile::Read(Int16* data, std::size_t sampleCount)
////////////////////////////////////////////////////////////
void SoundFile::Write(const Int16* data, std::size_t sampleCount)
{
if (myFile && data && sampleCount)
if (m_file && data && sampleCount)
{
// Write small chunks instead of everything at once,
// to avoid a stack overflow in libsndfile (happens only with OGG format)
while (sampleCount > 0)
{
std::size_t count = sampleCount > 10000 ? 10000 : sampleCount;
sf_write_short(myFile, data, count);
sf_write_short(m_file, data, count);
data += count;
sampleCount -= count;
}
@ -252,10 +252,10 @@ void SoundFile::Write(const Int16* data, std::size_t sampleCount)
////////////////////////////////////////////////////////////
void SoundFile::Seek(Time timeOffset)
{
if (myFile)
if (m_file)
{
sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.AsSeconds() * mySampleRate);
sf_seek(myFile, frameOffset, SEEK_SET);
sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.AsSeconds() * m_sampleRate);
sf_seek(m_file, frameOffset, SEEK_SET);
}
}

View file

@ -199,11 +199,11 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
SNDFILE* myFile; ///< File descriptor
Memory myMemory; ///< Memory reading info
std::size_t mySampleCount; ///< Total number of samples in the file
unsigned int myChannelCount; ///< Number of channels used by the sound
unsigned int mySampleRate; ///< Number of samples per second
SNDFILE* m_file; ///< File descriptor
Memory m_memory; ///< Memory reading info
std::size_t m_sampleCount; ///< Total number of samples in the file
unsigned int m_channelCount; ///< Number of channels used by the sound
unsigned int m_sampleRate; ///< Number of samples per second
};
} // namespace priv

View file

@ -45,9 +45,9 @@ namespace sf
{
////////////////////////////////////////////////////////////
SoundRecorder::SoundRecorder() :
myThread (&SoundRecorder::Record, this),
mySampleRate (0),
myIsCapturing(false)
m_thread (&SoundRecorder::Record, this),
m_sampleRate (0),
m_isCapturing(false)
{
priv::EnsureALInit();
}
@ -86,10 +86,10 @@ void SoundRecorder::Start(unsigned int sampleRate)
}
// Clear the array of samples
mySamples.clear();
m_samples.clear();
// Store the sample rate
mySampleRate = sampleRate;
m_sampleRate = sampleRate;
// Notify derived class
if (OnStart())
@ -98,8 +98,8 @@ void SoundRecorder::Start(unsigned int sampleRate)
alcCaptureStart(captureDevice);
// Start the capture in a new thread, to avoid blocking the main thread
myIsCapturing = true;
myThread.Launch();
m_isCapturing = true;
m_thread.Launch();
}
}
@ -108,15 +108,15 @@ void SoundRecorder::Start(unsigned int sampleRate)
void SoundRecorder::Stop()
{
// Stop the capturing thread
myIsCapturing = false;
myThread.Wait();
m_isCapturing = false;
m_thread.Wait();
}
////////////////////////////////////////////////////////////
unsigned int SoundRecorder::GetSampleRate() const
{
return mySampleRate;
return m_sampleRate;
}
@ -146,7 +146,7 @@ void SoundRecorder::OnStop()
////////////////////////////////////////////////////////////
void SoundRecorder::Record()
{
while (myIsCapturing)
while (m_isCapturing)
{
// Process available samples
ProcessCapturedSamples();
@ -173,14 +173,14 @@ void SoundRecorder::ProcessCapturedSamples()
if (samplesAvailable > 0)
{
// Get the recorded samples
mySamples.resize(samplesAvailable);
alcCaptureSamples(captureDevice, &mySamples[0], samplesAvailable);
m_samples.resize(samplesAvailable);
alcCaptureSamples(captureDevice, &m_samples[0], samplesAvailable);
// Forward them to the derived class
if (!OnProcessSamples(&mySamples[0], mySamples.size()))
if (!OnProcessSamples(&m_samples[0], m_samples.size()))
{
// The user wants to stop the capture
myIsCapturing = false;
m_isCapturing = false;
}
}
}

View file

@ -36,8 +36,8 @@ SoundSource::SoundSource()
{
priv::EnsureALInit();
ALCheck(alGenSources(1, &mySource));
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
ALCheck(alGenSources(1, &m_source));
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
}
@ -46,8 +46,8 @@ SoundSource::SoundSource(const SoundSource& copy)
{
priv::EnsureALInit();
ALCheck(alGenSources(1, &mySource));
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
ALCheck(alGenSources(1, &m_source));
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
SetPitch(copy.GetPitch());
SetVolume(copy.GetVolume());
@ -61,28 +61,28 @@ SoundSource::SoundSource(const SoundSource& copy)
////////////////////////////////////////////////////////////
SoundSource::~SoundSource()
{
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
ALCheck(alDeleteSources(1, &mySource));
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
ALCheck(alDeleteSources(1, &m_source));
}
////////////////////////////////////////////////////////////
void SoundSource::SetPitch(float pitch)
{
ALCheck(alSourcef(mySource, AL_PITCH, pitch));
ALCheck(alSourcef(m_source, AL_PITCH, pitch));
}
////////////////////////////////////////////////////////////
void SoundSource::SetVolume(float volume)
{
ALCheck(alSourcef(mySource, AL_GAIN, volume * 0.01f));
ALCheck(alSourcef(m_source, AL_GAIN, volume * 0.01f));
}
////////////////////////////////////////////////////////////
void SoundSource::SetPosition(float x, float y, float z)
{
ALCheck(alSource3f(mySource, AL_POSITION, x, y, z));
ALCheck(alSource3f(m_source, AL_POSITION, x, y, z));
}
@ -96,21 +96,21 @@ void SoundSource::SetPosition(const Vector3f& position)
////////////////////////////////////////////////////////////
void SoundSource::SetRelativeToListener(bool relative)
{
ALCheck(alSourcei(mySource, AL_SOURCE_RELATIVE, relative));
ALCheck(alSourcei(m_source, AL_SOURCE_RELATIVE, relative));
}
////////////////////////////////////////////////////////////
void SoundSource::SetMinDistance(float distance)
{
ALCheck(alSourcef(mySource, AL_REFERENCE_DISTANCE, distance));
ALCheck(alSourcef(m_source, AL_REFERENCE_DISTANCE, distance));
}
////////////////////////////////////////////////////////////
void SoundSource::SetAttenuation(float attenuation)
{
ALCheck(alSourcef(mySource, AL_ROLLOFF_FACTOR, attenuation));
ALCheck(alSourcef(m_source, AL_ROLLOFF_FACTOR, attenuation));
}
@ -118,7 +118,7 @@ void SoundSource::SetAttenuation(float attenuation)
float SoundSource::GetPitch() const
{
ALfloat pitch;
ALCheck(alGetSourcef(mySource, AL_PITCH, &pitch));
ALCheck(alGetSourcef(m_source, AL_PITCH, &pitch));
return pitch;
}
@ -128,7 +128,7 @@ float SoundSource::GetPitch() const
float SoundSource::GetVolume() const
{
ALfloat gain;
ALCheck(alGetSourcef(mySource, AL_GAIN, &gain));
ALCheck(alGetSourcef(m_source, AL_GAIN, &gain));
return gain * 100.f;
}
@ -138,7 +138,7 @@ float SoundSource::GetVolume() const
Vector3f SoundSource::GetPosition() const
{
Vector3f position;
ALCheck(alGetSource3f(mySource, AL_POSITION, &position.x, &position.y, &position.z));
ALCheck(alGetSource3f(m_source, AL_POSITION, &position.x, &position.y, &position.z));
return position;
}
@ -148,7 +148,7 @@ Vector3f SoundSource::GetPosition() const
bool SoundSource::IsRelativeToListener() const
{
ALint relative;
ALCheck(alGetSourcei(mySource, AL_SOURCE_RELATIVE, &relative));
ALCheck(alGetSourcei(m_source, AL_SOURCE_RELATIVE, &relative));
return relative != 0;
}
@ -158,7 +158,7 @@ bool SoundSource::IsRelativeToListener() const
float SoundSource::GetMinDistance() const
{
ALfloat distance;
ALCheck(alGetSourcef(mySource, AL_REFERENCE_DISTANCE, &distance));
ALCheck(alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &distance));
return distance;
}
@ -168,7 +168,7 @@ float SoundSource::GetMinDistance() const
float SoundSource::GetAttenuation() const
{
ALfloat attenuation;
ALCheck(alGetSourcef(mySource, AL_ROLLOFF_FACTOR, &attenuation));
ALCheck(alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &attenuation));
return attenuation;
}
@ -178,7 +178,7 @@ float SoundSource::GetAttenuation() const
SoundSource::Status SoundSource::GetStatus() const
{
ALint status;
ALCheck(alGetSourcei(mySource, AL_SOURCE_STATE, &status));
ALCheck(alGetSourcei(m_source, AL_SOURCE_STATE, &status));
switch (status)
{

View file

@ -40,13 +40,13 @@ namespace sf
{
////////////////////////////////////////////////////////////
SoundStream::SoundStream() :
myThread (&SoundStream::Stream, this),
myIsStreaming (false),
myChannelCount (0),
mySampleRate (0),
myFormat (0),
myLoop (false),
mySamplesProcessed(0)
m_thread (&SoundStream::Stream, this),
m_isStreaming (false),
m_channelCount (0),
m_sampleRate (0),
m_format (0),
m_loop (false),
m_samplesProcessed(0)
{
}
@ -63,18 +63,18 @@ SoundStream::~SoundStream()
////////////////////////////////////////////////////////////
void SoundStream::Initialize(unsigned int channelCount, unsigned int sampleRate)
{
myChannelCount = channelCount;
mySampleRate = sampleRate;
m_channelCount = channelCount;
m_sampleRate = sampleRate;
// Deduce the format from the number of channels
myFormat = priv::AudioDevice::GetFormatFromChannelCount(channelCount);
m_format = priv::AudioDevice::GetFormatFromChannelCount(channelCount);
// Check if the format is valid
if (myFormat == 0)
if (m_format == 0)
{
myChannelCount = 0;
mySampleRate = 0;
Err() << "Unsupported number of channels (" << myChannelCount << ")" << std::endl;
m_channelCount = 0;
m_sampleRate = 0;
Err() << "Unsupported number of channels (" << m_channelCount << ")" << std::endl;
}
}
@ -83,16 +83,16 @@ void SoundStream::Initialize(unsigned int channelCount, unsigned int sampleRate)
void SoundStream::Play()
{
// Check if the sound parameters have been set
if (myFormat == 0)
if (m_format == 0)
{
Err() << "Failed to play audio stream: sound parameters have not been initialized (call Initialize first)" << std::endl;
return;
}
// If the sound is already playing (probably paused), just resume it
if (myIsStreaming)
if (m_isStreaming)
{
ALCheck(alSourcePlay(mySource));
ALCheck(alSourcePlay(m_source));
return;
}
@ -100,16 +100,16 @@ void SoundStream::Play()
OnSeek(Time::Zero);
// Start updating the stream in a separate thread to avoid blocking the application
mySamplesProcessed = 0;
myIsStreaming = true;
myThread.Launch();
m_samplesProcessed = 0;
m_isStreaming = true;
m_thread.Launch();
}
////////////////////////////////////////////////////////////
void SoundStream::Pause()
{
ALCheck(alSourcePause(mySource));
ALCheck(alSourcePause(m_source));
}
@ -117,22 +117,22 @@ void SoundStream::Pause()
void SoundStream::Stop()
{
// Wait for the thread to terminate
myIsStreaming = false;
myThread.Wait();
m_isStreaming = false;
m_thread.Wait();
}
////////////////////////////////////////////////////////////
unsigned int SoundStream::GetChannelCount() const
{
return myChannelCount;
return m_channelCount;
}
////////////////////////////////////////////////////////////
unsigned int SoundStream::GetSampleRate() const
{
return mySampleRate;
return m_sampleRate;
}
@ -142,7 +142,7 @@ SoundStream::Status SoundStream::GetStatus() const
Status status = SoundSource::GetStatus();
// To compensate for the lag between Play() and alSourcePlay()
if ((status == Stopped) && myIsStreaming)
if ((status == Stopped) && m_isStreaming)
status = Playing;
return status;
@ -159,9 +159,9 @@ void SoundStream::SetPlayingOffset(Time timeOffset)
OnSeek(timeOffset);
// Restart streaming
mySamplesProcessed = static_cast<Uint64>(timeOffset.AsSeconds() * mySampleRate * myChannelCount);
myIsStreaming = true;
myThread.Launch();
m_samplesProcessed = static_cast<Uint64>(timeOffset.AsSeconds() * m_sampleRate * m_channelCount);
m_isStreaming = true;
m_thread.Launch();
}
@ -169,23 +169,23 @@ void SoundStream::SetPlayingOffset(Time timeOffset)
Time SoundStream::GetPlayingOffset() const
{
ALfloat seconds = 0.f;
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
ALCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &seconds));
return Seconds(seconds + static_cast<float>(mySamplesProcessed) / mySampleRate / myChannelCount);
return Seconds(seconds + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
}
////////////////////////////////////////////////////////////
void SoundStream::SetLoop(bool loop)
{
myLoop = loop;
m_loop = loop;
}
////////////////////////////////////////////////////////////
bool SoundStream::GetLoop() const
{
return myLoop;
return m_loop;
}
@ -193,17 +193,17 @@ bool SoundStream::GetLoop() const
void SoundStream::Stream()
{
// Create the buffers
ALCheck(alGenBuffers(BufferCount, myBuffers));
ALCheck(alGenBuffers(BufferCount, m_buffers));
for (int i = 0; i < BufferCount; ++i)
myEndBuffers[i] = false;
m_endBuffers[i] = false;
// Fill the queue
bool requestStop = FillQueue();
// Play the sound
ALCheck(alSourcePlay(mySource));
ALCheck(alSourcePlay(m_source));
while (myIsStreaming)
while (m_isStreaming)
{
// The stream has been interrupted!
if (SoundSource::GetStatus() == Stopped)
@ -211,47 +211,47 @@ void SoundStream::Stream()
if (!requestStop)
{
// Just continue
ALCheck(alSourcePlay(mySource));
ALCheck(alSourcePlay(m_source));
}
else
{
// End streaming
myIsStreaming = false;
m_isStreaming = false;
}
}
// Get the number of buffers that have been processed (ie. ready for reuse)
ALint nbProcessed = 0;
ALCheck(alGetSourcei(mySource, AL_BUFFERS_PROCESSED, &nbProcessed));
ALCheck(alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &nbProcessed));
while (nbProcessed--)
{
// Pop the first unused buffer from the queue
ALuint buffer;
ALCheck(alSourceUnqueueBuffers(mySource, 1, &buffer));
ALCheck(alSourceUnqueueBuffers(m_source, 1, &buffer));
// Find its number
unsigned int bufferNum = 0;
for (int i = 0; i < BufferCount; ++i)
if (myBuffers[i] == buffer)
if (m_buffers[i] == buffer)
{
bufferNum = i;
break;
}
// Retrieve its size and add it to the samples count
if (myEndBuffers[bufferNum])
if (m_endBuffers[bufferNum])
{
// This was the last buffer: reset the sample count
mySamplesProcessed = 0;
myEndBuffers[bufferNum] = false;
m_samplesProcessed = 0;
m_endBuffers[bufferNum] = false;
}
else
{
ALint size, bits;
ALCheck(alGetBufferi(buffer, AL_SIZE, &size));
ALCheck(alGetBufferi(buffer, AL_BITS, &bits));
mySamplesProcessed += size / (bits / 8);
m_samplesProcessed += size / (bits / 8);
}
// Fill it and push it back into the playing queue
@ -268,14 +268,14 @@ void SoundStream::Stream()
}
// Stop the playback
ALCheck(alSourceStop(mySource));
ALCheck(alSourceStop(m_source));
// Unqueue any buffer left in the queue
ClearQueue();
// Delete the buffers
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
ALCheck(alDeleteBuffers(BufferCount, myBuffers));
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
ALCheck(alDeleteBuffers(BufferCount, m_buffers));
}
@ -289,10 +289,10 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
if (!OnGetData(data))
{
// Mark the buffer as the last one (so that we know when to reset the playing position)
myEndBuffers[bufferNum] = true;
m_endBuffers[bufferNum] = true;
// Check if the stream must loop or stop
if (myLoop)
if (m_loop)
{
// Return to the beginning of the stream source
OnSeek(Time::Zero);
@ -313,14 +313,14 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
// Fill the buffer if some data was returned
if (data.Samples && data.SampleCount)
{
unsigned int buffer = myBuffers[bufferNum];
unsigned int buffer = m_buffers[bufferNum];
// Fill the buffer
ALsizei size = static_cast<ALsizei>(data.SampleCount) * sizeof(Int16);
ALCheck(alBufferData(buffer, myFormat, data.Samples, size, mySampleRate));
ALCheck(alBufferData(buffer, m_format, data.Samples, size, m_sampleRate));
// Push it into the sound queue
ALCheck(alSourceQueueBuffers(mySource, 1, &buffer));
ALCheck(alSourceQueueBuffers(m_source, 1, &buffer));
}
return requestStop;
@ -347,12 +347,12 @@ void SoundStream::ClearQueue()
{
// Get the number of buffers still in the queue
ALint nbQueued;
ALCheck(alGetSourcei(mySource, AL_BUFFERS_QUEUED, &nbQueued));
ALCheck(alGetSourcei(m_source, AL_BUFFERS_QUEUED, &nbQueued));
// Unqueue them all
ALuint buffer;
for (ALint i = 0; i < nbQueued; ++i)
ALCheck(alSourceUnqueueBuffers(mySource, 1, &buffer));
ALCheck(alSourceUnqueueBuffers(m_source, 1, &buffer));
}
} // namespace sf

View file

@ -33,8 +33,8 @@ namespace sf
{
////////////////////////////////////////////////////////////
CircleShape::CircleShape(float radius, unsigned int pointCount) :
myRadius (radius),
myPointCount(pointCount)
m_radius (radius),
m_pointCount(pointCount)
{
Update();
}
@ -43,7 +43,7 @@ myPointCount(pointCount)
////////////////////////////////////////////////////////////
void CircleShape::SetRadius(float radius)
{
myRadius = radius;
m_radius = radius;
Update();
}
@ -51,21 +51,21 @@ void CircleShape::SetRadius(float radius)
////////////////////////////////////////////////////////////
float CircleShape::GetRadius() const
{
return myRadius;
return m_radius;
}
////////////////////////////////////////////////////////////
void CircleShape::SetPointCount(unsigned int count)
{
myPointCount = count;
m_pointCount = count;
Update();
}
////////////////////////////////////////////////////////////
unsigned int CircleShape::GetPointCount() const
{
return myPointCount;
return m_pointCount;
}
@ -74,11 +74,11 @@ Vector2f CircleShape::GetPoint(unsigned int index) const
{
static const float pi = 3.141592654f;
float angle = index * 2 * pi / myPointCount - pi / 2;
float x = std::cos(angle) * myRadius;
float y = std::sin(angle) * myRadius;
float angle = index * 2 * pi / m_pointCount - pi / 2;
float x = std::cos(angle) * m_radius;
float y = std::sin(angle) * m_radius;
return Vector2f(myRadius + x, myRadius + y);
return Vector2f(m_radius + x, m_radius + y);
}
} // namespace sf

View file

@ -40,7 +40,7 @@ ConvexShape::ConvexShape(unsigned int pointCount)
////////////////////////////////////////////////////////////
void ConvexShape::SetPointCount(unsigned int count)
{
myPoints.resize(count);
m_points.resize(count);
Update();
}
@ -48,14 +48,14 @@ void ConvexShape::SetPointCount(unsigned int count)
////////////////////////////////////////////////////////////
unsigned int ConvexShape::GetPointCount() const
{
return static_cast<unsigned int>(myPoints.size());
return static_cast<unsigned int>(m_points.size());
}
////////////////////////////////////////////////////////////
void ConvexShape::SetPoint(unsigned int index, const Vector2f& point)
{
myPoints[index] = point;
m_points[index] = point;
Update();
}
@ -63,7 +63,7 @@ void ConvexShape::SetPoint(unsigned int index, const Vector2f& point)
////////////////////////////////////////////////////////////
Vector2f ConvexShape::GetPoint(unsigned int index) const
{
return myPoints[index];
return m_points[index];
}
} // namespace sf

View file

@ -63,10 +63,10 @@ namespace sf
{
////////////////////////////////////////////////////////////
Font::Font() :
myLibrary (NULL),
myFace (NULL),
myStreamRec(NULL),
myRefCount (NULL)
m_library (NULL),
m_face (NULL),
m_streamRec(NULL),
m_refCount (NULL)
{
}
@ -74,18 +74,18 @@ myRefCount (NULL)
////////////////////////////////////////////////////////////
Font::Font(const Font& copy) :
myLibrary (copy.myLibrary),
myFace (copy.myFace),
myStreamRec (copy.myStreamRec),
myRefCount (copy.myRefCount),
myPages (copy.myPages),
myPixelBuffer(copy.myPixelBuffer)
m_library (copy.m_library),
m_face (copy.m_face),
m_streamRec (copy.m_streamRec),
m_refCount (copy.m_refCount),
m_pages (copy.m_pages),
m_pixelBuffer(copy.m_pixelBuffer)
{
// Note: as FreeType doesn't provide functions for copying/cloning,
// we must share all the FreeType pointers
if (myRefCount)
(*myRefCount)++;
if (m_refCount)
(*m_refCount)++;
}
@ -101,7 +101,7 @@ bool Font::LoadFromFile(const std::string& filename)
{
// Cleanup the previous resources
Cleanup();
myRefCount = new int(1);
m_refCount = new int(1);
// Initialize FreeType
// Note: we initialize FreeType for every font instance in order to avoid having a single
@ -112,11 +112,11 @@ bool Font::LoadFromFile(const std::string& filename)
Err() << "Failed to load font \"" << filename << "\" (failed to initialize FreeType)" << std::endl;
return false;
}
myLibrary = library;
m_library = library;
// Load the new font face from the specified file
FT_Face face;
if (FT_New_Face(static_cast<FT_Library>(myLibrary), filename.c_str(), 0, &face) != 0)
if (FT_New_Face(static_cast<FT_Library>(m_library), filename.c_str(), 0, &face) != 0)
{
Err() << "Failed to load font \"" << filename << "\" (failed to create the font face)" << std::endl;
return false;
@ -130,7 +130,7 @@ bool Font::LoadFromFile(const std::string& filename)
}
// Store the loaded font in our ugly void* :)
myFace = face;
m_face = face;
return true;
}
@ -141,7 +141,7 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
{
// Cleanup the previous resources
Cleanup();
myRefCount = new int(1);
m_refCount = new int(1);
// Initialize FreeType
// Note: we initialize FreeType for every font instance in order to avoid having a single
@ -152,11 +152,11 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
Err() << "Failed to load font from memory (failed to initialize FreeType)" << std::endl;
return false;
}
myLibrary = library;
m_library = library;
// Load the new font face from the specified file
FT_Face face;
if (FT_New_Memory_Face(static_cast<FT_Library>(myLibrary), reinterpret_cast<const FT_Byte*>(data), static_cast<FT_Long>(sizeInBytes), 0, &face) != 0)
if (FT_New_Memory_Face(static_cast<FT_Library>(m_library), reinterpret_cast<const FT_Byte*>(data), static_cast<FT_Long>(sizeInBytes), 0, &face) != 0)
{
Err() << "Failed to load font from memory (failed to create the font face)" << std::endl;
return false;
@ -170,7 +170,7 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
}
// Store the loaded font in our ugly void* :)
myFace = face;
m_face = face;
return true;
}
@ -181,7 +181,7 @@ bool Font::LoadFromStream(InputStream& stream)
{
// Cleanup the previous resources
Cleanup();
myRefCount = new int(1);
m_refCount = new int(1);
// Initialize FreeType
// Note: we initialize FreeType for every font instance in order to avoid having a single
@ -192,7 +192,7 @@ bool Font::LoadFromStream(InputStream& stream)
Err() << "Failed to load font from stream (failed to initialize FreeType)" << std::endl;
return false;
}
myLibrary = library;
m_library = library;
// Prepare a wrapper for our stream, that we'll pass to FreeType callbacks
FT_StreamRec* rec = new FT_StreamRec;
@ -212,7 +212,7 @@ bool Font::LoadFromStream(InputStream& stream)
// Load the new font face from the specified stream
FT_Face face;
if (FT_Open_Face(static_cast<FT_Library>(myLibrary), &args, 0, &face) != 0)
if (FT_Open_Face(static_cast<FT_Library>(m_library), &args, 0, &face) != 0)
{
Err() << "Failed to load font from stream (failed to create the font face)" << std::endl;
return false;
@ -226,8 +226,8 @@ bool Font::LoadFromStream(InputStream& stream)
}
// Store the loaded font in our ugly void* :)
myFace = face;
myStreamRec = rec;
m_face = face;
m_streamRec = rec;
return true;
}
@ -237,7 +237,7 @@ bool Font::LoadFromStream(InputStream& stream)
const Glyph& Font::GetGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
{
// Get the page corresponding to the character size
GlyphTable& glyphs = myPages[characterSize].Glyphs;
GlyphTable& glyphs = m_pages[characterSize].Glyphs;
// Build the key by combining the code point and the bold flag
Uint32 key = ((bold ? 1 : 0) << 31) | codePoint;
@ -265,7 +265,7 @@ int Font::GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) co
if (first == 0 || second == 0)
return 0;
FT_Face face = static_cast<FT_Face>(myFace);
FT_Face face = static_cast<FT_Face>(m_face);
if (face && FT_HAS_KERNING(face) && SetCurrentSize(characterSize))
{
@ -291,7 +291,7 @@ int Font::GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) co
////////////////////////////////////////////////////////////
int Font::GetLineSpacing(unsigned int characterSize) const
{
FT_Face face = static_cast<FT_Face>(myFace);
FT_Face face = static_cast<FT_Face>(m_face);
if (face && SetCurrentSize(characterSize))
{
@ -307,7 +307,7 @@ int Font::GetLineSpacing(unsigned int characterSize) const
////////////////////////////////////////////////////////////
const Texture& Font::GetTexture(unsigned int characterSize) const
{
return myPages[characterSize].Texture;
return m_pages[characterSize].Texture;
}
@ -316,11 +316,11 @@ Font& Font::operator =(const Font& right)
{
Font temp(right);
std::swap(myLibrary, temp.myLibrary);
std::swap(myFace, temp.myFace);
std::swap(myPages, temp.myPages);
std::swap(myPixelBuffer, temp.myPixelBuffer);
std::swap(myRefCount, temp.myRefCount);
std::swap(m_library, temp.m_library);
std::swap(m_face, temp.m_face);
std::swap(m_pages, temp.m_pages);
std::swap(m_pixelBuffer, temp.m_pixelBuffer);
std::swap(m_refCount, temp.m_refCount);
return *this;
}
@ -352,38 +352,38 @@ const Font& Font::GetDefaultFont()
void Font::Cleanup()
{
// Check if we must destroy the FreeType pointers
if (myRefCount)
if (m_refCount)
{
// Decrease the reference counter
(*myRefCount)--;
(*m_refCount)--;
// Free the resources only if we are the last owner
if (*myRefCount == 0)
if (*m_refCount == 0)
{
// Delete the reference counter
delete myRefCount;
delete m_refCount;
// Destroy the font face
if (myFace)
FT_Done_Face(static_cast<FT_Face>(myFace));
if (m_face)
FT_Done_Face(static_cast<FT_Face>(m_face));
// Destroy the stream rec instance, if any (must be done after FT_Done_Face!)
if (myStreamRec)
delete static_cast<FT_StreamRec*>(myStreamRec);
if (m_streamRec)
delete static_cast<FT_StreamRec*>(m_streamRec);
// Close the library
if (myLibrary)
FT_Done_FreeType(static_cast<FT_Library>(myLibrary));
if (m_library)
FT_Done_FreeType(static_cast<FT_Library>(m_library));
}
}
// Reset members
myLibrary = NULL;
myFace = NULL;
myStreamRec = NULL;
myRefCount = NULL;
myPages.clear();
myPixelBuffer.clear();
m_library = NULL;
m_face = NULL;
m_streamRec = NULL;
m_refCount = NULL;
m_pages.clear();
m_pixelBuffer.clear();
}
@ -394,7 +394,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
Glyph glyph;
// First, transform our ugly void* to a FT_Face
FT_Face face = static_cast<FT_Face>(myFace);
FT_Face face = static_cast<FT_Face>(m_face);
if (!face)
return glyph;
@ -428,7 +428,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
// Apply bold if necessary -- fallback technique using bitmap (lower quality)
if (bold && !outline)
{
FT_Bitmap_Embolden(static_cast<FT_Library>(myLibrary), &bitmap, weight, weight);
FT_Bitmap_Embolden(static_cast<FT_Library>(m_library), &bitmap, weight, weight);
}
// Compute the glyph's advance offset
@ -445,7 +445,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
const unsigned int padding = 1;
// Get the glyphs page corresponding to the character size
Page& page = myPages[characterSize];
Page& page = m_pages[characterSize];
// Find a good position for the new glyph into the texture
glyph.TextureRect = FindGlyphRect(page, width + 2 * padding, height + 2 * padding);
@ -457,7 +457,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
glyph.Bounds.Height = height + 2 * padding;
// Extract the glyph's pixels from the bitmap
myPixelBuffer.resize(width * height * 4, 255);
m_pixelBuffer.resize(width * height * 4, 255);
const Uint8* pixels = bitmap.buffer;
if (bitmap.pixel_mode == FT_PIXEL_MODE_MONO)
{
@ -468,7 +468,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
{
// The color channels remain white, just fill the alpha channel
std::size_t index = (x + y * width) * 4 + 3;
myPixelBuffer[index] = ((pixels[x / 8]) & (1 << (7 - (x % 8)))) ? 255 : 0;
m_pixelBuffer[index] = ((pixels[x / 8]) & (1 << (7 - (x % 8)))) ? 255 : 0;
}
pixels += bitmap.pitch;
}
@ -482,7 +482,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
{
// The color channels remain white, just fill the alpha channel
std::size_t index = (x + y * width) * 4 + 3;
myPixelBuffer[index] = pixels[x];
m_pixelBuffer[index] = pixels[x];
}
pixels += bitmap.pitch;
}
@ -493,7 +493,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
unsigned int y = glyph.TextureRect.Top + padding;
unsigned int width = glyph.TextureRect.Width - 2 * padding;
unsigned int height = glyph.TextureRect.Height - 2 * padding;
page.Texture.Update(&myPixelBuffer[0], width, height, x, y);
page.Texture.Update(&m_pixelBuffer[0], width, height, x, y);
}
// Delete the FT glyph
@ -577,7 +577,7 @@ bool Font::SetCurrentSize(unsigned int characterSize) const
// FT_Set_Pixel_Sizes is an expensive function, so we must call it
// only when necessary to avoid killing performances
FT_Face face = static_cast<FT_Face>(myFace);
FT_Face face = static_cast<FT_Face>(m_face);
FT_UShort currentSize = face->size->metrics.x_ppem;
if (currentSize != characterSize)

View file

@ -36,8 +36,8 @@ namespace sf
{
////////////////////////////////////////////////////////////
Image::Image() :
myWidth (0),
myHeight(0)
m_width (0),
m_height(0)
{
}
@ -47,15 +47,15 @@ myHeight(0)
void Image::Create(unsigned int width, unsigned int height, const Color& color)
{
// Assign the new size
myWidth = width;
myHeight = height;
m_width = width;
m_height = height;
// Resize the pixel buffer
myPixels.resize(width * height * 4);
m_pixels.resize(width * height * 4);
// Fill it with the specified color
Uint8* ptr = &myPixels[0];
Uint8* end = ptr + myPixels.size();
Uint8* ptr = &m_pixels[0];
Uint8* end = ptr + m_pixels.size();
while (ptr < end)
{
*ptr++ = color.r;
@ -72,20 +72,20 @@ void Image::Create(unsigned int width, unsigned int height, const Uint8* pixels)
if (pixels)
{
// Assign the new size
myWidth = width;
myHeight = height;
m_width = width;
m_height = height;
// Copy the pixels
std::size_t size = width * height * 4;
myPixels.resize(size);
std::memcpy(&myPixels[0], pixels, size); // faster than vector::assign
m_pixels.resize(size);
std::memcpy(&m_pixels[0], pixels, size); // faster than vector::assign
}
else
{
// Create an empty image
myWidth = 0;
myHeight = 0;
myPixels.clear();
m_width = 0;
m_height = 0;
m_pixels.clear();
}
}
@ -93,42 +93,42 @@ void Image::Create(unsigned int width, unsigned int height, const Uint8* pixels)
////////////////////////////////////////////////////////////
bool Image::LoadFromFile(const std::string& filename)
{
return priv::ImageLoader::GetInstance().LoadImageFromFile(filename, myPixels, myWidth, myHeight);
return priv::ImageLoader::GetInstance().LoadImageFromFile(filename, m_pixels, m_width, m_height);
}
////////////////////////////////////////////////////////////
bool Image::LoadFromMemory(const void* data, std::size_t size)
{
return priv::ImageLoader::GetInstance().LoadImageFromMemory(data, size, myPixels, myWidth, myHeight);
return priv::ImageLoader::GetInstance().LoadImageFromMemory(data, size, m_pixels, m_width, m_height);
}
////////////////////////////////////////////////////////////
bool Image::LoadFromStream(InputStream& stream)
{
return priv::ImageLoader::GetInstance().LoadImageFromStream(stream, myPixels, myWidth, myHeight);
return priv::ImageLoader::GetInstance().LoadImageFromStream(stream, m_pixels, m_width, m_height);
}
////////////////////////////////////////////////////////////
bool Image::SaveToFile(const std::string& filename) const
{
return priv::ImageLoader::GetInstance().SaveImageToFile(filename, myPixels, myWidth, myHeight);
return priv::ImageLoader::GetInstance().SaveImageToFile(filename, m_pixels, m_width, m_height);
}
////////////////////////////////////////////////////////////
unsigned int Image::GetWidth() const
{
return myWidth;
return m_width;
}
////////////////////////////////////////////////////////////
unsigned int Image::GetHeight() const
{
return myHeight;
return m_height;
}
@ -136,11 +136,11 @@ unsigned int Image::GetHeight() const
void Image::CreateMaskFromColor(const Color& color, Uint8 alpha)
{
// Make sure that the image is not empty
if (!myPixels.empty())
if (!m_pixels.empty())
{
// Replace the alpha of the pixels that match the transparent color
Uint8* ptr = &myPixels[0];
Uint8* end = ptr + myPixels.size();
Uint8* ptr = &m_pixels[0];
Uint8* end = ptr + m_pixels.size();
while (ptr < end)
{
if ((ptr[0] == color.r) && (ptr[1] == color.g) && (ptr[2] == color.b) && (ptr[3] == color.a))
@ -155,7 +155,7 @@ void Image::CreateMaskFromColor(const Color& color, Uint8 alpha)
void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect, bool applyAlpha)
{
// Make sure that both images are valid
if ((source.myWidth == 0) || (source.myHeight == 0) || (myWidth == 0) || (myHeight == 0))
if ((source.m_width == 0) || (source.m_height == 0) || (m_width == 0) || (m_height == 0))
return;
// Adjust the source rectangle
@ -164,22 +164,22 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
{
srcRect.Left = 0;
srcRect.Top = 0;
srcRect.Width = source.myWidth;
srcRect.Height = source.myHeight;
srcRect.Width = source.m_width;
srcRect.Height = source.m_height;
}
else
{
if (srcRect.Left < 0) srcRect.Left = 0;
if (srcRect.Top < 0) srcRect.Top = 0;
if (srcRect.Width > static_cast<int>(source.myWidth)) srcRect.Width = source.myWidth;
if (srcRect.Height > static_cast<int>(source.myHeight)) srcRect.Height = source.myHeight;
if (srcRect.Width > static_cast<int>(source.m_width)) srcRect.Width = source.m_width;
if (srcRect.Height > static_cast<int>(source.m_height)) srcRect.Height = source.m_height;
}
// Then find the valid bounds of the destination rectangle
int width = srcRect.Width;
int height = srcRect.Height;
if (destX + width > myWidth) width = myWidth - destX;
if (destY + height > myHeight) height = myHeight - destY;
if (destX + width > m_width) width = m_width - destX;
if (destY + height > m_height) height = m_height - destY;
// Make sure the destination area is valid
if ((width <= 0) || (height <= 0))
@ -188,10 +188,10 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
// Precompute as much as possible
int pitch = width * 4;
int rows = height;
int srcStride = source.myWidth * 4;
int dstStride = myWidth * 4;
const Uint8* srcPixels = &source.myPixels[0] + (srcRect.Left + srcRect.Top * source.myWidth) * 4;
Uint8* dstPixels = &myPixels[0] + (destX + destY * myWidth) * 4;
int srcStride = source.m_width * 4;
int dstStride = m_width * 4;
const Uint8* srcPixels = &source.m_pixels[0] + (srcRect.Left + srcRect.Top * source.m_width) * 4;
Uint8* dstPixels = &m_pixels[0] + (destX + destY * m_width) * 4;
// Copy the pixels
if (applyAlpha)
@ -233,7 +233,7 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
////////////////////////////////////////////////////////////
void Image::SetPixel(unsigned int x, unsigned int y, const Color& color)
{
Uint8* pixel = &myPixels[(x + y * myWidth) * 4];
Uint8* pixel = &m_pixels[(x + y * m_width) * 4];
*pixel++ = color.r;
*pixel++ = color.g;
*pixel++ = color.b;
@ -244,7 +244,7 @@ void Image::SetPixel(unsigned int x, unsigned int y, const Color& color)
////////////////////////////////////////////////////////////
Color Image::GetPixel(unsigned int x, unsigned int y) const
{
const Uint8* pixel = &myPixels[(x + y * myWidth) * 4];
const Uint8* pixel = &m_pixels[(x + y * m_width) * 4];
return Color(pixel[0], pixel[1], pixel[2], pixel[3]);
}
@ -252,9 +252,9 @@ Color Image::GetPixel(unsigned int x, unsigned int y) const
////////////////////////////////////////////////////////////
const Uint8* Image::GetPixelsPtr() const
{
if (!myPixels.empty())
if (!m_pixels.empty())
{
return &myPixels[0];
return &m_pixels[0];
}
else
{
@ -267,14 +267,14 @@ const Uint8* Image::GetPixelsPtr() const
////////////////////////////////////////////////////////////
void Image::FlipHorizontally()
{
if (!myPixels.empty())
if (!m_pixels.empty())
{
std::vector<Uint8> before = myPixels;
for (unsigned int y = 0; y < myHeight; ++y)
std::vector<Uint8> before = m_pixels;
for (unsigned int y = 0; y < m_height; ++y)
{
const Uint8* source = &before[y * myWidth * 4];
Uint8* dest = &myPixels[(y + 1) * myWidth * 4 - 4];
for (unsigned int x = 0; x < myWidth; ++x)
const Uint8* source = &before[y * m_width * 4];
Uint8* dest = &m_pixels[(y + 1) * m_width * 4 - 4];
for (unsigned int x = 0; x < m_width; ++x)
{
dest[0] = source[0];
dest[1] = source[1];
@ -292,14 +292,14 @@ void Image::FlipHorizontally()
////////////////////////////////////////////////////////////
void Image::FlipVertically()
{
if (!myPixels.empty())
if (!m_pixels.empty())
{
std::vector<Uint8> before = myPixels;
const Uint8* source = &before[myWidth * (myHeight - 1) * 4];
Uint8* dest = &myPixels[0];
std::size_t rowSize = myWidth * 4;
std::vector<Uint8> before = m_pixels;
const Uint8* source = &before[m_width * (m_height - 1) * 4];
Uint8* dest = &m_pixels[0];
std::size_t rowSize = m_width * 4;
for (unsigned int y = 0; y < myHeight; ++y)
for (unsigned int y = 0; y < m_height; ++y)
{
std::memcpy(dest, source, rowSize);
source -= rowSize;

View file

@ -41,7 +41,7 @@ RectangleShape::RectangleShape(const Vector2f& size)
////////////////////////////////////////////////////////////
void RectangleShape::SetSize(const Vector2f& size)
{
mySize = size;
m_size = size;
Update();
}
@ -49,7 +49,7 @@ void RectangleShape::SetSize(const Vector2f& size)
////////////////////////////////////////////////////////////
const Vector2f& RectangleShape::GetSize() const
{
return mySize;
return m_size;
}
@ -67,9 +67,9 @@ Vector2f RectangleShape::GetPoint(unsigned int index) const
{
default:
case 0: return Vector2f(0, 0);
case 1: return Vector2f(mySize.x, 0);
case 2: return Vector2f(mySize.x, mySize.y);
case 3: return Vector2f(0, mySize.y);
case 1: return Vector2f(m_size.x, 0);
case 2: return Vector2f(m_size.x, m_size.y);
case 3: return Vector2f(0, m_size.y);
}
}

View file

@ -38,9 +38,9 @@ namespace sf
{
////////////////////////////////////////////////////////////
RenderTarget::RenderTarget() :
myDefaultView(),
myView (),
myCache ()
m_defaultView(),
m_view (),
m_cache ()
{
}
@ -65,22 +65,22 @@ void RenderTarget::Clear(const Color& color)
////////////////////////////////////////////////////////////
void RenderTarget::SetView(const View& view)
{
myView = view;
myCache.ViewChanged = true;
m_view = view;
m_cache.ViewChanged = true;
}
////////////////////////////////////////////////////////////
const View& RenderTarget::GetView() const
{
return myView;
return m_view;
}
////////////////////////////////////////////////////////////
const View& RenderTarget::GetDefaultView() const
{
return myDefaultView;
return m_defaultView;
}
@ -143,14 +143,14 @@ void RenderTarget::Draw(const Vertex* vertices, unsigned int vertexCount,
// Pre-transform the vertices and store them into the vertex cache
for (unsigned int i = 0; i < vertexCount; ++i)
{
Vertex& vertex = myCache.VertexCache[i];
Vertex& vertex = m_cache.VertexCache[i];
vertex.Position = states.Transform * vertices[i].Position;
vertex.Color = vertices[i].Color;
vertex.TexCoords = vertices[i].TexCoords;
}
// Since vertices are transformed, we must use an identity transform to render them
if (!myCache.UseVertexCache)
if (!m_cache.UseVertexCache)
ApplyTransform(Transform::Identity);
}
else
@ -159,16 +159,16 @@ void RenderTarget::Draw(const Vertex* vertices, unsigned int vertexCount,
}
// Apply the view
if (myCache.ViewChanged)
if (m_cache.ViewChanged)
ApplyCurrentView();
// Apply the blend mode
if (states.BlendMode != myCache.LastBlendMode)
if (states.BlendMode != m_cache.LastBlendMode)
ApplyBlendMode(states.BlendMode);
// Apply the texture
Uint64 textureId = states.Texture ? states.Texture->myCacheId : 0;
if (textureId != myCache.LastTextureId)
Uint64 textureId = states.Texture ? states.Texture->m_cacheId : 0;
if (textureId != m_cache.LastTextureId)
ApplyTexture(states.Texture);
// Apply the shader
@ -179,8 +179,8 @@ void RenderTarget::Draw(const Vertex* vertices, unsigned int vertexCount,
if (useVertexCache)
{
// ... and if we already used it previously, we don't need to set the pointers again
if (!myCache.UseVertexCache)
vertices = myCache.VertexCache;
if (!m_cache.UseVertexCache)
vertices = m_cache.VertexCache;
else
vertices = NULL;
}
@ -207,7 +207,7 @@ void RenderTarget::Draw(const Vertex* vertices, unsigned int vertexCount,
ApplyShader(NULL);
// Update the cache
myCache.UseVertexCache = useVertexCache;
m_cache.UseVertexCache = useVertexCache;
}
}
@ -272,7 +272,7 @@ void RenderTarget::ResetGLStates()
ApplyTexture(NULL);
if (Shader::IsAvailable())
ApplyShader(NULL);
myCache.UseVertexCache = false;
m_cache.UseVertexCache = false;
// Set the default view
SetView(GetView());
@ -284,8 +284,8 @@ void RenderTarget::ResetGLStates()
void RenderTarget::Initialize()
{
// Setup the default and current views
myDefaultView.Reset(FloatRect(0, 0, static_cast<float>(GetSize().x), static_cast<float>(GetSize().y)));
myView = myDefaultView;
m_defaultView.Reset(FloatRect(0, 0, static_cast<float>(GetSize().x), static_cast<float>(GetSize().y)));
m_view = m_defaultView;
// Initialize the default OpenGL render-states
ResetGLStates();
@ -296,18 +296,18 @@ void RenderTarget::Initialize()
void RenderTarget::ApplyCurrentView()
{
// Set the viewport
IntRect viewport = GetViewport(myView);
IntRect viewport = GetViewport(m_view);
int top = GetSize().y - (viewport.Top + viewport.Height);
GLCheck(glViewport(viewport.Left, top, viewport.Width, viewport.Height));
// Set the projection matrix
GLCheck(glMatrixMode(GL_PROJECTION));
GLCheck(glLoadMatrixf(myView.GetTransform().GetMatrix()));
GLCheck(glLoadMatrixf(m_view.GetTransform().GetMatrix()));
// Go back to model-view mode
GLCheck(glMatrixMode(GL_MODELVIEW));
myCache.ViewChanged = false;
m_cache.ViewChanged = false;
}
@ -343,7 +343,7 @@ void RenderTarget::ApplyBlendMode(BlendMode mode)
break;
}
myCache.LastBlendMode = mode;
m_cache.LastBlendMode = mode;
}
@ -364,7 +364,7 @@ void RenderTarget::ApplyTexture(const Texture* texture)
else
GLCheck(glBindTexture(GL_TEXTURE_2D, 0));
myCache.LastTextureId = texture ? texture->myCacheId : 0;
m_cache.LastTextureId = texture ? texture->m_cacheId : 0;
}

View file

@ -35,7 +35,7 @@ namespace sf
{
////////////////////////////////////////////////////////////
RenderTexture::RenderTexture() :
myImpl(NULL)
m_impl(NULL)
{
}
@ -44,7 +44,7 @@ myImpl(NULL)
////////////////////////////////////////////////////////////
RenderTexture::~RenderTexture()
{
delete myImpl;
delete m_impl;
}
@ -52,7 +52,7 @@ RenderTexture::~RenderTexture()
bool RenderTexture::Create(unsigned int width, unsigned int height, bool depthBuffer)
{
// Create the texture
if (!myTexture.Create(width, height))
if (!m_texture.Create(width, height))
{
Err() << "Impossible to create render texture (failed to create the target texture)" << std::endl;
return false;
@ -62,20 +62,20 @@ bool RenderTexture::Create(unsigned int width, unsigned int height, bool depthBu
SetSmooth(false);
// Create the implementation
delete myImpl;
delete m_impl;
if (priv::RenderTextureImplFBO::IsAvailable())
{
// Use frame-buffer object (FBO)
myImpl = new priv::RenderTextureImplFBO;
m_impl = new priv::RenderTextureImplFBO;
}
else
{
// Use default implementation
myImpl = new priv::RenderTextureImplDefault;
m_impl = new priv::RenderTextureImplDefault;
}
// Initialize the render texture
if (!myImpl->Create(width, height, myTexture.myTexture, depthBuffer))
if (!m_impl->Create(width, height, m_texture.m_texture, depthBuffer))
return false;
// We can now initialize the render target part
@ -88,21 +88,21 @@ bool RenderTexture::Create(unsigned int width, unsigned int height, bool depthBu
////////////////////////////////////////////////////////////
void RenderTexture::SetSmooth(bool smooth)
{
myTexture.SetSmooth(smooth);
m_texture.SetSmooth(smooth);
}
////////////////////////////////////////////////////////////
bool RenderTexture::IsSmooth() const
{
return myTexture.IsSmooth();
return m_texture.IsSmooth();
}
////////////////////////////////////////////////////////////
bool RenderTexture::SetActive(bool active)
{
return myImpl && myImpl->Activate(active);
return m_impl && m_impl->Activate(active);
}
@ -112,8 +112,8 @@ void RenderTexture::Display()
// Update the target texture
if (SetActive(true))
{
myImpl->UpdateTexture(myTexture.myTexture);
myTexture.myPixelsFlipped = true;
m_impl->UpdateTexture(m_texture.m_texture);
m_texture.m_pixelsFlipped = true;
}
}
@ -121,14 +121,14 @@ void RenderTexture::Display()
////////////////////////////////////////////////////////////
Vector2u RenderTexture::GetSize() const
{
return Vector2u(myTexture.GetWidth(), myTexture.GetHeight());
return Vector2u(m_texture.GetWidth(), m_texture.GetHeight());
}
////////////////////////////////////////////////////////////
const Texture& RenderTexture::GetTexture() const
{
return myTexture;
return m_texture;
}

View file

@ -38,9 +38,9 @@ namespace priv
{
////////////////////////////////////////////////////////////
RenderTextureImplDefault::RenderTextureImplDefault() :
myContext(0),
myWidth (0),
myHeight (0)
m_context(0),
m_width (0),
m_height (0)
{
}
@ -50,7 +50,7 @@ myHeight (0)
RenderTextureImplDefault::~RenderTextureImplDefault()
{
// Destroy the context
delete myContext;
delete m_context;
}
@ -58,11 +58,11 @@ RenderTextureImplDefault::~RenderTextureImplDefault()
bool RenderTextureImplDefault::Create(unsigned int width, unsigned int height, unsigned int, bool depthBuffer)
{
// Store the dimensions
myWidth = width;
myHeight = height;
m_width = width;
m_height = height;
// Create the in-memory OpenGL context
myContext = new Context(ContextSettings(depthBuffer ? 32 : 0), width, height);
m_context = new Context(ContextSettings(depthBuffer ? 32 : 0), width, height);
return true;
}
@ -71,7 +71,7 @@ bool RenderTextureImplDefault::Create(unsigned int width, unsigned int height, u
////////////////////////////////////////////////////////////
bool RenderTextureImplDefault::Activate(bool active)
{
return myContext->SetActive(active);
return m_context->SetActive(active);
}
@ -83,7 +83,7 @@ void RenderTextureImplDefault::UpdateTexture(unsigned int textureId)
// Copy the rendered pixels to the texture
GLCheck(glBindTexture(GL_TEXTURE_2D, textureId));
GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, myWidth, myHeight));
GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height));
}
} // namespace priv

View file

@ -94,9 +94,9 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Context* myContext; ///< P-Buffer based context
unsigned int myWidth; ///< Width of the P-Buffer
unsigned int myHeight; ///< Height of the P-Buffer
Context* m_context; ///< P-Buffer based context
unsigned int m_width; ///< Width of the P-Buffer
unsigned int m_height; ///< Height of the P-Buffer
};
} // namespace priv

View file

@ -37,8 +37,8 @@ namespace priv
{
////////////////////////////////////////////////////////////
RenderTextureImplFBO::RenderTextureImplFBO() :
myFrameBuffer(0),
myDepthBuffer(0)
m_frameBuffer(0),
m_depthBuffer(0)
{
}
@ -50,21 +50,21 @@ RenderTextureImplFBO::~RenderTextureImplFBO()
EnsureGlContext();
// Destroy the depth buffer
if (myDepthBuffer)
if (m_depthBuffer)
{
GLuint depthBuffer = static_cast<GLuint>(myDepthBuffer);
GLuint depthBuffer = static_cast<GLuint>(m_depthBuffer);
GLCheck(glDeleteFramebuffersEXT(1, &depthBuffer));
}
// Destroy the frame buffer
if (myFrameBuffer)
if (m_frameBuffer)
{
GLuint frameBuffer = static_cast<GLuint>(myFrameBuffer);
GLuint frameBuffer = static_cast<GLuint>(m_frameBuffer);
GLCheck(glDeleteFramebuffersEXT(1, &frameBuffer));
}
// Delete the context
delete myContext;
delete m_context;
}
@ -84,33 +84,33 @@ bool RenderTextureImplFBO::IsAvailable()
bool RenderTextureImplFBO::Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer)
{
// Create the context
myContext = new Context;
m_context = new Context;
// Create the framebuffer object
GLuint frameBuffer = 0;
GLCheck(glGenFramebuffersEXT(1, &frameBuffer));
myFrameBuffer = static_cast<unsigned int>(frameBuffer);
if (!myFrameBuffer)
m_frameBuffer = static_cast<unsigned int>(frameBuffer);
if (!m_frameBuffer)
{
Err() << "Impossible to create render texture (failed to create the frame buffer object)" << std::endl;
return false;
}
GLCheck(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFrameBuffer));
GLCheck(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBuffer));
// Create the depth buffer if requested
if (depthBuffer)
{
GLuint depth = 0;
GLCheck(glGenRenderbuffersEXT(1, &depth));
myDepthBuffer = static_cast<unsigned int>(depth);
if (!myDepthBuffer)
m_depthBuffer = static_cast<unsigned int>(depth);
if (!m_depthBuffer)
{
Err() << "Impossible to create render texture (failed to create the attached depth buffer)" << std::endl;
return false;
}
GLCheck(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, myDepthBuffer));
GLCheck(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer));
GLCheck(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height));
GLCheck(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, myDepthBuffer));
GLCheck(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer));
}
// Link the texture to the frame buffer
@ -131,7 +131,7 @@ bool RenderTextureImplFBO::Create(unsigned int width, unsigned int height, unsig
////////////////////////////////////////////////////////////
bool RenderTextureImplFBO::Activate(bool active)
{
return myContext->SetActive(active);
return m_context->SetActive(active);
}
////////////////////////////////////////////////////////////

View file

@ -102,9 +102,9 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Context* myContext; ///< Needs a separate OpenGL context for not messing up the other ones
unsigned int myFrameBuffer; ///< OpenGL frame buffer object
unsigned int myDepthBuffer; ///< Optional depth buffer attached to the frame buffer
Context* m_context; ///< Needs a separate OpenGL context for not messing up the other ones
unsigned int m_frameBuffer; ///< OpenGL frame buffer object
unsigned int m_depthBuffer; ///< Optional depth buffer attached to the frame buffer
};
} // namespace priv

View file

@ -85,8 +85,8 @@ Shader::CurrentTextureType Shader::CurrentTexture;
////////////////////////////////////////////////////////////
Shader::Shader() :
myShaderProgram (0),
myCurrentTexture(-1)
m_shaderProgram (0),
m_currentTexture(-1)
{
}
@ -97,8 +97,8 @@ Shader::~Shader()
EnsureGlContext();
// Destroy effect program
if (myShaderProgram)
GLCheck(glDeleteObjectARB(myShaderProgram));
if (m_shaderProgram)
GLCheck(glDeleteObjectARB(m_shaderProgram));
}
@ -210,16 +210,16 @@ bool Shader::LoadFromStream(InputStream& vertexShaderStream, InputStream& fragme
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, float x)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Enable program
GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
GLCheck(glUseProgramObjectARB(myShaderProgram));
GLCheck(glUseProgramObjectARB(m_shaderProgram));
// Get parameter location and assign it new values
GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str());
GLint location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (location != -1)
GLCheck(glUniform1fARB(location, x));
else
@ -234,16 +234,16 @@ void Shader::SetParameter(const std::string& name, float x)
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, float x, float y)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Enable program
GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
GLCheck(glUseProgramObjectARB(myShaderProgram));
GLCheck(glUseProgramObjectARB(m_shaderProgram));
// Get parameter location and assign it new values
GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str());
GLint location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (location != -1)
GLCheck(glUniform2fARB(location, x, y));
else
@ -258,16 +258,16 @@ void Shader::SetParameter(const std::string& name, float x, float y)
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, float x, float y, float z)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Enable program
GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
GLCheck(glUseProgramObjectARB(myShaderProgram));
GLCheck(glUseProgramObjectARB(m_shaderProgram));
// Get parameter location and assign it new values
GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str());
GLint location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (location != -1)
GLCheck(glUniform3fARB(location, x, y, z));
else
@ -282,16 +282,16 @@ void Shader::SetParameter(const std::string& name, float x, float y, float z)
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, float x, float y, float z, float w)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Enable program
GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
GLCheck(glUseProgramObjectARB(myShaderProgram));
GLCheck(glUseProgramObjectARB(m_shaderProgram));
// Get parameter location and assign it new values
GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str());
GLint location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (location != -1)
GLCheck(glUniform4fARB(location, x, y, z, w));
else
@ -327,16 +327,16 @@ void Shader::SetParameter(const std::string& name, const Color& color)
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, const sf::Transform& transform)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Enable program
GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
GLCheck(glUseProgramObjectARB(myShaderProgram));
GLCheck(glUseProgramObjectARB(m_shaderProgram));
// Get parameter location and assign it new values
GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str());
GLint location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (location != -1)
GLCheck(glUniformMatrix4fvARB(location, 1, GL_FALSE, transform.GetMatrix()));
else
@ -351,12 +351,12 @@ void Shader::SetParameter(const std::string& name, const sf::Transform& transfor
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, const Texture& texture)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Find the location of the variable in the shader
int location = glGetUniformLocationARB(myShaderProgram, name.c_str());
int location = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (location == -1)
{
Err() << "Texture \"" << name << "\" not found in shader" << std::endl;
@ -364,18 +364,18 @@ void Shader::SetParameter(const std::string& name, const Texture& texture)
}
// Store the location -> texture mapping
TextureTable::iterator it = myTextures.find(location);
if (it == myTextures.end())
TextureTable::iterator it = m_textures.find(location);
if (it == m_textures.end())
{
// New entry, make sure there are enough texture units
static const GLint maxUnits = GetMaxTextureUnits();
if (myTextures.size() + 1 >= static_cast<std::size_t>(maxUnits))
if (m_textures.size() + 1 >= static_cast<std::size_t>(maxUnits))
{
Err() << "Impossible to use texture \"" << name << "\" for shader: all available texture units are used" << std::endl;
return;
}
myTextures[location] = &texture;
m_textures[location] = &texture;
}
else
{
@ -389,13 +389,13 @@ void Shader::SetParameter(const std::string& name, const Texture& texture)
////////////////////////////////////////////////////////////
void Shader::SetParameter(const std::string& name, CurrentTextureType)
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Find the location of the variable in the shader
myCurrentTexture = glGetUniformLocationARB(myShaderProgram, name.c_str());
if (myCurrentTexture == -1)
m_currentTexture = glGetUniformLocationARB(m_shaderProgram, name.c_str());
if (m_currentTexture == -1)
Err() << "Texture \"" << name << "\" not found in shader" << std::endl;
}
}
@ -404,19 +404,19 @@ void Shader::SetParameter(const std::string& name, CurrentTextureType)
////////////////////////////////////////////////////////////
void Shader::Bind() const
{
if (myShaderProgram)
if (m_shaderProgram)
{
EnsureGlContext();
// Enable the program
GLCheck(glUseProgramObjectARB(myShaderProgram));
GLCheck(glUseProgramObjectARB(m_shaderProgram));
// Bind the textures
BindTextures();
// Bind the current texture
if (myCurrentTexture != -1)
GLCheck(glUniform1iARB(myCurrentTexture, 0));
if (m_currentTexture != -1)
GLCheck(glUniform1iARB(m_currentTexture, 0));
}
}
@ -459,11 +459,11 @@ bool Shader::Compile(const char* vertexShaderCode, const char* fragmentShaderCod
}
// Destroy the shader if it was already created
if (myShaderProgram)
GLCheck(glDeleteObjectARB(myShaderProgram));
if (m_shaderProgram)
GLCheck(glDeleteObjectARB(m_shaderProgram));
// Create the program
myShaderProgram = glCreateProgramObjectARB();
m_shaderProgram = glCreateProgramObjectARB();
// Create the vertex shader if needed
if (vertexShaderCode)
@ -483,13 +483,13 @@ bool Shader::Compile(const char* vertexShaderCode, const char* fragmentShaderCod
Err() << "Failed to compile vertex shader:" << std::endl
<< log << std::endl;
GLCheck(glDeleteObjectARB(vertexShader));
GLCheck(glDeleteObjectARB(myShaderProgram));
myShaderProgram = 0;
GLCheck(glDeleteObjectARB(m_shaderProgram));
m_shaderProgram = 0;
return false;
}
// Attach the shader to the program, and delete it (not needed anymore)
GLCheck(glAttachObjectARB(myShaderProgram, vertexShader));
GLCheck(glAttachObjectARB(m_shaderProgram, vertexShader));
GLCheck(glDeleteObjectARB(vertexShader));
}
@ -511,30 +511,30 @@ bool Shader::Compile(const char* vertexShaderCode, const char* fragmentShaderCod
Err() << "Failed to compile fragment shader:" << std::endl
<< log << std::endl;
GLCheck(glDeleteObjectARB(fragmentShader));
GLCheck(glDeleteObjectARB(myShaderProgram));
myShaderProgram = 0;
GLCheck(glDeleteObjectARB(m_shaderProgram));
m_shaderProgram = 0;
return false;
}
// Attach the shader to the program, and delete it (not needed anymore)
GLCheck(glAttachObjectARB(myShaderProgram, fragmentShader));
GLCheck(glAttachObjectARB(m_shaderProgram, fragmentShader));
GLCheck(glDeleteObjectARB(fragmentShader));
}
// Link the program
GLCheck(glLinkProgramARB(myShaderProgram));
GLCheck(glLinkProgramARB(m_shaderProgram));
// Check the link log
GLint success;
GLCheck(glGetObjectParameterivARB(myShaderProgram, GL_OBJECT_LINK_STATUS_ARB, &success));
GLCheck(glGetObjectParameterivARB(m_shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &success));
if (success == GL_FALSE)
{
char log[1024];
GLCheck(glGetInfoLogARB(myShaderProgram, sizeof(log), 0, log));
GLCheck(glGetInfoLogARB(m_shaderProgram, sizeof(log), 0, log));
Err() << "Failed to link shader:" << std::endl
<< log << std::endl;
GLCheck(glDeleteObjectARB(myShaderProgram));
myShaderProgram = 0;
GLCheck(glDeleteObjectARB(m_shaderProgram));
m_shaderProgram = 0;
return false;
}
@ -545,8 +545,8 @@ bool Shader::Compile(const char* vertexShaderCode, const char* fragmentShaderCod
////////////////////////////////////////////////////////////
void Shader::BindTextures() const
{
TextureTable::const_iterator it = myTextures.begin();
for (std::size_t i = 0; i < myTextures.size(); ++i)
TextureTable::const_iterator it = m_textures.begin();
for (std::size_t i = 0; i < m_textures.size(); ++i)
{
GLint index = static_cast<GLsizei>(i + 1);
GLCheck(glUniform1iARB(it->first, index));

View file

@ -58,25 +58,25 @@ Shape::~Shape()
void Shape::SetTexture(const Texture* texture, bool resetRect)
{
// Recompute the texture area if requested, or if there was no texture before
if (texture && (resetRect || !myTexture))
if (texture && (resetRect || !m_texture))
SetTextureRect(IntRect(0, 0, texture->GetWidth(), texture->GetHeight()));
// Assign the new texture
myTexture = texture;
m_texture = texture;
}
////////////////////////////////////////////////////////////
const Texture* Shape::GetTexture() const
{
return myTexture;
return m_texture;
}
////////////////////////////////////////////////////////////
void Shape::SetTextureRect(const IntRect& rect)
{
myTextureRect = rect;
m_textureRect = rect;
UpdateTexCoords();
}
@ -84,14 +84,14 @@ void Shape::SetTextureRect(const IntRect& rect)
////////////////////////////////////////////////////////////
const IntRect& Shape::GetTextureRect() const
{
return myTextureRect;
return m_textureRect;
}
////////////////////////////////////////////////////////////
void Shape::SetFillColor(const Color& color)
{
myFillColor = color;
m_fillColor = color;
UpdateFillColors();
}
@ -99,14 +99,14 @@ void Shape::SetFillColor(const Color& color)
////////////////////////////////////////////////////////////
const Color& Shape::GetFillColor() const
{
return myFillColor;
return m_fillColor;
}
////////////////////////////////////////////////////////////
void Shape::SetOutlineColor(const Color& color)
{
myOutlineColor = color;
m_outlineColor = color;
UpdateOutlineColors();
}
@ -114,14 +114,14 @@ void Shape::SetOutlineColor(const Color& color)
////////////////////////////////////////////////////////////
const Color& Shape::GetOutlineColor() const
{
return myOutlineColor;
return m_outlineColor;
}
////////////////////////////////////////////////////////////
void Shape::SetOutlineThickness(float thickness)
{
myOutlineThickness = thickness;
m_outlineThickness = thickness;
Update(); // recompute everything because the whole shape must be offset
}
@ -129,14 +129,14 @@ void Shape::SetOutlineThickness(float thickness)
////////////////////////////////////////////////////////////
float Shape::GetOutlineThickness() const
{
return myOutlineThickness;
return m_outlineThickness;
}
////////////////////////////////////////////////////////////
FloatRect Shape::GetLocalBounds() const
{
return myBounds;
return m_bounds;
}
@ -149,15 +149,15 @@ FloatRect Shape::GetGlobalBounds() const
////////////////////////////////////////////////////////////
Shape::Shape() :
myTexture (NULL),
myTextureRect (),
myFillColor (255, 255, 255),
myOutlineColor (255, 255, 255),
myOutlineThickness(0),
myVertices (TrianglesFan),
myOutlineVertices (TrianglesStrip),
myInsideBounds (),
myBounds ()
m_texture (NULL),
m_textureRect (),
m_fillColor (255, 255, 255),
m_outlineColor (255, 255, 255),
m_outlineThickness(0),
m_vertices (TrianglesFan),
m_outlineVertices (TrianglesStrip),
m_insideBounds (),
m_bounds ()
{
}
@ -169,25 +169,25 @@ void Shape::Update()
unsigned int count = GetPointCount();
if (count < 3)
{
myVertices.Resize(0);
myOutlineVertices.Resize(0);
m_vertices.Resize(0);
m_outlineVertices.Resize(0);
return;
}
myVertices.Resize(count + 2); // + 2 for center and repeated first point
m_vertices.Resize(count + 2); // + 2 for center and repeated first point
// Position
for (unsigned int i = 0; i < count; ++i)
myVertices[i + 1].Position = GetPoint(i);
myVertices[count + 1].Position = myVertices[1].Position;
m_vertices[i + 1].Position = GetPoint(i);
m_vertices[count + 1].Position = m_vertices[1].Position;
// Update the bounding rectangle
myVertices[0] = myVertices[1]; // so that the result of GetBounds() is correct
myInsideBounds = myVertices.GetBounds();
m_vertices[0] = m_vertices[1]; // so that the result of GetBounds() is correct
m_insideBounds = m_vertices.GetBounds();
// Compute the center and make it the first vertex
myVertices[0].Position.x = myInsideBounds.Left + myInsideBounds.Width / 2;
myVertices[0].Position.y = myInsideBounds.Top + myInsideBounds.Height / 2;
m_vertices[0].Position.x = m_insideBounds.Left + m_insideBounds.Width / 2;
m_vertices[0].Position.y = m_insideBounds.Top + m_insideBounds.Height / 2;
// Color
UpdateFillColors();
@ -206,17 +206,17 @@ void Shape::Draw(RenderTarget& target, RenderStates states) const
states.Transform *= GetTransform();
// Render the inside
if (myFillColor.a > 0)
if (m_fillColor.a > 0)
{
states.Texture = myTexture;
target.Draw(myVertices, states);
states.Texture = m_texture;
target.Draw(m_vertices, states);
}
// Render the outline
if ((myOutlineColor.a > 0) && (myOutlineThickness > 0))
if ((m_outlineColor.a > 0) && (m_outlineThickness > 0))
{
states.Texture = NULL;
target.Draw(myOutlineVertices, states);
target.Draw(m_outlineVertices, states);
}
}
@ -224,20 +224,20 @@ void Shape::Draw(RenderTarget& target, RenderStates states) const
////////////////////////////////////////////////////////////
void Shape::UpdateFillColors()
{
for (unsigned int i = 0; i < myVertices.GetVertexCount(); ++i)
myVertices[i].Color = myFillColor;
for (unsigned int i = 0; i < m_vertices.GetVertexCount(); ++i)
m_vertices[i].Color = m_fillColor;
}
////////////////////////////////////////////////////////////
void Shape::UpdateTexCoords()
{
for (unsigned int i = 0; i < myVertices.GetVertexCount(); ++i)
for (unsigned int i = 0; i < m_vertices.GetVertexCount(); ++i)
{
float xratio = (myVertices[i].Position.x - myInsideBounds.Left) / myInsideBounds.Width;
float yratio = (myVertices[i].Position.y - myInsideBounds.Top) / myInsideBounds.Height;
myVertices[i].TexCoords.x = myTextureRect.Left + myTextureRect.Width * xratio;
myVertices[i].TexCoords.y = myTextureRect.Top + myTextureRect.Height * yratio;
float xratio = (m_vertices[i].Position.x - m_insideBounds.Left) / m_insideBounds.Width;
float yratio = (m_vertices[i].Position.y - m_insideBounds.Top) / m_insideBounds.Height;
m_vertices[i].TexCoords.x = m_textureRect.Left + m_textureRect.Width * xratio;
m_vertices[i].TexCoords.y = m_textureRect.Top + m_textureRect.Height * yratio;
}
}
@ -245,17 +245,17 @@ void Shape::UpdateTexCoords()
////////////////////////////////////////////////////////////
void Shape::UpdateOutline()
{
unsigned int count = myVertices.GetVertexCount() - 2;
myOutlineVertices.Resize((count + 1) * 2);
unsigned int count = m_vertices.GetVertexCount() - 2;
m_outlineVertices.Resize((count + 1) * 2);
for (unsigned int i = 0; i < count; ++i)
{
unsigned int index = i + 1;
// Get the two segments shared by the current point
Vector2f p0 = (i == 0) ? myVertices[count].Position : myVertices[index - 1].Position;
Vector2f p1 = myVertices[index].Position;
Vector2f p2 = myVertices[index + 1].Position;
Vector2f p0 = (i == 0) ? m_vertices[count].Position : m_vertices[index - 1].Position;
Vector2f p1 = m_vertices[index].Position;
Vector2f p2 = m_vertices[index + 1].Position;
// Compute their normal
Vector2f n1 = ComputeNormal(p0, p1);
@ -266,27 +266,27 @@ void Shape::UpdateOutline()
Vector2f normal = -(n1 + n2) / factor;
// Update the outline points
myOutlineVertices[i * 2 + 0].Position = p1;
myOutlineVertices[i * 2 + 1].Position = p1 + normal * myOutlineThickness;
m_outlineVertices[i * 2 + 0].Position = p1;
m_outlineVertices[i * 2 + 1].Position = p1 + normal * m_outlineThickness;
}
// Duplicate the first point at the end, to close the outline
myOutlineVertices[count * 2 + 0].Position = myOutlineVertices[0].Position;
myOutlineVertices[count * 2 + 1].Position = myOutlineVertices[1].Position;
m_outlineVertices[count * 2 + 0].Position = m_outlineVertices[0].Position;
m_outlineVertices[count * 2 + 1].Position = m_outlineVertices[1].Position;
// Update outline colors
UpdateOutlineColors();
// Update the shape's bounds
myBounds = myOutlineVertices.GetBounds();
m_bounds = m_outlineVertices.GetBounds();
}
////////////////////////////////////////////////////////////
void Shape::UpdateOutlineColors()
{
for (unsigned int i = 0; i < myOutlineVertices.GetVertexCount(); ++i)
myOutlineVertices[i].Color = myOutlineColor;
for (unsigned int i = 0; i < m_outlineVertices.GetVertexCount(); ++i)
m_outlineVertices[i].Color = m_outlineColor;
}
} // namespace sf

View file

@ -34,16 +34,16 @@ namespace sf
{
////////////////////////////////////////////////////////////
Sprite::Sprite() :
myTexture (NULL),
myTextureRect(0, 0, 0, 0)
m_texture (NULL),
m_textureRect(0, 0, 0, 0)
{
}
////////////////////////////////////////////////////////////
Sprite::Sprite(const Texture& texture) :
myTexture (NULL),
myTextureRect(0, 0, 0, 0)
m_texture (NULL),
m_textureRect(0, 0, 0, 0)
{
SetTexture(texture);
}
@ -51,8 +51,8 @@ myTextureRect(0, 0, 0, 0)
////////////////////////////////////////////////////////////
Sprite::Sprite(const Texture& texture, const IntRect& rectangle) :
myTexture (NULL),
myTextureRect(0, 0, 0, 0)
m_texture (NULL),
m_textureRect(0, 0, 0, 0)
{
SetTexture(texture);
SetTextureRect(rectangle);
@ -63,20 +63,20 @@ myTextureRect(0, 0, 0, 0)
void Sprite::SetTexture(const Texture& texture, bool resetRect)
{
// Recompute the texture area if requested, or if there was no valid texture before
if (resetRect || !myTexture)
if (resetRect || !m_texture)
SetTextureRect(IntRect(0, 0, texture.GetWidth(), texture.GetHeight()));
// Assign the new texture
myTexture = &texture;
m_texture = &texture;
}
////////////////////////////////////////////////////////////
void Sprite::SetTextureRect(const IntRect& rectangle)
{
if (rectangle != myTextureRect)
if (rectangle != m_textureRect)
{
myTextureRect = rectangle;
m_textureRect = rectangle;
UpdatePositions();
UpdateTexCoords();
}
@ -87,39 +87,39 @@ void Sprite::SetTextureRect(const IntRect& rectangle)
void Sprite::SetColor(const Color& color)
{
// Update the vertices' color
myVertices[0].Color = color;
myVertices[1].Color = color;
myVertices[2].Color = color;
myVertices[3].Color = color;
m_vertices[0].Color = color;
m_vertices[1].Color = color;
m_vertices[2].Color = color;
m_vertices[3].Color = color;
}
////////////////////////////////////////////////////////////
const Texture* Sprite::GetTexture() const
{
return myTexture;
return m_texture;
}
////////////////////////////////////////////////////////////
const IntRect& Sprite::GetTextureRect() const
{
return myTextureRect;
return m_textureRect;
}
////////////////////////////////////////////////////////////
const Color& Sprite::GetColor() const
{
return myVertices[0].Color;
return m_vertices[0].Color;
}
////////////////////////////////////////////////////////////
FloatRect Sprite::GetLocalBounds() const
{
float width = static_cast<float>(myTextureRect.Width);
float height = static_cast<float>(myTextureRect.Height);
float width = static_cast<float>(m_textureRect.Width);
float height = static_cast<float>(m_textureRect.Height);
return FloatRect(0.f, 0.f, width, height);
}
@ -135,11 +135,11 @@ FloatRect Sprite::GetGlobalBounds() const
////////////////////////////////////////////////////////////
void Sprite::Draw(RenderTarget& target, RenderStates states) const
{
if (myTexture)
if (m_texture)
{
states.Transform *= GetTransform();
states.Texture = myTexture;
target.Draw(myVertices, 4, Quads, states);
states.Texture = m_texture;
target.Draw(m_vertices, 4, Quads, states);
}
}
@ -147,28 +147,28 @@ void Sprite::Draw(RenderTarget& target, RenderStates states) const
////////////////////////////////////////////////////////////
void Sprite::UpdatePositions()
{
float width = static_cast<float>(myTextureRect.Width);
float height = static_cast<float>(myTextureRect.Height);
float width = static_cast<float>(m_textureRect.Width);
float height = static_cast<float>(m_textureRect.Height);
myVertices[0].Position = Vector2f(0, 0);
myVertices[1].Position = Vector2f(0, height);
myVertices[2].Position = Vector2f(width, height);
myVertices[3].Position = Vector2f(width, 0);
m_vertices[0].Position = Vector2f(0, 0);
m_vertices[1].Position = Vector2f(0, height);
m_vertices[2].Position = Vector2f(width, height);
m_vertices[3].Position = Vector2f(width, 0);
}
////////////////////////////////////////////////////////////
void Sprite::UpdateTexCoords()
{
float left = static_cast<float>(myTextureRect.Left);
float right = left + myTextureRect.Width;
float top = static_cast<float>(myTextureRect.Top);
float bottom = top + myTextureRect.Height;
float left = static_cast<float>(m_textureRect.Left);
float right = left + m_textureRect.Width;
float top = static_cast<float>(m_textureRect.Top);
float bottom = top + m_textureRect.Height;
myVertices[0].TexCoords = Vector2f(left, top);
myVertices[1].TexCoords = Vector2f(left, bottom);
myVertices[2].TexCoords = Vector2f(right, bottom);
myVertices[3].TexCoords = Vector2f(right, top);
m_vertices[0].TexCoords = Vector2f(left, top);
m_vertices[1].TexCoords = Vector2f(left, bottom);
m_vertices[2].TexCoords = Vector2f(right, bottom);
m_vertices[3].TexCoords = Vector2f(right, top);
}
} // namespace sf

View file

@ -35,13 +35,13 @@ namespace sf
{
////////////////////////////////////////////////////////////
Text::Text() :
myString (),
myFont (&Font::GetDefaultFont()),
myCharacterSize(30),
myStyle (Regular),
myColor (255, 255, 255),
myVertices (Quads),
myBounds ()
m_string (),
m_font (&Font::GetDefaultFont()),
m_characterSize(30),
m_style (Regular),
m_color (255, 255, 255),
m_vertices (Quads),
m_bounds ()
{
}
@ -49,13 +49,13 @@ myBounds ()
////////////////////////////////////////////////////////////
Text::Text(const String& string, const Font& font, unsigned int characterSize) :
myString (string),
myFont (&font),
myCharacterSize(characterSize),
myStyle (Regular),
myColor (255, 255, 255),
myVertices (Quads),
myBounds ()
m_string (string),
m_font (&font),
m_characterSize(characterSize),
m_style (Regular),
m_color (255, 255, 255),
m_vertices (Quads),
m_bounds ()
{
UpdateGeometry();
}
@ -64,7 +64,7 @@ myBounds ()
////////////////////////////////////////////////////////////
void Text::SetString(const String& string)
{
myString = string;
m_string = string;
UpdateGeometry();
}
@ -72,9 +72,9 @@ void Text::SetString(const String& string)
////////////////////////////////////////////////////////////
void Text::SetFont(const Font& font)
{
if (myFont != &font)
if (m_font != &font)
{
myFont = &font;
m_font = &font;
UpdateGeometry();
}
}
@ -83,9 +83,9 @@ void Text::SetFont(const Font& font)
////////////////////////////////////////////////////////////
void Text::SetCharacterSize(unsigned int size)
{
if (myCharacterSize != size)
if (m_characterSize != size)
{
myCharacterSize = size;
m_characterSize = size;
UpdateGeometry();
}
}
@ -94,9 +94,9 @@ void Text::SetCharacterSize(unsigned int size)
////////////////////////////////////////////////////////////
void Text::SetStyle(Uint32 style)
{
if (myStyle != style)
if (m_style != style)
{
myStyle = style;
m_style = style;
UpdateGeometry();
}
}
@ -105,11 +105,11 @@ void Text::SetStyle(Uint32 style)
////////////////////////////////////////////////////////////
void Text::SetColor(const Color& color)
{
if (color != myColor)
if (color != m_color)
{
myColor = color;
for (unsigned int i = 0; i < myVertices.GetVertexCount(); ++i)
myVertices[i].Color = myColor;
m_color = color;
for (unsigned int i = 0; i < m_vertices.GetVertexCount(); ++i)
m_vertices[i].Color = m_color;
}
}
@ -117,62 +117,62 @@ void Text::SetColor(const Color& color)
////////////////////////////////////////////////////////////
const String& Text::GetString() const
{
return myString;
return m_string;
}
////////////////////////////////////////////////////////////
const Font& Text::GetFont() const
{
assert(myFont != NULL); // can never be NULL, always &Font::GetDefaultFont() by default
return *myFont;
assert(m_font != NULL); // can never be NULL, always &Font::GetDefaultFont() by default
return *m_font;
}
////////////////////////////////////////////////////////////
unsigned int Text::GetCharacterSize() const
{
return myCharacterSize;
return m_characterSize;
}
////////////////////////////////////////////////////////////
Uint32 Text::GetStyle() const
{
return myStyle;
return m_style;
}
////////////////////////////////////////////////////////////
const Color& Text::GetColor() const
{
return myColor;
return m_color;
}
////////////////////////////////////////////////////////////
Vector2f Text::FindCharacterPos(std::size_t index) const
{
assert(myFont != NULL);
assert(m_font != NULL);
// Adjust the index if it's out of range
if (index > myString.GetSize())
index = myString.GetSize();
if (index > m_string.GetSize())
index = m_string.GetSize();
// Precompute the variables needed by the algorithm
bool bold = (myStyle & Bold) != 0;
float hspace = static_cast<float>(myFont->GetGlyph(L' ', myCharacterSize, bold).Advance);
float vspace = static_cast<float>(myFont->GetLineSpacing(myCharacterSize));
bool bold = (m_style & Bold) != 0;
float hspace = static_cast<float>(m_font->GetGlyph(L' ', m_characterSize, bold).Advance);
float vspace = static_cast<float>(m_font->GetLineSpacing(m_characterSize));
// Compute the position
Vector2f position;
Uint32 prevChar = 0;
for (std::size_t i = 0; i < index; ++i)
{
Uint32 curChar = myString[i];
Uint32 curChar = m_string[i];
// Apply the kerning offset
position.x += static_cast<float>(myFont->GetKerning(prevChar, curChar, myCharacterSize));
position.x += static_cast<float>(m_font->GetKerning(prevChar, curChar, m_characterSize));
prevChar = curChar;
// Handle special characters
@ -185,7 +185,7 @@ Vector2f Text::FindCharacterPos(std::size_t index) const
}
// For regular characters, add the advance offset of the glyph
position.x += static_cast<float>(myFont->GetGlyph(curChar, myCharacterSize, bold).Advance);
position.x += static_cast<float>(m_font->GetGlyph(curChar, m_characterSize, bold).Advance);
}
// Transform the position to global coordinates
@ -198,7 +198,7 @@ Vector2f Text::FindCharacterPos(std::size_t index) const
////////////////////////////////////////////////////////////
FloatRect Text::GetLocalBounds() const
{
return myBounds;
return m_bounds;
}
@ -212,48 +212,48 @@ FloatRect Text::GetGlobalBounds() const
////////////////////////////////////////////////////////////
void Text::Draw(RenderTarget& target, RenderStates states) const
{
assert(myFont != NULL);
assert(m_font != NULL);
states.Transform *= GetTransform();
states.BlendMode = BlendAlpha; // alpha blending is mandatory for proper text rendering
states.Texture = &myFont->GetTexture(myCharacterSize);
target.Draw(myVertices, states);
states.Texture = &m_font->GetTexture(m_characterSize);
target.Draw(m_vertices, states);
}
////////////////////////////////////////////////////////////
void Text::UpdateGeometry()
{
assert(myFont != NULL);
assert(m_font != NULL);
// Clear the previous geometry
myVertices.Clear();
m_vertices.Clear();
// No text: nothing to draw
if (myString.IsEmpty())
if (m_string.IsEmpty())
return;
// Compute values related to the text style
bool bold = (myStyle & Bold) != 0;
bool underlined = (myStyle & Underlined) != 0;
float italic = (myStyle & Italic) ? 0.208f : 0.f; // 12 degrees
float underlineOffset = myCharacterSize * 0.1f;
float underlineThickness = myCharacterSize * (bold ? 0.1f : 0.07f);
bool bold = (m_style & Bold) != 0;
bool underlined = (m_style & Underlined) != 0;
float italic = (m_style & Italic) ? 0.208f : 0.f; // 12 degrees
float underlineOffset = m_characterSize * 0.1f;
float underlineThickness = m_characterSize * (bold ? 0.1f : 0.07f);
// Precompute the variables needed by the algorithm
float hspace = static_cast<float>(myFont->GetGlyph(L' ', myCharacterSize, bold).Advance);
float vspace = static_cast<float>(myFont->GetLineSpacing(myCharacterSize));
float hspace = static_cast<float>(m_font->GetGlyph(L' ', m_characterSize, bold).Advance);
float vspace = static_cast<float>(m_font->GetLineSpacing(m_characterSize));
float x = 0.f;
float y = static_cast<float>(myCharacterSize);
float y = static_cast<float>(m_characterSize);
// Create one quad for each character
Uint32 prevChar = 0;
for (std::size_t i = 0; i < myString.GetSize(); ++i)
for (std::size_t i = 0; i < m_string.GetSize(); ++i)
{
Uint32 curChar = myString[i];
Uint32 curChar = m_string[i];
// Apply the kerning offset
x += static_cast<float>(myFont->GetKerning(prevChar, curChar, myCharacterSize));
x += static_cast<float>(m_font->GetKerning(prevChar, curChar, m_characterSize));
prevChar = curChar;
// If we're using the underlined style and there's a new line, draw a line
@ -262,10 +262,10 @@ void Text::UpdateGeometry()
float top = y + underlineOffset;
float bottom = top + underlineThickness;
myVertices.Append(Vertex(Vector2f(0, top), myColor, Vector2f(1, 1)));
myVertices.Append(Vertex(Vector2f(x, top), myColor, Vector2f(1, 1)));
myVertices.Append(Vertex(Vector2f(x, bottom), myColor, Vector2f(1, 1)));
myVertices.Append(Vertex(Vector2f(0, bottom), myColor, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(0, top), m_color, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(x, bottom), m_color, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
}
// Handle special characters
@ -278,7 +278,7 @@ void Text::UpdateGeometry()
}
// Extract the current glyph's description
const Glyph& glyph = myFont->GetGlyph(curChar, myCharacterSize, bold);
const Glyph& glyph = m_font->GetGlyph(curChar, m_characterSize, bold);
int left = glyph.Bounds.Left;
int top = glyph.Bounds.Top;
@ -291,10 +291,10 @@ void Text::UpdateGeometry()
float v2 = static_cast<float>(glyph.TextureRect.Top + glyph.TextureRect.Height);
// Add a quad for the current character
myVertices.Append(Vertex(Vector2f(x + left - italic * top, y + top), myColor, Vector2f(u1, v1)));
myVertices.Append(Vertex(Vector2f(x + right - italic * top, y + top), myColor, Vector2f(u2, v1)));
myVertices.Append(Vertex(Vector2f(x + right - italic * bottom, y + bottom), myColor, Vector2f(u2, v2)));
myVertices.Append(Vertex(Vector2f(x + left - italic * bottom, y + bottom), myColor, Vector2f(u1, v2)));
m_vertices.Append(Vertex(Vector2f(x + left - italic * top, y + top), m_color, Vector2f(u1, v1)));
m_vertices.Append(Vertex(Vector2f(x + right - italic * top, y + top), m_color, Vector2f(u2, v1)));
m_vertices.Append(Vertex(Vector2f(x + right - italic * bottom, y + bottom), m_color, Vector2f(u2, v2)));
m_vertices.Append(Vertex(Vector2f(x + left - italic * bottom, y + bottom), m_color, Vector2f(u1, v2)));
// Advance to the next character
x += glyph.Advance;
@ -306,14 +306,14 @@ void Text::UpdateGeometry()
float top = y + underlineOffset;
float bottom = top + underlineThickness;
myVertices.Append(Vertex(Vector2f(0, top), myColor, Vector2f(1, 1)));
myVertices.Append(Vertex(Vector2f(x, top), myColor, Vector2f(1, 1)));
myVertices.Append(Vertex(Vector2f(x, bottom), myColor, Vector2f(1, 1)));
myVertices.Append(Vertex(Vector2f(0, bottom), myColor, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(0, top), m_color, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(x, bottom), m_color, Vector2f(1, 1)));
m_vertices.Append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
}
// Recompute the bounding rectangle
myBounds = myVertices.GetBounds();
m_bounds = m_vertices.GetBounds();
}
} // namespace sf

View file

@ -56,15 +56,15 @@ namespace sf
{
////////////////////////////////////////////////////////////
Texture::Texture() :
myWidth (0),
myHeight (0),
myTextureWidth (0),
myTextureHeight(0),
myTexture (0),
myIsSmooth (false),
myIsRepeated (false),
myPixelsFlipped(false),
myCacheId (GetUniqueId())
m_width (0),
m_height (0),
m_textureWidth (0),
m_textureHeight(0),
m_texture (0),
m_isSmooth (false),
m_isRepeated (false),
m_pixelsFlipped(false),
m_cacheId (GetUniqueId())
{
}
@ -72,17 +72,17 @@ myCacheId (GetUniqueId())
////////////////////////////////////////////////////////////
Texture::Texture(const Texture& copy) :
myWidth (0),
myHeight (0),
myTextureWidth (0),
myTextureHeight(0),
myTexture (0),
myIsSmooth (copy.myIsSmooth),
myIsRepeated (copy.myIsRepeated),
myPixelsFlipped(false),
myCacheId (GetUniqueId())
m_width (0),
m_height (0),
m_textureWidth (0),
m_textureHeight(0),
m_texture (0),
m_isSmooth (copy.m_isSmooth),
m_isRepeated (copy.m_isRepeated),
m_pixelsFlipped(false),
m_cacheId (GetUniqueId())
{
if (copy.myTexture)
if (copy.m_texture)
LoadFromImage(copy.CopyToImage());
}
@ -91,11 +91,11 @@ myCacheId (GetUniqueId())
Texture::~Texture()
{
// Destroy the OpenGL texture
if (myTexture)
if (m_texture)
{
EnsureGlContext();
GLuint Texture = static_cast<GLuint>(myTexture);
GLuint Texture = static_cast<GLuint>(m_texture);
GLCheck(glDeleteTextures(1, &Texture));
}
}
@ -127,33 +127,33 @@ bool Texture::Create(unsigned int width, unsigned int height)
}
// All the validity checks passed, we can store the new texture settings
myWidth = width;
myHeight = height;
myTextureWidth = textureWidth;
myTextureHeight = textureHeight;
myPixelsFlipped = false;
m_width = width;
m_height = height;
m_textureWidth = textureWidth;
m_textureHeight = textureHeight;
m_pixelsFlipped = false;
EnsureGlContext();
// Create the OpenGL texture if it doesn't exist yet
if (!myTexture)
if (!m_texture)
{
GLuint texture;
GLCheck(glGenTextures(1, &texture));
myTexture = static_cast<unsigned int>(texture);
m_texture = static_cast<unsigned int>(texture);
}
// Make sure that the current texture binding will be preserved
priv::TextureSaver save;
// Initialize the texture
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTextureWidth, myTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, myIsRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, myIsRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
myCacheId = GetUniqueId();
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_textureWidth, m_textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
m_cacheId = GetUniqueId();
return true;
}
@ -224,10 +224,10 @@ bool Texture::LoadFromImage(const Image& image, const IntRect& area)
// Copy the pixels to the texture, row by row
const Uint8* pixels = image.GetPixelsPtr() + 4 * (rectangle.Left + (width * rectangle.Top));
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
for (int i = 0; i < rectangle.Height; ++i)
{
GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, myWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, m_width, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
pixels += 4 * width;
}
@ -244,14 +244,14 @@ bool Texture::LoadFromImage(const Image& image, const IntRect& area)
////////////////////////////////////////////////////////////
unsigned int Texture::GetWidth() const
{
return myWidth;
return m_width;
}
////////////////////////////////////////////////////////////
unsigned int Texture::GetHeight() const
{
return myHeight;
return m_height;
}
@ -259,7 +259,7 @@ unsigned int Texture::GetHeight() const
Image Texture::CopyToImage() const
{
// Easy case: empty texture
if (!myTexture)
if (!m_texture)
return Image();
EnsureGlContext();
@ -268,12 +268,12 @@ Image Texture::CopyToImage() const
priv::TextureSaver save;
// Create an array of pixels
std::vector<Uint8> pixels(myWidth * myHeight * 4);
std::vector<Uint8> pixels(m_width * m_height * 4);
if ((myWidth == myTextureWidth) && (myHeight == myTextureHeight) && !myPixelsFlipped)
if ((m_width == m_textureWidth) && (m_height == m_textureHeight) && !m_pixelsFlipped)
{
// Texture is not padded nor flipped, we can use a direct copy
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]));
}
else
@ -281,24 +281,24 @@ Image Texture::CopyToImage() const
// Texture is either padded or flipped, we have to use a slower algorithm
// All the pixels will first be copied to a temporary array
std::vector<Uint8> allPixels(myTextureWidth * myTextureHeight * 4);
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
std::vector<Uint8> allPixels(m_textureWidth * m_textureHeight * 4);
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &allPixels[0]));
// Then we copy the useful pixels from the temporary array to the final one
const Uint8* src = &allPixels[0];
Uint8* dst = &pixels[0];
int srcPitch = myTextureWidth * 4;
int dstPitch = myWidth * 4;
int srcPitch = m_textureWidth * 4;
int dstPitch = m_width * 4;
// Handle the case where source pixels are flipped vertically
if (myPixelsFlipped)
if (m_pixelsFlipped)
{
src += srcPitch * (myHeight - 1);
src += srcPitch * (m_height - 1);
srcPitch = -srcPitch;
}
for (unsigned int i = 0; i < myHeight; ++i)
for (unsigned int i = 0; i < m_height; ++i)
{
std::memcpy(dst, src, dstPitch);
src += srcPitch;
@ -308,7 +308,7 @@ Image Texture::CopyToImage() const
// Create the image
Image image;
image.Create(myWidth, myHeight, &pixels[0]);
image.Create(m_width, m_height, &pixels[0]);
return image;
}
@ -318,17 +318,17 @@ Image Texture::CopyToImage() const
void Texture::Update(const Uint8* pixels)
{
// Update the whole texture
Update(pixels, myWidth, myHeight, 0, 0);
Update(pixels, m_width, m_height, 0, 0);
}
////////////////////////////////////////////////////////////
void Texture::Update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
{
assert(x + width <= myWidth);
assert(y + height <= myHeight);
assert(x + width <= m_width);
assert(y + height <= m_height);
if (pixels && myTexture)
if (pixels && m_texture)
{
EnsureGlContext();
@ -336,10 +336,10 @@ void Texture::Update(const Uint8* pixels, unsigned int width, unsigned int heigh
priv::TextureSaver save;
// Copy pixels from the given array to the texture
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
myPixelsFlipped = false;
myCacheId = GetUniqueId();
m_pixelsFlipped = false;
m_cacheId = GetUniqueId();
}
}
@ -369,19 +369,19 @@ void Texture::Update(const Window& window)
////////////////////////////////////////////////////////////
void Texture::Update(const Window& window, unsigned int x, unsigned int y)
{
assert(x + window.GetSize().x <= myWidth);
assert(y + window.GetSize().y <= myHeight);
assert(x + window.GetSize().x <= m_width);
assert(y + window.GetSize().y <= m_height);
if (myTexture && window.SetActive(true))
if (m_texture && window.SetActive(true))
{
// Make sure that the current texture binding will be preserved
priv::TextureSaver save;
// Copy pixels from the back-buffer to the texture
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.GetSize().x, window.GetSize().y));
myPixelsFlipped = true;
myCacheId = GetUniqueId();
m_pixelsFlipped = true;
m_cacheId = GetUniqueId();
}
}
@ -390,10 +390,10 @@ void Texture::Update(const Window& window, unsigned int x, unsigned int y)
void Texture::Bind(CoordinateType coordinateType) const
{
// Bind the texture
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
// Check if we need to define a special texture matrix
if ((coordinateType == Pixels) || myPixelsFlipped)
if ((coordinateType == Pixels) || m_pixelsFlipped)
{
GLfloat matrix[16] = {1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
@ -404,15 +404,15 @@ void Texture::Bind(CoordinateType coordinateType) const
// setup scale factors that convert the range [0 .. size] to [0 .. 1]
if (coordinateType == Pixels)
{
matrix[0] = 1.f / myTextureWidth;
matrix[5] = 1.f / myTextureHeight;
matrix[0] = 1.f / m_textureWidth;
matrix[5] = 1.f / m_textureHeight;
}
// If pixels are flipped we must invert the Y axis
if (myPixelsFlipped)
if (m_pixelsFlipped)
{
matrix[5] = -matrix[5];
matrix[13] = static_cast<float>(myHeight / myTextureHeight);
matrix[13] = static_cast<float>(m_height / m_textureHeight);
}
// Load the matrix
@ -428,20 +428,20 @@ void Texture::Bind(CoordinateType coordinateType) const
////////////////////////////////////////////////////////////
void Texture::SetSmooth(bool smooth)
{
if (smooth != myIsSmooth)
if (smooth != m_isSmooth)
{
myIsSmooth = smooth;
m_isSmooth = smooth;
if (myTexture)
if (m_texture)
{
EnsureGlContext();
// Make sure that the current texture binding will be preserved
priv::TextureSaver save;
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
}
}
}
@ -450,27 +450,27 @@ void Texture::SetSmooth(bool smooth)
////////////////////////////////////////////////////////////
bool Texture::IsSmooth() const
{
return myIsSmooth;
return m_isSmooth;
}
////////////////////////////////////////////////////////////
void Texture::SetRepeated(bool repeated)
{
if (repeated != myIsRepeated)
if (repeated != m_isRepeated)
{
myIsRepeated = repeated;
m_isRepeated = repeated;
if (myTexture)
if (m_texture)
{
EnsureGlContext();
// Make sure that the current texture binding will be preserved
priv::TextureSaver save;
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, myIsRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, myIsRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : GL_CLAMP_TO_EDGE));
}
}
}
@ -479,7 +479,7 @@ void Texture::SetRepeated(bool repeated)
////////////////////////////////////////////////////////////
bool Texture::IsRepeated() const
{
return myIsRepeated;
return m_isRepeated;
}
@ -500,15 +500,15 @@ Texture& Texture::operator =(const Texture& right)
{
Texture temp(right);
std::swap(myWidth, temp.myWidth);
std::swap(myHeight, temp.myHeight);
std::swap(myTextureWidth, temp.myTextureWidth);
std::swap(myTextureHeight, temp.myTextureHeight);
std::swap(myTexture, temp.myTexture);
std::swap(myIsSmooth, temp.myIsSmooth);
std::swap(myIsRepeated, temp.myIsRepeated);
std::swap(myPixelsFlipped, temp.myPixelsFlipped);
myCacheId = GetUniqueId();
std::swap(m_width, temp.m_width);
std::swap(m_height, temp.m_height);
std::swap(m_textureWidth, temp.m_textureWidth);
std::swap(m_textureHeight, temp.m_textureHeight);
std::swap(m_texture, temp.m_texture);
std::swap(m_isSmooth, temp.m_isSmooth);
std::swap(m_isRepeated, temp.m_isRepeated);
std::swap(m_pixelsFlipped, temp.m_pixelsFlipped);
m_cacheId = GetUniqueId();
return *this;
}

View file

@ -35,14 +35,14 @@ namespace priv
////////////////////////////////////////////////////////////
TextureSaver::TextureSaver()
{
GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &myTextureBinding));
GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &m_textureBinding));
}
////////////////////////////////////////////////////////////
TextureSaver::~TextureSaver()
{
GLCheck(glBindTexture(GL_TEXTURE_2D, myTextureBinding));
GLCheck(glBindTexture(GL_TEXTURE_2D, m_textureBinding));
}
} // namespace priv

View file

@ -64,7 +64,7 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
GLint myTextureBinding; ///< Texture binding to restore
GLint m_textureBinding; ///< Texture binding to restore
};
} // namespace priv

View file

@ -39,10 +39,10 @@ const Transform Transform::Identity;
Transform::Transform()
{
// Identity matrix
myMatrix[0] = 1.f; myMatrix[4] = 0.f; myMatrix[8] = 0.f; myMatrix[12] = 0.f;
myMatrix[1] = 0.f; myMatrix[5] = 1.f; myMatrix[9] = 0.f; myMatrix[13] = 0.f;
myMatrix[2] = 0.f; myMatrix[6] = 0.f; myMatrix[10] = 1.f; myMatrix[14] = 0.f;
myMatrix[3] = 0.f; myMatrix[7] = 0.f; myMatrix[11] = 0.f; myMatrix[15] = 1.f;
m_matrix[0] = 1.f; m_matrix[4] = 0.f; m_matrix[8] = 0.f; m_matrix[12] = 0.f;
m_matrix[1] = 0.f; m_matrix[5] = 1.f; m_matrix[9] = 0.f; m_matrix[13] = 0.f;
m_matrix[2] = 0.f; m_matrix[6] = 0.f; m_matrix[10] = 1.f; m_matrix[14] = 0.f;
m_matrix[3] = 0.f; m_matrix[7] = 0.f; m_matrix[11] = 0.f; m_matrix[15] = 1.f;
}
@ -51,17 +51,17 @@ Transform::Transform(float a00, float a01, float a02,
float a10, float a11, float a12,
float a20, float a21, float a22)
{
myMatrix[0] = a00; myMatrix[4] = a01; myMatrix[8] = 0.f; myMatrix[12] = a02;
myMatrix[1] = a10; myMatrix[5] = a11; myMatrix[9] = 0.f; myMatrix[13] = a12;
myMatrix[2] = 0.f; myMatrix[6] = 0.f; myMatrix[10] = 1.f; myMatrix[14] = 0.f;
myMatrix[3] = a20; myMatrix[7] = a21; myMatrix[11] = 0.f; myMatrix[15] = a22;
m_matrix[0] = a00; m_matrix[4] = a01; m_matrix[8] = 0.f; m_matrix[12] = a02;
m_matrix[1] = a10; m_matrix[5] = a11; m_matrix[9] = 0.f; m_matrix[13] = a12;
m_matrix[2] = 0.f; m_matrix[6] = 0.f; m_matrix[10] = 1.f; m_matrix[14] = 0.f;
m_matrix[3] = a20; m_matrix[7] = a21; m_matrix[11] = 0.f; m_matrix[15] = a22;
}
////////////////////////////////////////////////////////////
const float* Transform::GetMatrix() const
{
return myMatrix;
return m_matrix;
}
@ -69,23 +69,23 @@ const float* Transform::GetMatrix() const
Transform Transform::GetInverse() const
{
// Compute the determinant
float det = myMatrix[0] * (myMatrix[15] * myMatrix[5] - myMatrix[7] * myMatrix[13]) -
myMatrix[1] * (myMatrix[15] * myMatrix[4] - myMatrix[7] * myMatrix[12]) +
myMatrix[3] * (myMatrix[13] * myMatrix[4] - myMatrix[5] * myMatrix[12]);
float det = m_matrix[0] * (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) -
m_matrix[1] * (m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) +
m_matrix[3] * (m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]);
// Compute the inverse if the determinant is not zero
// (don't use an epsilon because the determinant may *really* be tiny)
if (det != 0.f)
{
return Transform( (myMatrix[15] * myMatrix[5] - myMatrix[7] * myMatrix[13]) / det,
-(myMatrix[15] * myMatrix[4] - myMatrix[7] * myMatrix[12]) / det,
(myMatrix[13] * myMatrix[4] - myMatrix[5] * myMatrix[12]) / det,
-(myMatrix[15] * myMatrix[1] - myMatrix[3] * myMatrix[13]) / det,
(myMatrix[15] * myMatrix[0] - myMatrix[3] * myMatrix[12]) / det,
-(myMatrix[13] * myMatrix[0] - myMatrix[1] * myMatrix[12]) / det,
(myMatrix[7] * myMatrix[1] - myMatrix[3] * myMatrix[5]) / det,
-(myMatrix[7] * myMatrix[0] - myMatrix[3] * myMatrix[4]) / det,
(myMatrix[5] * myMatrix[0] - myMatrix[1] * myMatrix[4]) / det);
return Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
-(m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
(m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]) / det,
-(m_matrix[15] * m_matrix[1] - m_matrix[3] * m_matrix[13]) / det,
(m_matrix[15] * m_matrix[0] - m_matrix[3] * m_matrix[12]) / det,
-(m_matrix[13] * m_matrix[0] - m_matrix[1] * m_matrix[12]) / det,
(m_matrix[7] * m_matrix[1] - m_matrix[3] * m_matrix[5]) / det,
-(m_matrix[7] * m_matrix[0] - m_matrix[3] * m_matrix[4]) / det,
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det);
}
else
{
@ -97,8 +97,8 @@ Transform Transform::GetInverse() const
////////////////////////////////////////////////////////////
Vector2f Transform::TransformPoint(float x, float y) const
{
return Vector2f(myMatrix[0] * x + myMatrix[4] * y + myMatrix[12],
myMatrix[1] * x + myMatrix[5] * y + myMatrix[13]);
return Vector2f(m_matrix[0] * x + m_matrix[4] * y + m_matrix[12],
m_matrix[1] * x + m_matrix[5] * y + m_matrix[13]);
}
@ -141,8 +141,8 @@ FloatRect Transform::TransformRect(const FloatRect& rectangle) const
////////////////////////////////////////////////////////////
Transform& Transform::Combine(const Transform& transform)
{
const float* a = myMatrix;
const float* b = transform.myMatrix;
const float* a = m_matrix;
const float* b = transform.m_matrix;
*this = Transform(a[0] * b[0] + a[4] * b[1] + a[12] * b[3],
a[0] * b[4] + a[4] * b[5] + a[12] * b[7],

View file

@ -33,14 +33,14 @@ namespace sf
{
////////////////////////////////////////////////////////////
Transformable::Transformable() :
myOrigin (0, 0),
myPosition (0, 0),
myRotation (0),
myScale (1, 1),
myTransform (),
myTransformNeedUpdate (true),
myInverseTransform (),
myInverseTransformNeedUpdate(true)
m_origin (0, 0),
m_position (0, 0),
m_rotation (0),
m_scale (1, 1),
m_transform (),
m_transformNeedUpdate (true),
m_inverseTransform (),
m_inverseTransformNeedUpdate(true)
{
}
@ -54,10 +54,10 @@ Transformable::~Transformable()
////////////////////////////////////////////////////////////
void Transformable::SetPosition(float x, float y)
{
myPosition.x = x;
myPosition.y = y;
myTransformNeedUpdate = true;
myInverseTransformNeedUpdate = true;
m_position.x = x;
m_position.y = y;
m_transformNeedUpdate = true;
m_inverseTransformNeedUpdate = true;
}
@ -71,19 +71,19 @@ void Transformable::SetPosition(const Vector2f& position)
////////////////////////////////////////////////////////////
void Transformable::SetRotation(float angle)
{
myRotation = angle;
myTransformNeedUpdate = true;
myInverseTransformNeedUpdate = true;
m_rotation = angle;
m_transformNeedUpdate = true;
m_inverseTransformNeedUpdate = true;
}
////////////////////////////////////////////////////////////
void Transformable::SetScale(float factorX, float factorY)
{
myScale.x = factorX;
myScale.y = factorY;
myTransformNeedUpdate = true;
myInverseTransformNeedUpdate = true;
m_scale.x = factorX;
m_scale.y = factorY;
m_transformNeedUpdate = true;
m_inverseTransformNeedUpdate = true;
}
@ -97,10 +97,10 @@ void Transformable::SetScale(const Vector2f& factors)
////////////////////////////////////////////////////////////
void Transformable::SetOrigin(float x, float y)
{
myOrigin.x = x;
myOrigin.y = y;
myTransformNeedUpdate = true;
myInverseTransformNeedUpdate = true;
m_origin.x = x;
m_origin.y = y;
m_transformNeedUpdate = true;
m_inverseTransformNeedUpdate = true;
}
@ -114,63 +114,63 @@ void Transformable::SetOrigin(const Vector2f& origin)
////////////////////////////////////////////////////////////
const Vector2f& Transformable::GetPosition() const
{
return myPosition;
return m_position;
}
////////////////////////////////////////////////////////////
float Transformable::GetRotation() const
{
return myRotation;
return m_rotation;
}
////////////////////////////////////////////////////////////
const Vector2f& Transformable::GetScale() const
{
return myScale;
return m_scale;
}
////////////////////////////////////////////////////////////
const Vector2f& Transformable::GetOrigin() const
{
return myOrigin;
return m_origin;
}
////////////////////////////////////////////////////////////
void Transformable::Move(float offsetX, float offsetY)
{
SetPosition(myPosition.x + offsetX, myPosition.y + offsetY);
SetPosition(m_position.x + offsetX, m_position.y + offsetY);
}
////////////////////////////////////////////////////////////
void Transformable::Move(const Vector2f& offset)
{
SetPosition(myPosition.x + offset.x, myPosition.y + offset.y);
SetPosition(m_position.x + offset.x, m_position.y + offset.y);
}
////////////////////////////////////////////////////////////
void Transformable::Rotate(float angle)
{
SetRotation(myRotation + angle);
SetRotation(m_rotation + angle);
}
////////////////////////////////////////////////////////////
void Transformable::Scale(float factorX, float factorY)
{
SetScale(myScale.x * factorX, myScale.y * factorY);
SetScale(m_scale.x * factorX, m_scale.y * factorY);
}
////////////////////////////////////////////////////////////
void Transformable::Scale(const Vector2f& factor)
{
SetScale(myScale.x * factor.x, myScale.y * factor.y);
SetScale(m_scale.x * factor.x, m_scale.y * factor.y);
}
@ -178,25 +178,25 @@ void Transformable::Scale(const Vector2f& factor)
const Transform& Transformable::GetTransform() const
{
// Recompute the combined transform if needed
if (myTransformNeedUpdate)
if (m_transformNeedUpdate)
{
float angle = -myRotation * 3.141592654f / 180.f;
float angle = -m_rotation * 3.141592654f / 180.f;
float cosine = static_cast<float>(std::cos(angle));
float sine = static_cast<float>(std::sin(angle));
float sxc = myScale.x * cosine;
float syc = myScale.y * cosine;
float sxs = myScale.x * sine;
float sys = myScale.y * sine;
float tx = -myOrigin.x * sxc - myOrigin.y * sys + myPosition.x;
float ty = myOrigin.x * sxs - myOrigin.y * syc + myPosition.y;
float sxc = m_scale.x * cosine;
float syc = m_scale.y * cosine;
float sxs = m_scale.x * sine;
float sys = m_scale.y * sine;
float tx = -m_origin.x * sxc - m_origin.y * sys + m_position.x;
float ty = m_origin.x * sxs - m_origin.y * syc + m_position.y;
myTransform = Transform( sxc, sys, tx,
m_transform = Transform( sxc, sys, tx,
-sxs, syc, ty,
0.f, 0.f, 1.f);
myTransformNeedUpdate = false;
m_transformNeedUpdate = false;
}
return myTransform;
return m_transform;
}
@ -204,13 +204,13 @@ const Transform& Transformable::GetTransform() const
const Transform& Transformable::GetInverseTransform() const
{
// Recompute the inverse transform if needed
if (myInverseTransformNeedUpdate)
if (m_inverseTransformNeedUpdate)
{
myInverseTransform = GetTransform().GetInverse();
myInverseTransformNeedUpdate = false;
m_inverseTransform = GetTransform().GetInverse();
m_inverseTransformNeedUpdate = false;
}
return myInverseTransform;
return m_inverseTransform;
}
} // namespace sf

View file

@ -33,16 +33,16 @@ namespace sf
{
////////////////////////////////////////////////////////////
VertexArray::VertexArray() :
myVertices (),
myPrimitiveType(Points)
m_vertices (),
m_primitiveType(Points)
{
}
////////////////////////////////////////////////////////////
VertexArray::VertexArray(PrimitiveType type, unsigned int vertexCount) :
myVertices (vertexCount),
myPrimitiveType(type)
m_vertices (vertexCount),
m_primitiveType(type)
{
}
@ -50,72 +50,72 @@ myPrimitiveType(type)
////////////////////////////////////////////////////////////
unsigned int VertexArray::GetVertexCount() const
{
return static_cast<unsigned int>(myVertices.size());
return static_cast<unsigned int>(m_vertices.size());
}
////////////////////////////////////////////////////////////
Vertex& VertexArray::operator [](unsigned int index)
{
return myVertices[index];
return m_vertices[index];
}
////////////////////////////////////////////////////////////
const Vertex& VertexArray::operator [](unsigned int index) const
{
return myVertices[index];
return m_vertices[index];
}
////////////////////////////////////////////////////////////
void VertexArray::Clear()
{
myVertices.clear();
m_vertices.clear();
}
////////////////////////////////////////////////////////////
void VertexArray::Resize(unsigned int vertexCount)
{
myVertices.resize(vertexCount);
m_vertices.resize(vertexCount);
}
////////////////////////////////////////////////////////////
void VertexArray::Append(const Vertex& vertex)
{
myVertices.push_back(vertex);
m_vertices.push_back(vertex);
}
////////////////////////////////////////////////////////////
void VertexArray::SetPrimitiveType(PrimitiveType type)
{
myPrimitiveType = type;
m_primitiveType = type;
}
////////////////////////////////////////////////////////////
PrimitiveType VertexArray::GetPrimitiveType() const
{
return myPrimitiveType;
return m_primitiveType;
}
////////////////////////////////////////////////////////////
FloatRect VertexArray::GetBounds() const
{
if (!myVertices.empty())
if (!m_vertices.empty())
{
float left = myVertices[0].Position.x;
float top = myVertices[0].Position.y;
float right = myVertices[0].Position.x;
float bottom = myVertices[0].Position.y;
float left = m_vertices[0].Position.x;
float top = m_vertices[0].Position.y;
float right = m_vertices[0].Position.x;
float bottom = m_vertices[0].Position.y;
for (std::size_t i = 0; i < myVertices.size(); ++i)
for (std::size_t i = 0; i < m_vertices.size(); ++i)
{
Vector2f position = myVertices[i].Position;
Vector2f position = m_vertices[i].Position;
// Update left and right
if (position.x < left)
@ -143,8 +143,8 @@ FloatRect VertexArray::GetBounds() const
////////////////////////////////////////////////////////////
void VertexArray::Draw(RenderTarget& target, RenderStates states) const
{
if (!myVertices.empty())
target.Draw(&myVertices[0], static_cast<unsigned int>(myVertices.size()), myPrimitiveType, states);
if (!m_vertices.empty())
target.Draw(&m_vertices[0], static_cast<unsigned int>(m_vertices.size()), m_primitiveType, states);
}
} // namespace sf

View file

@ -33,12 +33,12 @@ namespace sf
{
////////////////////////////////////////////////////////////
View::View() :
myCenter (),
mySize (),
myRotation (0),
myViewport (0, 0, 1, 1),
myTransformUpdated (false),
myInvTransformUpdated(false)
m_center (),
m_size (),
m_rotation (0),
m_viewport (0, 0, 1, 1),
m_transformUpdated (false),
m_invTransformUpdated(false)
{
Reset(FloatRect(0, 0, 1000, 1000));
}
@ -46,12 +46,12 @@ myInvTransformUpdated(false)
////////////////////////////////////////////////////////////
View::View(const FloatRect& rectangle) :
myCenter (),
mySize (),
myRotation (0),
myViewport (0, 0, 1, 1),
myTransformUpdated (false),
myInvTransformUpdated(false)
m_center (),
m_size (),
m_rotation (0),
m_viewport (0, 0, 1, 1),
m_transformUpdated (false),
m_invTransformUpdated(false)
{
Reset(rectangle);
}
@ -59,12 +59,12 @@ myInvTransformUpdated(false)
////////////////////////////////////////////////////////////
View::View(const Vector2f& center, const Vector2f& size) :
myCenter (center),
mySize (size),
myRotation (0),
myViewport (0, 0, 1, 1),
myTransformUpdated (false),
myInvTransformUpdated(false)
m_center (center),
m_size (size),
m_rotation (0),
m_viewport (0, 0, 1, 1),
m_transformUpdated (false),
m_invTransformUpdated(false)
{
}
@ -72,11 +72,11 @@ myInvTransformUpdated(false)
////////////////////////////////////////////////////////////
void View::SetCenter(float x, float y)
{
myCenter.x = x;
myCenter.y = y;
m_center.x = x;
m_center.y = y;
myTransformUpdated = false;
myInvTransformUpdated = false;
m_transformUpdated = false;
m_invTransformUpdated = false;
}
@ -90,11 +90,11 @@ void View::SetCenter(const Vector2f& center)
////////////////////////////////////////////////////////////
void View::SetSize(float width, float height)
{
mySize.x = width;
mySize.y = height;
m_size.x = width;
m_size.y = height;
myTransformUpdated = false;
myInvTransformUpdated = false;
m_transformUpdated = false;
m_invTransformUpdated = false;
}
@ -108,89 +108,89 @@ void View::SetSize(const Vector2f& size)
////////////////////////////////////////////////////////////
void View::SetRotation(float angle)
{
myRotation = static_cast<float>(fmod(angle, 360));
if (myRotation < 0)
myRotation += 360.f;
m_rotation = static_cast<float>(fmod(angle, 360));
if (m_rotation < 0)
m_rotation += 360.f;
myTransformUpdated = false;
myInvTransformUpdated = false;
m_transformUpdated = false;
m_invTransformUpdated = false;
}
////////////////////////////////////////////////////////////
void View::SetViewport(const FloatRect& viewport)
{
myViewport = viewport;
m_viewport = viewport;
}
////////////////////////////////////////////////////////////
void View::Reset(const FloatRect& rectangle)
{
myCenter.x = rectangle.Left + rectangle.Width / 2.f;
myCenter.y = rectangle.Top + rectangle.Height / 2.f;
mySize.x = rectangle.Width;
mySize.y = rectangle.Height;
myRotation = 0;
m_center.x = rectangle.Left + rectangle.Width / 2.f;
m_center.y = rectangle.Top + rectangle.Height / 2.f;
m_size.x = rectangle.Width;
m_size.y = rectangle.Height;
m_rotation = 0;
myTransformUpdated = false;
myInvTransformUpdated = false;
m_transformUpdated = false;
m_invTransformUpdated = false;
}
////////////////////////////////////////////////////////////
const Vector2f& View::GetCenter() const
{
return myCenter;
return m_center;
}
////////////////////////////////////////////////////////////
const Vector2f& View::GetSize() const
{
return mySize;
return m_size;
}
////////////////////////////////////////////////////////////
float View::GetRotation() const
{
return myRotation;
return m_rotation;
}
////////////////////////////////////////////////////////////
const FloatRect& View::GetViewport() const
{
return myViewport;
return m_viewport;
}
////////////////////////////////////////////////////////////
void View::Move(float offsetX, float offsetY)
{
SetCenter(myCenter.x + offsetX, myCenter.y + offsetY);
SetCenter(m_center.x + offsetX, m_center.y + offsetY);
}
////////////////////////////////////////////////////////////
void View::Move(const Vector2f& offset)
{
SetCenter(myCenter + offset);
SetCenter(m_center + offset);
}
////////////////////////////////////////////////////////////
void View::Rotate(float angle)
{
SetRotation(myRotation + angle);
SetRotation(m_rotation + angle);
}
////////////////////////////////////////////////////////////
void View::Zoom(float factor)
{
SetSize(mySize.x * factor, mySize.y * factor);
SetSize(m_size.x * factor, m_size.y * factor);
}
@ -198,29 +198,29 @@ void View::Zoom(float factor)
const Transform& View::GetTransform() const
{
// Recompute the matrix if needed
if (!myTransformUpdated)
if (!m_transformUpdated)
{
// Rotation components
float angle = myRotation * 3.141592654f / 180.f;
float angle = m_rotation * 3.141592654f / 180.f;
float cosine = static_cast<float>(std::cos(angle));
float sine = static_cast<float>(std::sin(angle));
float tx = -myCenter.x * cosine - myCenter.y * sine + myCenter.x;
float ty = myCenter.x * sine - myCenter.y * cosine + myCenter.y;
float tx = -m_center.x * cosine - m_center.y * sine + m_center.x;
float ty = m_center.x * sine - m_center.y * cosine + m_center.y;
// Projection components
float a = 2.f / mySize.x;
float b = -2.f / mySize.y;
float c = -a * myCenter.x;
float d = -b * myCenter.y;
float a = 2.f / m_size.x;
float b = -2.f / m_size.y;
float c = -a * m_center.x;
float d = -b * m_center.y;
// Rebuild the projection matrix
myTransform = Transform( a * cosine, a * sine, a * tx + c,
m_transform = Transform( a * cosine, a * sine, a * tx + c,
-b * sine, b * cosine, b * ty + d,
0.f, 0.f, 1.f);
myTransformUpdated = true;
m_transformUpdated = true;
}
return myTransform;
return m_transform;
}
@ -228,13 +228,13 @@ const Transform& View::GetTransform() const
const Transform& View::GetInverseTransform() const
{
// Recompute the matrix if needed
if (!myInvTransformUpdated)
if (!m_invTransformUpdated)
{
myInverseTransform = GetTransform().GetInverse();
myInvTransformUpdated = true;
m_inverseTransform = GetTransform().GetInverse();
m_invTransformUpdated = true;
}
return myInverseTransform;
return m_inverseTransform;
}
} // namespace sf

View file

@ -57,15 +57,15 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Ftp& myFtp; ///< Reference to the owner Ftp instance
TcpSocket myDataSocket; ///< Socket used for data transfers
Ftp& m_ftp; ///< Reference to the owner Ftp instance
TcpSocket m_dataSocket; ///< Socket used for data transfers
};
////////////////////////////////////////////////////////////
Ftp::Response::Response(Status code, const std::string& message) :
myStatus (code),
myMessage(message)
m_status (code),
m_message(message)
{
}
@ -74,21 +74,21 @@ myMessage(message)
////////////////////////////////////////////////////////////
bool Ftp::Response::IsOk() const
{
return myStatus < 400;
return m_status < 400;
}
////////////////////////////////////////////////////////////
Ftp::Response::Status Ftp::Response::GetStatus() const
{
return myStatus;
return m_status;
}
////////////////////////////////////////////////////////////
const std::string& Ftp::Response::GetMessage() const
{
return myMessage;
return m_message;
}
@ -101,7 +101,7 @@ Ftp::Response(response)
// Extract the directory from the server response
std::string::size_type begin = GetMessage().find('"', 0);
std::string::size_type end = GetMessage().find('"', begin + 1);
myDirectory = GetMessage().substr(begin + 1, end - begin - 1);
m_directory = GetMessage().substr(begin + 1, end - begin - 1);
}
}
@ -109,7 +109,7 @@ Ftp::Response(response)
////////////////////////////////////////////////////////////
const std::string& Ftp::DirectoryResponse::GetDirectory() const
{
return myDirectory;
return m_directory;
}
@ -124,7 +124,7 @@ Ftp::Response(response)
std::string::size_type lastPos = 0;
for (std::string::size_type pos = paths.find("\r\n"); pos != std::string::npos; pos = paths.find("\r\n", lastPos))
{
myFilenames.push_back(paths.substr(lastPos, pos - lastPos));
m_filenames.push_back(paths.substr(lastPos, pos - lastPos));
lastPos = pos + 2;
}
}
@ -134,7 +134,7 @@ Ftp::Response(response)
////////////////////////////////////////////////////////////
const std::vector<std::string>& Ftp::ListingResponse::GetFilenames() const
{
return myFilenames;
return m_filenames;
}
@ -149,7 +149,7 @@ Ftp::~Ftp()
Ftp::Response Ftp::Connect(const IpAddress& server, unsigned short port, Time timeout)
{
// Connect to the server
if (myCommandSocket.Connect(server, port, timeout) != Socket::Done)
if (m_commandSocket.Connect(server, port, timeout) != Socket::Done)
return Response(Response::ConnectionFailed);
// Get the response to the connection
@ -181,7 +181,7 @@ Ftp::Response Ftp::Disconnect()
// Send the exit command
Response response = SendCommand("QUIT");
if (response.IsOk())
myCommandSocket.Disconnect();
m_commandSocket.Disconnect();
return response;
}
@ -376,7 +376,7 @@ Ftp::Response Ftp::SendCommand(const std::string& command, const std::string& pa
commandStr = command + "\r\n";
// Send it to the server
if (myCommandSocket.Send(commandStr.c_str(), commandStr.length()) != Socket::Done)
if (m_commandSocket.Send(commandStr.c_str(), commandStr.length()) != Socket::Done)
return Response(Response::ConnectionClosed);
// Get the response
@ -399,7 +399,7 @@ Ftp::Response Ftp::GetResponse()
// Receive the response from the server
char buffer[1024];
std::size_t length;
if (myCommandSocket.Receive(buffer, sizeof(buffer), length) != Socket::Done)
if (m_commandSocket.Receive(buffer, sizeof(buffer), length) != Socket::Done)
return Response(Response::ConnectionClosed);
// There can be several lines inside the received buffer, extract them all
@ -518,7 +518,7 @@ Ftp::Response Ftp::GetResponse()
////////////////////////////////////////////////////////////
Ftp::DataChannel::DataChannel(Ftp& owner) :
myFtp(owner)
m_ftp(owner)
{
}
@ -528,7 +528,7 @@ myFtp(owner)
Ftp::Response Ftp::DataChannel::Open(Ftp::TransferMode mode)
{
// Open a data connection in active mode (we connect to the server)
Ftp::Response response = myFtp.SendCommand("PASV");
Ftp::Response response = m_ftp.SendCommand("PASV");
if (response.IsOk())
{
// Extract the connection address and port from the response
@ -559,7 +559,7 @@ Ftp::Response Ftp::DataChannel::Open(Ftp::TransferMode mode)
static_cast<Uint8>(data[3]));
// Connect the data channel to the server
if (myDataSocket.Connect(address, port) == Socket::Done)
if (m_dataSocket.Connect(address, port) == Socket::Done)
{
// Translate the transfer mode to the corresponding FTP parameter
std::string modeStr;
@ -571,7 +571,7 @@ Ftp::Response Ftp::DataChannel::Open(Ftp::TransferMode mode)
}
// Set the transfer mode
response = myFtp.SendCommand("TYPE", modeStr);
response = m_ftp.SendCommand("TYPE", modeStr);
}
else
{
@ -592,13 +592,13 @@ void Ftp::DataChannel::Receive(std::vector<char>& data)
data.clear();
char buffer[1024];
std::size_t received;
while (myDataSocket.Receive(buffer, sizeof(buffer), received) == Socket::Done)
while (m_dataSocket.Receive(buffer, sizeof(buffer), received) == Socket::Done)
{
std::copy(buffer, buffer + received, std::back_inserter(data));
}
// Close the data socket
myDataSocket.Disconnect();
m_dataSocket.Disconnect();
}
@ -607,10 +607,10 @@ void Ftp::DataChannel::Send(const std::vector<char>& data)
{
// Send data
if (!data.empty())
myDataSocket.Send(&data[0], data.size());
m_dataSocket.Send(&data[0], data.size());
// Close the data socket
myDataSocket.Disconnect();
m_dataSocket.Disconnect();
}
} // namespace sf

View file

@ -59,40 +59,40 @@ Http::Request::Request(const std::string& uri, Method method, const std::string&
////////////////////////////////////////////////////////////
void Http::Request::SetField(const std::string& field, const std::string& value)
{
myFields[ToLower(field)] = value;
m_fields[ToLower(field)] = value;
}
////////////////////////////////////////////////////////////
void Http::Request::SetMethod(Http::Request::Method method)
{
myMethod = method;
m_method = method;
}
////////////////////////////////////////////////////////////
void Http::Request::SetUri(const std::string& uri)
{
myURI = uri;
m_uRI = uri;
// Make sure it starts with a '/'
if (myURI.empty() || (myURI[0] != '/'))
myURI.insert(0, "/");
if (m_uRI.empty() || (m_uRI[0] != '/'))
m_uRI.insert(0, "/");
}
////////////////////////////////////////////////////////////
void Http::Request::SetHttpVersion(unsigned int major, unsigned int minor)
{
myMajorVersion = major;
myMinorVersion = minor;
m_majorVersion = major;
m_minorVersion = minor;
}
////////////////////////////////////////////////////////////
void Http::Request::SetBody(const std::string& body)
{
myBody = body;
m_body = body;
}
@ -103,7 +103,7 @@ std::string Http::Request::Prepare() const
// Convert the method to its string representation
std::string method;
switch (myMethod)
switch (m_method)
{
default :
case Get : method = "GET"; break;
@ -112,11 +112,11 @@ std::string Http::Request::Prepare() const
}
// Write the first line containing the request type
out << method << " " << myURI << " ";
out << "HTTP/" << myMajorVersion << "." << myMinorVersion << "\r\n";
out << method << " " << m_uRI << " ";
out << "HTTP/" << m_majorVersion << "." << m_minorVersion << "\r\n";
// Write fields
for (FieldTable::const_iterator i = myFields.begin(); i != myFields.end(); ++i)
for (FieldTable::const_iterator i = m_fields.begin(); i != m_fields.end(); ++i)
{
out << i->first << ": " << i->second << "\r\n";
}
@ -125,7 +125,7 @@ std::string Http::Request::Prepare() const
out << "\r\n";
// Add the body
out << myBody;
out << m_body;
return out.str();
}
@ -134,15 +134,15 @@ std::string Http::Request::Prepare() const
////////////////////////////////////////////////////////////
bool Http::Request::HasField(const std::string& field) const
{
return myFields.find(ToLower(field)) != myFields.end();
return m_fields.find(ToLower(field)) != m_fields.end();
}
////////////////////////////////////////////////////////////
Http::Response::Response() :
myStatus (ConnectionFailed),
myMajorVersion(0),
myMinorVersion(0)
m_status (ConnectionFailed),
m_majorVersion(0),
m_minorVersion(0)
{
}
@ -151,8 +151,8 @@ myMinorVersion(0)
////////////////////////////////////////////////////////////
const std::string& Http::Response::GetField(const std::string& field) const
{
FieldTable::const_iterator it = myFields.find(ToLower(field));
if (it != myFields.end())
FieldTable::const_iterator it = m_fields.find(ToLower(field));
if (it != m_fields.end())
{
return it->second;
}
@ -167,28 +167,28 @@ const std::string& Http::Response::GetField(const std::string& field) const
////////////////////////////////////////////////////////////
Http::Response::Status Http::Response::GetStatus() const
{
return myStatus;
return m_status;
}
////////////////////////////////////////////////////////////
unsigned int Http::Response::GetMajorHttpVersion() const
{
return myMajorVersion;
return m_majorVersion;
}
////////////////////////////////////////////////////////////
unsigned int Http::Response::GetMinorHttpVersion() const
{
return myMinorVersion;
return m_minorVersion;
}
////////////////////////////////////////////////////////////
const std::string& Http::Response::GetBody() const
{
return myBody;
return m_body;
}
@ -205,13 +205,13 @@ void Http::Response::Parse(const std::string& data)
(ToLower(version.substr(0, 5)) == "http/") &&
isdigit(version[5]) && isdigit(version[7]))
{
myMajorVersion = version[5] - '0';
myMinorVersion = version[7] - '0';
m_majorVersion = version[5] - '0';
m_minorVersion = version[7] - '0';
}
else
{
// Invalid HTTP version
myStatus = InvalidResponse;
m_status = InvalidResponse;
return;
}
}
@ -220,12 +220,12 @@ void Http::Response::Parse(const std::string& data)
int status;
if (in >> status)
{
myStatus = static_cast<Status>(status);
m_status = static_cast<Status>(status);
}
else
{
// Invalid status code
myStatus = InvalidResponse;
m_status = InvalidResponse;
return;
}
@ -248,20 +248,20 @@ void Http::Response::Parse(const std::string& data)
value.erase(value.size() - 1);
// Add the field
myFields[ToLower(field)] = value;
m_fields[ToLower(field)] = value;
}
}
// Finally extract the body
myBody.clear();
std::copy(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>(), std::back_inserter(myBody));
m_body.clear();
std::copy(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>(), std::back_inserter(m_body));
}
////////////////////////////////////////////////////////////
Http::Http() :
myHost(),
myPort(0)
m_host(),
m_port(0)
{
}
@ -282,27 +282,27 @@ void Http::SetHost(const std::string& host, unsigned short port)
if (protocol.substr(0, 7) == "http://")
{
// HTTP protocol
myHostName = host.substr(7);
myPort = (port != 0 ? port : 80);
m_hostName = host.substr(7);
m_port = (port != 0 ? port : 80);
}
else if (protocol == "https://")
{
// HTTPS protocol
myHostName = host.substr(8);
myPort = (port != 0 ? port : 443);
m_hostName = host.substr(8);
m_port = (port != 0 ? port : 443);
}
else
{
// Undefined protocol - use HTTP
myHostName = host;
myPort = (port != 0 ? port : 80);
m_hostName = host;
m_port = (port != 0 ? port : 80);
}
// Remove any trailing '/' from the host name
if (!myHostName.empty() && (*myHostName.rbegin() == '/'))
myHostName.erase(myHostName.size() - 1);
if (!m_hostName.empty() && (*m_hostName.rbegin() == '/'))
m_hostName.erase(m_hostName.size() - 1);
myHost = IpAddress(myHostName);
m_host = IpAddress(m_hostName);
}
@ -321,19 +321,19 @@ Http::Response Http::SendRequest(const Http::Request& request, Time timeout)
}
if (!toSend.HasField("Host"))
{
toSend.SetField("Host", myHostName);
toSend.SetField("Host", m_hostName);
}
if (!toSend.HasField("Content-Length"))
{
std::ostringstream out;
out << toSend.myBody.size();
out << toSend.m_body.size();
toSend.SetField("Content-Length", out.str());
}
if ((toSend.myMethod == Request::Post) && !toSend.HasField("Content-Type"))
if ((toSend.m_method == Request::Post) && !toSend.HasField("Content-Type"))
{
toSend.SetField("Content-Type", "application/x-www-form-urlencoded");
}
if ((toSend.myMajorVersion * 10 + toSend.myMinorVersion >= 11) && !toSend.HasField("Connection"))
if ((toSend.m_majorVersion * 10 + toSend.m_minorVersion >= 11) && !toSend.HasField("Connection"))
{
toSend.SetField("Connection", "close");
}
@ -342,7 +342,7 @@ Http::Response Http::SendRequest(const Http::Request& request, Time timeout)
Response received;
// Connect the socket to the host
if (myConnection.Connect(myHost, myPort, timeout) == Socket::Done)
if (m_connection.Connect(m_host, m_port, timeout) == Socket::Done)
{
// Convert the request to string and send it through the connected socket
std::string requestStr = toSend.Prepare();
@ -350,13 +350,13 @@ Http::Response Http::SendRequest(const Http::Request& request, Time timeout)
if (!requestStr.empty())
{
// Send it through the socket
if (myConnection.Send(requestStr.c_str(), requestStr.size()) == Socket::Done)
if (m_connection.Send(requestStr.c_str(), requestStr.size()) == Socket::Done)
{
// Wait for the server's response
std::string receivedStr;
std::size_t size = 0;
char buffer[1024];
while (myConnection.Receive(buffer, sizeof(buffer), size) == Socket::Done)
while (m_connection.Receive(buffer, sizeof(buffer), size) == Socket::Done)
{
receivedStr.append(buffer, buffer + size);
}
@ -367,7 +367,7 @@ Http::Response Http::SendRequest(const Http::Request& request, Time timeout)
}
// Close the connection
myConnection.Disconnect();
m_connection.Disconnect();
}
return received;

View file

@ -69,7 +69,7 @@ const IpAddress IpAddress::Broadcast(255, 255, 255, 255);
////////////////////////////////////////////////////////////
IpAddress::IpAddress() :
myAddress(0)
m_address(0)
{
// We're using 0 (INADDR_ANY) instead of INADDR_NONE to represent the invalid address,
// because the latter is also the broadcast address (255.255.255.255); it's ok because
@ -79,28 +79,28 @@ myAddress(0)
////////////////////////////////////////////////////////////
IpAddress::IpAddress(const std::string& address) :
myAddress(Resolve(address))
m_address(Resolve(address))
{
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(const char* address) :
myAddress(Resolve(address))
m_address(Resolve(address))
{
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3) :
myAddress(htonl((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3))
m_address(htonl((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3))
{
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(Uint32 address) :
myAddress(htonl(address))
m_address(htonl(address))
{
}
@ -109,7 +109,7 @@ myAddress(htonl(address))
std::string IpAddress::ToString() const
{
in_addr address;
address.s_addr = myAddress;
address.s_addr = m_address;
return inet_ntoa(address);
}
@ -118,7 +118,7 @@ std::string IpAddress::ToString() const
////////////////////////////////////////////////////////////
Uint32 IpAddress::ToInteger() const
{
return ntohl(myAddress);
return ntohl(m_address);
}

View file

@ -35,8 +35,8 @@ namespace sf
{
////////////////////////////////////////////////////////////
Packet::Packet() :
myReadPos(0),
myIsValid(true)
m_readPos(0),
m_isValid(true)
{
}
@ -54,9 +54,9 @@ void Packet::Append(const void* data, std::size_t sizeInBytes)
{
if (data && (sizeInBytes > 0))
{
std::size_t start = myData.size();
myData.resize(start + sizeInBytes);
std::memcpy(&myData[start], data, sizeInBytes);
std::size_t start = m_data.size();
m_data.resize(start + sizeInBytes);
std::memcpy(&m_data[start], data, sizeInBytes);
}
}
@ -64,37 +64,37 @@ void Packet::Append(const void* data, std::size_t sizeInBytes)
////////////////////////////////////////////////////////////
void Packet::Clear()
{
myData.clear();
myReadPos = 0;
myIsValid = true;
m_data.clear();
m_readPos = 0;
m_isValid = true;
}
////////////////////////////////////////////////////////////
const char* Packet::GetData() const
{
return !myData.empty() ? &myData[0] : NULL;
return !m_data.empty() ? &m_data[0] : NULL;
}
////////////////////////////////////////////////////////////
std::size_t Packet::GetDataSize() const
{
return myData.size();
return m_data.size();
}
////////////////////////////////////////////////////////////
bool Packet::EndOfPacket() const
{
return myReadPos >= myData.size();
return m_readPos >= m_data.size();
}
////////////////////////////////////////////////////////////
Packet::operator BoolType() const
{
return myIsValid ? &Packet::CheckSize : NULL;
return m_isValid ? &Packet::CheckSize : NULL;
}
@ -114,8 +114,8 @@ Packet& Packet::operator >>(Int8& data)
{
if (CheckSize(sizeof(data)))
{
data = *reinterpret_cast<const Int8*>(GetData() + myReadPos);
myReadPos += sizeof(data);
data = *reinterpret_cast<const Int8*>(GetData() + m_readPos);
m_readPos += sizeof(data);
}
return *this;
@ -127,8 +127,8 @@ Packet& Packet::operator >>(Uint8& data)
{
if (CheckSize(sizeof(data)))
{
data = *reinterpret_cast<const Uint8*>(GetData() + myReadPos);
myReadPos += sizeof(data);
data = *reinterpret_cast<const Uint8*>(GetData() + m_readPos);
m_readPos += sizeof(data);
}
return *this;
@ -140,8 +140,8 @@ Packet& Packet::operator >>(Int16& data)
{
if (CheckSize(sizeof(data)))
{
data = ntohs(*reinterpret_cast<const Int16*>(GetData() + myReadPos));
myReadPos += sizeof(data);
data = ntohs(*reinterpret_cast<const Int16*>(GetData() + m_readPos));
m_readPos += sizeof(data);
}
return *this;
@ -153,8 +153,8 @@ Packet& Packet::operator >>(Uint16& data)
{
if (CheckSize(sizeof(data)))
{
data = ntohs(*reinterpret_cast<const Uint16*>(GetData() + myReadPos));
myReadPos += sizeof(data);
data = ntohs(*reinterpret_cast<const Uint16*>(GetData() + m_readPos));
m_readPos += sizeof(data);
}
return *this;
@ -166,8 +166,8 @@ Packet& Packet::operator >>(Int32& data)
{
if (CheckSize(sizeof(data)))
{
data = ntohl(*reinterpret_cast<const Int32*>(GetData() + myReadPos));
myReadPos += sizeof(data);
data = ntohl(*reinterpret_cast<const Int32*>(GetData() + m_readPos));
m_readPos += sizeof(data);
}
return *this;
@ -179,8 +179,8 @@ Packet& Packet::operator >>(Uint32& data)
{
if (CheckSize(sizeof(data)))
{
data = ntohl(*reinterpret_cast<const Uint32*>(GetData() + myReadPos));
myReadPos += sizeof(data);
data = ntohl(*reinterpret_cast<const Uint32*>(GetData() + m_readPos));
m_readPos += sizeof(data);
}
return *this;
@ -192,8 +192,8 @@ Packet& Packet::operator >>(float& data)
{
if (CheckSize(sizeof(data)))
{
data = *reinterpret_cast<const float*>(GetData() + myReadPos);
myReadPos += sizeof(data);
data = *reinterpret_cast<const float*>(GetData() + m_readPos);
m_readPos += sizeof(data);
}
return *this;
@ -205,8 +205,8 @@ Packet& Packet::operator >>(double& data)
{
if (CheckSize(sizeof(data)))
{
data = *reinterpret_cast<const double*>(GetData() + myReadPos);
myReadPos += sizeof(data);
data = *reinterpret_cast<const double*>(GetData() + m_readPos);
m_readPos += sizeof(data);
}
return *this;
@ -223,11 +223,11 @@ Packet& Packet::operator >>(char* data)
if ((length > 0) && CheckSize(length))
{
// Then extract characters
std::memcpy(data, GetData() + myReadPos, length);
std::memcpy(data, GetData() + m_readPos, length);
data[length] = '\0';
// Update reading position
myReadPos += length;
m_readPos += length;
}
return *this;
@ -245,10 +245,10 @@ Packet& Packet::operator >>(std::string& data)
if ((length > 0) && CheckSize(length))
{
// Then extract characters
data.assign(GetData() + myReadPos, length);
data.assign(GetData() + m_readPos, length);
// Update reading position
myReadPos += length;
m_readPos += length;
}
return *this;
@ -489,9 +489,9 @@ Packet& Packet::operator <<(const String& data)
////////////////////////////////////////////////////////////
bool Packet::CheckSize(std::size_t size)
{
myIsValid = myIsValid && (myReadPos + size <= myData.size());
m_isValid = m_isValid && (m_readPos + size <= m_data.size());
return myIsValid;
return m_isValid;
}

View file

@ -34,9 +34,9 @@ namespace sf
{
////////////////////////////////////////////////////////////
Socket::Socket(Type type) :
myType (type),
mySocket (priv::SocketImpl::InvalidSocket()),
myIsBlocking(true)
m_type (type),
m_socket (priv::SocketImpl::InvalidSocket()),
m_isBlocking(true)
{
}
@ -54,24 +54,24 @@ Socket::~Socket()
void Socket::SetBlocking(bool blocking)
{
// Apply if the socket is already created
if (mySocket != priv::SocketImpl::InvalidSocket())
priv::SocketImpl::SetBlocking(mySocket, blocking);
if (m_socket != priv::SocketImpl::InvalidSocket())
priv::SocketImpl::SetBlocking(m_socket, blocking);
myIsBlocking = blocking;
m_isBlocking = blocking;
}
////////////////////////////////////////////////////////////
bool Socket::IsBlocking() const
{
return myIsBlocking;
return m_isBlocking;
}
////////////////////////////////////////////////////////////
SocketHandle Socket::GetHandle() const
{
return mySocket;
return m_socket;
}
@ -79,9 +79,9 @@ SocketHandle Socket::GetHandle() const
void Socket::Create()
{
// Don't create the socket if it already exists
if (mySocket == priv::SocketImpl::InvalidSocket())
if (m_socket == priv::SocketImpl::InvalidSocket())
{
SocketHandle handle = socket(PF_INET, myType == Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
SocketHandle handle = socket(PF_INET, m_type == Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
Create(handle);
}
}
@ -91,19 +91,19 @@ void Socket::Create()
void Socket::Create(SocketHandle handle)
{
// Don't create the socket if it already exists
if (mySocket == priv::SocketImpl::InvalidSocket())
if (m_socket == priv::SocketImpl::InvalidSocket())
{
// Assign the new handle
mySocket = handle;
m_socket = handle;
// Set the current blocking state
SetBlocking(myIsBlocking);
SetBlocking(m_isBlocking);
if (myType == Tcp)
if (m_type == Tcp)
{
// Disable the Nagle algorithm (ie. removes buffering of TCP packets)
int yes = 1;
if (setsockopt(mySocket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>(&yes), sizeof(yes)) == -1)
if (setsockopt(m_socket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>(&yes), sizeof(yes)) == -1)
{
Err() << "Failed to set socket option \"TCP_NODELAY\" ; "
<< "all your TCP packets will be buffered" << std::endl;
@ -113,7 +113,7 @@ void Socket::Create(SocketHandle handle)
{
// Enable broadcast by default for UDP sockets
int yes = 1;
if (setsockopt(mySocket, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<char*>(&yes), sizeof(yes)) == -1)
if (setsockopt(m_socket, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<char*>(&yes), sizeof(yes)) == -1)
{
Err() << "Failed to enable broadcast on UDP socket" << std::endl;
}
@ -126,10 +126,10 @@ void Socket::Create(SocketHandle handle)
void Socket::Close()
{
// Close the socket
if (mySocket != priv::SocketImpl::InvalidSocket())
if (m_socket != priv::SocketImpl::InvalidSocket())
{
priv::SocketImpl::Close(mySocket);
mySocket = priv::SocketImpl::InvalidSocket();
priv::SocketImpl::Close(m_socket);
m_socket = priv::SocketImpl::InvalidSocket();
}
}

View file

@ -49,7 +49,7 @@ struct SocketSelector::SocketSelectorImpl
////////////////////////////////////////////////////////////
SocketSelector::SocketSelector() :
myImpl(new SocketSelectorImpl)
m_impl(new SocketSelectorImpl)
{
Clear();
}
@ -57,7 +57,7 @@ myImpl(new SocketSelectorImpl)
////////////////////////////////////////////////////////////
SocketSelector::SocketSelector(const SocketSelector& copy) :
myImpl(new SocketSelectorImpl(*copy.myImpl))
m_impl(new SocketSelectorImpl(*copy.m_impl))
{
}
@ -66,36 +66,36 @@ myImpl(new SocketSelectorImpl(*copy.myImpl))
////////////////////////////////////////////////////////////
SocketSelector::~SocketSelector()
{
delete myImpl;
delete m_impl;
}
////////////////////////////////////////////////////////////
void SocketSelector::Add(Socket& socket)
{
FD_SET(socket.GetHandle(), &myImpl->AllSockets);
FD_SET(socket.GetHandle(), &m_impl->AllSockets);
int size = static_cast<int>(socket.GetHandle());
if (size > myImpl->MaxSocket)
myImpl->MaxSocket = size;
if (size > m_impl->MaxSocket)
m_impl->MaxSocket = size;
}
////////////////////////////////////////////////////////////
void SocketSelector::Remove(Socket& socket)
{
FD_CLR(socket.GetHandle(), &myImpl->AllSockets);
FD_CLR(socket.GetHandle(), &myImpl->SocketsReady);
FD_CLR(socket.GetHandle(), &m_impl->AllSockets);
FD_CLR(socket.GetHandle(), &m_impl->SocketsReady);
}
////////////////////////////////////////////////////////////
void SocketSelector::Clear()
{
FD_ZERO(&myImpl->AllSockets);
FD_ZERO(&myImpl->SocketsReady);
FD_ZERO(&m_impl->AllSockets);
FD_ZERO(&m_impl->SocketsReady);
myImpl->MaxSocket = 0;
m_impl->MaxSocket = 0;
}
@ -108,10 +108,10 @@ bool SocketSelector::Wait(Time timeout)
time.tv_usec = static_cast<long>(timeout.AsMicroseconds() % 1000000);
// Initialize the set that will contain the sockets that are ready
myImpl->SocketsReady = myImpl->AllSockets;
m_impl->SocketsReady = m_impl->AllSockets;
// Wait until one of the sockets is ready for reading, or timeout is reached
int count = select(myImpl->MaxSocket + 1, &myImpl->SocketsReady, NULL, NULL, timeout != Time::Zero ? &time : NULL);
int count = select(m_impl->MaxSocket + 1, &m_impl->SocketsReady, NULL, NULL, timeout != Time::Zero ? &time : NULL);
return count > 0;
}
@ -120,7 +120,7 @@ bool SocketSelector::Wait(Time timeout)
////////////////////////////////////////////////////////////
bool SocketSelector::IsReady(Socket& socket) const
{
return FD_ISSET(socket.GetHandle(), &myImpl->SocketsReady) != 0;
return FD_ISSET(socket.GetHandle(), &m_impl->SocketsReady) != 0;
}
@ -129,7 +129,7 @@ SocketSelector& SocketSelector::operator =(const SocketSelector& right)
{
SocketSelector temp(right);
std::swap(myImpl, temp.myImpl);
std::swap(m_impl, temp.m_impl);
return *this;
}

View file

@ -201,7 +201,7 @@ void TcpSocket::Disconnect()
Close();
// Reset the pending packet data
myPendingPacket = PendingPacket();
m_pendingPacket = PendingPacket();
}
@ -305,35 +305,35 @@ Socket::Status TcpSocket::Receive(Packet& packet)
// We start by getting the size of the incoming packet
Uint32 packetSize = 0;
std::size_t received = 0;
if (myPendingPacket.SizeReceived < sizeof(myPendingPacket.Size))
if (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size))
{
// Loop until we've received the entire size of the packet
// (even a 4 byte variable may be received in more than one call)
while (myPendingPacket.SizeReceived < sizeof(myPendingPacket.Size))
while (m_pendingPacket.SizeReceived < sizeof(m_pendingPacket.Size))
{
char* data = reinterpret_cast<char*>(&myPendingPacket.Size) + myPendingPacket.SizeReceived;
Status status = Receive(data, sizeof(myPendingPacket.Size) - myPendingPacket.SizeReceived, received);
myPendingPacket.SizeReceived += received;
char* data = reinterpret_cast<char*>(&m_pendingPacket.Size) + m_pendingPacket.SizeReceived;
Status status = Receive(data, sizeof(m_pendingPacket.Size) - m_pendingPacket.SizeReceived, received);
m_pendingPacket.SizeReceived += received;
if (status != Done)
return status;
}
// The packet size has been fully received
packetSize = ntohl(myPendingPacket.Size);
packetSize = ntohl(m_pendingPacket.Size);
}
else
{
// The packet size has already been received in a previous call
packetSize = ntohl(myPendingPacket.Size);
packetSize = ntohl(m_pendingPacket.Size);
}
// Loop until we receive all the packet data
char buffer[1024];
while (myPendingPacket.Data.size() < packetSize)
while (m_pendingPacket.Data.size() < packetSize)
{
// Receive a chunk of data
std::size_t sizeToGet = std::min(static_cast<std::size_t>(packetSize - myPendingPacket.Data.size()), sizeof(buffer));
std::size_t sizeToGet = std::min(static_cast<std::size_t>(packetSize - m_pendingPacket.Data.size()), sizeof(buffer));
Status status = Receive(buffer, sizeToGet, received);
if (status != Done)
return status;
@ -341,18 +341,18 @@ Socket::Status TcpSocket::Receive(Packet& packet)
// Append it into the packet
if (received > 0)
{
myPendingPacket.Data.resize(myPendingPacket.Data.size() + received);
char* begin = &myPendingPacket.Data[0] + myPendingPacket.Data.size() - received;
m_pendingPacket.Data.resize(m_pendingPacket.Data.size() + received);
char* begin = &m_pendingPacket.Data[0] + m_pendingPacket.Data.size() - received;
std::memcpy(begin, buffer, received);
}
}
// We have received all the packet data: we can copy it to the user packet
if (!myPendingPacket.Data.empty())
packet.OnReceive(&myPendingPacket.Data[0], myPendingPacket.Data.size());
if (!m_pendingPacket.Data.empty())
packet.OnReceive(&m_pendingPacket.Data[0], m_pendingPacket.Data.size());
// Clear the pending packet data
myPendingPacket = PendingPacket();
m_pendingPacket = PendingPacket();
return Done;
}

View file

@ -38,7 +38,7 @@ namespace sf
////////////////////////////////////////////////////////////
UdpSocket::UdpSocket() :
Socket (Udp),
myBuffer(MaxDatagramSize)
m_buffer(MaxDatagramSize)
{
}
@ -179,12 +179,12 @@ Socket::Status UdpSocket::Receive(Packet& packet, IpAddress& remoteAddress, unsi
// Receive the datagram
std::size_t received = 0;
Status status = Receive(&myBuffer[0], myBuffer.size(), received, remoteAddress, remotePort);
Status status = Receive(&m_buffer[0], m_buffer.size(), received, remoteAddress, remotePort);
// If we received valid data, we can copy it to the user packet
packet.Clear();
if ((status == Done) && (received > 0))
packet.OnReceive(&myBuffer[0], received);
packet.OnReceive(&m_buffer[0], received);
return status;
}

View file

@ -38,7 +38,7 @@ namespace sf
{
////////////////////////////////////////////////////////////
Clock::Clock() :
myStartTime(priv::ClockImpl::GetCurrentTime())
m_startTime(priv::ClockImpl::GetCurrentTime())
{
}
@ -46,7 +46,7 @@ myStartTime(priv::ClockImpl::GetCurrentTime())
////////////////////////////////////////////////////////////
Time Clock::GetElapsedTime() const
{
return priv::ClockImpl::GetCurrentTime() - myStartTime;
return priv::ClockImpl::GetCurrentTime() - m_startTime;
}
@ -54,8 +54,8 @@ Time Clock::GetElapsedTime() const
Time Clock::Restart()
{
Time now = priv::ClockImpl::GetCurrentTime();
Time elapsed = now - myStartTime;
myStartTime = now;
Time elapsed = now - m_startTime;
m_startTime = now;
return elapsed;
}

View file

@ -33,16 +33,16 @@ namespace sf
{
////////////////////////////////////////////////////////////
Lock::Lock(Mutex& mutex) :
myMutex(mutex)
m_mutex(mutex)
{
myMutex.Lock();
m_mutex.Lock();
}
////////////////////////////////////////////////////////////
Lock::~Lock()
{
myMutex.Unlock();
m_mutex.Unlock();
}
} // namespace sf

View file

@ -44,28 +44,28 @@ namespace sf
////////////////////////////////////////////////////////////
Mutex::Mutex()
{
myMutexImpl = new priv::MutexImpl;
m_mutexImpl = new priv::MutexImpl;
}
////////////////////////////////////////////////////////////
Mutex::~Mutex()
{
delete myMutexImpl;
delete m_mutexImpl;
}
////////////////////////////////////////////////////////////
void Mutex::Lock()
{
myMutexImpl->Lock();
m_mutexImpl->Lock();
}
////////////////////////////////////////////////////////////
void Mutex::Unlock()
{
myMutexImpl->Unlock();
m_mutexImpl->Unlock();
}
} // namespace sf

View file

@ -46,21 +46,21 @@ String::String()
////////////////////////////////////////////////////////////
String::String(char ansiChar, const std::locale& locale)
{
myString += Utf32::DecodeAnsi(ansiChar, locale);
m_string += Utf32::DecodeAnsi(ansiChar, locale);
}
////////////////////////////////////////////////////////////
String::String(wchar_t wideChar)
{
myString += Utf32::DecodeWide(wideChar);
m_string += Utf32::DecodeWide(wideChar);
}
////////////////////////////////////////////////////////////
String::String(Uint32 utf32Char)
{
myString += utf32Char;
m_string += utf32Char;
}
@ -72,8 +72,8 @@ String::String(const char* ansiString, const std::locale& locale)
std::size_t length = strlen(ansiString);
if (length > 0)
{
myString.reserve(length + 1);
Utf32::FromAnsi(ansiString, ansiString + length, std::back_inserter(myString), locale);
m_string.reserve(length + 1);
Utf32::FromAnsi(ansiString, ansiString + length, std::back_inserter(m_string), locale);
}
}
}
@ -82,8 +82,8 @@ String::String(const char* ansiString, const std::locale& locale)
////////////////////////////////////////////////////////////
String::String(const std::string& ansiString, const std::locale& locale)
{
myString.reserve(ansiString.length() + 1);
Utf32::FromAnsi(ansiString.begin(), ansiString.end(), std::back_inserter(myString), locale);
m_string.reserve(ansiString.length() + 1);
Utf32::FromAnsi(ansiString.begin(), ansiString.end(), std::back_inserter(m_string), locale);
}
@ -95,8 +95,8 @@ String::String(const wchar_t* wideString)
std::size_t length = std::wcslen(wideString);
if (length > 0)
{
myString.reserve(length + 1);
Utf32::FromWide(wideString, wideString + length, std::back_inserter(myString));
m_string.reserve(length + 1);
Utf32::FromWide(wideString, wideString + length, std::back_inserter(m_string));
}
}
}
@ -105,8 +105,8 @@ String::String(const wchar_t* wideString)
////////////////////////////////////////////////////////////
String::String(const std::wstring& wideString)
{
myString.reserve(wideString.length() + 1);
Utf32::FromWide(wideString.begin(), wideString.end(), std::back_inserter(myString));
m_string.reserve(wideString.length() + 1);
Utf32::FromWide(wideString.begin(), wideString.end(), std::back_inserter(m_string));
}
@ -114,20 +114,20 @@ String::String(const std::wstring& wideString)
String::String(const Uint32* utf32String)
{
if (utf32String)
myString = utf32String;
m_string = utf32String;
}
////////////////////////////////////////////////////////////
String::String(const std::basic_string<Uint32>& utf32String) :
myString(utf32String)
m_string(utf32String)
{
}
////////////////////////////////////////////////////////////
String::String(const String& copy) :
myString(copy.myString)
m_string(copy.m_string)
{
}
@ -151,10 +151,10 @@ std::string String::ToAnsiString(const std::locale& locale) const
{
// Prepare the output string
std::string output;
output.reserve(myString.length() + 1);
output.reserve(m_string.length() + 1);
// Convert
Utf32::ToAnsi(myString.begin(), myString.end(), std::back_inserter(output), 0, locale);
Utf32::ToAnsi(m_string.begin(), m_string.end(), std::back_inserter(output), 0, locale);
return output;
}
@ -165,10 +165,10 @@ std::wstring String::ToWideString() const
{
// Prepare the output string
std::wstring output;
output.reserve(myString.length() + 1);
output.reserve(m_string.length() + 1);
// Convert
Utf32::ToWide(myString.begin(), myString.end(), std::back_inserter(output), 0);
Utf32::ToWide(m_string.begin(), m_string.end(), std::back_inserter(output), 0);
return output;
}
@ -177,7 +177,7 @@ std::wstring String::ToWideString() const
////////////////////////////////////////////////////////////
String& String::operator =(const String& right)
{
myString = right.myString;
m_string = right.m_string;
return *this;
}
@ -185,7 +185,7 @@ String& String::operator =(const String& right)
////////////////////////////////////////////////////////////
String& String::operator +=(const String& right)
{
myString += right.myString;
m_string += right.m_string;
return *this;
}
@ -193,98 +193,98 @@ String& String::operator +=(const String& right)
////////////////////////////////////////////////////////////
Uint32 String::operator [](std::size_t index) const
{
return myString[index];
return m_string[index];
}
////////////////////////////////////////////////////////////
Uint32& String::operator [](std::size_t index)
{
return myString[index];
return m_string[index];
}
////////////////////////////////////////////////////////////
void String::Clear()
{
myString.clear();
m_string.clear();
}
////////////////////////////////////////////////////////////
std::size_t String::GetSize() const
{
return myString.size();
return m_string.size();
}
////////////////////////////////////////////////////////////
bool String::IsEmpty() const
{
return myString.empty();
return m_string.empty();
}
////////////////////////////////////////////////////////////
void String::Erase(std::size_t position, std::size_t count)
{
myString.erase(position, count);
m_string.erase(position, count);
}
////////////////////////////////////////////////////////////
void String::Insert(std::size_t position, const String& str)
{
myString.insert(position, str.myString);
m_string.insert(position, str.m_string);
}
////////////////////////////////////////////////////////////
std::size_t String::Find(const String& str, std::size_t start) const
{
return myString.find(str.myString, start);
return m_string.find(str.m_string, start);
}
////////////////////////////////////////////////////////////
const Uint32* String::GetData() const
{
return myString.c_str();
return m_string.c_str();
}
////////////////////////////////////////////////////////////
String::Iterator String::Begin()
{
return myString.begin();
return m_string.begin();
}
////////////////////////////////////////////////////////////
String::ConstIterator String::Begin() const
{
return myString.begin();
return m_string.begin();
}
////////////////////////////////////////////////////////////
String::Iterator String::End()
{
return myString.end();
return m_string.end();
}
////////////////////////////////////////////////////////////
String::ConstIterator String::End() const
{
return myString.end();
return m_string.end();
}
////////////////////////////////////////////////////////////
bool operator ==(const String& left, const String& right)
{
return left.myString == right.myString;
return left.m_string == right.m_string;
}
@ -298,7 +298,7 @@ bool operator !=(const String& left, const String& right)
////////////////////////////////////////////////////////////
bool operator <(const String& left, const String& right)
{
return left.myString < right.myString;
return left.m_string < right.m_string;
}

View file

@ -41,7 +41,7 @@ namespace sf
Thread::~Thread()
{
Wait();
delete myEntryPoint;
delete m_entryPoint;
}
@ -49,18 +49,18 @@ Thread::~Thread()
void Thread::Launch()
{
Wait();
myImpl = new priv::ThreadImpl(this);
m_impl = new priv::ThreadImpl(this);
}
////////////////////////////////////////////////////////////
void Thread::Wait()
{
if (myImpl)
if (m_impl)
{
myImpl->Wait();
delete myImpl;
myImpl = NULL;
m_impl->Wait();
delete m_impl;
m_impl = NULL;
}
}
@ -68,11 +68,11 @@ void Thread::Wait()
////////////////////////////////////////////////////////////
void Thread::Terminate()
{
if (myImpl)
if (m_impl)
{
myImpl->Terminate();
delete myImpl;
myImpl = NULL;
m_impl->Terminate();
delete m_impl;
m_impl = NULL;
}
}
@ -80,7 +80,7 @@ void Thread::Terminate()
////////////////////////////////////////////////////////////
void Thread::Run()
{
myEntryPoint->Run();
m_entryPoint->Run();
}
} // namespace sf

View file

@ -44,7 +44,7 @@ namespace sf
////////////////////////////////////////////////////////////
ThreadLocal::ThreadLocal(void* value)
{
myImpl = new priv::ThreadLocalImpl;
m_impl = new priv::ThreadLocalImpl;
SetValue(value);
}
@ -52,21 +52,21 @@ ThreadLocal::ThreadLocal(void* value)
////////////////////////////////////////////////////////////
ThreadLocal::~ThreadLocal()
{
delete myImpl;
delete m_impl;
}
////////////////////////////////////////////////////////////
void ThreadLocal::SetValue(void* value)
{
myImpl->SetValue(value);
m_impl->SetValue(value);
}
////////////////////////////////////////////////////////////
void* ThreadLocal::GetValue() const
{
return myImpl->GetValue();
return m_impl->GetValue();
}
} // namespace sf

View file

@ -36,7 +36,7 @@ const Time Time::Zero;
////////////////////////////////////////////////////////////
Time::Time() :
myMicroseconds(0)
m_microseconds(0)
{
}
@ -44,27 +44,27 @@ myMicroseconds(0)
////////////////////////////////////////////////////////////
float Time::AsSeconds() const
{
return myMicroseconds / 1000000.f;
return m_microseconds / 1000000.f;
}
////////////////////////////////////////////////////////////
Int32 Time::AsMilliseconds() const
{
return static_cast<Uint32>(myMicroseconds / 1000);
return static_cast<Uint32>(m_microseconds / 1000);
}
////////////////////////////////////////////////////////////
Int64 Time::AsMicroseconds() const
{
return myMicroseconds;
return m_microseconds;
}
////////////////////////////////////////////////////////////
Time::Time(Int64 microseconds) :
myMicroseconds(microseconds)
m_microseconds(microseconds)
{
}

View file

@ -40,28 +40,28 @@ MutexImpl::MutexImpl()
pthread_mutexattr_init(&attributes);
pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&myMutex, &attributes);
pthread_mutex_init(&m_mutex, &attributes);
}
////////////////////////////////////////////////////////////
MutexImpl::~MutexImpl()
{
pthread_mutex_destroy(&myMutex);
pthread_mutex_destroy(&m_mutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
pthread_mutex_lock(&myMutex);
pthread_mutex_lock(&m_mutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Unlock()
{
pthread_mutex_unlock(&myMutex);
pthread_mutex_unlock(&m_mutex);
}
} // namespace priv

View file

@ -72,7 +72,7 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
pthread_mutex_t myMutex; ///< pthread handle of the mutex
pthread_mutex_t m_mutex; ///< pthread handle of the mutex
};
} // namespace priv

View file

@ -37,11 +37,11 @@ namespace priv
{
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner) :
myIsActive(true)
m_isActive(true)
{
myIsActive = pthread_create(&myThread, NULL, &ThreadImpl::EntryPoint, owner) == 0;
m_isActive = pthread_create(&m_thread, NULL, &ThreadImpl::EntryPoint, owner) == 0;
if (!myIsActive)
if (!m_isActive)
std::cerr << "Failed to create thread" << std::endl;
}
@ -49,10 +49,10 @@ myIsActive(true)
////////////////////////////////////////////////////////////
void ThreadImpl::Wait()
{
if (myIsActive)
if (m_isActive)
{
assert(pthread_equal(pthread_self(), myThread) == 0); // A thread cannot wait for itself!
pthread_join(myThread, NULL);
assert(pthread_equal(pthread_self(), m_thread) == 0); // A thread cannot wait for itself!
pthread_join(m_thread, NULL);
}
}
@ -60,8 +60,8 @@ void ThreadImpl::Wait()
////////////////////////////////////////////////////////////
void ThreadImpl::Terminate()
{
if (myIsActive)
pthread_cancel(myThread);
if (m_isActive)
pthread_cancel(m_thread);
}

View file

@ -80,8 +80,8 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
pthread_t myThread; ///< pthread thread instance
bool myIsActive; ///< Thread state (active or inactive)
pthread_t m_thread; ///< pthread thread instance
bool m_isActive; ///< Thread state (active or inactive)
};
} // namespace priv

View file

@ -35,28 +35,28 @@ namespace priv
////////////////////////////////////////////////////////////
ThreadLocalImpl::ThreadLocalImpl()
{
pthread_key_create(&myKey, NULL);
pthread_key_create(&m_key, NULL);
}
////////////////////////////////////////////////////////////
ThreadLocalImpl::~ThreadLocalImpl()
{
pthread_key_delete(myKey);
pthread_key_delete(m_key);
}
////////////////////////////////////////////////////////////
void ThreadLocalImpl::SetValue(void* value)
{
pthread_setspecific(myKey, value);
pthread_setspecific(m_key, value);
}
////////////////////////////////////////////////////////////
void* ThreadLocalImpl::GetValue() const
{
return pthread_getspecific(myKey);
return pthread_getspecific(m_key);
}
} // namespace priv

View file

@ -76,7 +76,7 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
pthread_key_t myKey; ///< Index of our thread-local storage slot
pthread_key_t m_key; ///< Index of our thread-local storage slot
};
} // namespace priv

View file

@ -35,28 +35,28 @@ namespace priv
////////////////////////////////////////////////////////////
MutexImpl::MutexImpl()
{
InitializeCriticalSection(&myMutex);
InitializeCriticalSection(&m_mutex);
}
////////////////////////////////////////////////////////////
MutexImpl::~MutexImpl()
{
DeleteCriticalSection(&myMutex);
DeleteCriticalSection(&m_mutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
EnterCriticalSection(&myMutex);
EnterCriticalSection(&m_mutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Unlock()
{
LeaveCriticalSection(&myMutex);
LeaveCriticalSection(&m_mutex);
}
} // namespace priv

View file

@ -72,7 +72,7 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
CRITICAL_SECTION myMutex; ///< Win32 handle of the mutex
CRITICAL_SECTION m_mutex; ///< Win32 handle of the mutex
};
} // namespace priv

View file

@ -39,9 +39,9 @@ namespace priv
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner)
{
myThread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &ThreadImpl::EntryPoint, owner, 0, &myThreadId));
m_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &ThreadImpl::EntryPoint, owner, 0, &m_threadId));
if (!myThread)
if (!m_thread)
Err() << "Failed to create thread" << std::endl;
}
@ -49,18 +49,18 @@ ThreadImpl::ThreadImpl(Thread* owner)
////////////////////////////////////////////////////////////
ThreadImpl::~ThreadImpl()
{
if (myThread)
CloseHandle(myThread);
if (m_thread)
CloseHandle(m_thread);
}
////////////////////////////////////////////////////////////
void ThreadImpl::Wait()
{
if (myThread)
if (m_thread)
{
assert(myThreadId != GetCurrentThreadId()); // A thread cannot wait for itself!
WaitForSingleObject(myThread, INFINITE);
assert(m_threadId != GetCurrentThreadId()); // A thread cannot wait for itself!
WaitForSingleObject(m_thread, INFINITE);
}
}
@ -68,8 +68,8 @@ void ThreadImpl::Wait()
////////////////////////////////////////////////////////////
void ThreadImpl::Terminate()
{
if (myThread)
TerminateThread(myThread, 0);
if (m_thread)
TerminateThread(m_thread, 0);
}

View file

@ -86,8 +86,8 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
HANDLE myThread; ///< Win32 thread handle
unsigned int myThreadId; ///< Win32 thread identifier
HANDLE m_thread; ///< Win32 thread handle
unsigned int m_threadId; ///< Win32 thread identifier
};
} // namespace priv

View file

@ -35,28 +35,28 @@ namespace priv
////////////////////////////////////////////////////////////
ThreadLocalImpl::ThreadLocalImpl()
{
myIndex = TlsAlloc();
m_index = TlsAlloc();
}
////////////////////////////////////////////////////////////
ThreadLocalImpl::~ThreadLocalImpl()
{
TlsFree(myIndex);
TlsFree(m_index);
}
////////////////////////////////////////////////////////////
void ThreadLocalImpl::SetValue(void* value)
{
TlsSetValue(myIndex, value);
TlsSetValue(m_index, value);
}
////////////////////////////////////////////////////////////
void* ThreadLocalImpl::GetValue() const
{
return TlsGetValue(myIndex);
return TlsGetValue(m_index);
}
} // namespace priv

View file

@ -76,7 +76,7 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
DWORD myIndex; ///< Index of our thread-local storage slot
DWORD m_index; ///< Index of our thread-local storage slot
};
} // namespace priv

View file

@ -34,7 +34,7 @@ namespace sf
////////////////////////////////////////////////////////////
Context::Context()
{
myContext = priv::GlContext::Create();
m_context = priv::GlContext::Create();
SetActive(true);
}
@ -42,21 +42,21 @@ Context::Context()
////////////////////////////////////////////////////////////
Context::~Context()
{
delete myContext;
delete m_context;
}
////////////////////////////////////////////////////////////
bool Context::SetActive(bool active)
{
return myContext->SetActive(active);
return m_context->SetActive(active);
}
////////////////////////////////////////////////////////////
Context::Context(const ContextSettings& settings, unsigned int width, unsigned int height)
{
myContext = priv::GlContext::Create(settings, width, height);
m_context = priv::GlContext::Create(settings, width, height);
SetActive(true);
}

View file

@ -186,7 +186,7 @@ GlContext::~GlContext()
////////////////////////////////////////////////////////////
const ContextSettings& GlContext::GetSettings() const
{
return mySettings;
return m_settings;
}
@ -260,18 +260,18 @@ void GlContext::Initialize()
if (version)
{
// The beginning of the returned string is "major.minor" (this is standard)
mySettings.MajorVersion = version[0] - '0';
mySettings.MinorVersion = version[2] - '0';
m_settings.MajorVersion = version[0] - '0';
m_settings.MinorVersion = version[2] - '0';
}
else
{
// Can't get the version number, assume 2.0
mySettings.MajorVersion = 2;
mySettings.MinorVersion = 0;
m_settings.MajorVersion = 2;
m_settings.MinorVersion = 0;
}
// Enable antialiasing if needed
if (mySettings.AntialiasingLevel > 0)
if (m_settings.AntialiasingLevel > 0)
glEnable(GL_MULTISAMPLE_ARB);
}

View file

@ -216,7 +216,7 @@ protected :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
ContextSettings mySettings; ///< Creation settings of the context
ContextSettings m_settings; ///< Creation settings of the context
private:

View file

@ -43,14 +43,14 @@ JoystickManager& JoystickManager::GetInstance()
////////////////////////////////////////////////////////////
const JoystickCaps& JoystickManager::GetCapabilities(unsigned int joystick) const
{
return myJoysticks[joystick].Capabilities;
return m_joysticks[joystick].Capabilities;
}
////////////////////////////////////////////////////////////
const JoystickState& JoystickManager::GetState(unsigned int joystick) const
{
return myJoysticks[joystick].State;
return m_joysticks[joystick].State;
}
@ -59,7 +59,7 @@ void JoystickManager::Update()
{
for (int i = 0; i < Joystick::Count; ++i)
{
Item& item = myJoysticks[i];
Item& item = m_joysticks[i];
if (item.State.Connected)
{
@ -101,8 +101,8 @@ JoystickManager::~JoystickManager()
{
for (int i = 0; i < Joystick::Count; ++i)
{
if (myJoysticks[i].State.Connected)
myJoysticks[i].Joystick.Close();
if (m_joysticks[i].State.Connected)
m_joysticks[i].Joystick.Close();
}
}

View file

@ -107,7 +107,7 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Item myJoysticks[Joystick::Count]; ///< Joysticks information and state
Item m_joysticks[Joystick::Count]; ///< Joysticks information and state
};
} // namespace priv

View file

@ -39,23 +39,23 @@ namespace priv
{
////////////////////////////////////////////////////////////
GlxContext::GlxContext(GlxContext* shared) :
myWindow (0),
myContext (NULL),
myOwnsWindow(true)
m_window (0),
m_context (NULL),
m_ownsWindow(true)
{
// Open a connection with the X server
myDisplay = XOpenDisplay(NULL);
m_display = XOpenDisplay(NULL);
// Create a dummy window (disabled and hidden)
int screen = DefaultScreen(myDisplay);
myWindow = XCreateWindow(myDisplay,
RootWindow(myDisplay, screen),
int screen = DefaultScreen(m_display);
m_window = XCreateWindow(m_display,
RootWindow(m_display, screen),
0, 0,
1, 1,
0,
DefaultDepth(myDisplay, screen),
DefaultDepth(m_display, screen),
InputOutput,
DefaultVisual(myDisplay, screen),
DefaultVisual(m_display, screen),
0, NULL);
// Create the context
@ -65,41 +65,41 @@ myOwnsWindow(true)
////////////////////////////////////////////////////////////
GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) :
myWindow (0),
myContext (NULL),
myOwnsWindow(false)
m_window (0),
m_context (NULL),
m_ownsWindow(false)
{
// Use the same display as the owner window (important!)
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
m_display = static_cast<const WindowImplX11*>(owner)->GetDisplay();
// Get the owner window and its device context
myWindow = static_cast< ::Window>(owner->GetSystemHandle());
m_window = static_cast< ::Window>(owner->GetSystemHandle());
// Create the context
if (myWindow)
if (m_window)
CreateContext(shared, bitsPerPixel, settings);
}
////////////////////////////////////////////////////////////
GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
myWindow (0),
myContext (NULL),
myOwnsWindow(true)
m_window (0),
m_context (NULL),
m_ownsWindow(true)
{
// Open a connection with the X server
myDisplay = XOpenDisplay(NULL);
m_display = XOpenDisplay(NULL);
// Create the hidden window
int screen = DefaultScreen(myDisplay);
myWindow = XCreateWindow(myDisplay,
RootWindow(myDisplay, screen),
int screen = DefaultScreen(m_display);
m_window = XCreateWindow(m_display,
RootWindow(m_display, screen),
0, 0,
width, height,
0,
DefaultDepth(myDisplay, screen),
DefaultDepth(m_display, screen),
InputOutput,
DefaultVisual(myDisplay, screen),
DefaultVisual(m_display, screen),
0, NULL);
// Create the context
@ -111,38 +111,38 @@ myOwnsWindow(true)
GlxContext::~GlxContext()
{
// Destroy the context
if (myContext)
if (m_context)
{
if (glXGetCurrentContext() == myContext)
glXMakeCurrent(myDisplay, None, NULL);
glXDestroyContext(myDisplay, myContext);
if (glXGetCurrentContext() == m_context)
glXMakeCurrent(m_display, None, NULL);
glXDestroyContext(m_display, m_context);
}
// Destroy the window if we own it
if (myWindow && myOwnsWindow)
if (m_window && m_ownsWindow)
{
XDestroyWindow(myDisplay, myWindow);
XFlush(myDisplay);
XDestroyWindow(m_display, m_window);
XFlush(m_display);
}
// Close the connection with the X server
if (myOwnsWindow)
XCloseDisplay(myDisplay);
if (m_ownsWindow)
XCloseDisplay(m_display);
}
////////////////////////////////////////////////////////////
bool GlxContext::MakeCurrent()
{
return myContext && glXMakeCurrent(myDisplay, myWindow, myContext);
return m_context && glXMakeCurrent(m_display, m_window, m_context);
}
////////////////////////////////////////////////////////////
void GlxContext::Display()
{
if (myWindow)
glXSwapBuffers(myDisplay, myWindow);
if (m_window)
glXSwapBuffers(m_display, m_window);
}
@ -160,11 +160,11 @@ void GlxContext::SetVerticalSyncEnabled(bool enabled)
void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings)
{
// Save the creation settings
mySettings = settings;
m_settings = settings;
// Get the attributes of the target window
XWindowAttributes windowAttributes;
if (XGetWindowAttributes(myDisplay, myWindow, &windowAttributes) == 0)
if (XGetWindowAttributes(m_display, m_window, &windowAttributes) == 0)
{
Err() << "Failed to get the window attributes" << std::endl;
return;
@ -174,11 +174,11 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co
XVisualInfo tpl;
tpl.depth = windowAttributes.depth;
tpl.visualid = XVisualIDFromVisual(windowAttributes.visual);
tpl.screen = DefaultScreen(myDisplay);
tpl.screen = DefaultScreen(m_display);
// Get all the visuals matching the template
int nbVisuals = 0;
XVisualInfo* visuals = XGetVisualInfo(myDisplay, VisualDepthMask | VisualIDMask | VisualScreenMask, &tpl, &nbVisuals);
XVisualInfo* visuals = XGetVisualInfo(m_display, VisualDepthMask | VisualIDMask | VisualScreenMask, &tpl, &nbVisuals);
if (!visuals || (nbVisuals == 0))
{
if (visuals)
@ -194,16 +194,16 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co
{
// Get the current visual attributes
int RGBA, doubleBuffer, red, green, blue, alpha, depth, stencil, multiSampling, samples;
glXGetConfig(myDisplay, &visuals[i], GLX_RGBA, &RGBA);
glXGetConfig(myDisplay, &visuals[i], GLX_DOUBLEBUFFER, &doubleBuffer);
glXGetConfig(myDisplay, &visuals[i], GLX_RED_SIZE, &red);
glXGetConfig(myDisplay, &visuals[i], GLX_GREEN_SIZE, &green);
glXGetConfig(myDisplay, &visuals[i], GLX_BLUE_SIZE, &blue);
glXGetConfig(myDisplay, &visuals[i], GLX_ALPHA_SIZE, &alpha);
glXGetConfig(myDisplay, &visuals[i], GLX_DEPTH_SIZE, &depth);
glXGetConfig(myDisplay, &visuals[i], GLX_STENCIL_SIZE, &stencil);
glXGetConfig(myDisplay, &visuals[i], GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
glXGetConfig(myDisplay, &visuals[i], GLX_SAMPLES_ARB, &samples);
glXGetConfig(m_display, &visuals[i], GLX_RGBA, &RGBA);
glXGetConfig(m_display, &visuals[i], GLX_DOUBLEBUFFER, &doubleBuffer);
glXGetConfig(m_display, &visuals[i], GLX_RED_SIZE, &red);
glXGetConfig(m_display, &visuals[i], GLX_GREEN_SIZE, &green);
glXGetConfig(m_display, &visuals[i], GLX_BLUE_SIZE, &blue);
glXGetConfig(m_display, &visuals[i], GLX_ALPHA_SIZE, &alpha);
glXGetConfig(m_display, &visuals[i], GLX_DEPTH_SIZE, &depth);
glXGetConfig(m_display, &visuals[i], GLX_STENCIL_SIZE, &stencil);
glXGetConfig(m_display, &visuals[i], GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
glXGetConfig(m_display, &visuals[i], GLX_SAMPLES_ARB, &samples);
// First check the mandatory parameters
if ((RGBA == 0) || (doubleBuffer == 0))
@ -211,7 +211,7 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co
// Evaluate the current configuration
int color = red + green + blue + alpha;
int score = EvaluateFormat(bitsPerPixel, mySettings, color, depth, stencil, multiSampling ? samples : 0);
int score = EvaluateFormat(bitsPerPixel, m_settings, color, depth, stencil, multiSampling ? samples : 0);
// Keep it if it's better than the current best
if (score < bestScore)
@ -229,28 +229,28 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co
}
// Get the context to share display lists with
GLXContext toShare = shared ? shared->myContext : NULL;
GLXContext toShare = shared ? shared->m_context : NULL;
// Create the OpenGL context -- first try context versions >= 3.0 if it is requested (they require special code)
while (!myContext && (mySettings.MajorVersion >= 3))
while (!m_context && (m_settings.MajorVersion >= 3))
{
const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
if (glXCreateContextAttribsARB)
{
int nbConfigs = 0;
GLXFBConfig* configs = glXChooseFBConfig(myDisplay, DefaultScreen(myDisplay), NULL, &nbConfigs);
GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), NULL, &nbConfigs);
if (configs && nbConfigs)
{
// Create the context
int attributes[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, mySettings.MajorVersion,
GLX_CONTEXT_MINOR_VERSION_ARB, mySettings.MinorVersion,
GLX_CONTEXT_MAJOR_VERSION_ARB, m_settings.MajorVersion,
GLX_CONTEXT_MINOR_VERSION_ARB, m_settings.MinorVersion,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
0, 0
};
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
m_context = glXCreateContextAttribsARB(m_display, configs[0], toShare, true, attributes);
}
if (configs)
@ -259,31 +259,31 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co
// If we couldn't create the context, lower the version number and try again -- stop at 3.0
// Invalid version numbers will be generated by this algorithm (like 3.9), but we really don't care
if (!myContext)
if (!m_context)
{
if (mySettings.MinorVersion > 0)
if (m_settings.MinorVersion > 0)
{
// If the minor version is not 0, we decrease it and try again
mySettings.MinorVersion--;
m_settings.MinorVersion--;
}
else
{
// If the minor version is 0, we decrease the major version
mySettings.MajorVersion--;
mySettings.MinorVersion = 9;
m_settings.MajorVersion--;
m_settings.MinorVersion = 9;
}
}
}
// If the OpenGL >= 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context
if (!myContext)
if (!m_context)
{
// set the context version to 2.0 (arbitrary)
mySettings.MajorVersion = 2;
mySettings.MinorVersion = 0;
m_settings.MajorVersion = 2;
m_settings.MinorVersion = 0;
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
if (!myContext)
m_context = glXCreateContext(m_display, bestVisual, toShare, true);
if (!m_context)
{
Err() << "Failed to create an OpenGL context for this window" << std::endl;
return;
@ -292,18 +292,18 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co
// Update the creation settings from the chosen format
int depth, stencil, multiSampling, samples;
glXGetConfig(myDisplay, bestVisual, GLX_DEPTH_SIZE, &depth);
glXGetConfig(myDisplay, bestVisual, GLX_STENCIL_SIZE, &stencil);
glXGetConfig(myDisplay, bestVisual, GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
glXGetConfig(myDisplay, bestVisual, GLX_SAMPLES_ARB, &samples);
mySettings.DepthBits = static_cast<unsigned int>(depth);
mySettings.StencilBits = static_cast<unsigned int>(stencil);
mySettings.AntialiasingLevel = multiSampling ? samples : 0;
glXGetConfig(m_display, bestVisual, GLX_DEPTH_SIZE, &depth);
glXGetConfig(m_display, bestVisual, GLX_STENCIL_SIZE, &stencil);
glXGetConfig(m_display, bestVisual, GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
glXGetConfig(m_display, bestVisual, GLX_SAMPLES_ARB, &samples);
m_settings.DepthBits = static_cast<unsigned int>(depth);
m_settings.StencilBits = static_cast<unsigned int>(stencil);
m_settings.AntialiasingLevel = multiSampling ? samples : 0;
// Change the target window's colormap so that it matches the context's one
::Window root = RootWindow(myDisplay, DefaultScreen(myDisplay));
Colormap colorMap = XCreateColormap(myDisplay, root, bestVisual->visual, AllocNone);
XSetWindowColormap(myDisplay, myWindow, colorMap);
::Window root = RootWindow(m_display, DefaultScreen(m_display));
Colormap colorMap = XCreateColormap(m_display, root, bestVisual->visual, AllocNone);
XSetWindowColormap(m_display, m_window, colorMap);
// Free the temporary visuals array
XFree(visuals);

View file

@ -124,10 +124,10 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
::Display* myDisplay; ///< Connection to the X server
::Window myWindow; ///< Window to which the context is attached
GLXContext myContext; ///< OpenGL context
bool myOwnsWindow; ///< Do we own the window associated to the context?
::Display* m_display; ///< Connection to the X server
::Window m_window; ///< Window to which the context is attached
GLXContext m_context; ///< OpenGL context
bool m_ownsWindow; ///< Do we own the window associated to the context?
};
} // namespace priv

View file

@ -53,17 +53,17 @@ bool JoystickImpl::Open(unsigned int index)
std::ostringstream oss;
oss << "/dev/input/js" << index;
myFile = open(oss.str().c_str(), O_RDONLY);
if (myFile > 0)
m_file = open(oss.str().c_str(), O_RDONLY);
if (m_file > 0)
{
// Use non-blocking mode
fcntl(myFile, F_SETFL, O_NONBLOCK);
fcntl(m_file, F_SETFL, O_NONBLOCK);
// Retrieve the axes mapping
ioctl(myFile, JSIOCGAXMAP, myMapping);
ioctl(m_file, JSIOCGAXMAP, m_mapping);
// Reset the joystick state
myState = JoystickState();
m_state = JoystickState();
return true;
}
@ -77,7 +77,7 @@ bool JoystickImpl::Open(unsigned int index)
////////////////////////////////////////////////////////////
void JoystickImpl::Close()
{
close(myFile);
close(m_file);
}
@ -88,17 +88,17 @@ JoystickCaps JoystickImpl::GetCapabilities() const
// Get the number of buttons
char buttonCount;
ioctl(myFile, JSIOCGBUTTONS, &buttonCount);
ioctl(m_file, JSIOCGBUTTONS, &buttonCount);
caps.ButtonCount = buttonCount;
if (caps.ButtonCount > Joystick::ButtonCount)
caps.ButtonCount = Joystick::ButtonCount;
// Get the supported axes
char axesCount;
ioctl(myFile, JSIOCGAXES, &axesCount);
ioctl(m_file, JSIOCGAXES, &axesCount);
for (int i = 0; i < axesCount; ++i)
{
switch (myMapping[i])
switch (m_mapping[i])
{
case ABS_X : caps.Axes[Joystick::X] = true; break;
case ABS_Y : caps.Axes[Joystick::Y] = true; break;
@ -123,7 +123,7 @@ JoystickState JoystickImpl::JoystickImpl::Update()
{
// pop events from the joystick file
js_event joyState;
while (read(myFile, &joyState, sizeof(joyState)) > 0)
while (read(m_file, &joyState, sizeof(joyState)) > 0)
{
switch (joyState.type & ~JS_EVENT_INIT)
{
@ -131,18 +131,18 @@ JoystickState JoystickImpl::JoystickImpl::Update()
case JS_EVENT_AXIS :
{
float value = joyState.value * 100.f / 32767.f;
switch (myMapping[joyState.number])
switch (m_mapping[joyState.number])
{
case ABS_X : myState.Axes[Joystick::X] = value; break;
case ABS_Y : myState.Axes[Joystick::Y] = value; break;
case ABS_X : m_state.Axes[Joystick::X] = value; break;
case ABS_Y : m_state.Axes[Joystick::Y] = value; break;
case ABS_Z :
case ABS_THROTTLE : myState.Axes[Joystick::Z] = value; break;
case ABS_THROTTLE : m_state.Axes[Joystick::Z] = value; break;
case ABS_RZ:
case ABS_RUDDER: myState.Axes[Joystick::R] = value; break;
case ABS_RX : myState.Axes[Joystick::U] = value; break;
case ABS_RY : myState.Axes[Joystick::V] = value; break;
case ABS_HAT0X : myState.Axes[Joystick::PovX] = value; break;
case ABS_HAT0Y : myState.Axes[Joystick::PovY] = value; break;
case ABS_RUDDER: m_state.Axes[Joystick::R] = value; break;
case ABS_RX : m_state.Axes[Joystick::U] = value; break;
case ABS_RY : m_state.Axes[Joystick::V] = value; break;
case ABS_HAT0X : m_state.Axes[Joystick::PovX] = value; break;
case ABS_HAT0Y : m_state.Axes[Joystick::PovY] = value; break;
default : break;
}
break;
@ -152,16 +152,16 @@ JoystickState JoystickImpl::JoystickImpl::Update()
case JS_EVENT_BUTTON :
{
if (joyState.number < Joystick::ButtonCount)
myState.Buttons[joyState.number] = (joyState.value != 0);
m_state.Buttons[joyState.number] = (joyState.value != 0);
break;
}
}
}
// Check the connection state of the joystick (read() fails with an error != EGAIN if it's no longer connected)
myState.Connected = (errno == EAGAIN);
m_state.Connected = (errno == EAGAIN);
return myState;
return m_state;
}
} // namespace priv

View file

@ -96,9 +96,9 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
int myFile; ///< File descriptor of the joystick
char myMapping[ABS_MAX + 1]; ///< Axes mapping (index to axis id)
JoystickState myState; ///< Current state of the joystick
int m_file; ///< File descriptor of the joystick
char m_mapping[ABS_MAX + 1]; ///< Axes mapping (index to axis id)
JoystickState m_state; ///< Current state of the joystick
};
} // namespace priv

View file

@ -62,26 +62,26 @@ namespace priv
{
////////////////////////////////////////////////////////////
WindowImplX11::WindowImplX11(WindowHandle handle) :
myWindow (0),
myInputMethod (NULL),
myInputContext(NULL),
myIsExternal (true),
myAtomClose (0),
myOldVideoMode(-1),
myHiddenCursor(0),
myKeyRepeat (true)
m_window (0),
m_inputMethod (NULL),
m_inputContext(NULL),
m_isExternal (true),
m_atomClose (0),
m_oldVideoMode(-1),
m_hiddenCursor(0),
m_keyRepeat (true)
{
// Open a connection with the X server
myDisplay = XOpenDisplay(NULL);
myScreen = DefaultScreen(myDisplay);
m_display = XOpenDisplay(NULL);
m_screen = DefaultScreen(m_display);
// Save the window handle
myWindow = handle;
m_window = handle;
if (myWindow)
if (m_window)
{
// Make sure the window is listening to all the requiered events
XSelectInput(myDisplay, myWindow, eventMask & ~ButtonPressMask);
XSelectInput(m_display, m_window, eventMask & ~ButtonPressMask);
// Do some common initializations
Initialize();
@ -91,26 +91,26 @@ myKeyRepeat (true)
////////////////////////////////////////////////////////////
WindowImplX11::WindowImplX11(VideoMode mode, const std::string& title, unsigned long style) :
myWindow (0),
myInputMethod (NULL),
myInputContext(NULL),
myIsExternal (false),
myAtomClose (0),
myOldVideoMode(-1),
myHiddenCursor(0),
myKeyRepeat (true)
m_window (0),
m_inputMethod (NULL),
m_inputContext(NULL),
m_isExternal (false),
m_atomClose (0),
m_oldVideoMode(-1),
m_hiddenCursor(0),
m_keyRepeat (true)
{
// Open a connection with the X server
myDisplay = XOpenDisplay(NULL);
myScreen = DefaultScreen(myDisplay);
m_display = XOpenDisplay(NULL);
m_screen = DefaultScreen(m_display);
// Compute position and size
int left, top;
bool fullscreen = (style & Style::Fullscreen) != 0;
if (!fullscreen)
{
left = (DisplayWidth(myDisplay, myScreen) - mode.Width) / 2;
top = (DisplayHeight(myDisplay, myScreen) - mode.Height) / 2;
left = (DisplayWidth(m_display, m_screen) - mode.Width) / 2;
top = (DisplayHeight(m_display, m_screen) - mode.Height) / 2;
}
else
{
@ -130,16 +130,16 @@ myKeyRepeat (true)
attributes.override_redirect = fullscreen;
// Create the window
myWindow = XCreateWindow(myDisplay,
RootWindow(myDisplay, myScreen),
m_window = XCreateWindow(m_display,
RootWindow(m_display, m_screen),
left, top,
width, height,
0,
DefaultDepth(myDisplay, myScreen),
DefaultDepth(m_display, m_screen),
InputOutput,
DefaultVisual(myDisplay, myScreen),
DefaultVisual(m_display, m_screen),
CWEventMask | CWOverrideRedirect, &attributes);
if (!myWindow)
if (!m_window)
{
Err() << "Failed to create window" << std::endl;
return;
@ -151,7 +151,7 @@ myKeyRepeat (true)
// Set the window's style (tell the windows manager to change our window's decorations and functions according to the requested style)
if (!fullscreen)
{
Atom WMHintsAtom = XInternAtom(myDisplay, "_MOTIF_WM_HINTS", false);
Atom WMHintsAtom = XInternAtom(m_display, "_MOTIF_WM_HINTS", false);
if (WMHintsAtom)
{
static const unsigned long MWM_HINTS_FUNCTIONS = 1 << 0;
@ -203,7 +203,7 @@ myKeyRepeat (true)
}
const unsigned char* ptr = reinterpret_cast<const unsigned char*>(&hints);
XChangeProperty(myDisplay, myWindow, WMHintsAtom, WMHintsAtom, 32, PropModeReplace, ptr, 5);
XChangeProperty(m_display, m_window, WMHintsAtom, WMHintsAtom, 32, PropModeReplace, ptr, 5);
}
// This is a hack to force some windows managers to disable resizing
@ -213,7 +213,7 @@ myKeyRepeat (true)
sizeHints.flags = PMinSize | PMaxSize;
sizeHints.min_width = sizeHints.max_width = width;
sizeHints.min_height = sizeHints.max_height = height;
XSetWMNormalHints(myDisplay, myWindow, &sizeHints);
XSetWMNormalHints(m_display, m_window, &sizeHints);
}
}
@ -223,8 +223,8 @@ myKeyRepeat (true)
// In fullscreen mode, we must grab keyboard and mouse inputs
if (fullscreen)
{
XGrabPointer(myDisplay, myWindow, true, 0, GrabModeAsync, GrabModeAsync, myWindow, None, CurrentTime);
XGrabKeyboard(myDisplay, myWindow, true, GrabModeAsync, GrabModeAsync, CurrentTime);
XGrabPointer(m_display, m_window, true, 0, GrabModeAsync, GrabModeAsync, m_window, None, CurrentTime);
XGrabKeyboard(m_display, m_window, true, GrabModeAsync, GrabModeAsync, CurrentTime);
}
}
@ -236,40 +236,40 @@ WindowImplX11::~WindowImplX11()
Cleanup();
// Destroy the cursor
if (myHiddenCursor)
XFreeCursor(myDisplay, myHiddenCursor);
if (m_hiddenCursor)
XFreeCursor(m_display, m_hiddenCursor);
// Destroy the input context
if (myInputContext)
XDestroyIC(myInputContext);
if (m_inputContext)
XDestroyIC(m_inputContext);
// Destroy the window
if (myWindow && !myIsExternal)
if (m_window && !m_isExternal)
{
XDestroyWindow(myDisplay, myWindow);
XFlush(myDisplay);
XDestroyWindow(m_display, m_window);
XFlush(m_display);
}
// Close the input method
if (myInputMethod)
XCloseIM(myInputMethod);
if (m_inputMethod)
XCloseIM(m_inputMethod);
// Close the connection with the X server
XCloseDisplay(myDisplay);
XCloseDisplay(m_display);
}
////////////////////////////////////////////////////////////
::Display* WindowImplX11::GetDisplay() const
{
return myDisplay;
return m_display;
}
////////////////////////////////////////////////////////////
WindowHandle WindowImplX11::GetSystemHandle() const
{
return myWindow;
return m_window;
}
@ -277,7 +277,7 @@ WindowHandle WindowImplX11::GetSystemHandle() const
void WindowImplX11::ProcessEvents()
{
XEvent event;
while (XCheckIfEvent(myDisplay, &event, &CheckEvent, reinterpret_cast<XPointer>(myWindow)))
while (XCheckIfEvent(m_display, &event, &CheckEvent, reinterpret_cast<XPointer>(m_window)))
{
ProcessEvent(event);
}
@ -288,7 +288,7 @@ void WindowImplX11::ProcessEvents()
Vector2i WindowImplX11::GetPosition() const
{
XWindowAttributes attributes;
XGetWindowAttributes(myDisplay, myWindow, &attributes);
XGetWindowAttributes(m_display, m_window, &attributes);
return Vector2i(attributes.x, attributes.y);
}
@ -296,8 +296,8 @@ Vector2i WindowImplX11::GetPosition() const
////////////////////////////////////////////////////////////
void WindowImplX11::SetPosition(const Vector2i& position)
{
XMoveWindow(myDisplay, myWindow, position.x, position.y);
XFlush(myDisplay);
XMoveWindow(m_display, m_window, position.x, position.y);
XFlush(m_display);
}
@ -305,7 +305,7 @@ void WindowImplX11::SetPosition(const Vector2i& position)
Vector2u WindowImplX11::GetSize() const
{
XWindowAttributes attributes;
XGetWindowAttributes(myDisplay, myWindow, &attributes);
XGetWindowAttributes(m_display, m_window, &attributes);
return Vector2u(attributes.width, attributes.height);
}
@ -313,15 +313,15 @@ Vector2u WindowImplX11::GetSize() const
////////////////////////////////////////////////////////////
void WindowImplX11::SetSize(const Vector2u& size)
{
XResizeWindow(myDisplay, myWindow, size.x, size.y);
XFlush(myDisplay);
XResizeWindow(m_display, m_window, size.x, size.y);
XFlush(m_display);
}
////////////////////////////////////////////////////////////
void WindowImplX11::SetTitle(const std::string& title)
{
XStoreName(myDisplay, myWindow, title.c_str());
XStoreName(m_display, m_window, title.c_str());
}
@ -340,19 +340,19 @@ void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8
}
// Create the icon pixmap
Visual* defVisual = DefaultVisual(myDisplay, myScreen);
unsigned int defDepth = DefaultDepth(myDisplay, myScreen);
XImage* iconImage = XCreateImage(myDisplay, defVisual, defDepth, ZPixmap, 0, (char*)iconPixels, width, height, 32, 0);
Visual* defVisual = DefaultVisual(m_display, m_screen);
unsigned int defDepth = DefaultDepth(m_display, m_screen);
XImage* iconImage = XCreateImage(m_display, defVisual, defDepth, ZPixmap, 0, (char*)iconPixels, width, height, 32, 0);
if (!iconImage)
{
Err() << "Failed to set the window's icon" << std::endl;
return;
}
Pixmap iconPixmap = XCreatePixmap(myDisplay, RootWindow(myDisplay, myScreen), width, height, defDepth);
Pixmap iconPixmap = XCreatePixmap(m_display, RootWindow(m_display, m_screen), width, height, defDepth);
XGCValues values;
GC iconGC = XCreateGC(myDisplay, iconPixmap, 0, &values);
XPutImage(myDisplay, iconPixmap, iconGC, iconImage, 0, 0, 0, 0, width, height);
XFreeGC(myDisplay, iconGC);
GC iconGC = XCreateGC(m_display, iconPixmap, 0, &values);
XPutImage(m_display, iconPixmap, iconGC, iconImage, 0, 0, 0, 0, width, height);
XFreeGC(m_display, iconGC);
XDestroyImage(iconImage);
// Create the mask pixmap (must have 1 bit depth)
@ -372,17 +372,17 @@ void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8
}
}
}
Pixmap maskPixmap = XCreatePixmapFromBitmapData(myDisplay, myWindow, (char*)&maskPixels[0], width, height, 1, 0, 1);
Pixmap maskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, (char*)&maskPixels[0], width, height, 1, 0, 1);
// Send our new icon to the window through the WMHints
XWMHints* hints = XAllocWMHints();
hints->flags = IconPixmapHint | IconMaskHint;
hints->icon_pixmap = iconPixmap;
hints->icon_mask = maskPixmap;
XSetWMHints(myDisplay, myWindow, hints);
XSetWMHints(m_display, m_window, hints);
XFree(hints);
XFlush(myDisplay);
XFlush(m_display);
}
@ -390,26 +390,26 @@ void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8
void WindowImplX11::SetVisible(bool visible)
{
if (visible)
XMapWindow(myDisplay, myWindow);
XMapWindow(m_display, m_window);
else
XUnmapWindow(myDisplay, myWindow);
XUnmapWindow(m_display, m_window);
XFlush(myDisplay);
XFlush(m_display);
}
////////////////////////////////////////////////////////////
void WindowImplX11::SetMouseCursorVisible(bool visible)
{
XDefineCursor(myDisplay, myWindow, visible ? None : myHiddenCursor);
XFlush(myDisplay);
XDefineCursor(m_display, m_window, visible ? None : m_hiddenCursor);
XFlush(m_display);
}
////////////////////////////////////////////////////////////
void WindowImplX11::SetKeyRepeatEnabled(bool enabled)
{
myKeyRepeat = enabled;
m_keyRepeat = enabled;
}
@ -418,15 +418,15 @@ void WindowImplX11::SwitchToFullscreen(const VideoMode& mode)
{
// Check if the XRandR extension is present
int version;
if (XQueryExtension(myDisplay, "RANDR", &version, &version, &version))
if (XQueryExtension(m_display, "RANDR", &version, &version, &version))
{
// Get the current configuration
XRRScreenConfiguration* config = XRRGetScreenInfo(myDisplay, RootWindow(myDisplay, myScreen));
XRRScreenConfiguration* config = XRRGetScreenInfo(m_display, RootWindow(m_display, m_screen));
if (config)
{
// Get the current rotation
Rotation currentRotation;
myOldVideoMode = XRRConfigCurrentConfiguration(config, &currentRotation);
m_oldVideoMode = XRRConfigCurrentConfiguration(config, &currentRotation);
// Get the available screen sizes
int nbSizes;
@ -439,7 +439,7 @@ void WindowImplX11::SwitchToFullscreen(const VideoMode& mode)
if ((sizes[i].width == static_cast<int>(mode.Width)) && (sizes[i].height == static_cast<int>(mode.Height)))
{
// Switch to fullscreen mode
XRRSetScreenConfig(myDisplay, config, RootWindow(myDisplay, myScreen), i, currentRotation, CurrentTime);
XRRSetScreenConfig(m_display, config, RootWindow(m_display, m_screen), i, currentRotation, CurrentTime);
// Set "this" as the current fullscreen window
fullscreenWindow = this;
@ -469,38 +469,38 @@ void WindowImplX11::SwitchToFullscreen(const VideoMode& mode)
void WindowImplX11::Initialize()
{
// Make sure the "last key release" is initialized with invalid values
myLastKeyReleaseEvent.type = -1;
m_lastKeyReleaseEvent.type = -1;
// Get the atom defining the close event
myAtomClose = XInternAtom(myDisplay, "WM_DELETE_WINDOW", false);
XSetWMProtocols(myDisplay, myWindow, &myAtomClose, 1);
m_atomClose = XInternAtom(m_display, "WM_DELETE_WINDOW", false);
XSetWMProtocols(m_display, m_window, &m_atomClose, 1);
// Create the input context
myInputMethod = XOpenIM(myDisplay, NULL, NULL, NULL);
if (myInputMethod)
m_inputMethod = XOpenIM(m_display, NULL, NULL, NULL);
if (m_inputMethod)
{
myInputContext = XCreateIC(myInputMethod,
XNClientWindow, myWindow,
XNFocusWindow, myWindow,
m_inputContext = XCreateIC(m_inputMethod,
XNClientWindow, m_window,
XNFocusWindow, m_window,
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
NULL);
}
else
{
myInputContext = NULL;
m_inputContext = NULL;
}
if (!myInputContext)
if (!m_inputContext)
Err() << "Failed to create input context for window -- TextEntered event won't be able to return unicode" << std::endl;
// Show the window
XMapWindow(myDisplay, myWindow);
XFlush(myDisplay);
XMapWindow(m_display, m_window);
XFlush(m_display);
// Create the hiden cursor
CreateHiddenCursor();
// Flush the commands queue
XFlush(myDisplay);
XFlush(m_display);
}
@ -508,19 +508,19 @@ void WindowImplX11::Initialize()
void WindowImplX11::CreateHiddenCursor()
{
// Create the cursor's pixmap (1x1 pixels)
Pixmap cursorPixmap = XCreatePixmap(myDisplay, myWindow, 1, 1, 1);
GC graphicsContext = XCreateGC(myDisplay, cursorPixmap, 0, NULL);
XDrawPoint(myDisplay, cursorPixmap, graphicsContext, 0, 0);
XFreeGC(myDisplay, graphicsContext);
Pixmap cursorPixmap = XCreatePixmap(m_display, m_window, 1, 1, 1);
GC graphicsContext = XCreateGC(m_display, cursorPixmap, 0, NULL);
XDrawPoint(m_display, cursorPixmap, graphicsContext, 0, 0);
XFreeGC(m_display, graphicsContext);
// Create the cursor, using the pixmap as both the shape and the mask of the cursor
XColor color;
color.flags = DoRed | DoGreen | DoBlue;
color.red = color.blue = color.green = 0;
myHiddenCursor = XCreatePixmapCursor(myDisplay, cursorPixmap, cursorPixmap, &color, &color, 0, 0);
m_hiddenCursor = XCreatePixmapCursor(m_display, cursorPixmap, cursorPixmap, &color, &color, 0, 0);
// We don't need the pixmap any longer, free it
XFreePixmap(myDisplay, cursorPixmap);
XFreePixmap(m_display, cursorPixmap);
}
@ -531,7 +531,7 @@ void WindowImplX11::Cleanup()
if (fullscreenWindow == this)
{
// Get current screen info
XRRScreenConfiguration* config = XRRGetScreenInfo(myDisplay, RootWindow(myDisplay, myScreen));
XRRScreenConfiguration* config = XRRGetScreenInfo(m_display, RootWindow(m_display, m_screen));
if (config)
{
// Get the current rotation
@ -539,7 +539,7 @@ void WindowImplX11::Cleanup()
XRRConfigCurrentConfiguration(config, &currentRotation);
// Reset the video mode
XRRSetScreenConfig(myDisplay, config, RootWindow(myDisplay, myScreen), myOldVideoMode, currentRotation, CurrentTime);
XRRSetScreenConfig(m_display, config, RootWindow(m_display, m_screen), m_oldVideoMode, currentRotation, CurrentTime);
// Free the configuration instance
XRRFreeScreenConfigInfo(config);
@ -575,20 +575,20 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
// - KeyPress events are a little bit harder to handle: they depend on the EnableKeyRepeat state,
// and we need to properly forward the first one.
char keys[32];
XQueryKeymap(myDisplay, keys);
XQueryKeymap(m_display, keys);
if (keys[windowEvent.xkey.keycode / 8] & (1 << (windowEvent.xkey.keycode % 8)))
{
// KeyRelease event + key down = repeated event --> discard
if (windowEvent.type == KeyRelease)
{
myLastKeyReleaseEvent = windowEvent;
m_lastKeyReleaseEvent = windowEvent;
return false;
}
// KeyPress event + key repeat disabled + matching KeyRelease event = repeated event --> discard
if ((windowEvent.type == KeyPress) && !myKeyRepeat &&
(myLastKeyReleaseEvent.xkey.keycode == windowEvent.xkey.keycode) &&
(myLastKeyReleaseEvent.xkey.time == windowEvent.xkey.time))
if ((windowEvent.type == KeyPress) && !m_keyRepeat &&
(m_lastKeyReleaseEvent.xkey.keycode == windowEvent.xkey.keycode) &&
(m_lastKeyReleaseEvent.xkey.time == windowEvent.xkey.time))
{
return false;
}
@ -611,8 +611,8 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
case FocusIn :
{
// Update the input context
if (myInputContext)
XSetICFocus(myInputContext);
if (m_inputContext)
XSetICFocus(m_inputContext);
Event event;
event.Type = Event::GainedFocus;
@ -624,8 +624,8 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
case FocusOut :
{
// Update the input context
if (myInputContext)
XUnsetICFocus(myInputContext);
if (m_inputContext)
XUnsetICFocus(m_inputContext);
Event event;
event.Type = Event::LostFocus;
@ -647,7 +647,7 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
// Close event
case ClientMessage :
{
if ((windowEvent.xclient.format == 32) && (windowEvent.xclient.data.l[0]) == static_cast<long>(myAtomClose))
if ((windowEvent.xclient.format == 32) && (windowEvent.xclient.data.l[0]) == static_cast<long>(m_atomClose))
{
Event event;
event.Type = Event::Closed;
@ -680,11 +680,11 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
if (!XFilterEvent(&windowEvent, None))
{
#ifdef X_HAVE_UTF8_STRING
if (myInputContext)
if (m_inputContext)
{
Status status;
Uint8 keyBuffer[16];
int length = Xutf8LookupString(myInputContext, &windowEvent.xkey, reinterpret_cast<char*>(keyBuffer), sizeof(keyBuffer), NULL, &status);
int length = Xutf8LookupString(m_inputContext, &windowEvent.xkey, reinterpret_cast<char*>(keyBuffer), sizeof(keyBuffer), NULL, &status);
if (length > 0)
{
Uint32 unicode = 0;

View file

@ -222,17 +222,17 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
::Window myWindow; ///< X11 structure defining our window
::Display* myDisplay; ///< Pointer to the display
int myScreen; ///< Screen identifier
XIM myInputMethod; ///< Input method linked to the X display
XIC myInputContext; ///< Input context used to get unicode input in our window
bool myIsExternal; ///< Tell whether the window has been created externally or by SFML
Atom myAtomClose; ///< Atom used to identify the close event
int myOldVideoMode; ///< Video mode in use before we switch to fullscreen
Cursor myHiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one
bool myKeyRepeat; ///< Is the KeyRepeat feature enabled ?
XEvent myLastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events)
::Window m_window; ///< X11 structure defining our window
::Display* m_display; ///< Pointer to the display
int m_screen; ///< Screen identifier
XIM m_inputMethod; ///< Input method linked to the X display
XIC m_inputContext; ///< Input context used to get unicode input in our window
bool m_isExternal; ///< Tell whether the window has been created externally or by SFML
Atom m_atomClose; ///< Atom used to identify the close event
int m_oldVideoMode; ///< Video mode in use before we switch to fullscreen
Cursor m_hiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one
bool m_keyRepeat; ///< Is the KeyRepeat feature enabled ?
XEvent m_lastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events)
};
} // namespace priv

View file

@ -49,10 +49,10 @@ bool JoystickImpl::IsConnected(unsigned int index)
bool JoystickImpl::Open(unsigned int index)
{
// No explicit "open" action is required
myIndex = JOYSTICKID1 + index;
m_index = JOYSTICKID1 + index;
// Store the joystick capabilities
return joyGetDevCaps(myIndex, &myCaps, sizeof(myCaps)) == JOYERR_NOERROR;
return joyGetDevCaps(m_index, &m_caps, sizeof(m_caps)) == JOYERR_NOERROR;
}
@ -68,18 +68,18 @@ JoystickCaps JoystickImpl::GetCapabilities() const
{
JoystickCaps caps;
caps.ButtonCount = myCaps.wNumButtons;
caps.ButtonCount = m_caps.wNumButtons;
if (caps.ButtonCount > Joystick::ButtonCount)
caps.ButtonCount = Joystick::ButtonCount;
caps.Axes[Joystick::X] = true;
caps.Axes[Joystick::Y] = true;
caps.Axes[Joystick::Z] = (myCaps.wCaps & JOYCAPS_HASZ) != 0;
caps.Axes[Joystick::R] = (myCaps.wCaps & JOYCAPS_HASR) != 0;
caps.Axes[Joystick::U] = (myCaps.wCaps & JOYCAPS_HASU) != 0;
caps.Axes[Joystick::V] = (myCaps.wCaps & JOYCAPS_HASV) != 0;
caps.Axes[Joystick::PovX] = (myCaps.wCaps & JOYCAPS_HASPOV) != 0;
caps.Axes[Joystick::PovY] = (myCaps.wCaps & JOYCAPS_HASPOV) != 0;
caps.Axes[Joystick::Z] = (m_caps.wCaps & JOYCAPS_HASZ) != 0;
caps.Axes[Joystick::R] = (m_caps.wCaps & JOYCAPS_HASR) != 0;
caps.Axes[Joystick::U] = (m_caps.wCaps & JOYCAPS_HASU) != 0;
caps.Axes[Joystick::V] = (m_caps.wCaps & JOYCAPS_HASV) != 0;
caps.Axes[Joystick::PovX] = (m_caps.wCaps & JOYCAPS_HASPOV) != 0;
caps.Axes[Joystick::PovY] = (m_caps.wCaps & JOYCAPS_HASPOV) != 0;
return caps;
}
@ -93,20 +93,20 @@ JoystickState JoystickImpl::Update()
// Get the current joystick state
JOYINFOEX pos;
pos.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR | JOY_RETURNU | JOY_RETURNV | JOY_RETURNBUTTONS;
pos.dwFlags |= (myCaps.wCaps & JOYCAPS_POVCTS) ? JOY_RETURNPOVCTS : JOY_RETURNPOV;
pos.dwFlags |= (m_caps.wCaps & JOYCAPS_POVCTS) ? JOY_RETURNPOVCTS : JOY_RETURNPOV;
pos.dwSize = sizeof(JOYINFOEX);
if (joyGetPosEx(myIndex, &pos) == JOYERR_NOERROR)
if (joyGetPosEx(m_index, &pos) == JOYERR_NOERROR)
{
// The joystick is connected
state.Connected = true;
// Axes
state.Axes[Joystick::X] = (pos.dwXpos - (myCaps.wXmax + myCaps.wXmin) / 2.f) * 200.f / (myCaps.wXmax - myCaps.wXmin);
state.Axes[Joystick::Y] = (pos.dwYpos - (myCaps.wYmax + myCaps.wYmin) / 2.f) * 200.f / (myCaps.wYmax - myCaps.wYmin);
state.Axes[Joystick::Z] = (pos.dwZpos - (myCaps.wZmax + myCaps.wZmin) / 2.f) * 200.f / (myCaps.wZmax - myCaps.wZmin);
state.Axes[Joystick::R] = (pos.dwRpos - (myCaps.wRmax + myCaps.wRmin) / 2.f) * 200.f / (myCaps.wRmax - myCaps.wRmin);
state.Axes[Joystick::U] = (pos.dwUpos - (myCaps.wUmax + myCaps.wUmin) / 2.f) * 200.f / (myCaps.wUmax - myCaps.wUmin);
state.Axes[Joystick::V] = (pos.dwVpos - (myCaps.wVmax + myCaps.wVmin) / 2.f) * 200.f / (myCaps.wVmax - myCaps.wVmin);
state.Axes[Joystick::X] = (pos.dwXpos - (m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / (m_caps.wXmax - m_caps.wXmin);
state.Axes[Joystick::Y] = (pos.dwYpos - (m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / (m_caps.wYmax - m_caps.wYmin);
state.Axes[Joystick::Z] = (pos.dwZpos - (m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / (m_caps.wZmax - m_caps.wZmin);
state.Axes[Joystick::R] = (pos.dwRpos - (m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / (m_caps.wRmax - m_caps.wRmin);
state.Axes[Joystick::U] = (pos.dwUpos - (m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / (m_caps.wUmax - m_caps.wUmin);
state.Axes[Joystick::V] = (pos.dwVpos - (m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / (m_caps.wVmax - m_caps.wVmin);
// Special case for POV, it is given as an angle
if (pos.dwPOV != 0xFFFF)

View file

@ -95,8 +95,8 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
unsigned int myIndex; ///< Index of the joystick
JOYCAPS myCaps; ///< Joystick capabilities
unsigned int m_index; ///< Index of the joystick
JOYCAPS m_caps; ///< Joystick capabilities
};
} // namespace priv

View file

@ -39,49 +39,49 @@ namespace priv
{
////////////////////////////////////////////////////////////
WglContext::WglContext(WglContext* shared) :
myWindow (NULL),
myDeviceContext(NULL),
myContext (NULL),
myOwnsWindow (true)
m_window (NULL),
m_deviceContext(NULL),
m_context (NULL),
m_ownsWindow (true)
{
// Creating a dummy window is mandatory: we could create a memory DC but then
// its pixel format wouldn't match the regular contexts' format, and thus
// wglShareLists would always fail. Too bad...
// Create a dummy window (disabled and hidden)
myWindow = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);
ShowWindow(myWindow, SW_HIDE);
myDeviceContext = GetDC(myWindow);
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);
ShowWindow(m_window, SW_HIDE);
m_deviceContext = GetDC(m_window);
// Create the context
if (myDeviceContext)
if (m_deviceContext)
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings());
}
////////////////////////////////////////////////////////////
WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) :
myWindow (NULL),
myDeviceContext(NULL),
myContext (NULL),
myOwnsWindow (false)
m_window (NULL),
m_deviceContext(NULL),
m_context (NULL),
m_ownsWindow (false)
{
// Get the owner window and its device context
myWindow = owner->GetSystemHandle();
myDeviceContext = GetDC(myWindow);
m_window = owner->GetSystemHandle();
m_deviceContext = GetDC(m_window);
// Create the context
if (myDeviceContext)
if (m_deviceContext)
CreateContext(shared, bitsPerPixel, settings);
}
////////////////////////////////////////////////////////////
WglContext::WglContext(WglContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
myWindow (NULL),
myDeviceContext(NULL),
myContext (NULL),
myOwnsWindow (true)
m_window (NULL),
m_deviceContext(NULL),
m_context (NULL),
m_ownsWindow (true)
{
// The target of the context is a hidden window.
// We can't create a memory DC (the resulting context wouldn't be compatible
@ -89,12 +89,12 @@ myOwnsWindow (true)
// we can still support them in the future if this solution is not good enough.
// Create the hidden window
myWindow = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);
ShowWindow(myWindow, SW_HIDE);
myDeviceContext = GetDC(myWindow);
m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);
ShowWindow(m_window, SW_HIDE);
m_deviceContext = GetDC(m_window);
// Create the context
if (myDeviceContext)
if (m_deviceContext)
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, settings);
}
@ -103,35 +103,35 @@ myOwnsWindow (true)
WglContext::~WglContext()
{
// Destroy the OpenGL context
if (myContext)
if (m_context)
{
if (wglGetCurrentContext() == myContext)
if (wglGetCurrentContext() == m_context)
wglMakeCurrent(NULL, NULL);
wglDeleteContext(myContext);
wglDeleteContext(m_context);
}
// Destroy the device context
if (myDeviceContext)
ReleaseDC(myWindow, myDeviceContext);
if (m_deviceContext)
ReleaseDC(m_window, m_deviceContext);
// Destroy the window if we own it
if (myWindow && myOwnsWindow)
DestroyWindow(myWindow);
if (m_window && m_ownsWindow)
DestroyWindow(m_window);
}
////////////////////////////////////////////////////////////
bool WglContext::MakeCurrent()
{
return myDeviceContext && myContext && wglMakeCurrent(myDeviceContext, myContext);
return m_deviceContext && m_context && wglMakeCurrent(m_deviceContext, m_context);
}
////////////////////////////////////////////////////////////
void WglContext::Display()
{
if (myDeviceContext && myContext)
SwapBuffers(myDeviceContext);
if (m_deviceContext && m_context)
SwapBuffers(m_deviceContext);
}
@ -148,11 +148,11 @@ void WglContext::SetVerticalSyncEnabled(bool enabled)
void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings)
{
// Save the creation settings
mySettings = settings;
m_settings = settings;
// Let's find a suitable pixel format -- first try with antialiasing
int bestFormat = 0;
if (mySettings.AntialiasingLevel > 0)
if (m_settings.AntialiasingLevel > 0)
{
// Get the wglChoosePixelFormatARB function (it is an extension)
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(wglGetProcAddress("wglChoosePixelFormatARB"));
@ -165,8 +165,8 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB, (mySettings.AntialiasingLevel ? GL_TRUE : GL_FALSE),
WGL_SAMPLES_ARB, mySettings.AntialiasingLevel,
WGL_SAMPLE_BUFFERS_ARB, (m_settings.AntialiasingLevel ? GL_TRUE : GL_FALSE),
WGL_SAMPLES_ARB, m_settings.AntialiasingLevel,
0, 0
};
@ -174,13 +174,13 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
int formats[128];
UINT nbFormats;
float floatAttributes[] = {0, 0};
bool isValid = wglChoosePixelFormatARB(myDeviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0;
while ((!isValid || (nbFormats == 0)) && mySettings.AntialiasingLevel > 0)
bool isValid = wglChoosePixelFormatARB(m_deviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0;
while ((!isValid || (nbFormats == 0)) && m_settings.AntialiasingLevel > 0)
{
// Decrease the antialiasing level until we find a valid one
mySettings.AntialiasingLevel--;
intAttributes[11] = mySettings.AntialiasingLevel;
isValid = wglChoosePixelFormatARB(myDeviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0;
m_settings.AntialiasingLevel--;
intAttributes[11] = m_settings.AntialiasingLevel;
isValid = wglChoosePixelFormatARB(m_deviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0;
}
// Get the best format among the returned ones
@ -193,11 +193,11 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
PIXELFORMATDESCRIPTOR attributes;
attributes.nSize = sizeof(attributes);
attributes.nVersion = 1;
DescribePixelFormat(myDeviceContext, formats[i], sizeof(attributes), &attributes);
DescribePixelFormat(m_deviceContext, formats[i], sizeof(attributes), &attributes);
// Evaluate the current configuration
int color = attributes.cRedBits + attributes.cGreenBits + attributes.cBlueBits + attributes.cAlphaBits;
int score = EvaluateFormat(bitsPerPixel, mySettings, color, attributes.cDepthBits, attributes.cStencilBits, mySettings.AntialiasingLevel);
int score = EvaluateFormat(bitsPerPixel, m_settings, color, attributes.cDepthBits, attributes.cStencilBits, m_settings.AntialiasingLevel);
// Keep it if it's better than the current best
if (score < bestScore)
@ -212,7 +212,7 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
{
// wglChoosePixelFormatARB not supported ; disabling antialiasing
Err() << "Antialiasing is not supported ; it will be disabled" << std::endl;
mySettings.AntialiasingLevel = 0;
m_settings.AntialiasingLevel = 0;
}
}
@ -228,12 +228,12 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
descriptor.iPixelType = PFD_TYPE_RGBA;
descriptor.cColorBits = static_cast<BYTE>(bitsPerPixel);
descriptor.cDepthBits = static_cast<BYTE>(mySettings.DepthBits);
descriptor.cStencilBits = static_cast<BYTE>(mySettings.StencilBits);
descriptor.cDepthBits = static_cast<BYTE>(m_settings.DepthBits);
descriptor.cStencilBits = static_cast<BYTE>(m_settings.StencilBits);
descriptor.cAlphaBits = bitsPerPixel == 32 ? 8 : 0;
// Get the pixel format that best matches our requirements
bestFormat = ChoosePixelFormat(myDeviceContext, &descriptor);
bestFormat = ChoosePixelFormat(m_deviceContext, &descriptor);
if (bestFormat == 0)
{
Err() << "Failed to find a suitable pixel format for device context -- cannot create OpenGL context" << std::endl;
@ -245,63 +245,63 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
PIXELFORMATDESCRIPTOR actualFormat;
actualFormat.nSize = sizeof(actualFormat);
actualFormat.nVersion = 1;
DescribePixelFormat(myDeviceContext, bestFormat, sizeof(actualFormat), &actualFormat);
mySettings.DepthBits = actualFormat.cDepthBits;
mySettings.StencilBits = actualFormat.cStencilBits;
DescribePixelFormat(m_deviceContext, bestFormat, sizeof(actualFormat), &actualFormat);
m_settings.DepthBits = actualFormat.cDepthBits;
m_settings.StencilBits = actualFormat.cStencilBits;
// Set the chosen pixel format
if (!SetPixelFormat(myDeviceContext, bestFormat, &actualFormat))
if (!SetPixelFormat(m_deviceContext, bestFormat, &actualFormat))
{
Err() << "Failed to set pixel format for device context -- cannot create OpenGL context" << std::endl;
return;
}
// Get the context to share display lists with
HGLRC sharedContext = shared ? shared->myContext : NULL;
HGLRC sharedContext = shared ? shared->m_context : NULL;
// Create the OpenGL context -- first try context versions >= 3.0 if it is requested (they require special code)
while (!myContext && (mySettings.MajorVersion >= 3))
while (!m_context && (m_settings.MajorVersion >= 3))
{
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
if (wglCreateContextAttribsARB)
{
int attributes[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, mySettings.MajorVersion,
WGL_CONTEXT_MINOR_VERSION_ARB, mySettings.MinorVersion,
WGL_CONTEXT_MAJOR_VERSION_ARB, m_settings.MajorVersion,
WGL_CONTEXT_MINOR_VERSION_ARB, m_settings.MinorVersion,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
0, 0
};
myContext = wglCreateContextAttribsARB(myDeviceContext, sharedContext, attributes);
m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, attributes);
}
// If we couldn't create the context, lower the version number and try again -- stop at 3.0
// Invalid version numbers will be generated by this algorithm (like 3.9), but we really don't care
if (!myContext)
if (!m_context)
{
if (mySettings.MinorVersion > 0)
if (m_settings.MinorVersion > 0)
{
// If the minor version is not 0, we decrease it and try again
mySettings.MinorVersion--;
m_settings.MinorVersion--;
}
else
{
// If the minor version is 0, we decrease the major version
mySettings.MajorVersion--;
mySettings.MinorVersion = 9;
m_settings.MajorVersion--;
m_settings.MinorVersion = 9;
}
}
}
// If the OpenGL >= 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context
if (!myContext)
if (!m_context)
{
// set the context version to 2.0 (arbitrary)
mySettings.MajorVersion = 2;
mySettings.MinorVersion = 0;
m_settings.MajorVersion = 2;
m_settings.MinorVersion = 0;
myContext = wglCreateContext(myDeviceContext);
if (!myContext)
m_context = wglCreateContext(m_deviceContext);
if (!m_context)
{
Err() << "Failed to create an OpenGL context for this window" << std::endl;
return;
@ -314,7 +314,7 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co
static Mutex mutex;
Lock lock(mutex);
if (!wglShareLists(sharedContext, myContext))
if (!wglShareLists(sharedContext, m_context))
Err() << "Failed to share the OpenGL context" << std::endl;
}
}

View file

@ -124,10 +124,10 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
HWND myWindow; ///< Window to which the context is attached
HDC myDeviceContext; ///< Device context associated to the context
HGLRC myContext; ///< OpenGL context
bool myOwnsWindow; ///< Do we own the target window?
HWND m_window; ///< Window to which the context is attached
HDC m_deviceContext; ///< Device context associated to the context
HGLRC m_context; ///< OpenGL context
bool m_ownsWindow; ///< Do we own the target window?
};
} // namespace priv

View file

@ -61,30 +61,30 @@ namespace priv
{
////////////////////////////////////////////////////////////
WindowImplWin32::WindowImplWin32(WindowHandle handle) :
myHandle (handle),
myCallback (0),
myCursor (NULL),
myIcon (NULL),
myKeyRepeatEnabled(true),
myIsCursorIn (false)
m_handle (handle),
m_callback (0),
m_cursor (NULL),
m_icon (NULL),
m_keyRepeatEnabled(true),
m_isCursorIn (false)
{
if (myHandle)
if (m_handle)
{
// We change the event procedure of the control (it is important to save the old one)
SetWindowLongPtr(myHandle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
myCallback = SetWindowLongPtr(myHandle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&WindowImplWin32::GlobalOnEvent));
SetWindowLongPtr(m_handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
m_callback = SetWindowLongPtr(m_handle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&WindowImplWin32::GlobalOnEvent));
}
}
////////////////////////////////////////////////////////////
WindowImplWin32::WindowImplWin32(VideoMode mode, const std::string& title, Uint32 style) :
myHandle (NULL),
myCallback (0),
myCursor (NULL),
myIcon (NULL),
myKeyRepeatEnabled(true),
myIsCursorIn (false)
m_handle (NULL),
m_callback (0),
m_cursor (NULL),
m_icon (NULL),
m_keyRepeatEnabled(true),
m_isCursorIn (false)
{
// Register the window class at first call
if (WindowCount == 0)
@ -127,11 +127,11 @@ myIsCursorIn (false)
wchar_t wTitle[256];
int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast<int>(title.size()), wTitle, sizeof(wTitle) / sizeof(*wTitle));
wTitle[count] = L'\0';
myHandle = CreateWindowW(ClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
m_handle = CreateWindowW(ClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
}
else
{
myHandle = CreateWindowA(ClassNameA, title.c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
m_handle = CreateWindowA(ClassNameA, title.c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
}
// Switch to fullscreen if requested
@ -147,14 +147,14 @@ myIsCursorIn (false)
WindowImplWin32::~WindowImplWin32()
{
// Destroy the custom icon, if any
if (myIcon)
DestroyIcon(myIcon);
if (m_icon)
DestroyIcon(m_icon);
if (!myCallback)
if (!m_callback)
{
// Destroy the window
if (myHandle)
DestroyWindow(myHandle);
if (m_handle)
DestroyWindow(m_handle);
// Decrement the window count
WindowCount--;
@ -175,7 +175,7 @@ WindowImplWin32::~WindowImplWin32()
else
{
// The window is external : remove the hook on its message callback
SetWindowLongPtr(myHandle, GWLP_WNDPROC, myCallback);
SetWindowLongPtr(m_handle, GWLP_WNDPROC, m_callback);
}
}
@ -183,7 +183,7 @@ WindowImplWin32::~WindowImplWin32()
////////////////////////////////////////////////////////////
WindowHandle WindowImplWin32::GetSystemHandle() const
{
return myHandle;
return m_handle;
}
@ -191,10 +191,10 @@ WindowHandle WindowImplWin32::GetSystemHandle() const
void WindowImplWin32::ProcessEvents()
{
// We process the window events only if we own it
if (!myCallback)
if (!m_callback)
{
MSG message;
while (PeekMessage(&message, myHandle, 0, 0, PM_REMOVE))
while (PeekMessage(&message, m_handle, 0, 0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
@ -207,7 +207,7 @@ void WindowImplWin32::ProcessEvents()
Vector2i WindowImplWin32::GetPosition() const
{
RECT rect;
GetWindowRect(myHandle, &rect);
GetWindowRect(m_handle, &rect);
return Vector2i(rect.left, rect.top);
}
@ -216,7 +216,7 @@ Vector2i WindowImplWin32::GetPosition() const
////////////////////////////////////////////////////////////
void WindowImplWin32::SetPosition(const Vector2i& position)
{
SetWindowPos(myHandle, NULL, position.x, position.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
SetWindowPos(m_handle, NULL, position.x, position.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
@ -224,7 +224,7 @@ void WindowImplWin32::SetPosition(const Vector2i& position)
Vector2u WindowImplWin32::GetSize() const
{
RECT rect;
GetClientRect(myHandle, &rect);
GetClientRect(m_handle, &rect);
return Vector2u(rect.right - rect.left, rect.bottom - rect.top);
}
@ -236,18 +236,18 @@ void WindowImplWin32::SetSize(const Vector2u& size)
// SetWindowPos wants the total size of the window (including title bar and borders),
// so we have to compute it
RECT rectangle = {0, 0, size.x, size.y};
AdjustWindowRect(&rectangle, GetWindowLong(myHandle, GWL_STYLE), false);
AdjustWindowRect(&rectangle, GetWindowLong(m_handle, GWL_STYLE), false);
int width = rectangle.right - rectangle.left;
int height = rectangle.bottom - rectangle.top;
SetWindowPos(myHandle, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
SetWindowPos(m_handle, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
}
////////////////////////////////////////////////////////////
void WindowImplWin32::SetTitle(const std::string& title)
{
SetWindowText(myHandle, title.c_str());
SetWindowText(m_handle, title.c_str());
}
@ -255,8 +255,8 @@ void WindowImplWin32::SetTitle(const std::string& title)
void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels)
{
// First destroy the previous one
if (myIcon)
DestroyIcon(myIcon);
if (m_icon)
DestroyIcon(m_icon);
// Windows wants BGRA pixels: swap red and blue channels
std::vector<Uint8> iconPixels(width * height * 4);
@ -269,13 +269,13 @@ void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uin
}
// Create the icon from the pixel array
myIcon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &iconPixels[0]);
m_icon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &iconPixels[0]);
// Set it as both big and small icon of the window
if (myIcon)
if (m_icon)
{
SendMessage(myHandle, WM_SETICON, ICON_BIG, (LPARAM)myIcon);
SendMessage(myHandle, WM_SETICON, ICON_SMALL, (LPARAM)myIcon);
SendMessage(m_handle, WM_SETICON, ICON_BIG, (LPARAM)m_icon);
SendMessage(m_handle, WM_SETICON, ICON_SMALL, (LPARAM)m_icon);
}
else
{
@ -287,7 +287,7 @@ void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uin
////////////////////////////////////////////////////////////
void WindowImplWin32::SetVisible(bool visible)
{
ShowWindow(myHandle, visible ? SW_SHOW : SW_HIDE);
ShowWindow(m_handle, visible ? SW_SHOW : SW_HIDE);
}
@ -295,18 +295,18 @@ void WindowImplWin32::SetVisible(bool visible)
void WindowImplWin32::SetMouseCursorVisible(bool visible)
{
if (visible)
myCursor = LoadCursor(NULL, IDC_ARROW);
m_cursor = LoadCursor(NULL, IDC_ARROW);
else
myCursor = NULL;
m_cursor = NULL;
SetCursor(myCursor);
SetCursor(m_cursor);
}
////////////////////////////////////////////////////////////
void WindowImplWin32::SetKeyRepeatEnabled(bool enabled)
{
myKeyRepeatEnabled = enabled;
m_keyRepeatEnabled = enabled;
}
@ -364,12 +364,12 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode)
}
// Make the window flags compatible with fullscreen mode
SetWindowLong(myHandle, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
SetWindowLong(myHandle, GWL_EXSTYLE, WS_EX_APPWINDOW);
SetWindowLong(m_handle, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
SetWindowLong(m_handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
// Resize the window so that it fits the entire screen
SetWindowPos(myHandle, HWND_TOP, 0, 0, mode.Width, mode.Height, SWP_FRAMECHANGED);
ShowWindow(myHandle, SW_SHOW);
SetWindowPos(m_handle, HWND_TOP, 0, 0, mode.Width, mode.Height, SWP_FRAMECHANGED);
ShowWindow(m_handle, SW_SHOW);
// Set "this" as the current fullscreen window
FullscreenWindow = this;
@ -395,7 +395,7 @@ void WindowImplWin32::Cleanup()
void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
// Don't process any message until window is created
if (myHandle == NULL)
if (m_handle == NULL)
return;
switch (message)
@ -413,7 +413,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
// The mouse has moved, if the cursor is in our window we must refresh the cursor
if (LOWORD(lParam) == HTCLIENT)
SetCursor(myCursor);
SetCursor(m_cursor);
break;
}
@ -435,7 +435,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
// Get the new size
RECT rectangle;
GetClientRect(myHandle, &rectangle);
GetClientRect(m_handle, &rectangle);
Event event;
event.Type = Event::Resized;
@ -467,7 +467,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
// Text event
case WM_CHAR :
{
if (myKeyRepeatEnabled || ((lParam & (1 << 30)) == 0))
if (m_keyRepeatEnabled || ((lParam & (1 << 30)) == 0))
{
Event event;
event.Type = Event::TextEntered;
@ -481,7 +481,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
case WM_KEYDOWN :
case WM_SYSKEYDOWN :
{
if (myKeyRepeatEnabled || ((HIWORD(lParam) & KF_REPEAT) == 0))
if (m_keyRepeatEnabled || ((HIWORD(lParam) & KF_REPEAT) == 0))
{
Event event;
event.Type = Event::KeyPressed;
@ -517,7 +517,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
POINT position;
position.x = static_cast<Int16>(LOWORD(lParam));
position.y = static_cast<Int16>(HIWORD(lParam));
ScreenToClient(myHandle, &position);
ScreenToClient(m_handle, &position);
Event event;
event.Type = Event::MouseWheelMoved;
@ -628,15 +628,15 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEMOVE :
{
// Check if we need to generate a MouseEntered event
if (!myIsCursorIn)
if (!m_isCursorIn)
{
TRACKMOUSEEVENT mouseEvent;
mouseEvent.cbSize = sizeof(TRACKMOUSEEVENT);
mouseEvent.hwndTrack = myHandle;
mouseEvent.hwndTrack = m_handle;
mouseEvent.dwFlags = TME_LEAVE;
TrackMouseEvent(&mouseEvent);
myIsCursorIn = true;
m_isCursorIn = true;
Event event;
event.Type = Event::MouseEntered;
@ -654,7 +654,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
// Mouse leave event
case WM_MOUSELEAVE :
{
myIsCursorIn = false;
m_isCursorIn = false;
Event event;
event.Type = Event::MouseLeft;
@ -825,8 +825,8 @@ LRESULT CALLBACK WindowImplWin32::GlobalOnEvent(HWND handle, UINT message, WPARA
{
window->ProcessEvent(message, wParam, lParam);
if (window->myCallback)
return CallWindowProc(reinterpret_cast<WNDPROC>(window->myCallback), handle, message, wParam, lParam);
if (window->m_callback)
return CallWindowProc(reinterpret_cast<WNDPROC>(window->m_callback), handle, message, wParam, lParam);
}
// We don't forward the WM_CLOSE message to prevent the OS from automatically destroying the window

View file

@ -230,12 +230,12 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
HWND myHandle; ///< Win32 handle of the window
LONG_PTR myCallback; ///< Stores the original event callback function of the control
HCURSOR myCursor; ///< The system cursor to display into the window
HICON myIcon; ///< Custom icon assigned to the window
bool myKeyRepeatEnabled; ///< Automatic key-repeat state for keydown events
bool myIsCursorIn; ///< Is the mouse cursor in the window's area ?
HWND m_handle; ///< Win32 handle of the window
LONG_PTR m_callback; ///< Stores the original event callback function of the control
HCURSOR m_cursor; ///< The system cursor to display into the window
HICON m_icon; ///< Custom icon assigned to the window
bool m_keyRepeatEnabled; ///< Automatic key-repeat state for keydown events
bool m_isCursorIn; ///< Is the mouse cursor in the window's area ?
};
} // namespace priv

View file

@ -42,9 +42,9 @@ namespace sf
{
////////////////////////////////////////////////////////////
Window::Window() :
myImpl (NULL),
myContext (NULL),
myFrameTimeLimit(Time::Zero)
m_impl (NULL),
m_context (NULL),
m_frameTimeLimit(Time::Zero)
{
}
@ -52,9 +52,9 @@ myFrameTimeLimit(Time::Zero)
////////////////////////////////////////////////////////////
Window::Window(VideoMode mode, const std::string& title, Uint32 style, const ContextSettings& settings) :
myImpl (NULL),
myContext (NULL),
myFrameTimeLimit(Time::Zero)
m_impl (NULL),
m_context (NULL),
m_frameTimeLimit(Time::Zero)
{
Create(mode, title, style, settings);
}
@ -62,9 +62,9 @@ myFrameTimeLimit(Time::Zero)
////////////////////////////////////////////////////////////
Window::Window(WindowHandle handle, const ContextSettings& settings) :
myImpl (NULL),
myContext (NULL),
myFrameTimeLimit(Time::Zero)
m_impl (NULL),
m_context (NULL),
m_frameTimeLimit(Time::Zero)
{
Create(handle, settings);
}
@ -111,10 +111,10 @@ void Window::Create(VideoMode mode, const std::string& title, Uint32 style, cons
style |= Style::Titlebar;
// Recreate the window implementation
myImpl = priv::WindowImpl::Create(mode, title, style);
m_impl = priv::WindowImpl::Create(mode, title, style);
// Recreate the context
myContext = priv::GlContext::Create(settings, myImpl, mode.BitsPerPixel);
m_context = priv::GlContext::Create(settings, m_impl, mode.BitsPerPixel);
// Perform common initializations
Initialize();
@ -128,10 +128,10 @@ void Window::Create(WindowHandle handle, const ContextSettings& settings)
Close();
// Recreate the window implementation
myImpl = priv::WindowImpl::Create(handle);
m_impl = priv::WindowImpl::Create(handle);
// Recreate the context
myContext = priv::GlContext::Create(settings, myImpl, VideoMode::GetDesktopMode().BitsPerPixel);
m_context = priv::GlContext::Create(settings, m_impl, VideoMode::GetDesktopMode().BitsPerPixel);
// Perform common initializations
Initialize();
@ -141,18 +141,18 @@ void Window::Create(WindowHandle handle, const ContextSettings& settings)
////////////////////////////////////////////////////////////
void Window::Close()
{
if (myContext)
if (m_context)
{
// Delete the context
delete myContext;
myContext = NULL;
delete m_context;
m_context = NULL;
}
if (myImpl)
if (m_impl)
{
// Delete the window implementation
delete myImpl;
myImpl = NULL;
delete m_impl;
m_impl = NULL;
}
// Update the fullscreen window
@ -164,7 +164,7 @@ void Window::Close()
////////////////////////////////////////////////////////////
bool Window::IsOpen() const
{
return myImpl != NULL;
return m_impl != NULL;
}
@ -173,14 +173,14 @@ const ContextSettings& Window::GetSettings() const
{
static const ContextSettings empty(0, 0, 0);
return myContext ? myContext->GetSettings() : empty;
return m_context ? m_context->GetSettings() : empty;
}
////////////////////////////////////////////////////////////
bool Window::PollEvent(Event& event)
{
if (myImpl && myImpl->PopEvent(event, false))
if (m_impl && m_impl->PopEvent(event, false))
{
return FilterEvent(event);
}
@ -194,7 +194,7 @@ bool Window::PollEvent(Event& event)
////////////////////////////////////////////////////////////
bool Window::WaitEvent(Event& event)
{
if (myImpl && myImpl->PopEvent(event, true))
if (m_impl && m_impl->PopEvent(event, true))
{
return FilterEvent(event);
}
@ -208,54 +208,54 @@ bool Window::WaitEvent(Event& event)
////////////////////////////////////////////////////////////
Vector2i Window::GetPosition() const
{
return myImpl ? myImpl->GetPosition() : Vector2i();
return m_impl ? m_impl->GetPosition() : Vector2i();
}
////////////////////////////////////////////////////////////
void Window::SetPosition(const Vector2i& position)
{
if (myImpl)
myImpl->SetPosition(position);
if (m_impl)
m_impl->SetPosition(position);
}
////////////////////////////////////////////////////////////
Vector2u Window::GetSize() const
{
return myImpl ? myImpl->GetSize() : Vector2u();
return m_impl ? m_impl->GetSize() : Vector2u();
}
////////////////////////////////////////////////////////////
void Window::SetSize(const Vector2u size)
{
if (myImpl)
myImpl->SetSize(size);
if (m_impl)
m_impl->SetSize(size);
}
////////////////////////////////////////////////////////////
void Window::SetTitle(const std::string& title)
{
if (myImpl)
myImpl->SetTitle(title);
if (m_impl)
m_impl->SetTitle(title);
}
////////////////////////////////////////////////////////////
void Window::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels)
{
if (myImpl)
myImpl->SetIcon(width, height, pixels);
if (m_impl)
m_impl->SetIcon(width, height, pixels);
}
////////////////////////////////////////////////////////////
void Window::SetVisible(bool visible)
{
if (myImpl)
myImpl->SetVisible(visible);
if (m_impl)
m_impl->SetVisible(visible);
}
@ -263,23 +263,23 @@ void Window::SetVisible(bool visible)
void Window::SetVerticalSyncEnabled(bool enabled)
{
if (SetActive())
myContext->SetVerticalSyncEnabled(enabled);
m_context->SetVerticalSyncEnabled(enabled);
}
////////////////////////////////////////////////////////////
void Window::SetMouseCursorVisible(bool visible)
{
if (myImpl)
myImpl->SetMouseCursorVisible(visible);
if (m_impl)
m_impl->SetMouseCursorVisible(visible);
}
////////////////////////////////////////////////////////////
void Window::SetKeyRepeatEnabled(bool enabled)
{
if (myImpl)
myImpl->SetKeyRepeatEnabled(enabled);
if (m_impl)
m_impl->SetKeyRepeatEnabled(enabled);
}
@ -287,26 +287,26 @@ void Window::SetKeyRepeatEnabled(bool enabled)
void Window::SetFramerateLimit(unsigned int limit)
{
if (limit > 0)
myFrameTimeLimit = Seconds(1.f / limit);
m_frameTimeLimit = Seconds(1.f / limit);
else
myFrameTimeLimit = Time::Zero;
m_frameTimeLimit = Time::Zero;
}
////////////////////////////////////////////////////////////
void Window::SetJoystickThreshold(float threshold)
{
if (myImpl)
myImpl->SetJoystickThreshold(threshold);
if (m_impl)
m_impl->SetJoystickThreshold(threshold);
}
////////////////////////////////////////////////////////////
bool Window::SetActive(bool active) const
{
if (myContext)
if (m_context)
{
if (myContext->SetActive(active))
if (m_context->SetActive(active))
{
return true;
}
@ -328,13 +328,13 @@ void Window::Display()
{
// Display the backbuffer on screen
if (SetActive())
myContext->Display();
m_context->Display();
// Limit the framerate if needed
if (myFrameTimeLimit != Time::Zero)
if (m_frameTimeLimit != Time::Zero)
{
Sleep(myFrameTimeLimit - myClock.GetElapsedTime());
myClock.Restart();
Sleep(m_frameTimeLimit - m_clock.GetElapsedTime());
m_clock.Restart();
}
}
@ -342,7 +342,7 @@ void Window::Display()
////////////////////////////////////////////////////////////
WindowHandle Window::GetSystemHandle() const
{
return myImpl ? myImpl->GetSystemHandle() : 0;
return m_impl ? m_impl->GetSystemHandle() : 0;
}
@ -381,7 +381,7 @@ void Window::Initialize()
SetKeyRepeatEnabled(true);
// Reset frame time
myClock.Restart();
m_clock.Restart();
// Activate the window
SetActive();

View file

@ -70,12 +70,12 @@ WindowImpl* WindowImpl::Create(WindowHandle handle)
////////////////////////////////////////////////////////////
WindowImpl::WindowImpl() :
myJoyThreshold(0.1f)
m_joyThreshold(0.1f)
{
// Get the initial joystick states
JoystickManager::GetInstance().Update();
for (unsigned int i = 0; i < Joystick::Count; ++i)
myJoyStates[i] = JoystickManager::GetInstance().GetState(i);
m_joyStates[i] = JoystickManager::GetInstance().GetState(i);
}
@ -89,7 +89,7 @@ WindowImpl::~WindowImpl()
////////////////////////////////////////////////////////////
void WindowImpl::SetJoystickThreshold(float threshold)
{
myJoyThreshold = threshold;
m_joyThreshold = threshold;
}
@ -97,7 +97,7 @@ void WindowImpl::SetJoystickThreshold(float threshold)
bool WindowImpl::PopEvent(Event& event, bool block)
{
// If the event queue is empty, let's first check if new events are available from the OS
if (myEvents.empty())
if (m_events.empty())
{
if (!block)
{
@ -112,7 +112,7 @@ bool WindowImpl::PopEvent(Event& event, bool block)
// Here we use a manual wait loop instead of the optimized
// wait-event provided by the OS, so that we don't skip joystick
// events (which require polling)
while (myEvents.empty())
while (m_events.empty())
{
ProcessJoystickEvents();
ProcessEvents();
@ -122,10 +122,10 @@ bool WindowImpl::PopEvent(Event& event, bool block)
}
// Pop the first event of the queue, if it is not empty
if (!myEvents.empty())
if (!m_events.empty())
{
event = myEvents.front();
myEvents.pop();
event = m_events.front();
m_events.pop();
return true;
}
@ -137,7 +137,7 @@ bool WindowImpl::PopEvent(Event& event, bool block)
////////////////////////////////////////////////////////////
void WindowImpl::PushEvent(const Event& event)
{
myEvents.push(event);
m_events.push(event);
}
@ -150,12 +150,12 @@ void WindowImpl::ProcessJoystickEvents()
for (unsigned int i = 0; i < Joystick::Count; ++i)
{
// Copy the previous state of the joystick and get the new one
JoystickState previousState = myJoyStates[i];
myJoyStates[i] = JoystickManager::GetInstance().GetState(i);
JoystickState previousState = m_joyStates[i];
m_joyStates[i] = JoystickManager::GetInstance().GetState(i);
JoystickCaps caps = JoystickManager::GetInstance().GetCapabilities(i);
// Connection state
bool connected = myJoyStates[i].Connected;
bool connected = m_joyStates[i].Connected;
if (previousState.Connected ^ connected)
{
Event event;
@ -173,8 +173,8 @@ void WindowImpl::ProcessJoystickEvents()
{
Joystick::Axis axis = static_cast<Joystick::Axis>(j);
float prevPos = previousState.Axes[axis];
float currPos = myJoyStates[i].Axes[axis];
if (fabs(currPos - prevPos) >= myJoyThreshold)
float currPos = m_joyStates[i].Axes[axis];
if (fabs(currPos - prevPos) >= m_joyThreshold)
{
Event event;
event.Type = Event::JoystickMoved;
@ -190,7 +190,7 @@ void WindowImpl::ProcessJoystickEvents()
for (unsigned int j = 0; j < caps.ButtonCount; ++j)
{
bool prevPressed = previousState.Buttons[j];
bool currPressed = myJoyStates[i].Buttons[j];
bool currPressed = m_joyStates[i].Buttons[j];
if (prevPressed ^ currPressed)
{

View file

@ -228,9 +228,9 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::queue<Event> myEvents; ///< Queue of available events
JoystickState myJoyStates[Joystick::Count]; ///< Previous state of the joysticks
float myJoyThreshold; ///< Joystick threshold (minimum motion for MOVE event to be generated)
std::queue<Event> m_events; ///< Queue of available events
JoystickState m_joyStates[Joystick::Count]; ///< Previous state of the joysticks
float m_joyThreshold; ///< Joystick threshold (minimum motion for MOVE event to be generated)
};
} // namespace priv