Changed the naming convention for member variables (prefix changed from "my" to "m_")
This commit is contained in:
parent
15e9d999b3
commit
ff5b69d312
@ -21,23 +21,23 @@ public :
|
||||
|
||||
const std::string& GetName() const
|
||||
{
|
||||
return myName;
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void Load()
|
||||
{
|
||||
myIsLoaded = sf::Shader::IsAvailable() && OnLoad();
|
||||
m_isLoaded = sf::Shader::IsAvailable() && OnLoad();
|
||||
}
|
||||
|
||||
void Update(float time, float x, float y)
|
||||
{
|
||||
if (myIsLoaded)
|
||||
if (m_isLoaded)
|
||||
OnUpdate(time, x, y);
|
||||
}
|
||||
|
||||
void Draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
if (myIsLoaded)
|
||||
if (m_isLoaded)
|
||||
{
|
||||
OnDraw(target, states);
|
||||
}
|
||||
@ -53,8 +53,8 @@ public :
|
||||
protected :
|
||||
|
||||
Effect(const std::string& name) :
|
||||
myName(name),
|
||||
myIsLoaded(false)
|
||||
m_name(name),
|
||||
m_isLoaded(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -67,8 +67,8 @@ private :
|
||||
|
||||
private :
|
||||
|
||||
std::string myName;
|
||||
bool myIsLoaded;
|
||||
std::string m_name;
|
||||
bool m_isLoaded;
|
||||
};
|
||||
|
||||
#endif // EFFECT_HPP
|
||||
|
@ -23,34 +23,34 @@ public :
|
||||
bool OnLoad()
|
||||
{
|
||||
// Load the texture and initialize the sprite
|
||||
if (!myTexture.LoadFromFile("resources/background.jpg"))
|
||||
if (!m_texture.LoadFromFile("resources/background.jpg"))
|
||||
return false;
|
||||
mySprite.SetTexture(myTexture);
|
||||
m_sprite.SetTexture(m_texture);
|
||||
|
||||
// Load the shader
|
||||
if (!myShader.LoadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
|
||||
if (!m_shader.LoadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
|
||||
return false;
|
||||
myShader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
m_shader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnUpdate(float, float x, float y)
|
||||
{
|
||||
myShader.SetParameter("pixel_threshold", (x + y) / 30);
|
||||
m_shader.SetParameter("pixel_threshold", (x + y) / 30);
|
||||
}
|
||||
|
||||
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &myShader;
|
||||
target.Draw(mySprite, states);
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(m_sprite, states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
sf::Texture myTexture;
|
||||
sf::Sprite mySprite;
|
||||
sf::Shader myShader;
|
||||
sf::Texture m_texture;
|
||||
sf::Sprite m_sprite;
|
||||
sf::Shader m_shader;
|
||||
};
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ public :
|
||||
bool OnLoad()
|
||||
{
|
||||
// Create the text
|
||||
myText.SetString("Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n"
|
||||
m_text.SetString("Praesent suscipit augue in velit pulvinar hendrerit varius purus aliquam.\n"
|
||||
"Mauris mi odio, bibendum quis fringilla a, laoreet vel orci. Proin vitae vulputate tortor.\n"
|
||||
"Praesent cursus ultrices justo, ut feugiat ante vehicula quis.\n"
|
||||
"Donec fringilla scelerisque mauris et viverra.\n"
|
||||
@ -87,11 +87,11 @@ public :
|
||||
"Mauris ultricies dolor sed massa convallis sed aliquet augue fringilla.\n"
|
||||
"Duis erat eros, porta in accumsan in, blandit quis sem.\n"
|
||||
"In hac habitasse platea dictumst. Etiam fringilla est id odio dapibus sit amet semper dui laoreet.\n");
|
||||
myText.SetCharacterSize(22);
|
||||
myText.SetPosition(30, 20);
|
||||
m_text.SetCharacterSize(22);
|
||||
m_text.SetPosition(30, 20);
|
||||
|
||||
// Load the shader
|
||||
if (!myShader.LoadFromFile("resources/wave.vert", "resources/blur.frag"))
|
||||
if (!m_shader.LoadFromFile("resources/wave.vert", "resources/blur.frag"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -99,21 +99,21 @@ public :
|
||||
|
||||
void OnUpdate(float time, float x, float y)
|
||||
{
|
||||
myShader.SetParameter("wave_phase", time);
|
||||
myShader.SetParameter("wave_amplitude", x * 40, y * 40);
|
||||
myShader.SetParameter("blur_radius", (x + y) * 0.008f);
|
||||
m_shader.SetParameter("wave_phase", time);
|
||||
m_shader.SetParameter("wave_amplitude", x * 40, y * 40);
|
||||
m_shader.SetParameter("blur_radius", (x + y) * 0.008f);
|
||||
}
|
||||
|
||||
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &myShader;
|
||||
target.Draw(myText, states);
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(m_text, states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
sf::Text myText;
|
||||
sf::Shader myShader;
|
||||
sf::Text m_text;
|
||||
sf::Shader m_shader;
|
||||
};
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ public :
|
||||
bool OnLoad()
|
||||
{
|
||||
// Create the points
|
||||
myPoints.SetPrimitiveType(sf::Points);
|
||||
m_points.SetPrimitiveType(sf::Points);
|
||||
for (int i = 0; i < 40000; ++i)
|
||||
{
|
||||
float x = static_cast<float>(std::rand() % 800);
|
||||
@ -140,11 +140,11 @@ public :
|
||||
sf::Uint8 r = std::rand() % 255;
|
||||
sf::Uint8 g = std::rand() % 255;
|
||||
sf::Uint8 b = std::rand() % 255;
|
||||
myPoints.Append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
|
||||
m_points.Append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
|
||||
}
|
||||
|
||||
// Load the shader
|
||||
if (!myShader.LoadFromFile("resources/storm.vert", "resources/blink.frag"))
|
||||
if (!m_shader.LoadFromFile("resources/storm.vert", "resources/blink.frag"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -153,22 +153,22 @@ public :
|
||||
void OnUpdate(float time, float x, float y)
|
||||
{
|
||||
float radius = 200 + std::cos(time) * 150;
|
||||
myShader.SetParameter("storm_position", x * 800, y * 600);
|
||||
myShader.SetParameter("storm_inner_radius", radius / 3);
|
||||
myShader.SetParameter("storm_total_radius", radius);
|
||||
myShader.SetParameter("blink_alpha", 0.5f + std::cos(time * 3) * 0.25f);
|
||||
m_shader.SetParameter("storm_position", x * 800, y * 600);
|
||||
m_shader.SetParameter("storm_inner_radius", radius / 3);
|
||||
m_shader.SetParameter("storm_total_radius", radius);
|
||||
m_shader.SetParameter("blink_alpha", 0.5f + std::cos(time * 3) * 0.25f);
|
||||
}
|
||||
|
||||
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &myShader;
|
||||
target.Draw(myPoints, states);
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(m_points, states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
sf::VertexArray myPoints;
|
||||
sf::Shader myShader;
|
||||
sf::VertexArray m_points;
|
||||
sf::Shader m_shader;
|
||||
};
|
||||
|
||||
|
||||
@ -187,71 +187,71 @@ public :
|
||||
bool OnLoad()
|
||||
{
|
||||
// Create the off-screen surface
|
||||
if (!mySurface.Create(800, 600))
|
||||
if (!m_surface.Create(800, 600))
|
||||
return false;
|
||||
mySurface.SetSmooth(true);
|
||||
m_surface.SetSmooth(true);
|
||||
|
||||
// Load the textures
|
||||
if (!myBackgroundTexture.LoadFromFile("resources/sfml.png"))
|
||||
if (!m_backgroundTexture.LoadFromFile("resources/sfml.png"))
|
||||
return false;
|
||||
myBackgroundTexture.SetSmooth(true);
|
||||
if (!myEntityTexture.LoadFromFile("resources/devices.png"))
|
||||
m_backgroundTexture.SetSmooth(true);
|
||||
if (!m_entityTexture.LoadFromFile("resources/devices.png"))
|
||||
return false;
|
||||
myEntityTexture.SetSmooth(true);
|
||||
m_entityTexture.SetSmooth(true);
|
||||
|
||||
// Initialize the background sprite
|
||||
myBackgroundSprite.SetTexture(myBackgroundTexture);
|
||||
myBackgroundSprite.SetPosition(135, 100);
|
||||
m_backgroundSprite.SetTexture(m_backgroundTexture);
|
||||
m_backgroundSprite.SetPosition(135, 100);
|
||||
|
||||
// Load the moving entities
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
sf::Sprite entity(myEntityTexture, sf::IntRect(96 * i, 0, 96, 96));
|
||||
myEntities.push_back(entity);
|
||||
sf::Sprite entity(m_entityTexture, sf::IntRect(96 * i, 0, 96, 96));
|
||||
m_entities.push_back(entity);
|
||||
}
|
||||
|
||||
// Load the shader
|
||||
if (!myShader.LoadFromFile("resources/edge.frag", sf::Shader::Fragment))
|
||||
if (!m_shader.LoadFromFile("resources/edge.frag", sf::Shader::Fragment))
|
||||
return false;
|
||||
myShader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
m_shader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnUpdate(float time, float x, float y)
|
||||
{
|
||||
myShader.SetParameter("edge_threshold", 1 - (x + y) / 2);
|
||||
m_shader.SetParameter("edge_threshold", 1 - (x + y) / 2);
|
||||
|
||||
// Update the position of the moving entities
|
||||
for (std::size_t i = 0; i < myEntities.size(); ++i)
|
||||
for (std::size_t i = 0; i < m_entities.size(); ++i)
|
||||
{
|
||||
float x = std::cos(0.25f * (time * i + (myEntities.size() - i))) * 300 + 350;
|
||||
float y = std::sin(0.25f * (time * (myEntities.size() - i) + i)) * 200 + 250;
|
||||
myEntities[i].SetPosition(x, y);
|
||||
float x = std::cos(0.25f * (time * i + (m_entities.size() - i))) * 300 + 350;
|
||||
float y = std::sin(0.25f * (time * (m_entities.size() - i) + i)) * 200 + 250;
|
||||
m_entities[i].SetPosition(x, y);
|
||||
}
|
||||
|
||||
// Render the updated scene to the off-screen surface
|
||||
mySurface.Clear(sf::Color::White);
|
||||
mySurface.Draw(myBackgroundSprite);
|
||||
for (std::size_t i = 0; i < myEntities.size(); ++i)
|
||||
mySurface.Draw(myEntities[i]);
|
||||
mySurface.Display();
|
||||
m_surface.Clear(sf::Color::White);
|
||||
m_surface.Draw(m_backgroundSprite);
|
||||
for (std::size_t i = 0; i < m_entities.size(); ++i)
|
||||
m_surface.Draw(m_entities[i]);
|
||||
m_surface.Display();
|
||||
}
|
||||
|
||||
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &myShader;
|
||||
target.Draw(sf::Sprite(mySurface.GetTexture()), states);
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(sf::Sprite(m_surface.GetTexture()), states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
sf::RenderTexture mySurface;
|
||||
sf::Texture myBackgroundTexture;
|
||||
sf::Texture myEntityTexture;
|
||||
sf::Sprite myBackgroundSprite;
|
||||
std::vector<sf::Sprite> myEntities;
|
||||
sf::Shader myShader;
|
||||
sf::RenderTexture m_surface;
|
||||
sf::Texture m_backgroundTexture;
|
||||
sf::Texture m_entityTexture;
|
||||
sf::Sprite m_backgroundSprite;
|
||||
std::vector<sf::Sprite> m_entities;
|
||||
sf::Shader m_shader;
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,8 +27,8 @@ public :
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
NetworkRecorder(const sf::IpAddress& host, unsigned short port) :
|
||||
myHost(host),
|
||||
myPort(port)
|
||||
m_host(host),
|
||||
m_port(port)
|
||||
{
|
||||
}
|
||||
|
||||
@ -40,9 +40,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnStart()
|
||||
{
|
||||
if (mySocket.Connect(myHost, myPort) == sf::Socket::Done)
|
||||
if (m_socket.Connect(m_host, m_port) == sf::Socket::Done)
|
||||
{
|
||||
std::cout << "Connected to server " << myHost << std::endl;
|
||||
std::cout << "Connected to server " << m_host << std::endl;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -63,7 +63,7 @@ private :
|
||||
packet.Append(samples, sampleCount * sizeof(sf::Int16));
|
||||
|
||||
// Send the audio packet to the server
|
||||
return mySocket.Send(packet) == sf::Socket::Done;
|
||||
return m_socket.Send(packet) == sf::Socket::Done;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -75,18 +75,18 @@ private :
|
||||
// Send a "end-of-stream" packet
|
||||
sf::Packet packet;
|
||||
packet << endOfStream;
|
||||
mySocket.Send(packet);
|
||||
m_socket.Send(packet);
|
||||
|
||||
// Close the socket
|
||||
mySocket.Disconnect();
|
||||
m_socket.Disconnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::IpAddress myHost; ///< Address of the remote host
|
||||
unsigned short myPort; ///< Remote port
|
||||
sf::TcpSocket mySocket; ///< Socket used to communicate with the server
|
||||
sf::IpAddress m_host; ///< Address of the remote host
|
||||
unsigned short m_port; ///< Remote port
|
||||
sf::TcpSocket m_socket; ///< Socket used to communicate with the server
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,8 +26,8 @@ public :
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
NetworkAudioStream() :
|
||||
myOffset (0),
|
||||
myHasFinished(false)
|
||||
m_offset (0),
|
||||
m_hasFinished(false)
|
||||
{
|
||||
// Set the sound parameters
|
||||
Initialize(1, 44100);
|
||||
@ -39,17 +39,17 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
void Start(unsigned short port)
|
||||
{
|
||||
if (!myHasFinished)
|
||||
if (!m_hasFinished)
|
||||
{
|
||||
// Listen to the given port for incoming connections
|
||||
if (myListener.Listen(port) != sf::Socket::Done)
|
||||
if (m_listener.Listen(port) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
|
||||
|
||||
// Wait for a connection
|
||||
if (myListener.Accept(myClient) != sf::Socket::Done)
|
||||
if (m_listener.Accept(m_client) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Client connected: " << myClient.GetRemoteAddress() << std::endl;
|
||||
std::cout << "Client connected: " << m_client.GetRemoteAddress() << std::endl;
|
||||
|
||||
// Start playback
|
||||
Play();
|
||||
@ -73,26 +73,26 @@ private :
|
||||
virtual bool OnGetData(sf::SoundStream::Chunk& data)
|
||||
{
|
||||
// We have reached the end of the buffer and all audio data have been played : we can stop playback
|
||||
if ((myOffset >= mySamples.size()) && myHasFinished)
|
||||
if ((m_offset >= m_samples.size()) && m_hasFinished)
|
||||
return false;
|
||||
|
||||
// No new data has arrived since last update : wait until we get some
|
||||
while ((myOffset >= mySamples.size()) && !myHasFinished)
|
||||
while ((m_offset >= m_samples.size()) && !m_hasFinished)
|
||||
sf::Sleep(sf::Milliseconds(10));
|
||||
|
||||
// Copy samples into a local buffer to avoid synchronization problems
|
||||
// (don't forget that we run in two separate threads)
|
||||
{
|
||||
sf::Lock lock(myMutex);
|
||||
myTempBuffer.assign(mySamples.begin() + myOffset, mySamples.end());
|
||||
sf::Lock lock(m_mutex);
|
||||
m_tempBuffer.assign(m_samples.begin() + m_offset, m_samples.end());
|
||||
}
|
||||
|
||||
// Fill audio data to pass to the stream
|
||||
data.Samples = &myTempBuffer[0];
|
||||
data.SampleCount = myTempBuffer.size();
|
||||
data.Samples = &m_tempBuffer[0];
|
||||
data.SampleCount = m_tempBuffer.size();
|
||||
|
||||
// Update the playing offset
|
||||
myOffset += myTempBuffer.size();
|
||||
m_offset += m_tempBuffer.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -103,7 +103,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(sf::Time timeOffset)
|
||||
{
|
||||
myOffset = timeOffset.AsMilliseconds() * GetSampleRate() * GetChannelCount() / 1000;
|
||||
m_offset = timeOffset.AsMilliseconds() * GetSampleRate() * GetChannelCount() / 1000;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -112,11 +112,11 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
void ReceiveLoop()
|
||||
{
|
||||
while (!myHasFinished)
|
||||
while (!m_hasFinished)
|
||||
{
|
||||
// Get waiting audio data from the network
|
||||
sf::Packet packet;
|
||||
if (myClient.Receive(packet) != sf::Socket::Done)
|
||||
if (m_client.Receive(packet) != sf::Socket::Done)
|
||||
break;
|
||||
|
||||
// Extract the message ID
|
||||
@ -132,21 +132,21 @@ private :
|
||||
// Don't forget that the other thread can access the sample array at any time
|
||||
// (so we protect any operation on it with the mutex)
|
||||
{
|
||||
sf::Lock lock(myMutex);
|
||||
std::copy(samples, samples + sampleCount, std::back_inserter(mySamples));
|
||||
sf::Lock lock(m_mutex);
|
||||
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
|
||||
}
|
||||
}
|
||||
else if (id == endOfStream)
|
||||
{
|
||||
// End of stream reached : we stop receiving audio data
|
||||
std::cout << "Audio data has been 100% received!" << std::endl;
|
||||
myHasFinished = true;
|
||||
m_hasFinished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Something's wrong...
|
||||
std::cout << "Invalid packet received..." << std::endl;
|
||||
myHasFinished = true;
|
||||
m_hasFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,13 +154,13 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::TcpListener myListener;
|
||||
sf::TcpSocket myClient;
|
||||
sf::Mutex myMutex;
|
||||
std::vector<sf::Int16> mySamples;
|
||||
std::vector<sf::Int16> myTempBuffer;
|
||||
std::size_t myOffset;
|
||||
bool myHasFinished;
|
||||
sf::TcpListener m_listener;
|
||||
sf::TcpSocket m_client;
|
||||
sf::Mutex m_mutex;
|
||||
std::vector<sf::Int16> m_samples;
|
||||
std::vector<sf::Int16> m_tempBuffer;
|
||||
std::size_t m_offset;
|
||||
bool m_hasFinished;
|
||||
};
|
||||
|
||||
|
||||
|
@ -162,10 +162,10 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::SoundFile* myFile; ///< Sound file
|
||||
Time myDuration; ///< Music duration
|
||||
std::vector<Int16> mySamples; ///< Temporary buffer of samples
|
||||
Mutex myMutex; ///< Mutex protecting the data
|
||||
priv::SoundFile* m_file; ///< Sound file
|
||||
Time m_duration; ///< Music duration
|
||||
std::vector<Int16> m_samples; ///< Temporary buffer of samples
|
||||
Mutex m_mutex; ///< Mutex protecting the data
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -215,7 +215,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
const SoundBuffer* myBuffer; ///< Sound buffer bound to the source
|
||||
const SoundBuffer* m_buffer; ///< Sound buffer bound to the source
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -279,10 +279,10 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int myBuffer; ///< OpenAL buffer identifier
|
||||
std::vector<Int16> mySamples; ///< Samples buffer
|
||||
Time myDuration; ///< Sound duration
|
||||
mutable SoundList mySounds; ///< List of sounds that are using this buffer
|
||||
unsigned int m_buffer; ///< OpenAL buffer identifier
|
||||
std::vector<Int16> m_samples; ///< Samples buffer
|
||||
Time m_duration; ///< Sound duration
|
||||
mutable SoundList m_sounds; ///< List of sounds that are using this buffer
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -88,8 +88,8 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<Int16> mySamples; ///< Temporary sample buffer to hold the recorded data
|
||||
SoundBuffer myBuffer; ///< Sound buffer that will contain the recorded data
|
||||
std::vector<Int16> m_samples; ///< Temporary sample buffer to hold the recorded data
|
||||
SoundBuffer m_buffer; ///< Sound buffer that will contain the recorded data
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -181,10 +181,10 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Thread myThread; ///< Thread running the background recording task
|
||||
std::vector<Int16> mySamples; ///< Buffer to store captured samples
|
||||
unsigned int mySampleRate; ///< Sample rate
|
||||
bool myIsCapturing; ///< Capturing state
|
||||
Thread m_thread; ///< Thread running the background recording task
|
||||
std::vector<Int16> m_samples; ///< Buffer to store captured samples
|
||||
unsigned int m_sampleRate; ///< Sample rate
|
||||
bool m_isCapturing; ///< Capturing state
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -260,7 +260,7 @@ protected :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int mySource; ///< OpenAL source identifier
|
||||
unsigned int m_source; ///< OpenAL source identifier
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -281,15 +281,15 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Thread myThread; ///< Thread running the background tasks
|
||||
bool myIsStreaming; ///< Streaming state (true = playing, false = stopped)
|
||||
unsigned int myBuffers[BufferCount]; ///< Sound buffers used to store temporary audio data
|
||||
unsigned int myChannelCount; ///< Number of channels (1 = mono, 2 = stereo, ...)
|
||||
unsigned int mySampleRate; ///< Frequency (samples / second)
|
||||
Uint32 myFormat; ///< Format of the internal sound buffers
|
||||
bool myLoop; ///< Loop flag (true to loop, false to play once)
|
||||
Uint64 mySamplesProcessed; ///< Number of buffers processed since beginning of the stream
|
||||
bool myEndBuffers[BufferCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
|
||||
Thread m_thread; ///< Thread running the background tasks
|
||||
bool m_isStreaming; ///< Streaming state (true = playing, false = stopped)
|
||||
unsigned int m_buffers[BufferCount]; ///< Sound buffers used to store temporary audio data
|
||||
unsigned int m_channelCount; ///< Number of channels (1 = mono, 2 = stereo, ...)
|
||||
unsigned int m_sampleRate; ///< Frequency (samples / second)
|
||||
Uint32 m_format; ///< Format of the internal sound buffers
|
||||
bool m_loop; ///< Loop flag (true to loop, false to play once)
|
||||
Uint64 m_samplesProcessed; ///< Number of buffers processed since beginning of the stream
|
||||
bool m_endBuffers[BufferCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -108,8 +108,8 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
float myRadius; ///< Radius of the circle
|
||||
unsigned int myPointCount; ///< Number of points composing the circle
|
||||
float m_radius; ///< Radius of the circle
|
||||
unsigned int m_pointCount; ///< Number of points composing the circle
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -109,7 +109,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<Vector2f> myPoints; ///< Points composing the convex polygon
|
||||
std::vector<Vector2f> m_points; ///< Points composing the convex polygon
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -103,11 +103,11 @@ private :
|
||||
/// virtual void Draw(sf::RenderTarget& target, RenderStates states) const
|
||||
/// {
|
||||
/// // You can draw other high-level objects
|
||||
/// target.Draw(mySprite, states);
|
||||
/// target.Draw(m_sprite, states);
|
||||
///
|
||||
/// // ... or use the low-level API
|
||||
/// states.Texture = &myTexture;
|
||||
/// target.Draw(myVertices, states);
|
||||
/// states.Texture = &m_texture;
|
||||
/// target.Draw(m_vertices, states);
|
||||
///
|
||||
/// // ... or draw with OpenGL directly
|
||||
/// glBegin(GL_QUADS);
|
||||
@ -115,9 +115,9 @@ private :
|
||||
/// glEnd();
|
||||
/// }
|
||||
///
|
||||
/// sf::Sprite mySprite;
|
||||
/// sf::Texture myTexture;
|
||||
/// sf::VertexArray myVertices;
|
||||
/// sf::Sprite m_sprite;
|
||||
/// sf::Texture m_texture;
|
||||
/// sf::VertexArray m_vertices;
|
||||
/// };
|
||||
/// \endcode
|
||||
///
|
||||
|
@ -293,12 +293,12 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
void* myLibrary; ///< Pointer to the internal library interface (it is typeless to avoid exposing implementation details)
|
||||
void* myFace; ///< Pointer to the internal font face (it is typeless to avoid exposing implementation details)
|
||||
void* myStreamRec; ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details)
|
||||
int* myRefCount; ///< Reference counter used by implicit sharing
|
||||
mutable PageTable myPages; ///< Table containing the glyphs pages by character size
|
||||
mutable std::vector<Uint8> myPixelBuffer; ///< Pixel buffer holding a glyph's pixels before being written to the texture
|
||||
void* m_library; ///< Pointer to the internal library interface (it is typeless to avoid exposing implementation details)
|
||||
void* m_face; ///< Pointer to the internal font face (it is typeless to avoid exposing implementation details)
|
||||
void* m_streamRec; ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details)
|
||||
int* m_refCount; ///< Reference counter used by implicit sharing
|
||||
mutable PageTable m_pages; ///< Table containing the glyphs pages by character size
|
||||
mutable std::vector<Uint8> m_pixelBuffer; ///< Pixel buffer holding a glyph's pixels before being written to the texture
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -267,9 +267,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int myWidth; ///< Image width
|
||||
unsigned int myHeight; ///< Image Height
|
||||
std::vector<Uint8> myPixels; ///< Pixels of the image
|
||||
unsigned int m_width; ///< Image width
|
||||
unsigned int m_height; ///< Image Height
|
||||
std::vector<Uint8> m_pixels; ///< Pixels of the image
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -95,7 +95,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f mySize; ///< Size of the rectangle
|
||||
Vector2f m_size; ///< Size of the rectangle
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -366,9 +366,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
View myDefaultView; ///< Default view
|
||||
View myView; ///< Current view
|
||||
StatesCache myCache; ///< Render states cache
|
||||
View m_defaultView; ///< Default view
|
||||
View m_view; ///< Current view
|
||||
StatesCache m_cache; ///< Render states cache
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -181,8 +181,8 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::RenderTextureImpl* myImpl; ///< Platform/hardware specific implementation
|
||||
Texture myTexture; ///< Target texture to draw on
|
||||
priv::RenderTextureImpl* m_impl; ///< Platform/hardware specific implementation
|
||||
Texture m_texture; ///< Target texture to draw on
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -522,9 +522,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int myShaderProgram; ///< OpenGL identifier for the program
|
||||
int myCurrentTexture; ///< Location of the current texture in the shader
|
||||
TextureTable myTextures; ///< Texture variables in the shader, mapped to their location
|
||||
unsigned int m_shaderProgram; ///< OpenGL identifier for the program
|
||||
int m_currentTexture; ///< Location of the current texture in the shader
|
||||
TextureTable m_textures; ///< Texture variables in the shader, mapped to their location
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -291,15 +291,15 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
const Texture* myTexture; ///< Texture of the shape
|
||||
IntRect myTextureRect; ///< Rectangle defining the area of the source texture to display
|
||||
Color myFillColor; ///< Fill color
|
||||
Color myOutlineColor; ///< Outline color
|
||||
float myOutlineThickness; ///< Thickness of the shape's outline
|
||||
VertexArray myVertices; ///< Vertex array containing the fill geometry
|
||||
VertexArray myOutlineVertices; ///< Vertex array containing the outline geometry
|
||||
FloatRect myInsideBounds; ///< Bounding rectangle of the inside (fill)
|
||||
FloatRect myBounds; ///< Bounding rectangle of the whole shape (outline + fill)
|
||||
const Texture* m_texture; ///< Texture of the shape
|
||||
IntRect m_textureRect; ///< Rectangle defining the area of the source texture to display
|
||||
Color m_fillColor; ///< Fill color
|
||||
Color m_outlineColor; ///< Outline color
|
||||
float m_outlineThickness; ///< Thickness of the shape's outline
|
||||
VertexArray m_vertices; ///< Vertex array containing the fill geometry
|
||||
VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
|
||||
FloatRect m_insideBounds; ///< Bounding rectangle of the inside (fill)
|
||||
FloatRect m_bounds; ///< Bounding rectangle of the whole shape (outline + fill)
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -215,9 +215,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex myVertices[4]; ///< Vertices defining the sprite's geometry
|
||||
const Texture* myTexture; ///< Texture of the sprite
|
||||
IntRect myTextureRect; ///< Rectangle defining the area of the source texture to display
|
||||
Vertex m_vertices[4]; ///< Vertices defining the sprite's geometry
|
||||
const Texture* m_texture; ///< Texture of the sprite
|
||||
IntRect m_textureRect; ///< Rectangle defining the area of the source texture to display
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -284,13 +284,13 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
String myString; ///< String to display
|
||||
const Font* myFont; ///< Font used to display the string
|
||||
unsigned int myCharacterSize; ///< Base size of characters, in pixels
|
||||
Uint32 myStyle; ///< Text style (see Style enum)
|
||||
Color myColor; ///< Text color
|
||||
VertexArray myVertices; ///< Vertex array containing the text's geometry
|
||||
FloatRect myBounds; ///< Bounding rectangle of the text (in local coordinates)
|
||||
String m_string; ///< String to display
|
||||
const Font* m_font; ///< Font used to display the string
|
||||
unsigned int m_characterSize; ///< Base size of characters, in pixels
|
||||
Uint32 m_style; ///< Text style (see Style enum)
|
||||
Color m_color; ///< Text color
|
||||
VertexArray m_vertices; ///< Vertex array containing the text's geometry
|
||||
FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -489,15 +489,15 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int myWidth; ///< Image width
|
||||
unsigned int myHeight; ///< Image Height
|
||||
unsigned int myTextureWidth; ///< Actual texture width (can be greater than image width because of padding)
|
||||
unsigned int myTextureHeight; ///< Actual texture height (can be greater than image height because of padding)
|
||||
unsigned int myTexture; ///< Internal texture identifier
|
||||
bool myIsSmooth; ///< Status of the smooth filter
|
||||
bool myIsRepeated; ///< Is the texture in repeat mode?
|
||||
mutable bool myPixelsFlipped; ///< To work around the inconsistency in Y orientation
|
||||
Uint64 myCacheId; ///< Unique number that identifies the texture to the render target's cache
|
||||
unsigned int m_width; ///< Image width
|
||||
unsigned int m_height; ///< Image Height
|
||||
unsigned int m_textureWidth; ///< Actual texture width (can be greater than image width because of padding)
|
||||
unsigned int m_textureHeight; ///< Actual texture height (can be greater than image height because of padding)
|
||||
unsigned int m_texture; ///< Internal texture identifier
|
||||
bool m_isSmooth; ///< Status of the smooth filter
|
||||
bool m_isRepeated; ///< Is the texture in repeat mode?
|
||||
mutable bool m_pixelsFlipped; ///< To work around the inconsistency in Y orientation
|
||||
Uint64 m_cacheId; ///< Unique number that identifies the texture to the render target's cache
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -358,7 +358,7 @@ private:
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
float myMatrix[16]; ///< 4x4 matrix defining the transformation
|
||||
float m_matrix[16]; ///< 4x4 matrix defining the transformation
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -316,14 +316,14 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f myOrigin; ///< Origin of translation/rotation/scaling of the object
|
||||
Vector2f myPosition; ///< Position of the object in the 2D world
|
||||
float myRotation; ///< Orientation of the object, in degrees
|
||||
Vector2f myScale; ///< Scale of the object
|
||||
mutable Transform myTransform; ///< Combined transformation of the object
|
||||
mutable bool myTransformNeedUpdate; ///< Does the transform need to be recomputed?
|
||||
mutable Transform myInverseTransform; ///< Combined transformation of the object
|
||||
mutable bool myInverseTransformNeedUpdate; ///< Does the transform need to be recomputed?
|
||||
Vector2f m_origin; ///< Origin of translation/rotation/scaling of the object
|
||||
Vector2f m_position; ///< Position of the object in the 2D world
|
||||
float m_rotation; ///< Orientation of the object, in degrees
|
||||
Vector2f m_scale; ///< Scale of the object
|
||||
mutable Transform m_transform; ///< Combined transformation of the object
|
||||
mutable bool m_transformNeedUpdate; ///< Does the transform need to be recomputed?
|
||||
mutable Transform m_inverseTransform; ///< Combined transformation of the object
|
||||
mutable bool m_inverseTransformNeedUpdate; ///< Does the transform need to be recomputed?
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -187,8 +187,8 @@ private:
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<Vertex> myVertices; ///< Vertices contained in the array
|
||||
PrimitiveType myPrimitiveType; ///< Type of primitives to draw
|
||||
std::vector<Vertex> m_vertices; ///< Vertices contained in the array
|
||||
PrimitiveType m_primitiveType; ///< Type of primitives to draw
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -269,14 +269,14 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f myCenter; ///< Center of the view, in scene coordinates
|
||||
Vector2f mySize; ///< Size of the view, in scene coordinates
|
||||
float myRotation; ///< Angle of rotation of the view rectangle, in degrees
|
||||
FloatRect myViewport; ///< Viewport rectangle, expressed as a factor of the render-target's size
|
||||
mutable Transform myTransform; ///< Precomputed projection transform corresponding to the view
|
||||
mutable Transform myInverseTransform; ///< Precomputed inverse projection transform corresponding to the view
|
||||
mutable bool myTransformUpdated; ///< Internal state telling if the transform needs to be updated
|
||||
mutable bool myInvTransformUpdated; ///< Internal state telling if the inverse transform needs to be updated
|
||||
Vector2f m_center; ///< Center of the view, in scene coordinates
|
||||
Vector2f m_size; ///< Size of the view, in scene coordinates
|
||||
float m_rotation; ///< Angle of rotation of the view rectangle, in degrees
|
||||
FloatRect m_viewport; ///< Viewport rectangle, expressed as a factor of the render-target's size
|
||||
mutable Transform m_transform; ///< Precomputed projection transform corresponding to the view
|
||||
mutable Transform m_inverseTransform; ///< Precomputed inverse projection transform corresponding to the view
|
||||
mutable bool m_transformUpdated; ///< Internal state telling if the transform needs to be updated
|
||||
mutable bool m_invTransformUpdated; ///< Internal state telling if the inverse transform needs to be updated
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -177,8 +177,8 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Status myStatus; ///< Status code returned from the server
|
||||
std::string myMessage; ///< Last message received from the server
|
||||
Status m_status; ///< Status code returned from the server
|
||||
std::string m_message; ///< Last message received from the server
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -210,7 +210,7 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::string myDirectory; ///< Directory extracted from the response message
|
||||
std::string m_directory; ///< Directory extracted from the response message
|
||||
};
|
||||
|
||||
|
||||
@ -244,7 +244,7 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<std::string> myFilenames; ///< Filenames extracted from the data
|
||||
std::vector<std::string> m_filenames; ///< Filenames extracted from the data
|
||||
};
|
||||
|
||||
|
||||
@ -517,7 +517,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
TcpSocket myCommandSocket; ///< Socket holding the control connection with the server
|
||||
TcpSocket m_commandSocket; ///< Socket holding the control connection with the server
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -176,12 +176,12 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
FieldTable myFields; ///< Fields of the header associated to their value
|
||||
Method myMethod; ///< Method to use for the request
|
||||
std::string myURI; ///< Target URI of the request
|
||||
unsigned int myMajorVersion; ///< Major HTTP version
|
||||
unsigned int myMinorVersion; ///< Minor HTTP version
|
||||
std::string myBody; ///< Body of the request
|
||||
FieldTable m_fields; ///< Fields of the header associated to their value
|
||||
Method m_method; ///< Method to use for the request
|
||||
std::string m_uRI; ///< Target URI of the request
|
||||
unsigned int m_majorVersion; ///< Major HTTP version
|
||||
unsigned int m_minorVersion; ///< Minor HTTP version
|
||||
std::string m_body; ///< Body of the request
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -324,11 +324,11 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
FieldTable myFields; ///< Fields of the header
|
||||
Status myStatus; ///< Status code
|
||||
unsigned int myMajorVersion; ///< Major HTTP version
|
||||
unsigned int myMinorVersion; ///< Minor HTTP version
|
||||
std::string myBody; ///< Body of the response
|
||||
FieldTable m_fields; ///< Fields of the header
|
||||
Status m_status; ///< Status code
|
||||
unsigned int m_majorVersion; ///< Major HTTP version
|
||||
unsigned int m_minorVersion; ///< Minor HTTP version
|
||||
std::string m_body; ///< Body of the response
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -395,10 +395,10 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
TcpSocket myConnection; ///< Connection to the host
|
||||
IpAddress myHost; ///< Web host address
|
||||
std::string myHostName; ///< Web host name
|
||||
unsigned short myPort; ///< Port used for connection with host
|
||||
TcpSocket m_connection; ///< Connection to the host
|
||||
IpAddress m_host; ///< Web host address
|
||||
std::string m_hostName; ///< Web host name
|
||||
unsigned short m_port; ///< Port used for connection with host
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -190,7 +190,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint32 myAddress; ///< Address stored as an unsigned 32 bits integer
|
||||
Uint32 m_address; ///< Address stored as an unsigned 32 bits integer
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -272,9 +272,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<char> myData; ///< Data stored in the packet
|
||||
std::size_t myReadPos; ///< Current reading position in the packet
|
||||
bool myIsValid; ///< Reading state of the packet
|
||||
std::vector<char> m_data; ///< Data stored in the packet
|
||||
std::size_t m_readPos; ///< Current reading position in the packet
|
||||
bool m_isValid; ///< Reading state of the packet
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -172,9 +172,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Type myType; ///< Type of the socket (TCP or UDP)
|
||||
SocketHandle mySocket; ///< Socket descriptor
|
||||
bool myIsBlocking; ///< Current blocking mode of the socket
|
||||
Type m_type; ///< Type of the socket (TCP or UDP)
|
||||
SocketHandle m_socket; ///< Socket descriptor
|
||||
bool m_isBlocking; ///< Current blocking mode of the socket
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -157,7 +157,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
SocketSelectorImpl* myImpl; ///< Opaque pointer to the implementation (which requires OS-specific types)
|
||||
SocketSelectorImpl* m_impl; ///< Opaque pointer to the implementation (which requires OS-specific types)
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -204,7 +204,7 @@ private:
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
PendingPacket myPendingPacket; ///< Temporary data of the packet currently being received
|
||||
PendingPacket m_pendingPacket; ///< Temporary data of the packet currently being received
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -187,7 +187,7 @@ private:
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<char> myBuffer; ///< Temporary buffer holding the received data in Receive(Packet)
|
||||
std::vector<char> m_buffer; ///< Temporary buffer holding the received data in Receive(Packet)
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -78,7 +78,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Time myStartTime; ///< Time of last reset, in microseconds
|
||||
Time m_startTime; ///< Time of last reset, in microseconds
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -67,7 +67,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Mutex& myMutex; ///< Mutex to lock / unlock
|
||||
Mutex& m_mutex; ///< Mutex to lock / unlock
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -85,7 +85,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::MutexImpl* myMutexImpl; ///< OS-specific implementation
|
||||
priv::MutexImpl* m_mutexImpl; ///< OS-specific implementation
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -400,7 +400,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::basic_string<Uint32> myString; ///< Internal string of UTF-32 characters
|
||||
std::basic_string<Uint32> m_string; ///< Internal string of UTF-32 characters
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -186,8 +186,8 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::ThreadImpl* myImpl; ///< OS-specific implementation of the thread
|
||||
priv::ThreadFunc* myEntryPoint; ///< Abstraction of the function to run
|
||||
priv::ThreadImpl* m_impl; ///< OS-specific implementation of the thread
|
||||
priv::ThreadFunc* m_entryPoint; ///< Abstraction of the function to run
|
||||
};
|
||||
|
||||
#include <SFML/System/Thread.inl>
|
||||
|
@ -35,29 +35,29 @@ struct ThreadFunc
|
||||
template <typename T>
|
||||
struct ThreadFunctor : ThreadFunc
|
||||
{
|
||||
ThreadFunctor(T functor) : myFunctor(functor) {}
|
||||
virtual void Run() {myFunctor();}
|
||||
T myFunctor;
|
||||
ThreadFunctor(T functor) : m_functor(functor) {}
|
||||
virtual void Run() {m_functor();}
|
||||
T m_functor;
|
||||
};
|
||||
|
||||
// Specialization using a functor (including free functions) with one argument
|
||||
template <typename F, typename A>
|
||||
struct ThreadFunctorWithArg : ThreadFunc
|
||||
{
|
||||
ThreadFunctorWithArg(F function, A arg) : myFunction(function), myArg(arg) {}
|
||||
virtual void Run() {myFunction(myArg);}
|
||||
F myFunction;
|
||||
A myArg;
|
||||
ThreadFunctorWithArg(F function, A arg) : m_function(function), m_arg(arg) {}
|
||||
virtual void Run() {m_function(m_arg);}
|
||||
F m_function;
|
||||
A m_arg;
|
||||
};
|
||||
|
||||
// Specialization using a member function
|
||||
template <typename C>
|
||||
struct ThreadMemberFunc : ThreadFunc
|
||||
{
|
||||
ThreadMemberFunc(void(C::*function)(), C* object) : myFunction(function), myObject(object) {}
|
||||
virtual void Run() {(myObject->*myFunction)();}
|
||||
void(C::*myFunction)();
|
||||
C* myObject;
|
||||
ThreadMemberFunc(void(C::*function)(), C* object) : m_function(function), m_object(object) {}
|
||||
virtual void Run() {(m_object->*m_function)();}
|
||||
void(C::*m_function)();
|
||||
C* m_object;
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
@ -66,8 +66,8 @@ struct ThreadMemberFunc : ThreadFunc
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename F>
|
||||
Thread::Thread(F functor) :
|
||||
myImpl (NULL),
|
||||
myEntryPoint(new priv::ThreadFunctor<F>(functor))
|
||||
m_impl (NULL),
|
||||
m_entryPoint(new priv::ThreadFunctor<F>(functor))
|
||||
{
|
||||
}
|
||||
|
||||
@ -75,8 +75,8 @@ myEntryPoint(new priv::ThreadFunctor<F>(functor))
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename F, typename A>
|
||||
Thread::Thread(F function, A argument) :
|
||||
myImpl (NULL),
|
||||
myEntryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
|
||||
m_impl (NULL),
|
||||
m_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
|
||||
{
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ myEntryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename C>
|
||||
Thread::Thread(void(C::*function)(), C* object) :
|
||||
myImpl (NULL),
|
||||
myEntryPoint(new priv::ThreadMemberFunc<C>(function, object))
|
||||
m_impl (NULL),
|
||||
m_entryPoint(new priv::ThreadMemberFunc<C>(function, object))
|
||||
{
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::ThreadLocalImpl* myImpl; ///< Pointer to the OS specific implementation
|
||||
priv::ThreadLocalImpl* m_impl; ///< Pointer to the OS specific implementation
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -106,7 +106,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Int64 myMicroseconds; ///< Time value stored as microseconds
|
||||
Int64 m_microseconds; ///< Time value stored as microseconds
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -95,7 +95,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::GlContext* myContext; ///< Internal OpenGL context
|
||||
priv::GlContext* m_context; ///< Internal OpenGL context
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -467,10 +467,10 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
priv::WindowImpl* myImpl; ///< Platform-specific implementation of the window
|
||||
priv::GlContext* myContext; ///< Platform-specific implementation of the OpenGL context
|
||||
Clock myClock; ///< Clock for measuring the elapsed time between frames
|
||||
Time myFrameTimeLimit; ///< Current framerate limit
|
||||
priv::WindowImpl* m_impl; ///< Platform-specific implementation of the window
|
||||
priv::GlContext* m_context; ///< Platform-specific implementation of the OpenGL context
|
||||
Clock m_clock; ///< Clock for measuring the elapsed time between frames
|
||||
Time m_frameTimeLimit; ///< Current framerate limit
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -64,7 +64,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
GLint myTextureBinding; ///< Texture binding to restore
|
||||
GLint m_textureBinding; ///< Texture binding to restore
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
@ -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],
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user