Changed the naming convention for public member variables/functions and free functions (using lowerCase instead of UpperCase)
This commit is contained in:
parent
ff5b69d312
commit
14ac411542
|
@ -23,47 +23,47 @@
|
|||
///
|
||||
/// // Load a sprite to display
|
||||
/// sf::Texture texture;
|
||||
/// if (!texture.LoadFromFile("cute_image.jpg"))
|
||||
/// if (!texture.loadFromFile("cute_image.jpg"))
|
||||
/// return EXIT_FAILURE;
|
||||
/// sf::Sprite sprite(texture);
|
||||
///
|
||||
/// // Create a graphical text to display
|
||||
/// sf::Font font;
|
||||
/// if (!font.LoadFromFile("arial.ttf"))
|
||||
/// if (!font.loadFromFile("arial.ttf"))
|
||||
/// return EXIT_FAILURE;
|
||||
/// sf::Text text("Hello SFML", font, 50);
|
||||
///
|
||||
/// // Load a music to play
|
||||
/// sf::Music music;
|
||||
/// if (!music.OpenFromFile("nice_music.ogg"))
|
||||
/// if (!music.openFromFile("nice_music.ogg"))
|
||||
/// return EXIT_FAILURE;
|
||||
///
|
||||
/// // Play the music
|
||||
/// music.Play();
|
||||
/// music.play();
|
||||
///
|
||||
/// // Start the game loop
|
||||
/// while (window.IsOpen())
|
||||
/// while (window.isOpen())
|
||||
/// {
|
||||
/// // Process events
|
||||
/// sf::Event event;
|
||||
/// while (window.PollEvent(event))
|
||||
/// while (window.pollEvent(event))
|
||||
/// {
|
||||
/// // Close window : exit
|
||||
/// if (event.Type == sf::Event::Closed)
|
||||
/// window.Close();
|
||||
/// if (event.type == sf::Event::Closed)
|
||||
/// window.close();
|
||||
/// }
|
||||
///
|
||||
/// // Clear screen
|
||||
/// window.Clear();
|
||||
/// window.clear();
|
||||
///
|
||||
/// // Draw the sprite
|
||||
/// window.Draw(sprite);
|
||||
/// window.draw(sprite);
|
||||
///
|
||||
/// // Draw the string
|
||||
/// window.Draw(text);
|
||||
/// window.draw(text);
|
||||
///
|
||||
/// // Update the window
|
||||
/// window.Display();
|
||||
/// window.display();
|
||||
/// }
|
||||
///
|
||||
/// return EXIT_SUCCESS;
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
/// \param Window Target window to initialize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize(sf::Window& window)
|
||||
void initialize(sf::Window& window)
|
||||
{
|
||||
// Activate the window
|
||||
window.SetActive();
|
||||
window.setActive();
|
||||
|
||||
// Setup OpenGL states
|
||||
// Set color and depth clear value
|
||||
|
@ -43,10 +43,10 @@ void Initialize(sf::Window& window)
|
|||
/// \param elapsedTime Time elapsed since the last draw
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Draw(sf::Window& window, float elapsedTime)
|
||||
void draw(sf::Window& window, float elapsedTime)
|
||||
{
|
||||
// Activate the window
|
||||
window.SetActive();
|
||||
window.setActive();
|
||||
|
||||
// Clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -160,8 +160,8 @@ int main()
|
|||
sf::Clock clock;
|
||||
|
||||
// Initialize our views
|
||||
Initialize(SFMLView1);
|
||||
Initialize(SFMLView2);
|
||||
initialize(SFMLView1);
|
||||
initialize(SFMLView2);
|
||||
|
||||
// Start the event loop
|
||||
bool running = true;
|
||||
|
@ -184,12 +184,12 @@ int main()
|
|||
}
|
||||
|
||||
// Draw something into our views
|
||||
Draw(SFMLView1, clock.GetElapsedTime().AsSeconds());
|
||||
Draw(SFMLView2, clock.GetElapsedTime().AsSeconds() * 0.3f);
|
||||
draw(SFMLView1, clock.getElapsedTime().asSeconds());
|
||||
draw(SFMLView2, clock.getElapsedTime().asSeconds() * 0.3f);
|
||||
|
||||
// Display the views on screen
|
||||
SFMLView1.Display();
|
||||
SFMLView2.Display();
|
||||
SFMLView1.display();
|
||||
SFMLView2.display();
|
||||
}
|
||||
|
||||
// Close the display
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
std::ostream& operator <<(std::ostream& stream, const sf::Ftp::Response& response)
|
||||
{
|
||||
return stream << response.GetStatus() << response.GetMessage();
|
||||
return stream << response.getStatus() << response.getMessage();
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,9 +36,9 @@ int main()
|
|||
|
||||
// Connect to the server
|
||||
sf::Ftp server;
|
||||
sf::Ftp::Response connectResponse = server.Connect(address);
|
||||
sf::Ftp::Response connectResponse = server.connect(address);
|
||||
std::cout << connectResponse << std::endl;
|
||||
if (!connectResponse.IsOk())
|
||||
if (!connectResponse.isOk())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Ask for user name and password
|
||||
|
@ -49,9 +49,9 @@ int main()
|
|||
std::cin >> password;
|
||||
|
||||
// Login to the server
|
||||
sf::Ftp::Response loginResponse = server.Login(user, password);
|
||||
sf::Ftp::Response loginResponse = server.login(user, password);
|
||||
std::cout << loginResponse << std::endl;
|
||||
if (!loginResponse.IsOk())
|
||||
if (!loginResponse.isOk())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Main menu
|
||||
|
@ -91,18 +91,18 @@ int main()
|
|||
case 1 :
|
||||
{
|
||||
// Print the current server directory
|
||||
sf::Ftp::DirectoryResponse response = server.GetWorkingDirectory();
|
||||
sf::Ftp::DirectoryResponse response = server.getWorkingDirectory();
|
||||
std::cout << response << std::endl;
|
||||
std::cout << "Current directory is " << response.GetDirectory() << std::endl;
|
||||
std::cout << "Current directory is " << response.getDirectory() << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2 :
|
||||
{
|
||||
// Print the contents of the current server directory
|
||||
sf::Ftp::ListingResponse response = server.GetDirectoryListing();
|
||||
sf::Ftp::ListingResponse response = server.getDirectoryListing();
|
||||
std::cout << response << std::endl;
|
||||
std::vector<std::string> filenames = response.GetFilenames();
|
||||
std::vector<std::string> filenames = response.getFilenames();
|
||||
for (std::vector<std::string>::const_iterator it = filenames.begin(); it != filenames.end(); ++it)
|
||||
std::cout << *it << std::endl;
|
||||
break;
|
||||
|
@ -114,7 +114,7 @@ int main()
|
|||
std::string directory;
|
||||
std::cout << "Choose a directory: ";
|
||||
std::cin >> directory;
|
||||
std::cout << server.ChangeDirectory(directory) << std::endl;
|
||||
std::cout << server.changeDirectory(directory) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ int main()
|
|||
std::string directory;
|
||||
std::cout << "Name of the directory to create: ";
|
||||
std::cin >> directory;
|
||||
std::cout << server.CreateDirectory(directory) << std::endl;
|
||||
std::cout << server.createDirectory(directory) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ int main()
|
|||
std::string directory;
|
||||
std::cout << "Name of the directory to remove: ";
|
||||
std::cin >> directory;
|
||||
std::cout << server.DeleteDirectory(directory) << std::endl;
|
||||
std::cout << server.deleteDirectory(directory) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ int main()
|
|||
std::cin >> source;
|
||||
std::cout << "New name: ";
|
||||
std::cin >> destination;
|
||||
std::cout << server.RenameFile(source, destination) << std::endl;
|
||||
std::cout << server.renameFile(source, destination) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ int main()
|
|||
std::string filename;
|
||||
std::cout << "Name of the file to remove: ";
|
||||
std::cin >> filename;
|
||||
std::cout << server.DeleteFile(filename) << std::endl;
|
||||
std::cout << server.deleteFile(filename) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ int main()
|
|||
std::cin >> filename;
|
||||
std::cout << "Directory to download the file to: ";
|
||||
std::cin >> directory;
|
||||
std::cout << server.Download(filename, directory) << std::endl;
|
||||
std::cout << server.download(filename, directory) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ int main()
|
|||
std::cin >> filename;
|
||||
std::cout << "Directory to upload the file to (relative to current directory): ";
|
||||
std::cin >> directory;
|
||||
std::cout << server.Upload(filename, directory) << std::endl;
|
||||
std::cout << server.upload(filename, directory) << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ int main()
|
|||
|
||||
// Disconnect from the server
|
||||
std::cout << "Disconnecting from server..." << std::endl;
|
||||
std::cout << server.Disconnect() << std::endl;
|
||||
std::cout << server.disconnect() << std::endl;
|
||||
|
||||
// Wait until the user presses 'enter' key
|
||||
std::cout << "Press enter to exit..." << std::endl;
|
||||
|
|
|
@ -16,11 +16,11 @@ int main()
|
|||
{
|
||||
// Create the main window
|
||||
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML OpenGL", sf::Style::Default, sf::ContextSettings(32));
|
||||
window.SetVerticalSyncEnabled(true);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
// Create a sprite for the background
|
||||
sf::Texture backgroundTexture;
|
||||
if (!backgroundTexture.LoadFromFile("resources/background.jpg"))
|
||||
if (!backgroundTexture.loadFromFile("resources/background.jpg"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Sprite background(backgroundTexture);
|
||||
|
||||
|
@ -30,11 +30,11 @@ int main()
|
|||
GLuint texture = 0;
|
||||
{
|
||||
sf::Image image;
|
||||
if (!image.LoadFromFile("resources/texture.jpg"))
|
||||
if (!image.loadFromFile("resources/texture.jpg"))
|
||||
return EXIT_FAILURE;
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.GetWidth(), image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.GetPixelsPtr());
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.getWidth(), image.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.getPixelsPtr());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
|
@ -58,49 +58,49 @@ int main()
|
|||
sf::Clock clock;
|
||||
|
||||
// Start game loop
|
||||
while (window.IsOpen())
|
||||
while (window.isOpen())
|
||||
{
|
||||
// Process events
|
||||
sf::Event event;
|
||||
while (window.PollEvent(event))
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
// Close window : exit
|
||||
if (event.Type == sf::Event::Closed)
|
||||
window.Close();
|
||||
if (event.type == sf::Event::Closed)
|
||||
window.close();
|
||||
|
||||
// Escape key : exit
|
||||
if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape))
|
||||
window.Close();
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
|
||||
window.close();
|
||||
|
||||
// Adjust the viewport when the window is resized
|
||||
if (event.Type == sf::Event::Resized)
|
||||
glViewport(0, 0, event.Size.Width, event.Size.Height);
|
||||
if (event.type == sf::Event::Resized)
|
||||
glViewport(0, 0, event.size.width, event.size.height);
|
||||
}
|
||||
|
||||
// Draw the background
|
||||
window.PushGLStates();
|
||||
window.Draw(background);
|
||||
window.PopGLStates();
|
||||
window.pushGLStates();
|
||||
window.draw(background);
|
||||
window.popGLStates();
|
||||
|
||||
// Activate the window before using OpenGL commands.
|
||||
// This is useless here because we have only one window which is
|
||||
// always the active one, but don't forget it if you use multiple windows
|
||||
window.SetActive();
|
||||
window.setActive();
|
||||
|
||||
// Clear the depth buffer
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// We get the position of the mouse cursor, so that we can move the box accordingly
|
||||
float x = sf::Mouse::GetPosition(window).x * 200.f / window.GetSize().x - 100.f;
|
||||
float y = -sf::Mouse::GetPosition(window).y * 200.f / window.GetSize().y + 100.f;
|
||||
float x = sf::Mouse::getPosition(window).x * 200.f / window.getSize().x - 100.f;
|
||||
float y = -sf::Mouse::getPosition(window).y * 200.f / window.getSize().y + 100.f;
|
||||
|
||||
// Apply some transformations
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(x, y, -100.f);
|
||||
glRotatef(clock.GetElapsedTime().AsSeconds() * 50.f, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime().AsSeconds() * 30.f, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime().AsSeconds() * 90.f, 0.f, 0.f, 1.f);
|
||||
glRotatef(clock.getElapsedTime().asSeconds() * 50.f, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.getElapsedTime().asSeconds() * 30.f, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.getElapsedTime().asSeconds() * 90.f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Draw a cube
|
||||
float size = 20.f;
|
||||
|
@ -139,15 +139,15 @@ int main()
|
|||
glEnd();
|
||||
|
||||
// Draw some text on top of our OpenGL object
|
||||
window.PushGLStates();
|
||||
window.pushGLStates();
|
||||
sf::Text text("SFML / OpenGL demo");
|
||||
text.SetColor(sf::Color(255, 255, 255, 170));
|
||||
text.SetPosition(250.f, 450.f);
|
||||
window.Draw(text);
|
||||
window.PopGLStates();
|
||||
text.setColor(sf::Color(255, 255, 255, 170));
|
||||
text.setPosition(250.f, 450.f);
|
||||
window.draw(text);
|
||||
window.popGLStates();
|
||||
|
||||
// Finally, display the rendered frame on screen
|
||||
window.Display();
|
||||
window.display();
|
||||
}
|
||||
|
||||
// Don't forget to destroy our texture
|
||||
|
|
|
@ -28,54 +28,54 @@ int main()
|
|||
|
||||
// Create the window of the application
|
||||
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "SFML Pong");
|
||||
window.SetVerticalSyncEnabled(true);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
// Load the sounds used in the game
|
||||
sf::SoundBuffer ballSoundBuffer;
|
||||
if (!ballSoundBuffer.LoadFromFile("resources/ball.wav"))
|
||||
if (!ballSoundBuffer.loadFromFile("resources/ball.wav"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Sound ballSound(ballSoundBuffer);
|
||||
|
||||
// Create the left paddle
|
||||
sf::RectangleShape leftPaddle;
|
||||
leftPaddle.SetSize(paddleSize - sf::Vector2f(3, 3));
|
||||
leftPaddle.SetOutlineThickness(3);
|
||||
leftPaddle.SetOutlineColor(sf::Color::Black);
|
||||
leftPaddle.SetFillColor(sf::Color(100, 100, 200));
|
||||
leftPaddle.SetOrigin(paddleSize / 2.f);
|
||||
leftPaddle.setSize(paddleSize - sf::Vector2f(3, 3));
|
||||
leftPaddle.setOutlineThickness(3);
|
||||
leftPaddle.setOutlineColor(sf::Color::Black);
|
||||
leftPaddle.setFillColor(sf::Color(100, 100, 200));
|
||||
leftPaddle.setOrigin(paddleSize / 2.f);
|
||||
|
||||
// Create the right paddle
|
||||
sf::RectangleShape rightPaddle;
|
||||
rightPaddle.SetSize(paddleSize - sf::Vector2f(3, 3));
|
||||
rightPaddle.SetOutlineThickness(3);
|
||||
rightPaddle.SetOutlineColor(sf::Color::Black);
|
||||
rightPaddle.SetFillColor(sf::Color(200, 100, 100));
|
||||
rightPaddle.SetOrigin(paddleSize / 2.f);
|
||||
rightPaddle.setSize(paddleSize - sf::Vector2f(3, 3));
|
||||
rightPaddle.setOutlineThickness(3);
|
||||
rightPaddle.setOutlineColor(sf::Color::Black);
|
||||
rightPaddle.setFillColor(sf::Color(200, 100, 100));
|
||||
rightPaddle.setOrigin(paddleSize / 2.f);
|
||||
|
||||
// Create the ball
|
||||
sf::CircleShape ball;
|
||||
ball.SetRadius(ballRadius - 3);
|
||||
ball.SetOutlineThickness(3);
|
||||
ball.SetOutlineColor(sf::Color::Black);
|
||||
ball.SetFillColor(sf::Color::White);
|
||||
ball.SetOrigin(ballRadius / 2, ballRadius / 2);
|
||||
ball.setRadius(ballRadius - 3);
|
||||
ball.setOutlineThickness(3);
|
||||
ball.setOutlineColor(sf::Color::Black);
|
||||
ball.setFillColor(sf::Color::White);
|
||||
ball.setOrigin(ballRadius / 2, ballRadius / 2);
|
||||
|
||||
// Load the text font
|
||||
sf::Font font;
|
||||
if (!font.LoadFromFile("resources/sansation.ttf"))
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Initialize the pause message
|
||||
sf::Text pauseMessage;
|
||||
pauseMessage.SetFont(font);
|
||||
pauseMessage.SetCharacterSize(40);
|
||||
pauseMessage.SetPosition(170.f, 150.f);
|
||||
pauseMessage.SetColor(sf::Color::White);
|
||||
pauseMessage.SetString("Welcome to SFML pong!\nPress space to start the game");
|
||||
pauseMessage.setFont(font);
|
||||
pauseMessage.setCharacterSize(40);
|
||||
pauseMessage.setPosition(170.f, 150.f);
|
||||
pauseMessage.setColor(sf::Color::White);
|
||||
pauseMessage.setString("Welcome to SFML pong!\nPress space to start the game");
|
||||
|
||||
// Define the paddles properties
|
||||
sf::Clock AITimer;
|
||||
const sf::Time AITime = sf::Seconds(0.1f);
|
||||
const sf::Time AITime = sf::seconds(0.1f);
|
||||
const float paddleSpeed = 400.f;
|
||||
float rightPaddleSpeed = 0.f;
|
||||
const float ballSpeed = 400.f;
|
||||
|
@ -83,22 +83,22 @@ int main()
|
|||
|
||||
sf::Clock clock;
|
||||
bool isPlaying = false;
|
||||
while (window.IsOpen())
|
||||
while (window.isOpen())
|
||||
{
|
||||
// Handle events
|
||||
sf::Event event;
|
||||
while (window.PollEvent(event))
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
// Window closed or escape key pressed: exit
|
||||
if ((event.Type == sf::Event::Closed) ||
|
||||
((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape)))
|
||||
if ((event.type == sf::Event::Closed) ||
|
||||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
|
||||
{
|
||||
window.Close();
|
||||
window.close();
|
||||
break;
|
||||
}
|
||||
|
||||
// Space key pressed: play
|
||||
if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Space))
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
|
||||
{
|
||||
if (!isPlaying)
|
||||
{
|
||||
|
@ -106,9 +106,9 @@ int main()
|
|||
isPlaying = true;
|
||||
|
||||
// Reset the position of the paddles and ball
|
||||
leftPaddle.SetPosition(10 + paddleSize.x / 2, gameHeight / 2);
|
||||
rightPaddle.SetPosition(gameWidth - 10 - paddleSize.x / 2, gameHeight / 2);
|
||||
ball.SetPosition(gameWidth / 2, gameHeight / 2);
|
||||
leftPaddle.setPosition(10 + paddleSize.x / 2, gameHeight / 2);
|
||||
rightPaddle.setPosition(gameWidth - 10 - paddleSize.x / 2, gameHeight / 2);
|
||||
ball.setPosition(gameWidth / 2, gameHeight / 2);
|
||||
|
||||
// Reset the ball angle
|
||||
do
|
||||
|
@ -123,34 +123,34 @@ int main()
|
|||
|
||||
if (isPlaying)
|
||||
{
|
||||
float deltaTime = clock.Restart().AsSeconds();
|
||||
float deltaTime = clock.restart().asSeconds();
|
||||
|
||||
// Move the player's paddle
|
||||
if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Up) &&
|
||||
(leftPaddle.GetPosition().y - paddleSize.y / 2 > 5.f))
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) &&
|
||||
(leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
|
||||
{
|
||||
leftPaddle.Move(0.f, -paddleSpeed * deltaTime);
|
||||
leftPaddle.move(0.f, -paddleSpeed * deltaTime);
|
||||
}
|
||||
if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Down) &&
|
||||
(leftPaddle.GetPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) &&
|
||||
(leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
|
||||
{
|
||||
leftPaddle.Move(0.f, paddleSpeed * deltaTime);
|
||||
leftPaddle.move(0.f, paddleSpeed * deltaTime);
|
||||
}
|
||||
|
||||
// Move the computer's paddle
|
||||
if (((rightPaddleSpeed < 0.f) && (rightPaddle.GetPosition().y - paddleSize.y / 2 > 5.f)) ||
|
||||
((rightPaddleSpeed > 0.f) && (rightPaddle.GetPosition().y + paddleSize.y / 2 < gameHeight - 5.f)))
|
||||
if (((rightPaddleSpeed < 0.f) && (rightPaddle.getPosition().y - paddleSize.y / 2 > 5.f)) ||
|
||||
((rightPaddleSpeed > 0.f) && (rightPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f)))
|
||||
{
|
||||
rightPaddle.Move(0.f, rightPaddleSpeed * deltaTime);
|
||||
rightPaddle.move(0.f, rightPaddleSpeed * deltaTime);
|
||||
}
|
||||
|
||||
// Update the computer's paddle direction according to the ball position
|
||||
if (AITimer.GetElapsedTime() > AITime)
|
||||
if (AITimer.getElapsedTime() > AITime)
|
||||
{
|
||||
AITimer.Restart();
|
||||
if (ball.GetPosition().y + ballRadius > rightPaddle.GetPosition().y + paddleSize.y / 2)
|
||||
AITimer.restart();
|
||||
if (ball.getPosition().y + ballRadius > rightPaddle.getPosition().y + paddleSize.y / 2)
|
||||
rightPaddleSpeed = paddleSpeed;
|
||||
else if (ball.GetPosition().y - ballRadius < rightPaddle.GetPosition().y - paddleSize.y / 2)
|
||||
else if (ball.getPosition().y - ballRadius < rightPaddle.getPosition().y - paddleSize.y / 2)
|
||||
rightPaddleSpeed = -paddleSpeed;
|
||||
else
|
||||
rightPaddleSpeed = 0.f;
|
||||
|
@ -158,82 +158,82 @@ int main()
|
|||
|
||||
// Move the ball
|
||||
float factor = ballSpeed * deltaTime;
|
||||
ball.Move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
||||
ball.move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
||||
|
||||
// Check collisions between the ball and the screen
|
||||
if (ball.GetPosition().x - ballRadius < 0.f)
|
||||
if (ball.getPosition().x - ballRadius < 0.f)
|
||||
{
|
||||
isPlaying = false;
|
||||
pauseMessage.SetString("You lost !\nPress space to restart or\nescape to exit");
|
||||
pauseMessage.setString("You lost !\nPress space to restart or\nescape to exit");
|
||||
}
|
||||
if (ball.GetPosition().x + ballRadius > 800)
|
||||
if (ball.getPosition().x + ballRadius > 800)
|
||||
{
|
||||
isPlaying = false;
|
||||
pauseMessage.SetString("You won !\nPress space to restart or\nescape to exit");
|
||||
pauseMessage.setString("You won !\nPress space to restart or\nescape to exit");
|
||||
}
|
||||
if (ball.GetPosition().y - ballRadius < 0.f)
|
||||
if (ball.getPosition().y - ballRadius < 0.f)
|
||||
{
|
||||
ballSound.Play();
|
||||
ballSound.play();
|
||||
ballAngle = -ballAngle;
|
||||
ball.SetPosition(ball.GetPosition().x, ballRadius + 0.1f);
|
||||
ball.setPosition(ball.getPosition().x, ballRadius + 0.1f);
|
||||
}
|
||||
if (ball.GetPosition().y + ballRadius > gameHeight)
|
||||
if (ball.getPosition().y + ballRadius > gameHeight)
|
||||
{
|
||||
ballSound.Play();
|
||||
ballSound.play();
|
||||
ballAngle = -ballAngle;
|
||||
ball.SetPosition(ball.GetPosition().x, gameHeight - ballRadius - 0.1f);
|
||||
ball.setPosition(ball.getPosition().x, gameHeight - ballRadius - 0.1f);
|
||||
}
|
||||
|
||||
// Check the collisions between the ball and the paddles
|
||||
// Left Paddle
|
||||
if (ball.GetPosition().x - ballRadius < leftPaddle.GetPosition().x + paddleSize.x / 2 &&
|
||||
ball.GetPosition().x - ballRadius > leftPaddle.GetPosition().x &&
|
||||
ball.GetPosition().y + ballRadius >= leftPaddle.GetPosition().y - paddleSize.y / 2 &&
|
||||
ball.GetPosition().y - ballRadius <= leftPaddle.GetPosition().y + paddleSize.y / 2)
|
||||
if (ball.getPosition().x - ballRadius < leftPaddle.getPosition().x + paddleSize.x / 2 &&
|
||||
ball.getPosition().x - ballRadius > leftPaddle.getPosition().x &&
|
||||
ball.getPosition().y + ballRadius >= leftPaddle.getPosition().y - paddleSize.y / 2 &&
|
||||
ball.getPosition().y - ballRadius <= leftPaddle.getPosition().y + paddleSize.y / 2)
|
||||
{
|
||||
if (ball.GetPosition().y > leftPaddle.GetPosition().y)
|
||||
if (ball.getPosition().y > leftPaddle.getPosition().y)
|
||||
ballAngle = pi - ballAngle + (std::rand() % 20) * pi / 180;
|
||||
else
|
||||
ballAngle = pi - ballAngle - (std::rand() % 20) * pi / 180;
|
||||
|
||||
ballSound.Play();
|
||||
ball.SetPosition(leftPaddle.GetPosition().x + ballRadius + paddleSize.x / 2 + 0.1f, ball.GetPosition().y);
|
||||
ballSound.play();
|
||||
ball.setPosition(leftPaddle.getPosition().x + ballRadius + paddleSize.x / 2 + 0.1f, ball.getPosition().y);
|
||||
}
|
||||
|
||||
// Right Paddle
|
||||
if (ball.GetPosition().x + ballRadius > rightPaddle.GetPosition().x - paddleSize.x / 2 &&
|
||||
ball.GetPosition().x + ballRadius < rightPaddle.GetPosition().x &&
|
||||
ball.GetPosition().y + ballRadius >= rightPaddle.GetPosition().y - paddleSize.y / 2 &&
|
||||
ball.GetPosition().y - ballRadius <= rightPaddle.GetPosition().y + paddleSize.y / 2)
|
||||
if (ball.getPosition().x + ballRadius > rightPaddle.getPosition().x - paddleSize.x / 2 &&
|
||||
ball.getPosition().x + ballRadius < rightPaddle.getPosition().x &&
|
||||
ball.getPosition().y + ballRadius >= rightPaddle.getPosition().y - paddleSize.y / 2 &&
|
||||
ball.getPosition().y - ballRadius <= rightPaddle.getPosition().y + paddleSize.y / 2)
|
||||
{
|
||||
if (ball.GetPosition().y > rightPaddle.GetPosition().y)
|
||||
if (ball.getPosition().y > rightPaddle.getPosition().y)
|
||||
ballAngle = pi - ballAngle + (std::rand() % 20) * pi / 180;
|
||||
else
|
||||
ballAngle = pi - ballAngle - (std::rand() % 20) * pi / 180;
|
||||
|
||||
ballSound.Play();
|
||||
ball.SetPosition(rightPaddle.GetPosition().x - ballRadius - paddleSize.x / 2 - 0.1f, ball.GetPosition().y);
|
||||
ballSound.play();
|
||||
ball.setPosition(rightPaddle.getPosition().x - ballRadius - paddleSize.x / 2 - 0.1f, ball.getPosition().y);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the window
|
||||
window.Clear(sf::Color(50, 200, 50));
|
||||
window.clear(sf::Color(50, 200, 50));
|
||||
|
||||
if (isPlaying)
|
||||
{
|
||||
// Draw the paddles and the ball
|
||||
window.Draw(leftPaddle);
|
||||
window.Draw(rightPaddle);
|
||||
window.Draw(ball);
|
||||
window.draw(leftPaddle);
|
||||
window.draw(rightPaddle);
|
||||
window.draw(ball);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw the pause message
|
||||
window.Draw(pauseMessage);
|
||||
window.draw(pauseMessage);
|
||||
}
|
||||
|
||||
// Display things on screen
|
||||
window.Display();
|
||||
window.display();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
@ -19,34 +19,34 @@ public :
|
|||
{
|
||||
}
|
||||
|
||||
const std::string& GetName() const
|
||||
const std::string& getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void Load()
|
||||
void load()
|
||||
{
|
||||
m_isLoaded = sf::Shader::IsAvailable() && OnLoad();
|
||||
m_isLoaded = sf::Shader::isAvailable() && onLoad();
|
||||
}
|
||||
|
||||
void Update(float time, float x, float y)
|
||||
void update(float time, float x, float y)
|
||||
{
|
||||
if (m_isLoaded)
|
||||
OnUpdate(time, x, y);
|
||||
onUpdate(time, x, y);
|
||||
}
|
||||
|
||||
void Draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
void draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
if (m_isLoaded)
|
||||
{
|
||||
OnDraw(target, states);
|
||||
onDraw(target, states);
|
||||
}
|
||||
else
|
||||
{
|
||||
sf::Text error("Shader not\nsupported");
|
||||
error.SetPosition(320.f, 200.f);
|
||||
error.SetCharacterSize(36);
|
||||
target.Draw(error, states);
|
||||
error.setPosition(320.f, 200.f);
|
||||
error.setCharacterSize(36);
|
||||
target.draw(error, states);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,9 @@ protected :
|
|||
private :
|
||||
|
||||
// Virtual functions to be implemented in derived effects
|
||||
virtual bool OnLoad() = 0;
|
||||
virtual void OnUpdate(float time, float x, float y) = 0;
|
||||
virtual void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const = 0;
|
||||
virtual bool onLoad() = 0;
|
||||
virtual void onUpdate(float time, float x, float y) = 0;
|
||||
virtual void onDraw(sf::RenderTarget& target, sf::RenderStates states) const = 0;
|
||||
|
||||
private :
|
||||
|
||||
|
|
|
@ -20,30 +20,30 @@ public :
|
|||
{
|
||||
}
|
||||
|
||||
bool OnLoad()
|
||||
bool onLoad()
|
||||
{
|
||||
// Load the texture and initialize the sprite
|
||||
if (!m_texture.LoadFromFile("resources/background.jpg"))
|
||||
if (!m_texture.loadFromFile("resources/background.jpg"))
|
||||
return false;
|
||||
m_sprite.SetTexture(m_texture);
|
||||
m_sprite.setTexture(m_texture);
|
||||
|
||||
// Load the shader
|
||||
if (!m_shader.LoadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
|
||||
if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
|
||||
return false;
|
||||
m_shader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
m_shader.setParameter("texture", sf::Shader::CurrentTexture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnUpdate(float, float x, float y)
|
||||
void onUpdate(float, float x, float y)
|
||||
{
|
||||
m_shader.SetParameter("pixel_threshold", (x + y) / 30);
|
||||
m_shader.setParameter("pixel_threshold", (x + y) / 30);
|
||||
}
|
||||
|
||||
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(m_sprite, states);
|
||||
states.shader = &m_shader;
|
||||
target.draw(m_sprite, states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -66,10 +66,10 @@ public :
|
|||
{
|
||||
}
|
||||
|
||||
bool OnLoad()
|
||||
bool onLoad()
|
||||
{
|
||||
// Create the text
|
||||
m_text.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,27 +87,27 @@ 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");
|
||||
m_text.SetCharacterSize(22);
|
||||
m_text.SetPosition(30, 20);
|
||||
m_text.setCharacterSize(22);
|
||||
m_text.setPosition(30, 20);
|
||||
|
||||
// Load the shader
|
||||
if (!m_shader.LoadFromFile("resources/wave.vert", "resources/blur.frag"))
|
||||
if (!m_shader.loadFromFile("resources/wave.vert", "resources/blur.frag"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnUpdate(float time, float x, float y)
|
||||
void onUpdate(float time, float x, float y)
|
||||
{
|
||||
m_shader.SetParameter("wave_phase", time);
|
||||
m_shader.SetParameter("wave_amplitude", x * 40, y * 40);
|
||||
m_shader.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
|
||||
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(m_text, states);
|
||||
states.shader = &m_shader;
|
||||
target.draw(m_text, states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -129,10 +129,10 @@ public :
|
|||
{
|
||||
}
|
||||
|
||||
bool OnLoad()
|
||||
bool onLoad()
|
||||
{
|
||||
// Create the points
|
||||
m_points.SetPrimitiveType(sf::Points);
|
||||
m_points.setPrimitiveType(sf::Points);
|
||||
for (int i = 0; i < 40000; ++i)
|
||||
{
|
||||
float x = static_cast<float>(std::rand() % 800);
|
||||
|
@ -140,29 +140,29 @@ public :
|
|||
sf::Uint8 r = std::rand() % 255;
|
||||
sf::Uint8 g = std::rand() % 255;
|
||||
sf::Uint8 b = std::rand() % 255;
|
||||
m_points.Append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
|
||||
m_points.append(sf::Vertex(sf::Vector2f(x, y), sf::Color(r, g, b)));
|
||||
}
|
||||
|
||||
// Load the shader
|
||||
if (!m_shader.LoadFromFile("resources/storm.vert", "resources/blink.frag"))
|
||||
if (!m_shader.loadFromFile("resources/storm.vert", "resources/blink.frag"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnUpdate(float time, float x, float y)
|
||||
void onUpdate(float time, float x, float y)
|
||||
{
|
||||
float radius = 200 + std::cos(time) * 150;
|
||||
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);
|
||||
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
|
||||
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(m_points, states);
|
||||
states.shader = &m_shader;
|
||||
target.draw(m_points, states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -184,24 +184,24 @@ public :
|
|||
{
|
||||
}
|
||||
|
||||
bool OnLoad()
|
||||
bool onLoad()
|
||||
{
|
||||
// Create the off-screen surface
|
||||
if (!m_surface.Create(800, 600))
|
||||
if (!m_surface.create(800, 600))
|
||||
return false;
|
||||
m_surface.SetSmooth(true);
|
||||
m_surface.setSmooth(true);
|
||||
|
||||
// Load the textures
|
||||
if (!m_backgroundTexture.LoadFromFile("resources/sfml.png"))
|
||||
if (!m_backgroundTexture.loadFromFile("resources/sfml.png"))
|
||||
return false;
|
||||
m_backgroundTexture.SetSmooth(true);
|
||||
if (!m_entityTexture.LoadFromFile("resources/devices.png"))
|
||||
m_backgroundTexture.setSmooth(true);
|
||||
if (!m_entityTexture.loadFromFile("resources/devices.png"))
|
||||
return false;
|
||||
m_entityTexture.SetSmooth(true);
|
||||
m_entityTexture.setSmooth(true);
|
||||
|
||||
// Initialize the background sprite
|
||||
m_backgroundSprite.SetTexture(m_backgroundTexture);
|
||||
m_backgroundSprite.SetPosition(135, 100);
|
||||
m_backgroundSprite.setTexture(m_backgroundTexture);
|
||||
m_backgroundSprite.setPosition(135, 100);
|
||||
|
||||
// Load the moving entities
|
||||
for (int i = 0; i < 6; ++i)
|
||||
|
@ -211,37 +211,37 @@ public :
|
|||
}
|
||||
|
||||
// Load the shader
|
||||
if (!m_shader.LoadFromFile("resources/edge.frag", sf::Shader::Fragment))
|
||||
if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Fragment))
|
||||
return false;
|
||||
m_shader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
m_shader.setParameter("texture", sf::Shader::CurrentTexture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnUpdate(float time, float x, float y)
|
||||
void onUpdate(float time, float x, float y)
|
||||
{
|
||||
m_shader.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 < m_entities.size(); ++i)
|
||||
{
|
||||
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);
|
||||
m_entities[i].setPosition(x, y);
|
||||
}
|
||||
|
||||
// Render the updated scene to the off-screen surface
|
||||
m_surface.Clear(sf::Color::White);
|
||||
m_surface.Draw(m_backgroundSprite);
|
||||
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();
|
||||
m_surface.draw(m_entities[i]);
|
||||
m_surface.display();
|
||||
}
|
||||
|
||||
void OnDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
states.Shader = &m_shader;
|
||||
target.Draw(sf::Sprite(m_surface.GetTexture()), states);
|
||||
states.shader = &m_shader;
|
||||
target.draw(sf::Sprite(m_surface.getTexture()), states);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -265,7 +265,7 @@ int main()
|
|||
{
|
||||
// Create the main window
|
||||
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader");
|
||||
window.SetVerticalSyncEnabled(true);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
// Create the effects
|
||||
std::vector<Effect*> effects;
|
||||
|
@ -277,50 +277,50 @@ int main()
|
|||
|
||||
// Initialize them
|
||||
for (std::size_t i = 0; i < effects.size(); ++i)
|
||||
effects[i]->Load();
|
||||
effects[i]->load();
|
||||
|
||||
// Create the messages background
|
||||
sf::Texture textBackgroundTexture;
|
||||
if (!textBackgroundTexture.LoadFromFile("resources/text-background.png"))
|
||||
if (!textBackgroundTexture.loadFromFile("resources/text-background.png"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Sprite textBackground(textBackgroundTexture);
|
||||
textBackground.SetPosition(0, 520);
|
||||
textBackground.SetColor(sf::Color(255, 255, 255, 200));
|
||||
textBackground.setPosition(0, 520);
|
||||
textBackground.setColor(sf::Color(255, 255, 255, 200));
|
||||
|
||||
// Load the messages font
|
||||
sf::Font font;
|
||||
if (!font.LoadFromFile("resources/sansation.ttf"))
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Create the description text
|
||||
sf::Text description("Current effect: " + effects[current]->GetName(), font, 20);
|
||||
description.SetPosition(10, 530);
|
||||
description.SetColor(sf::Color(80, 80, 80));
|
||||
sf::Text description("Current effect: " + effects[current]->getName(), font, 20);
|
||||
description.setPosition(10, 530);
|
||||
description.setColor(sf::Color(80, 80, 80));
|
||||
|
||||
// Create the instructions text
|
||||
sf::Text instructions("Press left and right arrows to change the current shader", font, 20);
|
||||
instructions.SetPosition(280, 555);
|
||||
instructions.SetColor(sf::Color(80, 80, 80));
|
||||
instructions.setPosition(280, 555);
|
||||
instructions.setColor(sf::Color(80, 80, 80));
|
||||
|
||||
// Start the game loop
|
||||
sf::Clock clock;
|
||||
while (window.IsOpen())
|
||||
while (window.isOpen())
|
||||
{
|
||||
// Process events
|
||||
sf::Event event;
|
||||
while (window.PollEvent(event))
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
// Close window: exit
|
||||
if (event.Type == sf::Event::Closed)
|
||||
window.Close();
|
||||
if (event.type == sf::Event::Closed)
|
||||
window.close();
|
||||
|
||||
if (event.Type == sf::Event::KeyPressed)
|
||||
if (event.type == sf::Event::KeyPressed)
|
||||
{
|
||||
switch (event.Key.Code)
|
||||
switch (event.key.code)
|
||||
{
|
||||
// Escape key: exit
|
||||
case sf::Keyboard::Escape:
|
||||
window.Close();
|
||||
window.close();
|
||||
break;
|
||||
|
||||
// Left arrow key: previous shader
|
||||
|
@ -329,7 +329,7 @@ int main()
|
|||
current = effects.size() - 1;
|
||||
else
|
||||
current--;
|
||||
description.SetString("Current effect: " + effects[current]->GetName());
|
||||
description.setString("Current effect: " + effects[current]->getName());
|
||||
break;
|
||||
|
||||
// Right arrow key: next shader
|
||||
|
@ -338,7 +338,7 @@ int main()
|
|||
current = 0;
|
||||
else
|
||||
current++;
|
||||
description.SetString("Current effect: " + effects[current]->GetName());
|
||||
description.setString("Current effect: " + effects[current]->getName());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -348,23 +348,23 @@ int main()
|
|||
}
|
||||
|
||||
// Update the current example
|
||||
float x = static_cast<float>(sf::Mouse::GetPosition(window).x) / window.GetSize().x;
|
||||
float y = static_cast<float>(sf::Mouse::GetPosition(window).y) / window.GetSize().y;
|
||||
effects[current]->Update(clock.GetElapsedTime().AsSeconds(), x, y);
|
||||
float x = static_cast<float>(sf::Mouse::getPosition(window).x) / window.getSize().x;
|
||||
float y = static_cast<float>(sf::Mouse::getPosition(window).y) / window.getSize().y;
|
||||
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
||||
|
||||
// Clear the window
|
||||
window.Clear(sf::Color(255, 128, 0));
|
||||
window.clear(sf::Color(255, 128, 0));
|
||||
|
||||
// Draw the current example
|
||||
window.Draw(*effects[current]);
|
||||
window.draw(*effects[current]);
|
||||
|
||||
// Draw the text
|
||||
window.Draw(textBackground);
|
||||
window.Draw(instructions);
|
||||
window.Draw(description);
|
||||
window.draw(textBackground);
|
||||
window.draw(instructions);
|
||||
window.draw(description);
|
||||
|
||||
// Finally, display the rendered frame on screen
|
||||
window.Display();
|
||||
window.display();
|
||||
}
|
||||
|
||||
// delete the effects
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#include <cstdlib>
|
||||
|
||||
|
||||
void RunTcpServer(unsigned short Port);
|
||||
void RunTcpClient(unsigned short Port);
|
||||
void RunUdpServer(unsigned short Port);
|
||||
void RunUdpClient(unsigned short Port);
|
||||
void runTcpServer(unsigned short port);
|
||||
void runTcpClient(unsigned short port);
|
||||
void runUdpServer(unsigned short port);
|
||||
void runUdpClient(unsigned short port);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -37,17 +37,17 @@ int main()
|
|||
{
|
||||
// Test the TCP protocol
|
||||
if (who == 's')
|
||||
RunTcpServer(port);
|
||||
runTcpServer(port);
|
||||
else
|
||||
RunTcpClient(port);
|
||||
runTcpClient(port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Test the unconnected UDP protocol
|
||||
if (who == 's')
|
||||
RunUdpServer(port);
|
||||
runUdpServer(port);
|
||||
else
|
||||
RunUdpClient(port);
|
||||
runUdpClient(port);
|
||||
}
|
||||
|
||||
// Wait until the user presses 'enter' key
|
||||
|
|
|
@ -11,32 +11,32 @@
|
|||
/// send a message and wait for the answer.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void RunTcpServer(unsigned short port)
|
||||
void runTcpServer(unsigned short port)
|
||||
{
|
||||
// Create a server socket to accept new connections
|
||||
sf::TcpListener listener;
|
||||
|
||||
// Listen to the given port for incoming connections
|
||||
if (listener.Listen(port) != sf::Socket::Done)
|
||||
if (listener.listen(port) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
|
||||
|
||||
// Wait for a connection
|
||||
sf::TcpSocket socket;
|
||||
if (listener.Accept(socket) != sf::Socket::Done)
|
||||
if (listener.accept(socket) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Client connected: " << socket.GetRemoteAddress() << std::endl;
|
||||
std::cout << "Client connected: " << socket.getRemoteAddress() << std::endl;
|
||||
|
||||
// Send a message to the connected client
|
||||
const char out[] = "Hi, I'm the server";
|
||||
if (socket.Send(out, sizeof(out)) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
|
||||
|
||||
// Receive a message back from the client
|
||||
char in[128];
|
||||
std::size_t received;
|
||||
if (socket.Receive(in, sizeof(in), received) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Answer received from the client: \"" << in << "\"" << std::endl;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ void RunTcpServer(unsigned short port)
|
|||
/// welcome message and send an answer.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void RunTcpClient(unsigned short port)
|
||||
void runTcpClient(unsigned short port)
|
||||
{
|
||||
// Ask for the server address
|
||||
sf::IpAddress server;
|
||||
|
@ -62,20 +62,20 @@ void RunTcpClient(unsigned short port)
|
|||
sf::TcpSocket socket;
|
||||
|
||||
// Connect to the server
|
||||
if (socket.Connect(server, port) != sf::Socket::Done)
|
||||
if (socket.connect(server, port) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Connected to server " << server << std::endl;
|
||||
|
||||
// Receive a message from the server
|
||||
char in[128];
|
||||
std::size_t received;
|
||||
if (socket.Receive(in, sizeof(in), received) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message received from the server: \"" << in << "\"" << std::endl;
|
||||
|
||||
// Send an answer to the server
|
||||
const char out[] = "Hi, I'm a client";
|
||||
if (socket.Send(out, sizeof(out)) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
/// Launch a server, wait for a message, send an answer.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void RunUdpServer(unsigned short port)
|
||||
void runUdpServer(unsigned short port)
|
||||
{
|
||||
// Create a socket to receive a message from anyone
|
||||
sf::UdpSocket socket;
|
||||
|
||||
// Listen to messages on the specified port
|
||||
if (socket.Bind(port) != sf::Socket::Done)
|
||||
if (socket.bind(port) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Server is listening to port " << port << ", waiting for a message... " << std::endl;
|
||||
|
||||
|
@ -25,13 +25,13 @@ void RunUdpServer(unsigned short port)
|
|||
std::size_t received;
|
||||
sf::IpAddress sender;
|
||||
unsigned short senderPort;
|
||||
if (socket.Receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message received from client " << sender << ": \"" << in << "\"" << std::endl;
|
||||
|
||||
// Send an answer to the client
|
||||
const char out[] = "Hi, I'm the server";
|
||||
if (socket.Send(out, sizeof(out), sender, senderPort) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void RunUdpServer(unsigned short port)
|
|||
/// Send a message to the server, wait for the answer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void RunUdpClient(unsigned short port)
|
||||
void runUdpClient(unsigned short port)
|
||||
{
|
||||
// Ask for the server address
|
||||
sf::IpAddress server;
|
||||
|
@ -57,7 +57,7 @@ void RunUdpClient(unsigned short port)
|
|||
|
||||
// Send a message to the server
|
||||
const char out[] = "Hi, I'm a client";
|
||||
if (socket.Send(out, sizeof(out), server, port) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out), server, port) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
|
||||
|
||||
|
@ -66,7 +66,7 @@ void RunUdpClient(unsigned short port)
|
|||
std::size_t received;
|
||||
sf::IpAddress sender;
|
||||
unsigned short senderPort;
|
||||
if (socket.Receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Message received from " << sender << ": \"" << in << "\"" << std::endl;
|
||||
}
|
||||
|
|
|
@ -11,31 +11,31 @@
|
|||
/// Play a sound
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void PlaySound()
|
||||
void playSound()
|
||||
{
|
||||
// Load a sound buffer from a wav file
|
||||
sf::SoundBuffer buffer;
|
||||
if (!buffer.LoadFromFile("resources/canary.wav"))
|
||||
if (!buffer.loadFromFile("resources/canary.wav"))
|
||||
return;
|
||||
|
||||
// Display sound informations
|
||||
std::cout << "canary.wav :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration().AsSeconds() << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.getDuration().asSeconds() << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.getSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.getChannelCount() << " channels" << std::endl;
|
||||
|
||||
// Create a sound instance and play it
|
||||
sf::Sound sound(buffer);
|
||||
sound.Play();
|
||||
sound.play();
|
||||
|
||||
// Loop while the sound is playing
|
||||
while (sound.GetStatus() == sf::Sound::Playing)
|
||||
while (sound.getStatus() == sf::Sound::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::Sleep(sf::Milliseconds(100));
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.GetPlayingOffset().AsSeconds() << " sec ";
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.getPlayingOffset().asSeconds() << " sec ";
|
||||
std::cout << std::flush;
|
||||
}
|
||||
std::cout << std::endl << std::endl;
|
||||
|
@ -46,30 +46,30 @@ void PlaySound()
|
|||
/// Play a music
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void PlayMusic()
|
||||
void playMusic()
|
||||
{
|
||||
// Load an ogg music file
|
||||
sf::Music music;
|
||||
if (!music.OpenFromFile("resources/orchestral.ogg"))
|
||||
if (!music.openFromFile("resources/orchestral.ogg"))
|
||||
return;
|
||||
|
||||
// Display music informations
|
||||
std::cout << "orchestral.ogg :" << std::endl;
|
||||
std::cout << " " << music.GetDuration().AsSeconds() << " seconds" << std::endl;
|
||||
std::cout << " " << music.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.GetChannelCount() << " channels" << std::endl;
|
||||
std::cout << " " << music.getDuration().asSeconds() << " seconds" << std::endl;
|
||||
std::cout << " " << music.getSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.getChannelCount() << " channels" << std::endl;
|
||||
|
||||
// Play it
|
||||
music.Play();
|
||||
music.play();
|
||||
|
||||
// Loop while the music is playing
|
||||
while (music.GetStatus() == sf::Music::Playing)
|
||||
while (music.getStatus() == sf::Music::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::Sleep(sf::Milliseconds(100));
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.GetPlayingOffset().AsSeconds() << " sec ";
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.getPlayingOffset().asSeconds() << " sec ";
|
||||
std::cout << std::flush;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
@ -85,10 +85,10 @@ void PlayMusic()
|
|||
int main()
|
||||
{
|
||||
// Play a sound
|
||||
PlaySound();
|
||||
playSound();
|
||||
|
||||
// Play a music
|
||||
PlayMusic();
|
||||
playMusic();
|
||||
|
||||
// Wait until the user presses 'enter' key
|
||||
std::cout << "Press enter to exit..." << std::endl;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
int main()
|
||||
{
|
||||
// Check that the device can capture audio
|
||||
if (sf::SoundRecorder::IsAvailable() == false)
|
||||
if (sf::SoundRecorder::isAvailable() == false)
|
||||
{
|
||||
std::cout << "Sorry, audio capture is not supported by your system" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -36,19 +36,19 @@ int main()
|
|||
sf::SoundBufferRecorder recorder;
|
||||
|
||||
// Audio capture is done in a separate thread, so we can block the main thread while it is capturing
|
||||
recorder.Start(sampleRate);
|
||||
recorder.start(sampleRate);
|
||||
std::cout << "Recording... press enter to stop";
|
||||
std::cin.ignore(10000, '\n');
|
||||
recorder.Stop();
|
||||
recorder.stop();
|
||||
|
||||
// Get the buffer containing the captured data
|
||||
const sf::SoundBuffer& buffer = recorder.GetBuffer();
|
||||
const sf::SoundBuffer& buffer = recorder.getBuffer();
|
||||
|
||||
// Display captured sound informations
|
||||
std::cout << "Sound information :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration().AsSeconds() << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.getDuration().asSeconds() << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.getSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.getChannelCount() << " channels" << std::endl;
|
||||
|
||||
// Choose what to do with the recorded sound data
|
||||
char choice;
|
||||
|
@ -64,23 +64,23 @@ int main()
|
|||
std::getline(std::cin, filename);
|
||||
|
||||
// Save the buffer
|
||||
buffer.SaveToFile(filename);
|
||||
buffer.saveToFile(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a sound instance and play it
|
||||
sf::Sound sound(buffer);
|
||||
sound.Play();
|
||||
sound.play();
|
||||
|
||||
// Wait until finished
|
||||
while (sound.GetStatus() == sf::Sound::Playing)
|
||||
while (sound.getStatus() == sf::Sound::Playing)
|
||||
{
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.GetPlayingOffset().AsSeconds() << " sec";
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.getPlayingOffset().asSeconds() << " sec";
|
||||
std::cout << std::flush;
|
||||
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(sf::Milliseconds(100));
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ private :
|
|||
/// /see SoundRecorder::OnStart
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnStart()
|
||||
virtual bool onStart()
|
||||
{
|
||||
if (m_socket.Connect(m_host, m_port) == sf::Socket::Done)
|
||||
if (m_socket.connect(m_host, m_port) == sf::Socket::Done)
|
||||
{
|
||||
std::cout << "Connected to server " << m_host << std::endl;
|
||||
return true;
|
||||
|
@ -55,30 +55,30 @@ private :
|
|||
/// /see SoundRecorder::ProcessSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
|
||||
virtual bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
|
||||
{
|
||||
// Pack the audio samples into a network packet
|
||||
sf::Packet packet;
|
||||
packet << audioData;
|
||||
packet.Append(samples, sampleCount * sizeof(sf::Int16));
|
||||
packet.append(samples, sampleCount * sizeof(sf::Int16));
|
||||
|
||||
// Send the audio packet to the server
|
||||
return m_socket.Send(packet) == sf::Socket::Done;
|
||||
return m_socket.send(packet) == sf::Socket::Done;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see SoundRecorder::OnStop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnStop()
|
||||
virtual void onStop()
|
||||
{
|
||||
// Send a "end-of-stream" packet
|
||||
sf::Packet packet;
|
||||
packet << endOfStream;
|
||||
m_socket.Send(packet);
|
||||
m_socket.send(packet);
|
||||
|
||||
// Close the socket
|
||||
m_socket.Disconnect();
|
||||
m_socket.disconnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -95,10 +95,10 @@ private :
|
|||
/// start sending him audio data
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void DoClient(unsigned short port)
|
||||
void doClient(unsigned short port)
|
||||
{
|
||||
// Check that the device can capture audio
|
||||
if (sf::SoundRecorder::IsAvailable() == false)
|
||||
if (sf::SoundRecorder::isAvailable() == false)
|
||||
{
|
||||
std::cout << "Sorry, audio capture is not supported by your system" << std::endl;
|
||||
return;
|
||||
|
@ -122,8 +122,8 @@ void DoClient(unsigned short port)
|
|||
std::cin.ignore(10000, '\n');
|
||||
|
||||
// Start capturing audio data
|
||||
recorder.Start(44100);
|
||||
recorder.start(44100);
|
||||
std::cout << "Recording... press enter to stop";
|
||||
std::cin.ignore(10000, '\n');
|
||||
recorder.Stop();
|
||||
recorder.stop();
|
||||
}
|
||||
|
|
|
@ -30,37 +30,37 @@ public :
|
|||
m_hasFinished(false)
|
||||
{
|
||||
// Set the sound parameters
|
||||
Initialize(1, 44100);
|
||||
initialize(1, 44100);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Run the server, stream audio data from the client
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Start(unsigned short port)
|
||||
void start(unsigned short port)
|
||||
{
|
||||
if (!m_hasFinished)
|
||||
{
|
||||
// Listen to the given port for incoming connections
|
||||
if (m_listener.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 (m_listener.Accept(m_client) != sf::Socket::Done)
|
||||
if (m_listener.accept(m_client) != sf::Socket::Done)
|
||||
return;
|
||||
std::cout << "Client connected: " << m_client.GetRemoteAddress() << std::endl;
|
||||
std::cout << "Client connected: " << m_client.getRemoteAddress() << std::endl;
|
||||
|
||||
// Start playback
|
||||
Play();
|
||||
play();
|
||||
|
||||
// Start receiving audio data
|
||||
ReceiveLoop();
|
||||
receiveLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start playback
|
||||
Play();
|
||||
play();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ private :
|
|||
/// /see SoundStream::OnGetData
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnGetData(sf::SoundStream::Chunk& data)
|
||||
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 ((m_offset >= m_samples.size()) && m_hasFinished)
|
||||
|
@ -78,7 +78,7 @@ private :
|
|||
|
||||
// No new data has arrived since last update : wait until we get some
|
||||
while ((m_offset >= m_samples.size()) && !m_hasFinished)
|
||||
sf::Sleep(sf::Milliseconds(10));
|
||||
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)
|
||||
|
@ -88,8 +88,8 @@ private :
|
|||
}
|
||||
|
||||
// Fill audio data to pass to the stream
|
||||
data.Samples = &m_tempBuffer[0];
|
||||
data.SampleCount = m_tempBuffer.size();
|
||||
data.samples = &m_tempBuffer[0];
|
||||
data.sampleCount = m_tempBuffer.size();
|
||||
|
||||
// Update the playing offset
|
||||
m_offset += m_tempBuffer.size();
|
||||
|
@ -101,22 +101,22 @@ private :
|
|||
/// /see SoundStream::OnSeek
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(sf::Time timeOffset)
|
||||
virtual void onSeek(sf::Time timeOffset)
|
||||
{
|
||||
m_offset = timeOffset.AsMilliseconds() * GetSampleRate() * GetChannelCount() / 1000;
|
||||
m_offset = timeOffset.asMilliseconds() * getSampleRate() * getChannelCount() / 1000;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get audio data from the client until playback is stopped
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ReceiveLoop()
|
||||
void receiveLoop()
|
||||
{
|
||||
while (!m_hasFinished)
|
||||
{
|
||||
// Get waiting audio data from the network
|
||||
sf::Packet packet;
|
||||
if (m_client.Receive(packet) != sf::Socket::Done)
|
||||
if (m_client.receive(packet) != sf::Socket::Done)
|
||||
break;
|
||||
|
||||
// Extract the message ID
|
||||
|
@ -126,8 +126,8 @@ private :
|
|||
if (id == audioData)
|
||||
{
|
||||
// Extract audio samples from the packet, and append it to our samples buffer
|
||||
const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(packet.GetData() + 1);
|
||||
std::size_t sampleCount = (packet.GetDataSize() - 1) / sizeof(sf::Int16);
|
||||
const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(packet.getData() + 1);
|
||||
std::size_t sampleCount = (packet.getDataSize() - 1) / sizeof(sf::Int16);
|
||||
|
||||
// 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)
|
||||
|
@ -169,17 +169,17 @@ private :
|
|||
/// a connected client
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void DoServer(unsigned short port)
|
||||
void doServer(unsigned short port)
|
||||
{
|
||||
// Build an audio stream to play sound data as it is received through the network
|
||||
NetworkAudioStream audioStream;
|
||||
audioStream.Start(port);
|
||||
audioStream.start(port);
|
||||
|
||||
// Loop until the sound playback is finished
|
||||
while (audioStream.GetStatus() != sf::SoundStream::Stopped)
|
||||
while (audioStream.getStatus() != sf::SoundStream::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(sf::Milliseconds(100));
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
}
|
||||
|
||||
std::cin.ignore(10000, '\n');
|
||||
|
@ -189,12 +189,12 @@ void DoServer(unsigned short port)
|
|||
std::cin.ignore(10000, '\n');
|
||||
|
||||
// Replay the sound (just to make sure replaying the received data is OK)
|
||||
audioStream.Play();
|
||||
audioStream.play();
|
||||
|
||||
// Loop until the sound playback is finished
|
||||
while (audioStream.GetStatus() != sf::SoundStream::Stopped)
|
||||
while (audioStream.getStatus() != sf::SoundStream::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(sf::Milliseconds(100));
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
// Function prototypes
|
||||
// (I'm too lazy to put them into separate headers...)
|
||||
////////////////////////////////////////////////////////////
|
||||
void DoClient(unsigned short port);
|
||||
void DoServer(unsigned short port);
|
||||
void doClient(unsigned short port);
|
||||
void doServer(unsigned short port);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -34,12 +34,12 @@ int main()
|
|||
if (who == 's')
|
||||
{
|
||||
// Run as a server
|
||||
DoServer(port);
|
||||
doServer(port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run as a client
|
||||
DoClient(port);
|
||||
doClient(port);
|
||||
}
|
||||
|
||||
// Wait until the user presses 'enter' key
|
||||
|
|
|
@ -13,7 +13,7 @@ HWND button;
|
|||
/// Function called whenever one of our windows receives a message
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
LRESULT CALLBACK OnEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CALLBACK onEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ INT WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
|
|||
// Define a class for our main window
|
||||
WNDCLASS windowClass;
|
||||
windowClass.style = 0;
|
||||
windowClass.lpfnWndProc = &OnEvent;
|
||||
windowClass.lpfnWndProc = &onEvent;
|
||||
windowClass.cbClsExtra = 0;
|
||||
windowClass.cbWndExtra = 0;
|
||||
windowClass.hInstance = instance;
|
||||
|
@ -77,12 +77,12 @@ INT WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
|
|||
|
||||
// Load some textures to display
|
||||
sf::Texture texture1, texture2;
|
||||
if (!texture1.LoadFromFile("resources/image1.jpg") || !texture2.LoadFromFile("resources/image2.jpg"))
|
||||
if (!texture1.loadFromFile("resources/image1.jpg") || !texture2.loadFromFile("resources/image2.jpg"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Sprite sprite1(texture1);
|
||||
sf::Sprite sprite2(texture2);
|
||||
sprite1.SetOrigin(texture1.GetWidth() / 2.f, texture1.GetHeight() / 2.f);
|
||||
sprite1.SetPosition(sprite1.GetOrigin());
|
||||
sprite1.setOrigin(texture1.getWidth() / 2.f, texture1.getHeight() / 2.f);
|
||||
sprite1.setPosition(sprite1.getOrigin());
|
||||
|
||||
// Create a clock for measuring elapsed time
|
||||
sf::Clock clock;
|
||||
|
@ -100,23 +100,23 @@ INT WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
|
|||
}
|
||||
else
|
||||
{
|
||||
float time = clock.GetElapsedTime().AsSeconds();
|
||||
float time = clock.getElapsedTime().asSeconds();
|
||||
|
||||
// Clear views
|
||||
SFMLView1.Clear();
|
||||
SFMLView2.Clear();
|
||||
SFMLView1.clear();
|
||||
SFMLView2.clear();
|
||||
|
||||
// Draw sprite 1 on view 1
|
||||
sprite1.SetRotation(time * 100);
|
||||
SFMLView1.Draw(sprite1);
|
||||
sprite1.setRotation(time * 100);
|
||||
SFMLView1.draw(sprite1);
|
||||
|
||||
// Draw sprite 2 on view 2
|
||||
sprite2.SetPosition(std::cos(time) * 100.f, 0.f);
|
||||
SFMLView2.Draw(sprite2);
|
||||
sprite2.setPosition(std::cos(time) * 100.f, 0.f);
|
||||
SFMLView2.draw(sprite2);
|
||||
|
||||
// Display each view on screen
|
||||
SFMLView1.Display();
|
||||
SFMLView2.Display();
|
||||
SFMLView1.display();
|
||||
SFMLView2.display();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,29 +34,29 @@ int main()
|
|||
gluPerspective(90.f, 1.f, 1.f, 500.f);
|
||||
|
||||
// Start the game loop
|
||||
while (window.IsOpen())
|
||||
while (window.isOpen())
|
||||
{
|
||||
// Process events
|
||||
sf::Event event;
|
||||
while (window.PollEvent(event))
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
// Close window : exit
|
||||
if (event.Type == sf::Event::Closed)
|
||||
window.Close();
|
||||
if (event.type == sf::Event::Closed)
|
||||
window.close();
|
||||
|
||||
// Escape key : exit
|
||||
if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape))
|
||||
window.Close();
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
|
||||
window.close();
|
||||
|
||||
// Resize event : adjust viewport
|
||||
if (event.Type == sf::Event::Resized)
|
||||
glViewport(0, 0, event.Size.Width, event.Size.Height);
|
||||
if (event.type == sf::Event::Resized)
|
||||
glViewport(0, 0, event.size.width, event.size.height);
|
||||
}
|
||||
|
||||
// Activate the window before using OpenGL commands.
|
||||
// This is useless here because we have only one window which is
|
||||
// always the active one, but don't forget it if you use multiple windows
|
||||
window.SetActive();
|
||||
window.setActive();
|
||||
|
||||
// Clear color and depth buffer
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -65,9 +65,9 @@ int main()
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.f, 0.f, -200.f);
|
||||
glRotatef(clock.GetElapsedTime().AsSeconds() * 50, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime().AsSeconds() * 30, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime().AsSeconds() * 90, 0.f, 0.f, 1.f);
|
||||
glRotatef(clock.getElapsedTime().asSeconds() * 50, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.getElapsedTime().asSeconds() * 30, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.getElapsedTime().asSeconds() * 90, 0.f, 0.f, 1.f);
|
||||
|
||||
// Draw a cube
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -111,7 +111,7 @@ int main()
|
|||
glEnd();
|
||||
|
||||
// Finally, display the rendered frame on screen
|
||||
window.Display();
|
||||
window.display();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
@ -52,20 +52,20 @@ public :
|
|||
///
|
||||
/// \param volume New global volume, in the range [0, 100]
|
||||
///
|
||||
/// \see GetGlobalVolume
|
||||
/// \see getGlobalVolume
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetGlobalVolume(float volume);
|
||||
static void setGlobalVolume(float volume);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current value of the global volume
|
||||
///
|
||||
/// \return Current global volume, in the range [0, 100]
|
||||
///
|
||||
/// \see SetGlobalVolume
|
||||
/// \see setGlobalVolume
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static float GetGlobalVolume();
|
||||
static float getGlobalVolume();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of the listener in the scene
|
||||
|
@ -76,10 +76,10 @@ public :
|
|||
/// \param y Y coordinate of the listener's position
|
||||
/// \param z Z coordinate of the listener's position
|
||||
///
|
||||
/// \see GetPosition, SetDirection
|
||||
/// \see getPosition, setDirection
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetPosition(float x, float y, float z);
|
||||
static void setPosition(float x, float y, float z);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of the listener in the scene
|
||||
|
@ -88,20 +88,20 @@ public :
|
|||
///
|
||||
/// \param position New listener's position
|
||||
///
|
||||
/// \see GetPosition, SetDirection
|
||||
/// \see getPosition, setDirection
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetPosition(const Vector3f& position);
|
||||
static void setPosition(const Vector3f& position);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current position of the listener in the scene
|
||||
///
|
||||
/// \return Listener's position
|
||||
///
|
||||
/// \see SetPosition
|
||||
/// \see setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Vector3f GetPosition();
|
||||
static Vector3f getPosition();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the orientation of the listener in the scene
|
||||
|
@ -115,10 +115,10 @@ public :
|
|||
/// \param y Y coordinate of the listener's orientation
|
||||
/// \param z Z coordinate of the listener's orientation
|
||||
///
|
||||
/// \see GetDirection, SetPosition
|
||||
/// \see getDirection, setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetDirection(float x, float y, float z);
|
||||
static void setDirection(float x, float y, float z);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the orientation of the listener in the scene
|
||||
|
@ -130,20 +130,20 @@ public :
|
|||
///
|
||||
/// \param direction New listener's orientation
|
||||
///
|
||||
/// \see GetDirection, SetPosition
|
||||
/// \see getDirection, setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetDirection(const Vector3f& direction);
|
||||
static void setDirection(const Vector3f& direction);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current orientation of the listener in the scene
|
||||
///
|
||||
/// \return Listener's orientation
|
||||
///
|
||||
/// \see SetDirection
|
||||
/// \see setDirection
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Vector3f GetDirection();
|
||||
static Vector3f getDirection();
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -172,7 +172,7 @@ public :
|
|||
/// Usage example:
|
||||
/// \code
|
||||
/// // Move the listener to the position (1, 0, -5)
|
||||
/// sf::Listener::SetPosition(1, 0, -5);
|
||||
/// sf::Listener::setPosition(1, 0, -5);
|
||||
///
|
||||
/// // Make it face the right axis (1, 0, 0)
|
||||
/// sf::Listener::SetDirection(1, 0, 0);
|
||||
|
|
|
@ -68,7 +68,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// \brief Open a music from an audio file
|
||||
///
|
||||
/// This function doesn't start playing the music (call Play()
|
||||
/// This function doesn't start playing the music (call play()
|
||||
/// to do so).
|
||||
/// Here is a complete list of all the supported audio formats:
|
||||
/// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
|
||||
|
@ -78,15 +78,15 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see OpenFromMemory, OpenFromStream
|
||||
/// \see openFromMemory, openFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenFromFile(const std::string& filename);
|
||||
bool openFromFile(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Open a music from an audio file in memory
|
||||
///
|
||||
/// This function doesn't start playing the music (call Play()
|
||||
/// This function doesn't start playing the music (call play()
|
||||
/// to do so).
|
||||
/// Here is a complete list of all the supported audio formats:
|
||||
/// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
|
||||
|
@ -97,15 +97,15 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see OpenFromFile, OpenFromStream
|
||||
/// \see openFromFile, openFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
bool openFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Open a music from an audio file in a custom stream
|
||||
///
|
||||
/// This function doesn't start playing the music (call Play()
|
||||
/// This function doesn't start playing the music (call play()
|
||||
/// to do so).
|
||||
/// Here is a complete list of all the supported audio formats:
|
||||
/// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
|
||||
|
@ -115,10 +115,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see OpenFromFile, OpenFromMemory
|
||||
/// \see openFromFile, openFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenFromStream(InputStream& stream);
|
||||
bool openFromStream(InputStream& stream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total duration of the music
|
||||
|
@ -126,7 +126,7 @@ public :
|
|||
/// \return Music duration
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time GetDuration() const;
|
||||
Time getDuration() const;
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -141,7 +141,7 @@ protected :
|
|||
/// \return True to continue playback, false to stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnGetData(Chunk& data);
|
||||
virtual bool onGetData(Chunk& data);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current playing position in the stream source
|
||||
|
@ -149,7 +149,7 @@ protected :
|
|||
/// \param timeOffset New playing position, from the beginning of the music
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(Time timeOffset);
|
||||
virtual void onSeek(Time timeOffset);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -157,7 +157,7 @@ private :
|
|||
/// \brief Initialize the internal state after loading a new music
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize();
|
||||
void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -191,7 +191,7 @@ private :
|
|||
///
|
||||
/// As a sound stream, a music is played in its own thread in order
|
||||
/// not to block the rest of the program. This means that you can
|
||||
/// leave the music alone after calling Play(), it will manage itself
|
||||
/// leave the music alone after calling play(), it will manage itself
|
||||
/// very well.
|
||||
///
|
||||
/// Usage example:
|
||||
|
@ -200,19 +200,19 @@ private :
|
|||
/// sf::Music music;
|
||||
///
|
||||
/// // Open it from an audio file
|
||||
/// if (!music.OpenFromFile("music.ogg"))
|
||||
/// if (!music.openFromFile("music.ogg"))
|
||||
/// {
|
||||
/// // error...
|
||||
/// }
|
||||
///
|
||||
/// // Change some parameters
|
||||
/// music.SetPosition(0, 1, 10); // change its 3D position
|
||||
/// music.SetPitch(2); // increase the pitch
|
||||
/// music.SetVolume(50); // reduce the volume
|
||||
/// music.SetLoop(true); // make it loop
|
||||
/// music.setPosition(0, 1, 10); // change its 3D position
|
||||
/// music.setPitch(2); // increase the pitch
|
||||
/// music.setVolume(50); // reduce the volume
|
||||
/// music.setLoop(true); // make it loop
|
||||
///
|
||||
/// // Play it
|
||||
/// music.Play();
|
||||
/// music.play();
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Sound, sf::SoundStream
|
||||
|
|
|
@ -86,7 +86,7 @@ public :
|
|||
/// \see Pause, Stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Play();
|
||||
void play();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Pause the sound
|
||||
|
@ -97,19 +97,19 @@ public :
|
|||
/// \see Play, Stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Pause();
|
||||
void pause();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop playing the sound
|
||||
///
|
||||
/// This function stops the sound if it was playing or paused,
|
||||
/// and does nothing if it was already stopped.
|
||||
/// It also resets the playing position (unlike Pause()).
|
||||
/// It also resets the playing position (unlike pause()).
|
||||
///
|
||||
/// \see Play, Pause
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
void stop();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the source buffer containing the audio data to play
|
||||
|
@ -123,22 +123,22 @@ public :
|
|||
/// \see GetBuffer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetBuffer(const SoundBuffer& buffer);
|
||||
void setBuffer(const SoundBuffer& buffer);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set whether or not the sound should loop after reaching the end
|
||||
///
|
||||
/// If set, the sound will restart from beginning after
|
||||
/// reaching the end and so on, until it is stopped or
|
||||
/// SetLoop(false) is called.
|
||||
/// setLoop(false) is called.
|
||||
/// The default looping state for sound is false.
|
||||
///
|
||||
/// \param loop True to play in loop, false to play once
|
||||
///
|
||||
/// \see GetLoop
|
||||
/// \see getLoop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetLoop(bool loop);
|
||||
void setLoop(bool loop);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current playing position of the sound
|
||||
|
@ -148,10 +148,10 @@ public :
|
|||
///
|
||||
/// \param timeOffset New playing position, from the beginning of the sound
|
||||
///
|
||||
/// \see GetPlayingOffset
|
||||
/// \see getPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPlayingOffset(Time timeOffset);
|
||||
void setPlayingOffset(Time timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the audio buffer attached to the sound
|
||||
|
@ -159,27 +159,27 @@ public :
|
|||
/// \return Sound buffer attached to the sound (can be NULL)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const SoundBuffer* GetBuffer() const;
|
||||
const SoundBuffer* getBuffer() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether or not the sound is in loop mode
|
||||
///
|
||||
/// \return True if the sound is looping, false otherwise
|
||||
///
|
||||
/// \see SetLoop
|
||||
/// \see setLoop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool GetLoop() const;
|
||||
bool getLoop() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current playing position of the sound
|
||||
///
|
||||
/// \return Current playing position, from the beginning of the sound
|
||||
///
|
||||
/// \see SetPlayingOffset
|
||||
/// \see setPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time GetPlayingOffset() const;
|
||||
Time getPlayingOffset() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current status of the sound (stopped, paused, playing)
|
||||
|
@ -187,7 +187,7 @@ public :
|
|||
/// \return Current status of the sound
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -208,7 +208,7 @@ public :
|
|||
/// the sound from using a dead buffer.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ResetBuffer();
|
||||
void resetBuffer();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -242,7 +242,7 @@ private :
|
|||
///
|
||||
/// In order to work, a sound must be given a buffer of audio
|
||||
/// data to play. Audio data (samples) is stored in sf::SoundBuffer,
|
||||
/// and attached to a sound with the SetBuffer() function.
|
||||
/// and attached to a sound with the setBuffer() function.
|
||||
/// The buffer object attached to a sound must remain alive
|
||||
/// as long as the sound uses it. Note that multiple sounds
|
||||
/// can use the same sound buffer at the same time.
|
||||
|
@ -250,11 +250,11 @@ private :
|
|||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::SoundBuffer buffer;
|
||||
/// buffer.LoadFromFile("sound.wav");
|
||||
/// buffer.loadFromFile("sound.wav");
|
||||
///
|
||||
/// sf::Sound sound;
|
||||
/// sound.SetBuffer(buffer);
|
||||
/// sound.Play();
|
||||
/// sound.setBuffer(buffer);
|
||||
/// sound.play();
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::SoundBuffer, sf::Music
|
||||
|
|
|
@ -84,10 +84,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromMemory, LoadFromStream, LoadFromSamples, SaveToFile
|
||||
/// \see loadFromMemory, loadFromStream, loadFromSamples, saveToFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromFile(const std::string& filename);
|
||||
bool loadFromFile(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the sound buffer from a file in memory
|
||||
|
@ -101,10 +101,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromStream, LoadFromSamples
|
||||
/// \see loadFromFile, loadFromStream, loadFromSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
bool loadFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the sound buffer from a custom stream
|
||||
|
@ -117,10 +117,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory, LoadFromSamples
|
||||
/// \see loadFromFile, loadFromMemory, loadFromSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromStream(InputStream& stream);
|
||||
bool loadFromStream(InputStream& stream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the sound buffer from an array of audio samples
|
||||
|
@ -135,10 +135,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory, SaveToFile
|
||||
/// \see loadFromFile, loadFromMemory, saveToFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate);
|
||||
bool loadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Save the sound buffer to an audio file
|
||||
|
@ -151,37 +151,37 @@ public :
|
|||
///
|
||||
/// \return True if saving succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory, LoadFromSamples
|
||||
/// \see loadFromFile, loadFromMemory, loadFromSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SaveToFile(const std::string& filename) const;
|
||||
bool saveToFile(const std::string& filename) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the array of audio samples stored in the buffer
|
||||
///
|
||||
/// The format of the returned samples is 16 bits signed integer
|
||||
/// (sf::Int16). The total number of samples in this array
|
||||
/// is given by the GetSampleCount() function.
|
||||
/// is given by the getSampleCount() function.
|
||||
///
|
||||
/// \return Read-only pointer to the array of sound samples
|
||||
///
|
||||
/// \see GetSampleCount
|
||||
/// \see getSampleCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Int16* GetSamples() const;
|
||||
const Int16* getSamples() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of samples stored in the buffer
|
||||
///
|
||||
/// The array of samples can be accessed with the GetSamples()
|
||||
/// The array of samples can be accessed with the getSamples()
|
||||
/// function.
|
||||
///
|
||||
/// \return Number of samples
|
||||
///
|
||||
/// \see GetSamples
|
||||
/// \see getSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetSampleCount() const;
|
||||
std::size_t getSampleCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sample rate of the sound
|
||||
|
@ -192,10 +192,10 @@ public :
|
|||
///
|
||||
/// \return Sample rate (number of samples per second)
|
||||
///
|
||||
/// \see GetChannelCount, GetDuration
|
||||
/// \see getChannelCount, getDuration
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetSampleRate() const;
|
||||
unsigned int getSampleRate() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of channels used by the sound
|
||||
|
@ -205,20 +205,20 @@ public :
|
|||
///
|
||||
/// \return Number of channels
|
||||
///
|
||||
/// \see GetSampleRate, GetDuration
|
||||
/// \see getSampleRate, getDuration
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetChannelCount() const;
|
||||
unsigned int getChannelCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total duration of the sound
|
||||
///
|
||||
/// \return Sound duration
|
||||
///
|
||||
/// \see GetSampleRate, GetChannelCount
|
||||
/// \see getSampleRate, getChannelCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time GetDuration() const;
|
||||
Time getDuration() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -242,7 +242,7 @@ private :
|
|||
/// \return True on succesful initialization, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Initialize(priv::SoundFile& file);
|
||||
bool initialize(priv::SoundFile& file);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the internal buffer with the cached audio samples
|
||||
|
@ -253,7 +253,7 @@ private :
|
|||
/// \return True on success, false if any error happened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Update(unsigned int channelCount, unsigned int sampleRate);
|
||||
bool update(unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Add a sound to the list of sounds that use this buffer
|
||||
|
@ -261,7 +261,7 @@ private :
|
|||
/// \param sound Sound instance to attach
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void AttachSound(Sound* sound) const;
|
||||
void attachSound(Sound* sound) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove a sound from the list of sounds that use this buffer
|
||||
|
@ -269,7 +269,7 @@ private :
|
|||
/// \param sound Sound instance to detach
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void DetachSound(Sound* sound) const;
|
||||
void detachSound(Sound* sound) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -304,7 +304,7 @@ private :
|
|||
/// are like texture pixels, and a sf::SoundBuffer is similar to
|
||||
/// a sf::Texture.
|
||||
///
|
||||
/// A sound buffer can be loaded from a file (see LoadFromFile()
|
||||
/// A sound buffer can be loaded from a file (see loadFromFile()
|
||||
/// for the complete list of supported formats), from memory, from
|
||||
/// a custom stream (see sf::InputStream) or directly from an array
|
||||
/// of samples. It can also be saved back to a file.
|
||||
|
@ -333,25 +333,25 @@ private :
|
|||
/// sf::SoundBuffer buffer;
|
||||
///
|
||||
/// // Load it from a file
|
||||
/// if (!buffer.LoadFromFile("sound.wav"))
|
||||
/// if (!buffer.loadFromFile("sound.wav"))
|
||||
/// {
|
||||
/// // error...
|
||||
/// }
|
||||
///
|
||||
/// // Create a sound source and bind it to the buffer
|
||||
/// sf::Sound sound1;
|
||||
/// sound1.SetBuffer(buffer);
|
||||
/// sound1.setBuffer(buffer);
|
||||
///
|
||||
/// // Play the sound
|
||||
/// sound1.Play();
|
||||
/// sound1.play();
|
||||
///
|
||||
/// // Create another sound source bound to the same buffer
|
||||
/// sf::Sound sound2;
|
||||
/// sound2.SetBuffer(buffer);
|
||||
/// sound2.setBuffer(buffer);
|
||||
///
|
||||
/// // Play it with a higher pitch -- the first sound remains unchanged
|
||||
/// sound2.SetPitch(2);
|
||||
/// sound2.Play();
|
||||
/// sound2.setPitch(2);
|
||||
/// sound2.play();
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Sound, sf::SoundBufferRecorder
|
||||
|
|
|
@ -56,7 +56,7 @@ public :
|
|||
/// \return Read-only access to the sound buffer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const SoundBuffer& GetBuffer() const;
|
||||
const SoundBuffer& getBuffer() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -66,7 +66,7 @@ private :
|
|||
/// \return True to start the capture, or false to abort it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnStart();
|
||||
virtual bool onStart();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Process a new chunk of recorded samples
|
||||
|
@ -77,13 +77,13 @@ private :
|
|||
/// \return True to continue the capture, or false to stop it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnProcessSamples(const Int16* samples, std::size_t sampleCount);
|
||||
virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop capturing audio data
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnStop();
|
||||
virtual void onStop();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -105,29 +105,29 @@ private :
|
|||
/// through a sf::SoundBuffer, so that it can be played, saved
|
||||
/// to a file, etc.
|
||||
///
|
||||
/// It has the same simple interface as its base class (Start(), Stop())
|
||||
/// It has the same simple interface as its base class (start(), stop())
|
||||
/// and adds a function to retrieve the recorded sound buffer
|
||||
/// (GetBuffer()).
|
||||
/// (getBuffer()).
|
||||
///
|
||||
/// As usual, don't forget to call the IsAvailable() function
|
||||
/// As usual, don't forget to call the isAvailable() function
|
||||
/// before using this class (see sf::SoundRecorder for more details
|
||||
/// about this).
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// if (SoundBufferRecorder::IsAvailable())
|
||||
/// if (SoundBufferRecorder::isAvailable())
|
||||
/// {
|
||||
/// // Record some audio data
|
||||
/// SoundBufferRecorder recorder;
|
||||
/// recorder.Start();
|
||||
/// recorder.start();
|
||||
/// ...
|
||||
/// recorder.Stop();
|
||||
/// recorder.stop();
|
||||
///
|
||||
/// // Get the buffer containing the captured audio data
|
||||
/// const sf::SoundBuffer& buffer = recorder.GetBuffer();
|
||||
/// const sf::SoundBuffer& buffer = recorder.getBuffer();
|
||||
///
|
||||
/// // Save it to a file (for example...)
|
||||
/// buffer.SaveToFile("my_record.ogg");
|
||||
/// buffer.saveToFile("my_record.ogg");
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -61,18 +61,18 @@ public :
|
|||
///
|
||||
/// \param sampleRate Desired capture rate, in number of samples per second
|
||||
///
|
||||
/// \see Stop
|
||||
/// \see stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Start(unsigned int sampleRate = 44100);
|
||||
void start(unsigned int sampleRate = 44100);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop the capture
|
||||
///
|
||||
/// \see Start
|
||||
/// \see start
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
void stop();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sample rate
|
||||
|
@ -84,7 +84,7 @@ public :
|
|||
/// \return Sample rate, in samples per second
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetSampleRate() const;
|
||||
unsigned int getSampleRate() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the system supports audio capture
|
||||
|
@ -97,7 +97,7 @@ public :
|
|||
/// \return True if audio capture is supported, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsAvailable();
|
||||
static bool isAvailable();
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -122,7 +122,7 @@ private :
|
|||
/// \return True to start the capture, or false to abort it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnStart();
|
||||
virtual bool onStart();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Process a new chunk of recorded samples
|
||||
|
@ -138,7 +138,7 @@ private :
|
|||
/// \return True to continue the capture, or false to stop it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnProcessSamples(const Int16* samples, std::size_t sampleCount) = 0;
|
||||
virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop capturing audio data
|
||||
|
@ -149,7 +149,7 @@ private :
|
|||
/// implementation does nothing.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnStop();
|
||||
virtual void onStop();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Function called as the entry point of the thread
|
||||
|
@ -158,7 +158,7 @@ private :
|
|||
/// only when the capture is stopped.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Record();
|
||||
void record();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the new available audio samples and process them
|
||||
|
@ -168,7 +168,7 @@ private :
|
|||
/// forwards them to the derived class.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ProcessCapturedSamples();
|
||||
void processCapturedSamples();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Clean up the recorder's internal resources
|
||||
|
@ -176,7 +176,7 @@ private :
|
|||
/// This function is called when the capture stops.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void CleanUp();
|
||||
void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -220,8 +220,8 @@ private :
|
|||
///
|
||||
/// It is important to note that the audio capture happens in a
|
||||
/// separate thread, so that it doesn't block the rest of the
|
||||
/// program. In particular, the OnProcessSamples and OnStop
|
||||
/// virtual functions (but not OnStart) will be called
|
||||
/// program. In particular, the onProcessSamples and onStop
|
||||
/// virtual functions (but not onStart) will be called
|
||||
/// from this separate thread. It is important to keep this in
|
||||
/// mind, because you may have to take care of synchronization
|
||||
/// issues if you share data between threads.
|
||||
|
@ -230,7 +230,7 @@ private :
|
|||
/// \code
|
||||
/// class CustomRecorder : public sf::SoundRecorder
|
||||
/// {
|
||||
/// virtual bool OnStart() // optional
|
||||
/// virtual bool onStart() // optional
|
||||
/// {
|
||||
/// // Initialize whatever has to be done before the capture starts
|
||||
/// ...
|
||||
|
@ -239,7 +239,7 @@ private :
|
|||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// virtual bool OnProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
/// virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
/// {
|
||||
/// // Do something with the new chunk of samples (store them, send them, ...)
|
||||
/// ...
|
||||
|
@ -248,7 +248,7 @@ private :
|
|||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// virtual void OnStop() // optional
|
||||
/// virtual void onStop() // optional
|
||||
/// {
|
||||
/// // Clean up whatever has to be done after the capture ends
|
||||
/// ...
|
||||
|
@ -256,12 +256,12 @@ private :
|
|||
/// }
|
||||
///
|
||||
/// // Usage
|
||||
/// if (CustomRecorder::IsAvailable())
|
||||
/// if (CustomRecorder::isAvailable())
|
||||
/// {
|
||||
/// CustomRecorder recorder;
|
||||
/// recorder.Start();
|
||||
/// recorder.start();
|
||||
/// ...
|
||||
/// recorder.Stop();
|
||||
/// recorder.stop();
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -78,10 +78,10 @@ public :
|
|||
///
|
||||
/// \param pitch New pitch to apply to the sound
|
||||
///
|
||||
/// \see GetPitch
|
||||
/// \see getPitch
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPitch(float pitch);
|
||||
void setPitch(float pitch);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the volume of the sound
|
||||
|
@ -91,10 +91,10 @@ public :
|
|||
///
|
||||
/// \param volume Volume of the sound
|
||||
///
|
||||
/// \see GetVolume
|
||||
/// \see getVolume
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetVolume(float volume);
|
||||
void setVolume(float volume);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the 3D position of the sound in the audio scene
|
||||
|
@ -107,10 +107,10 @@ public :
|
|||
/// \param y Y coordinate of the position of the sound in the scene
|
||||
/// \param z Z coordinate of the position of the sound in the scene
|
||||
///
|
||||
/// \see GetPosition
|
||||
/// \see getPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y, float z);
|
||||
void setPosition(float x, float y, float z);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the 3D position of the sound in the audio scene
|
||||
|
@ -121,10 +121,10 @@ public :
|
|||
///
|
||||
/// \param position Position of the sound in the scene
|
||||
///
|
||||
/// \see GetPosition
|
||||
/// \see getPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPosition(const Vector3f& position);
|
||||
void setPosition(const Vector3f& position);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Make the sound's position relative to the listener or absolute
|
||||
|
@ -137,10 +137,10 @@ public :
|
|||
///
|
||||
/// \param relative True to set the position relative, false to set it absolute
|
||||
///
|
||||
/// \see IsRelativeToListener
|
||||
/// \see isRelativeToListener
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetRelativeToListener(bool relative);
|
||||
void setRelativeToListener(bool relative);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the minimum distance of the sound
|
||||
|
@ -154,10 +154,10 @@ public :
|
|||
///
|
||||
/// \param distance New minimum distance of the sound
|
||||
///
|
||||
/// \see GetMinDistance, SetAttenuation
|
||||
/// \see getMinDistance, setAttenuation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetMinDistance(float distance);
|
||||
void setMinDistance(float distance);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the attenuation factor of the sound
|
||||
|
@ -173,40 +173,40 @@ public :
|
|||
///
|
||||
/// \param attenuation New attenuation factor of the sound
|
||||
///
|
||||
/// \see GetAttenuation, SetMinDistance
|
||||
/// \see getAttenuation, setMinDistance
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetAttenuation(float attenuation);
|
||||
void setAttenuation(float attenuation);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the pitch of the sound
|
||||
///
|
||||
/// \return Pitch of the sound
|
||||
///
|
||||
/// \see SetPitch
|
||||
/// \see setPitch
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetPitch() const;
|
||||
float getPitch() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the volume of the sound
|
||||
///
|
||||
/// \return Volume of the sound, in the range [0, 100]
|
||||
///
|
||||
/// \see SetVolume
|
||||
/// \see setVolume
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetVolume() const;
|
||||
float getVolume() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the 3D position of the sound in the audio scene
|
||||
///
|
||||
/// \return Position of the sound
|
||||
///
|
||||
/// \see SetPosition
|
||||
/// \see setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f GetPosition() const;
|
||||
Vector3f getPosition() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether the sound's position is relative to the
|
||||
|
@ -214,30 +214,30 @@ public :
|
|||
///
|
||||
/// \return True if the position is relative, false if it's absolute
|
||||
///
|
||||
/// \see SetRelativeToListener
|
||||
/// \see setRelativeToListener
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsRelativeToListener() const;
|
||||
bool isRelativeToListener() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the minimum distance of the sound
|
||||
///
|
||||
/// \return Minimum distance of the sound
|
||||
///
|
||||
/// \see SetMinDistance, GetAttenuation
|
||||
/// \see setMinDistance, getAttenuation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetMinDistance() const;
|
||||
float getMinDistance() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the attenuation factor of the sound
|
||||
///
|
||||
/// \return Attenuation factor of the sound
|
||||
///
|
||||
/// \see SetAttenuation, GetMinDistance
|
||||
/// \see setAttenuation, getMinDistance
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetAttenuation() const;
|
||||
float getAttenuation() const;
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -255,7 +255,7 @@ protected :
|
|||
/// \return Current status of the sound
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
|
|
@ -51,8 +51,8 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct Chunk
|
||||
{
|
||||
const Int16* Samples; ///< Pointer to the audio samples
|
||||
std::size_t SampleCount; ///< Number of samples pointed by Samples
|
||||
const Int16* samples; ///< Pointer to the audio samples
|
||||
std::size_t sampleCount; ///< Number of samples pointed by Samples
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -70,10 +70,10 @@ public :
|
|||
/// This function uses its own thread so that it doesn't block
|
||||
/// the rest of the program while the stream is played.
|
||||
///
|
||||
/// \see Pause, Stop
|
||||
/// \see pause, stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Play();
|
||||
void play();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Pause the audio stream
|
||||
|
@ -81,22 +81,22 @@ public :
|
|||
/// This function pauses the stream if it was playing,
|
||||
/// otherwise (stream already paused or stopped) it has no effect.
|
||||
///
|
||||
/// \see Play, Stop
|
||||
/// \see play, stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Pause();
|
||||
void pause();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop playing the audio stream
|
||||
///
|
||||
/// This function stops the stream if it was playing or paused,
|
||||
/// and does nothing if it was already stopped.
|
||||
/// It also resets the playing position (unlike Pause()).
|
||||
/// It also resets the playing position (unlike pause()).
|
||||
///
|
||||
/// \see Play, Pause
|
||||
/// \see play, pause
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Stop();
|
||||
void stop();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the number of channels of the stream
|
||||
|
@ -106,7 +106,7 @@ public :
|
|||
/// \return Number of channels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetChannelCount() const;
|
||||
unsigned int getChannelCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the stream sample rate of the stream
|
||||
|
@ -117,7 +117,7 @@ public :
|
|||
/// \return Sample rate, in number of samples per second
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetSampleRate() const;
|
||||
unsigned int getSampleRate() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current status of the stream (stopped, paused, playing)
|
||||
|
@ -125,7 +125,7 @@ public :
|
|||
/// \return Current status
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current playing position of the stream
|
||||
|
@ -135,45 +135,45 @@ public :
|
|||
///
|
||||
/// \param timeOffset New playing position, from the beginning of the stream
|
||||
///
|
||||
/// \see GetPlayingOffset
|
||||
/// \see getPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPlayingOffset(Time timeOffset);
|
||||
void setPlayingOffset(Time timeOffset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current playing position of the stream
|
||||
///
|
||||
/// \return Current playing position, from the beginning of the stream
|
||||
///
|
||||
/// \see SetPlayingOffset
|
||||
/// \see setPlayingOffset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time GetPlayingOffset() const;
|
||||
Time getPlayingOffset() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set whether or not the stream should loop after reaching the end
|
||||
///
|
||||
/// If set, the stream will restart from beginning after
|
||||
/// reaching the end and so on, until it is stopped or
|
||||
/// SetLoop(false) is called.
|
||||
/// setLoop(false) is called.
|
||||
/// The default looping state for streams is false.
|
||||
///
|
||||
/// \param loop True to play in loop, false to play once
|
||||
///
|
||||
/// \see GetLoop
|
||||
/// \see getLoop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetLoop(bool loop);
|
||||
void setLoop(bool loop);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether or not the stream is in loop mode
|
||||
///
|
||||
/// \return True if the stream is looping, false otherwise
|
||||
///
|
||||
/// \see SetLoop
|
||||
/// \see setLoop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool GetLoop() const;
|
||||
bool getLoop() const;
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -190,7 +190,7 @@ protected :
|
|||
///
|
||||
/// This function must be called by derived classes as soon
|
||||
/// as they know the audio settings of the stream to play.
|
||||
/// Any attempt to manipulate the stream (Play(), ...) before
|
||||
/// Any attempt to manipulate the stream (play(), ...) before
|
||||
/// calling this function will fail.
|
||||
/// It can be called multiple times if the settings of the
|
||||
/// audio stream change, but only when the stream is stopped.
|
||||
|
@ -199,7 +199,7 @@ protected :
|
|||
/// \param sampleRate Sample rate, in samples per second
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize(unsigned int channelCount, unsigned int sampleRate);
|
||||
void initialize(unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -210,7 +210,7 @@ private :
|
|||
/// only when the sound is stopped.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Stream();
|
||||
void stream();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Request a new chunk of audio samples from the stream source
|
||||
|
@ -226,7 +226,7 @@ private :
|
|||
/// \return True to continue playback, false to stop
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnGetData(Chunk& data) = 0;
|
||||
virtual bool onGetData(Chunk& data) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current playing position in the stream source
|
||||
|
@ -237,7 +237,7 @@ private :
|
|||
/// \param timeOffset New playing position, relative to the beginning of the stream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(Time timeOffset) = 0;
|
||||
virtual void onSeek(Time timeOffset) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Fill a new buffer with audio samples, and append
|
||||
|
@ -252,7 +252,7 @@ private :
|
|||
/// \return True if the stream source has requested to stop, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool FillAndPushBuffer(unsigned int bufferNum);
|
||||
bool fillAndPushBuffer(unsigned int bufferNum);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Fill the audio buffers and put them all into the playing queue
|
||||
|
@ -263,7 +263,7 @@ private :
|
|||
/// \return True if the derived class has requested to stop, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool FillQueue();
|
||||
bool fillQueue();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Clear all the audio buffers and empty the playing queue
|
||||
|
@ -271,7 +271,7 @@ private :
|
|||
/// This function is called when the stream is stopped.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ClearQueue();
|
||||
void clearQueue();
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -320,8 +320,8 @@ private :
|
|||
/// by combining this class with the network module.
|
||||
///
|
||||
/// A derived class has to override two virtual functions:
|
||||
/// \li OnGetData fills a new chunk of audio data to be played
|
||||
/// \li OnSeek changes the current playing position in the source
|
||||
/// \li onGetData fills a new chunk of audio data to be played
|
||||
/// \li onSeek changes the current playing position in the source
|
||||
///
|
||||
/// It is important to note that each SoundStream is played in its
|
||||
/// own separate thread, so that the streaming loop doesn't block the
|
||||
|
@ -336,7 +336,7 @@ private :
|
|||
/// {
|
||||
/// public :
|
||||
///
|
||||
/// bool Open(const std::string& location)
|
||||
/// bool open(const std::string& location)
|
||||
/// {
|
||||
/// // Open the source and get audio settings
|
||||
/// ...
|
||||
|
@ -344,22 +344,22 @@ private :
|
|||
/// unsigned int sampleRate = ...;
|
||||
///
|
||||
/// // Initialize the stream -- important!
|
||||
/// Initialize(channelCount, sampleRate);
|
||||
/// initialize(channelCount, sampleRate);
|
||||
/// }
|
||||
///
|
||||
/// private :
|
||||
///
|
||||
/// virtual bool OnGetData(Chunk& data)
|
||||
/// virtual bool onGetData(Chunk& data)
|
||||
/// {
|
||||
/// // Fill the chunk with audio data from the stream source
|
||||
/// data.Samples = ...;
|
||||
/// data.SampleCount = ...;
|
||||
/// data.samples = ...;
|
||||
/// data.sampleCount = ...;
|
||||
///
|
||||
/// // Return true to continue playing
|
||||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// virtual void OnSeek(Uint32 timeOffset)
|
||||
/// virtual void onSeek(Uint32 timeOffset)
|
||||
/// {
|
||||
/// // Change the current position in the stream source
|
||||
/// ...
|
||||
|
@ -368,8 +368,8 @@ private :
|
|||
///
|
||||
/// // Usage
|
||||
/// CustomStream stream;
|
||||
/// stream.Open("path/to/stream");
|
||||
/// stream.Play();
|
||||
/// stream.open("path/to/stream");
|
||||
/// stream.play();
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Music
|
||||
|
|
|
@ -56,40 +56,40 @@ public :
|
|||
///
|
||||
/// \param radius New radius of the circle
|
||||
///
|
||||
/// \see GetRadius
|
||||
/// \see getRadius
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetRadius(float radius);
|
||||
void setRadius(float radius);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the radius of the circle
|
||||
///
|
||||
/// \return Radius of the circle
|
||||
///
|
||||
/// \see SetRadius
|
||||
/// \see setRadius
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetRadius() const;
|
||||
float getRadius() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the number of points of the circle
|
||||
///
|
||||
/// \param count New number of points of the circle
|
||||
///
|
||||
/// \see GetPointCount
|
||||
/// \see getPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPointCount(unsigned int count);
|
||||
void setPointCount(unsigned int count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points of the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
/// \see SetPointCount
|
||||
/// \see setPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointCount() const;
|
||||
virtual unsigned int getPointCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
|
@ -101,7 +101,7 @@ public :
|
|||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetPoint(unsigned int index) const;
|
||||
virtual Vector2f getPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -129,12 +129,12 @@ private :
|
|||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::CircleShape circle;
|
||||
/// circle.SetRadius(150);
|
||||
/// circle.SetOutlineColor(sf::Color::Red);
|
||||
/// circle.SetOutlineThickness(5);
|
||||
/// circle.SetPosition(10, 20);
|
||||
/// circle.setRadius(150);
|
||||
/// circle.setOutlineColor(sf::Color::Red);
|
||||
/// circle.setOutlineThickness(5);
|
||||
/// circle.setPosition(10, 20);
|
||||
/// ...
|
||||
/// window.Draw(circle);
|
||||
/// window.draw(circle);
|
||||
/// \endcode
|
||||
///
|
||||
/// Since the graphics card can't draw perfect circles, we have to
|
||||
|
|
|
@ -58,20 +58,20 @@ public :
|
|||
///
|
||||
/// \param count New number of points of the polygon
|
||||
///
|
||||
/// \see GetPointCount
|
||||
/// \see getPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPointCount(unsigned int count);
|
||||
void setPointCount(unsigned int count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points of the polygon
|
||||
///
|
||||
/// \return Number of points of the polygon
|
||||
///
|
||||
/// \see SetPointCount
|
||||
/// \see setPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointCount() const;
|
||||
virtual unsigned int getPointCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of a point
|
||||
|
@ -85,10 +85,10 @@ public :
|
|||
/// \param index Index of the point to change, in range [0 .. GetPointCount() - 1]
|
||||
/// \param point New position of the point
|
||||
///
|
||||
/// \see GetPoint
|
||||
/// \see getPoint
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPoint(unsigned int index, const Vector2f& point);
|
||||
void setPoint(unsigned int index, const Vector2f& point);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the position of a point
|
||||
|
@ -99,10 +99,10 @@ public :
|
|||
///
|
||||
/// \return Position of the index-th point of the polygon
|
||||
///
|
||||
/// \see SetPoint
|
||||
/// \see setPoint
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetPoint(unsigned int index) const;
|
||||
virtual Vector2f getPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -134,15 +134,15 @@ private :
|
|||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::ConvexShape polygon;
|
||||
/// polygon.SetPointCount(3);
|
||||
/// polygon.SetPoint(0, sf::Vector2f(0, 0));
|
||||
/// polygon.SetPoint(1, sf::Vector2f(0, 10));
|
||||
/// polygon.SetPoint(2, sf::Vector2f(25, 5));
|
||||
/// polygon.SetOutlineColor(sf::Color::Red);
|
||||
/// polygon.SetOutlineThickness(5);
|
||||
/// polygon.SetPosition(10, 20);
|
||||
/// polygon.setPointCount(3);
|
||||
/// polygon.setPoint(0, sf::Vector2f(0, 0));
|
||||
/// polygon.setPoint(1, sf::Vector2f(0, 10));
|
||||
/// polygon.setPoint(2, sf::Vector2f(25, 5));
|
||||
/// polygon.setOutlineColor(sf::Color::Red);
|
||||
/// polygon.setOutlineThickness(5);
|
||||
/// polygon.setPosition(10, 20);
|
||||
/// ...
|
||||
/// window.Draw(polygon);
|
||||
/// window.draw(polygon);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Shape, sf::RectangleShape, sf::CircleShape
|
||||
|
|
|
@ -66,7 +66,7 @@ private :
|
|||
/// \param states Current render states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void Draw(RenderTarget& target, RenderStates states) const = 0;
|
||||
virtual void draw(RenderTarget& target, RenderStates states) const = 0;
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -100,14 +100,14 @@ private :
|
|||
///
|
||||
/// private :
|
||||
///
|
||||
/// virtual void Draw(sf::RenderTarget& target, RenderStates states) const
|
||||
/// virtual void draw(sf::RenderTarget& target, RenderStates states) const
|
||||
/// {
|
||||
/// // You can draw other high-level objects
|
||||
/// target.Draw(m_sprite, states);
|
||||
/// target.draw(m_sprite, states);
|
||||
///
|
||||
/// // ... or use the low-level API
|
||||
/// states.Texture = &m_texture;
|
||||
/// target.Draw(m_vertices, states);
|
||||
/// target.draw(m_vertices, states);
|
||||
///
|
||||
/// // ... or draw with OpenGL directly
|
||||
/// glBegin(GL_QUADS);
|
||||
|
|
|
@ -88,10 +88,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromMemory, LoadFromStream
|
||||
/// \see loadFromMemory, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromFile(const std::string& filename);
|
||||
bool loadFromFile(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the font from a file in memory
|
||||
|
@ -107,10 +107,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromStream
|
||||
/// \see loadFromFile, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
bool loadFromMemory(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the font from a custom stream
|
||||
|
@ -125,10 +125,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory
|
||||
/// \see loadFromFile, loadFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromStream(InputStream& stream);
|
||||
bool loadFromStream(InputStream& stream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Retrieve a glyph of the font
|
||||
|
@ -140,7 +140,7 @@ public :
|
|||
/// \return The glyph corresponding to \a codePoint and \a characterSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Glyph& GetGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
|
||||
const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the kerning offset of two glyphs
|
||||
|
@ -158,7 +158,7 @@ public :
|
|||
/// \return Kerning value for \a first and \a second, in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) const;
|
||||
int getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the line spacing
|
||||
|
@ -171,7 +171,7 @@ public :
|
|||
/// \return Line spacing, in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int GetLineSpacing(unsigned int characterSize) const;
|
||||
int getLineSpacing(unsigned int characterSize) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Retrieve the texture containing the loaded glyphs of a certain size
|
||||
|
@ -185,7 +185,7 @@ public :
|
|||
/// \return Texture containing the glyphs of the requested size
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Texture& GetTexture(unsigned int characterSize) const;
|
||||
const Texture& getTexture(unsigned int characterSize) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -209,7 +209,7 @@ public :
|
|||
/// \return Reference to the built-in default font
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static const Font& GetDefaultFont();
|
||||
static const Font& getDefaultFont();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -219,11 +219,11 @@ private :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct Row
|
||||
{
|
||||
Row(unsigned int top, unsigned int height) : Width(0), Top(top), Height(height) {}
|
||||
Row(unsigned int top, unsigned int height) : width(0), top(top), height(height) {}
|
||||
|
||||
unsigned int Width; ///< Current width of the row
|
||||
unsigned int Top; ///< Y position of the row into the texture
|
||||
unsigned int Height; ///< Height of the row
|
||||
unsigned int width; ///< Current width of the row
|
||||
unsigned int top; ///< Y position of the row into the texture
|
||||
unsigned int height; ///< Height of the row
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -239,17 +239,17 @@ private :
|
|||
{
|
||||
Page();
|
||||
|
||||
GlyphTable Glyphs; ///< Table mapping code points to their corresponding glyph
|
||||
sf::Texture Texture; ///< Texture containing the pixels of the glyphs
|
||||
unsigned int NextRow; ///< Y position of the next new row in the texture
|
||||
std::vector<Row> Rows; ///< List containing the position of all the existing rows
|
||||
GlyphTable glyphs; ///< Table mapping code points to their corresponding glyph
|
||||
sf::Texture texture; ///< Texture containing the pixels of the glyphs
|
||||
unsigned int nextRow; ///< Y position of the next new row in the texture
|
||||
std::vector<Row> rows; ///< List containing the position of all the existing rows
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Free all the internal resources
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Cleanup();
|
||||
void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load a new glyph and store it in the cache
|
||||
|
@ -261,7 +261,7 @@ private :
|
|||
/// \return The glyph corresponding to \a codePoint and \a characterSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Glyph LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
|
||||
Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Find a suitable rectangle within the texture for a glyph
|
||||
|
@ -273,7 +273,7 @@ private :
|
|||
/// \return Found rectangle within the texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
IntRect FindGlyphRect(Page& page, unsigned int width, unsigned int height) const;
|
||||
IntRect findGlyphRect(Page& page, unsigned int width, unsigned int height) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Make sure that the given size is the current one
|
||||
|
@ -283,7 +283,7 @@ private :
|
|||
/// \return True on success, false if any error happened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SetCurrentSize(unsigned int characterSize) const;
|
||||
bool setCurrentSize(unsigned int characterSize) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -313,7 +313,7 @@ private :
|
|||
///
|
||||
/// Fonts can be loaded from a file, from memory or from a custom
|
||||
/// stream, and supports the most common types of fonts. See
|
||||
/// the LoadFromFile function for the complete list of supported formats.
|
||||
/// the loadFromFile function for the complete list of supported formats.
|
||||
///
|
||||
/// Once it is loaded, a sf::Font instance provides three
|
||||
/// types of informations about the font:
|
||||
|
@ -347,22 +347,22 @@ private :
|
|||
/// sf::Font font;
|
||||
///
|
||||
/// // Load it from a file
|
||||
/// if (!font.LoadFromFile("arial.ttf"))
|
||||
/// if (!font.loadFromFile("arial.ttf"))
|
||||
/// {
|
||||
/// // error...
|
||||
/// }
|
||||
///
|
||||
/// // Create a text which uses our font
|
||||
/// sf::Text text1;
|
||||
/// text1.SetFont(font);
|
||||
/// text1.SetCharacterSize(30);
|
||||
/// text1.SetStyle(sf::Text::Regular);
|
||||
/// text1.setFont(font);
|
||||
/// text1.setCharacterSize(30);
|
||||
/// text1.setStyle(sf::Text::Regular);
|
||||
///
|
||||
/// // Create another text using the same font, but with different parameters
|
||||
/// sf::Text text2;
|
||||
/// text2.SetFont(font);
|
||||
/// text2.SetCharacterSize(50);
|
||||
/// text1.SetStyle(sf::Text::Italic);
|
||||
/// text2.setFont(font);
|
||||
/// text2.setCharacterSize(50);
|
||||
/// text1.setStyle(sf::Text::Italic);
|
||||
/// \endcode
|
||||
///
|
||||
/// Apart from loading font files, and passing them to instances
|
||||
|
|
|
@ -46,14 +46,14 @@ public :
|
|||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Glyph() : Advance(0) {}
|
||||
Glyph() : advance(0) {}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
int Advance; ///< Offset to move horizontically to the next character
|
||||
IntRect Bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline
|
||||
IntRect TextureRect; ///< Texture coordinates of the glyph inside the font's texture
|
||||
int advance; ///< Offset to move horizontically to the next character
|
||||
IntRect bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline
|
||||
IntRect textureRect; ///< Texture coordinates of the glyph inside the font's texture
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -63,7 +63,7 @@ public :
|
|||
/// \param color Fill color
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
|
||||
void create(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create the image from an array of pixels
|
||||
|
@ -78,7 +78,7 @@ public :
|
|||
/// \param pixels Array of pixels to copy to the image
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(unsigned int width, unsigned int height, const Uint8* pixels);
|
||||
void create(unsigned int width, unsigned int height, const Uint8* pixels);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the image from a file on disk
|
||||
|
@ -92,10 +92,10 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromMemory, LoadFromStream, SaveToFile
|
||||
/// \see loadFromMemory, loadFromStream, saveToFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromFile(const std::string& filename);
|
||||
bool loadFromFile(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the image from a file in memory
|
||||
|
@ -110,10 +110,10 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromStream
|
||||
/// \see loadFromFile, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromMemory(const void* data, std::size_t size);
|
||||
bool loadFromMemory(const void* data, std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the image from a custom stream
|
||||
|
@ -127,10 +127,10 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory
|
||||
/// \see loadFromFile, loadFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromStream(InputStream& stream);
|
||||
bool loadFromStream(InputStream& stream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Save the image to a file on disk
|
||||
|
@ -144,30 +144,30 @@ public :
|
|||
///
|
||||
/// \return True if saving was successful
|
||||
///
|
||||
/// \see Create, LoadFromFile, LoadFromMemory
|
||||
/// \see create, loadFromFile, loadFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SaveToFile(const std::string& filename) const;
|
||||
bool saveToFile(const std::string& filename) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the width of the image
|
||||
///
|
||||
/// \return Width in pixels
|
||||
///
|
||||
/// \see GetHeight
|
||||
/// \see getHeight
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int getWidth() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the height of the image
|
||||
///
|
||||
/// \return Height in pixels
|
||||
///
|
||||
/// \see GetWidth
|
||||
/// \see getWidth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetHeight() const;
|
||||
unsigned int getHeight() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create a transparency mask from a specified color-key
|
||||
|
@ -180,7 +180,7 @@ public :
|
|||
/// \param alpha Alpha value to assign to transparent pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void CreateMaskFromColor(const Color& color, Uint8 alpha = 0);
|
||||
void createMaskFromColor(const Color& color, Uint8 alpha = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Copy pixels from another image onto this one
|
||||
|
@ -202,7 +202,7 @@ public :
|
|||
/// \param applyAlpha Should the copy take in account the source transparency?
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false);
|
||||
void copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the color of a pixel
|
||||
|
@ -215,10 +215,10 @@ public :
|
|||
/// \param y Y coordinate of pixel to change
|
||||
/// \param color New color of the pixel
|
||||
///
|
||||
/// \see GetPixel
|
||||
/// \see getPixel
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPixel(unsigned int x, unsigned int y, const Color& color);
|
||||
void setPixel(unsigned int x, unsigned int y, const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the color of a pixel
|
||||
|
@ -232,8 +232,10 @@ public :
|
|||
///
|
||||
/// \return Color of the pixel at coordinates (x, y)
|
||||
///
|
||||
/// \see setPixel
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Color GetPixel(unsigned int x, unsigned int y) const;
|
||||
Color getPixel(unsigned int x, unsigned int y) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a read-only pointer to the array of pixels
|
||||
|
@ -248,19 +250,19 @@ public :
|
|||
/// \return Read-only pointer to the array of pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Uint8* GetPixelsPtr() const;
|
||||
const Uint8* getPixelsPtr() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Flip the image horizontally (left <-> right)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void FlipHorizontally();
|
||||
void flipHorizontally();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Flip the image vertically (top <-> bottom)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void FlipVertically();
|
||||
void flipVertically();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -293,7 +295,7 @@ private :
|
|||
/// channels -- just like a sf::Color.
|
||||
/// All the functions that return an array of pixels follow
|
||||
/// this rule, and all parameters that you pass to sf::Image
|
||||
/// functions (such as LoadFromPixels) must use this
|
||||
/// functions (such as loadFromPixels) must use this
|
||||
/// representation as well.
|
||||
///
|
||||
/// A sf::Image can be copied, but it is a heavy resource and
|
||||
|
@ -304,24 +306,24 @@ private :
|
|||
/// \code
|
||||
/// // Load an image file from a file
|
||||
/// sf::Image background;
|
||||
/// if (!background.LoadFromFile("background.jpg"))
|
||||
/// if (!background.loadFromFile("background.jpg"))
|
||||
/// return -1;
|
||||
///
|
||||
/// // Create a 20x20 image filled with black color
|
||||
/// sf::Image image;
|
||||
/// if (!image.Create(20, 20, sf::Color::Black))
|
||||
/// if (!image.create(20, 20, sf::Color::Black))
|
||||
/// return -1;
|
||||
///
|
||||
/// // Copy image1 on image2 at position (10, 10)
|
||||
/// image.Copy(background, 10, 10);
|
||||
/// image.copy(background, 10, 10);
|
||||
///
|
||||
/// // Make the top-left pixel transparent
|
||||
/// sf::Color color = image.GetPixel(0, 0);
|
||||
/// sf::Color color = image.getPixel(0, 0);
|
||||
/// color.a = 0;
|
||||
/// image.SetPixel(0, 0, color);
|
||||
/// image.setPixel(0, 0, color);
|
||||
///
|
||||
/// // Save the image to a file
|
||||
/// if (!image.SaveToFile("result.png"))
|
||||
/// if (!image.saveToFile("result.png"))
|
||||
/// return -1;
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -100,10 +100,10 @@ public :
|
|||
///
|
||||
/// \return True if the point is inside, false otherwise
|
||||
///
|
||||
/// \see Intersects
|
||||
/// \see intersects
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Contains(T x, T y) const;
|
||||
bool contains(T x, T y) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a point is inside the rectangle's area
|
||||
|
@ -112,10 +112,10 @@ public :
|
|||
///
|
||||
/// \return True if the point is inside, false otherwise
|
||||
///
|
||||
/// \see Intersects
|
||||
/// \see intersects
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Contains(const Vector2<T>& point) const;
|
||||
bool contains(const Vector2<T>& point) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check the intersection between two rectangles
|
||||
|
@ -124,10 +124,10 @@ public :
|
|||
///
|
||||
/// \return True if rectangles overlap, false otherwise
|
||||
///
|
||||
/// \see Contains
|
||||
/// \see contains
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Intersects(const Rect<T>& rectangle) const;
|
||||
bool intersects(const Rect<T>& rectangle) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check the intersection between two rectangles
|
||||
|
@ -140,18 +140,18 @@ public :
|
|||
///
|
||||
/// \return True if rectangles overlap, false otherwise
|
||||
///
|
||||
/// \see Contains
|
||||
/// \see contains
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Intersects(const Rect<T>& rectangle, Rect<T>& intersection) const;
|
||||
bool intersects(const Rect<T>& rectangle, Rect<T>& intersection) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
T Left; ///< Left coordinate of the rectangle
|
||||
T Top; ///< Top coordinate of the rectangle
|
||||
T Width; ///< Width of the rectangle
|
||||
T Height; ///< Height of the rectangle
|
||||
T left; ///< Left coordinate of the rectangle
|
||||
T top; ///< Top coordinate of the rectangle
|
||||
T width; ///< Width of the rectangle
|
||||
T height; ///< Height of the rectangle
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -202,18 +202,18 @@ typedef Rect<float> FloatRect;
|
|||
///
|
||||
/// A rectangle is defined by its top-left corner and its size.
|
||||
/// It is a very simple class defined for convenience, so
|
||||
/// its member variables (Left, Top, Width and Height) are public
|
||||
/// its member variables (left, top, width and height) are public
|
||||
/// and can be accessed directly, just like the vector classes
|
||||
/// (Vector2 and Vector3).
|
||||
///
|
||||
/// To keep things simple, sf::Rect doesn't define
|
||||
/// functions to emulate the properties that are not directly
|
||||
/// members (such as Right, Bottom, Center, etc.), it rather
|
||||
/// members (such as right, bottom, center, etc.), it rather
|
||||
/// only provides intersection functions.
|
||||
///
|
||||
/// sf::Rect uses the usual rules for its boundaries:
|
||||
/// \li The Left and Top edges are included in the rectangle's area
|
||||
/// \li The right (Left + Width) and bottom (Top + Height) edges are excluded from the rectangle's area
|
||||
/// \li The left and top edges are included in the rectangle's area
|
||||
/// \li The right (left + width) and bottom (top + height) edges are excluded from the rectangle's area
|
||||
///
|
||||
/// This means that sf::IntRect(0, 0, 1, 1) and sf::IntRect(1, 1, 1, 1)
|
||||
/// don't intersect.
|
||||
|
@ -236,12 +236,12 @@ typedef Rect<float> FloatRect;
|
|||
/// sf::IntRect r2(position, size);
|
||||
///
|
||||
/// // Test intersections with the point (3, 1)
|
||||
/// bool b1 = r1.Contains(3, 1); // true
|
||||
/// bool b2 = r2.Contains(3, 1); // false
|
||||
/// bool b1 = r1.contains(3, 1); // true
|
||||
/// bool b2 = r2.contains(3, 1); // false
|
||||
///
|
||||
/// // Test the intersection between r1 and r2
|
||||
/// sf::IntRect result;
|
||||
/// bool b3 = r1.Intersects(r2, result); // true
|
||||
/// bool b3 = r1.intersects(r2, result); // true
|
||||
/// // result == (4, 2, 16, 3)
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Rect<T>::Rect() :
|
||||
Left (0),
|
||||
Top (0),
|
||||
Width (0),
|
||||
Height(0)
|
||||
left (0),
|
||||
top (0),
|
||||
width (0),
|
||||
height(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ Height(0)
|
|||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Rect<T>::Rect(T left, T top, T width, T height) :
|
||||
Left (left),
|
||||
Top (top),
|
||||
Width (width),
|
||||
Height(height)
|
||||
left (left),
|
||||
top (top),
|
||||
width (width),
|
||||
height(height)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ Height(height)
|
|||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Rect<T>::Rect(const Vector2<T>& position, const Vector2<T>& size) :
|
||||
Left (position.x),
|
||||
Top (position.y),
|
||||
Width (size.x),
|
||||
Height(size.y)
|
||||
left (position.x),
|
||||
top (position.y),
|
||||
width (size.x),
|
||||
height(size.y)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -63,53 +63,53 @@ Height(size.y)
|
|||
template <typename T>
|
||||
template <typename U>
|
||||
Rect<T>::Rect(const Rect<U>& rectangle) :
|
||||
Left (static_cast<T>(rectangle.Left)),
|
||||
Top (static_cast<T>(rectangle.Top)),
|
||||
Width (static_cast<T>(rectangle.Width)),
|
||||
Height(static_cast<T>(rectangle.Height))
|
||||
left (static_cast<T>(rectangle.left)),
|
||||
top (static_cast<T>(rectangle.Top)),
|
||||
width (static_cast<T>(rectangle.Width)),
|
||||
height(static_cast<T>(rectangle.Height))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
bool Rect<T>::Contains(T x, T y) const
|
||||
bool Rect<T>::contains(T x, T y) const
|
||||
{
|
||||
return (x >= Left) && (x < Left + Width) && (y >= Top) && (y < Top + Height);
|
||||
return (x >= left) && (x < left + width) && (y >= top) && (y < top + height);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
bool Rect<T>::Contains(const Vector2<T>& point) const
|
||||
bool Rect<T>::contains(const Vector2<T>& point) const
|
||||
{
|
||||
return Contains(point.x, point.y);
|
||||
return contains(point.x, point.y);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
bool Rect<T>::Intersects(const Rect<T>& rectangle) const
|
||||
bool Rect<T>::intersects(const Rect<T>& rectangle) const
|
||||
{
|
||||
Rect<T> intersection;
|
||||
return Intersects(rectangle, intersection);
|
||||
return intersects(rectangle, intersection);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
bool Rect<T>::Intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
|
||||
bool Rect<T>::intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
|
||||
{
|
||||
// Compute the intersection boundaries
|
||||
T left = std::max(Left, rectangle.Left);
|
||||
T top = std::max(Top, rectangle.Top);
|
||||
T right = std::min(Left + Width, rectangle.Left + rectangle.Width);
|
||||
T bottom = std::min(Top + Height, rectangle.Top + rectangle.Height);
|
||||
T interLeft = std::max(left, rectangle.left);
|
||||
T interTop = std::max(top, rectangle.top);
|
||||
T interRight = std::min(left + width, rectangle.left + rectangle.width);
|
||||
T interBottom = std::min(top + height, rectangle.top + rectangle.height);
|
||||
|
||||
// If the intersection is valid (positive non zero area), then there is an intersection
|
||||
if ((left < right) && (top < bottom))
|
||||
if ((interLeft < interRight) && (interTop < interBottom))
|
||||
{
|
||||
intersection = Rect<T>(left, top, right - left, bottom - top);
|
||||
intersection = Rect<T>(interLeft, interTop, interRight - interLeft, interBottom - interTop);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -124,8 +124,8 @@ bool Rect<T>::Intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
|
|||
template <typename T>
|
||||
inline bool operator ==(const Rect<T>& left, const Rect<T>& right)
|
||||
{
|
||||
return (left.Left == right.Left) && (left.Width == right.Width) &&
|
||||
(left.Top == right.Top) && (left.Height == right.Height);
|
||||
return (left.left == right.left) && (left.width == right.width) &&
|
||||
(left.top == right.top) && (left.height == right.height);
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,6 +133,5 @@ inline bool operator ==(const Rect<T>& left, const Rect<T>& right)
|
|||
template <typename T>
|
||||
inline bool operator !=(const Rect<T>& left, const Rect<T>& right)
|
||||
{
|
||||
return (left.Left != right.Left) || (left.Width != right.Width) ||
|
||||
(left.Top != right.Top) || (left.Height != right.Height);
|
||||
return !(left == right);
|
||||
}
|
||||
|
|
|
@ -55,20 +55,20 @@ public :
|
|||
///
|
||||
/// \param size New size of the rectangle
|
||||
///
|
||||
/// \see GetSize
|
||||
/// \see getSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSize(const Vector2f& size);
|
||||
void setSize(const Vector2f& size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the rectangle
|
||||
///
|
||||
/// \return Size of the rectangle
|
||||
///
|
||||
/// \see SetSize
|
||||
/// \see setSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetSize() const;
|
||||
const Vector2f& getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points defining the shape
|
||||
|
@ -76,7 +76,7 @@ public :
|
|||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointCount() const;
|
||||
virtual unsigned int getPointCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
|
@ -88,7 +88,7 @@ public :
|
|||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetPoint(unsigned int index) const;
|
||||
virtual Vector2f getPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -115,12 +115,12 @@ private :
|
|||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::RectangleShape rectangle;
|
||||
/// rectangle.SetSize(sf::Vector2f(100, 50));
|
||||
/// rectangle.SetOutlineColor(sf::Color::Red);
|
||||
/// rectangle.SetOutlineThickness(5);
|
||||
/// rectangle.SetPosition(10, 20);
|
||||
/// rectangle.setSize(sf::Vector2f(100, 50));
|
||||
/// rectangle.setOutlineColor(sf::Color::Red);
|
||||
/// rectangle.setOutlineThickness(5);
|
||||
/// rectangle.setPosition(10, 20);
|
||||
/// ...
|
||||
/// window.Draw(rectangle);
|
||||
/// window.draw(rectangle);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Shape, sf::CircleShape, sf::ConvexShape
|
||||
|
|
|
@ -66,7 +66,7 @@ public :
|
|||
/// \param blendMode Blend mode to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderStates(sf::BlendMode blendMode);
|
||||
RenderStates(BlendMode blendMode);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct a default set of render states with a custom transform
|
||||
|
@ -74,7 +74,7 @@ public :
|
|||
/// \param transform Transform to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderStates(const sf::Transform& transform);
|
||||
RenderStates(const Transform& transform);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct a default set of render states with a custom texture
|
||||
|
@ -82,7 +82,7 @@ public :
|
|||
/// \param texture Texture to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderStates(const sf::Texture* texture);
|
||||
RenderStates(const Texture* texture);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct a default set of render states with a custom shader
|
||||
|
@ -90,7 +90,7 @@ public :
|
|||
/// \param shader Shader to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderStates(const sf::Shader* shader);
|
||||
RenderStates(const Shader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct a set of render states with all its attributes
|
||||
|
@ -101,8 +101,8 @@ public :
|
|||
/// \param shader Shader to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderStates(sf::BlendMode blendMode, const sf::Transform& transform,
|
||||
const sf::Texture* texture, const sf::Shader* shader);
|
||||
RenderStates(BlendMode blendMode, const Transform& transform,
|
||||
const Texture* texture, const Shader* shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static member data
|
||||
|
@ -112,10 +112,10 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::BlendMode BlendMode; ///< Blending mode
|
||||
sf::Transform Transform; ///< Transform
|
||||
const sf::Texture* Texture; ///< Texture
|
||||
const sf::Shader* Shader; ///< Shader
|
||||
BlendMode blendMode; ///< Blending mode
|
||||
Transform transform; ///< Transform
|
||||
const Texture* texture; ///< Texture
|
||||
const Shader* shader; ///< Shader
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -158,7 +158,7 @@ public :
|
|||
/// function: sf::RenderStates has an implicit one-argument
|
||||
/// constructor for each state.
|
||||
/// \code
|
||||
/// window.Draw(sprite, shader);
|
||||
/// window.draw(sprite, shader);
|
||||
/// \endcode
|
||||
///
|
||||
/// When you're inside the Draw function of a drawable
|
||||
|
|
|
@ -67,7 +67,7 @@ public :
|
|||
/// \param color Fill color to use to clear the render target
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear(const Color& color = Color(0, 0, 0, 255));
|
||||
void clear(const Color& color = Color(0, 0, 0, 255));
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current active view
|
||||
|
@ -81,24 +81,24 @@ public :
|
|||
/// so it is not necessary to keep the original one alive
|
||||
/// after calling this function.
|
||||
/// To restore the original view of the target, you can pass
|
||||
/// the result of GetDefaultView() to this function.
|
||||
/// the result of getDefaultView() to this function.
|
||||
///
|
||||
/// \param view New view to use
|
||||
///
|
||||
/// \see GetView, GetDefaultView
|
||||
/// \see getView, getDefaultView
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetView(const View& view);
|
||||
void setView(const View& view);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the view currently in use in the render target
|
||||
///
|
||||
/// \return The view object that is currently used
|
||||
///
|
||||
/// \see SetView, GetDefaultView
|
||||
/// \see setView, getDefaultView
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const View& GetView() const;
|
||||
const View& getView() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the default view of the render target
|
||||
|
@ -108,10 +108,10 @@ public :
|
|||
///
|
||||
/// \return The default view of the render target
|
||||
///
|
||||
/// \see SetView, GetView
|
||||
/// \see setView, getView
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const View& GetDefaultView() const;
|
||||
const View& getDefaultView() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the viewport of a view, applied to this render target
|
||||
|
@ -126,7 +126,7 @@ public :
|
|||
/// \return Viewport rectangle, expressed in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
IntRect GetViewport(const View& view) const;
|
||||
IntRect getViewport(const View& view) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a point from target coordinates to view coordinates
|
||||
|
@ -150,7 +150,7 @@ public :
|
|||
/// \return The converted point, in "world" units
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f ConvertCoords(unsigned int x, unsigned int y) const;
|
||||
Vector2f convertCoords(unsigned int x, unsigned int y) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a point from target coordinates to view coordinates
|
||||
|
@ -176,7 +176,7 @@ public :
|
|||
/// \return The converted point, in "world" units
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f ConvertCoords(unsigned int x, unsigned int y, const View& view) const;
|
||||
Vector2f convertCoords(unsigned int x, unsigned int y, const View& view) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Draw a drawable object to the render-target
|
||||
|
@ -185,7 +185,7 @@ public :
|
|||
/// \param states Render states to use for drawing
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Draw(const Drawable& drawable, const RenderStates& states = RenderStates::Default);
|
||||
void draw(const Drawable& drawable, const RenderStates& states = RenderStates::Default);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Draw primitives defined by an array of vertices
|
||||
|
@ -196,7 +196,7 @@ public :
|
|||
/// \param states Render states to use for drawing
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Draw(const Vertex* vertices, unsigned int vertexCount,
|
||||
void draw(const Vertex* vertices, unsigned int vertexCount,
|
||||
PrimitiveType type, const RenderStates& states = RenderStates::Default);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -204,10 +204,8 @@ public :
|
|||
///
|
||||
/// \return Size in pixels
|
||||
///
|
||||
/// \see GetHeight
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2u GetSize() const = 0;
|
||||
virtual Vector2u getSize() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Save the current OpenGL render states and matrices
|
||||
|
@ -222,10 +220,10 @@ public :
|
|||
/// calls Draw functions. Example:
|
||||
/// \code
|
||||
/// // OpenGL code here...
|
||||
/// window.PushGLStates();
|
||||
/// window.Draw(...);
|
||||
/// window.Draw(...);
|
||||
/// window.PopGLStates();
|
||||
/// window.pushGLStates();
|
||||
/// window.draw(...);
|
||||
/// window.draw(...);
|
||||
/// window.popGLStates();
|
||||
/// // OpenGL code here...
|
||||
/// \endcode
|
||||
///
|
||||
|
@ -238,44 +236,44 @@ public :
|
|||
/// saved and restored). Take a look at the ResetGLStates
|
||||
/// function if you do so.
|
||||
///
|
||||
/// \see PopGLStates
|
||||
/// \see popGLStates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void PushGLStates();
|
||||
void pushGLStates();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Restore the previously saved OpenGL render states and matrices
|
||||
///
|
||||
/// See the description of PushGLStates to get a detailed
|
||||
/// See the description of pushGLStates to get a detailed
|
||||
/// description of these functions.
|
||||
///
|
||||
/// \see PushGLStates
|
||||
/// \see pushGLStates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void PopGLStates();
|
||||
void popGLStates();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Reset the internal OpenGL states so that the target is ready for drawing
|
||||
///
|
||||
/// This function can be used when you mix SFML drawing
|
||||
/// and direct OpenGL rendering, if you choose not to use
|
||||
/// PushGLStates/PopGLStates. It makes sure that all OpenGL
|
||||
/// states needed by SFML are set, so that subsequent Draw()
|
||||
/// pushGLStates/popGLStates. It makes sure that all OpenGL
|
||||
/// states needed by SFML are set, so that subsequent draw()
|
||||
/// calls will work as expected.
|
||||
///
|
||||
/// Example:
|
||||
/// \code
|
||||
/// // OpenGL code here...
|
||||
/// glPushAttrib(...);
|
||||
/// window.ResetGLStates();
|
||||
/// window.Draw(...);
|
||||
/// window.Draw(...);
|
||||
/// window.resetGLStates();
|
||||
/// window.draw(...);
|
||||
/// window.draw(...);
|
||||
/// glPopAttrib(...);
|
||||
/// // OpenGL code here...
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ResetGLStates();
|
||||
void resetGLStates();
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -292,13 +290,13 @@ protected :
|
|||
/// target is created and ready for drawing.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize();
|
||||
void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Apply the current view
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ApplyCurrentView();
|
||||
void applyCurrentView();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Apply a new blending mode
|
||||
|
@ -306,7 +304,7 @@ protected :
|
|||
/// \param mode Blending mode to apply
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ApplyBlendMode(BlendMode mode);
|
||||
void applyBlendMode(BlendMode mode);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Apply a new transform
|
||||
|
@ -314,7 +312,7 @@ protected :
|
|||
/// \param transform Transform to apply
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ApplyTransform(const Transform& transform);
|
||||
void applyTransform(const Transform& transform);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Apply a new texture
|
||||
|
@ -322,7 +320,7 @@ protected :
|
|||
/// \param texture Texture to apply
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ApplyTexture(const Texture* texture);
|
||||
void applyTexture(const Texture* texture);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Apply a new shader
|
||||
|
@ -330,7 +328,7 @@ protected :
|
|||
/// \param shader Shader to apply
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ApplyShader(const Shader* shader);
|
||||
void applyShader(const Shader* shader);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -346,7 +344,7 @@ private :
|
|||
/// \return True if the function succeeded
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active) = 0;
|
||||
virtual bool activate(bool active) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Render states cache
|
||||
|
@ -356,11 +354,11 @@ private :
|
|||
{
|
||||
enum {VertexCacheSize = 4};
|
||||
|
||||
bool ViewChanged; ///< Has the current view changed since last draw?
|
||||
BlendMode LastBlendMode; ///< Cached blending mode
|
||||
Uint64 LastTextureId; ///< Cached texture
|
||||
bool UseVertexCache; ///< Did we previously use the vertex cache?
|
||||
Vertex VertexCache[VertexCacheSize]; ///< Pre-transformed vertices cache
|
||||
bool viewChanged; ///< Has the current view changed since last draw?
|
||||
BlendMode lastBlendMode; ///< Cached blending mode
|
||||
Uint64 lastTextureId; ///< Cached texture
|
||||
bool useVertexCache; ///< Did we previously use the vertex cache?
|
||||
Vertex vertexCache[VertexCacheSize]; ///< Pre-transformed vertices cache
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -397,7 +395,7 @@ private :
|
|||
/// OpenGL stuff. It is even possible to mix together OpenGL calls
|
||||
/// and regular SFML drawing commands. When doing so, make sure that
|
||||
/// OpenGL states are not messed up by calling the
|
||||
/// PushGLStates/PopGLStates functions.
|
||||
/// pushGLStates/popGLStates functions.
|
||||
///
|
||||
/// \see sf::RenderWindow, sf::RenderTexture, sf::View
|
||||
///
|
||||
|
|
|
@ -52,9 +52,9 @@ public :
|
|||
/// \brief Default constructor
|
||||
///
|
||||
/// Constructs an empty, invalid render-texture. You must
|
||||
/// call Create to have a valid render-texture.
|
||||
/// call create to have a valid render-texture.
|
||||
///
|
||||
/// \see Create
|
||||
/// \see create
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderTexture();
|
||||
|
@ -76,37 +76,37 @@ public :
|
|||
/// a depth-buffer. Otherwise it is unnecessary, and you should
|
||||
/// leave this parameter to false (which is its default value).
|
||||
///
|
||||
/// \param width Width of the render-texture
|
||||
/// \param height Height of the render-texture
|
||||
/// \param depthBuffer Do you want this render-texture to have a depth buffer?
|
||||
/// \param width Width of the render-texture
|
||||
/// \param height Height of the render-texture
|
||||
/// \param depthBuffer Do you want this render-texture to have a depth buffer?
|
||||
///
|
||||
/// \return True if creation has been successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Create(unsigned int width, unsigned int height, bool depthBuffer = false);
|
||||
bool create(unsigned int width, unsigned int height, bool depthBuffer = false);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable texture smoothing
|
||||
///
|
||||
/// This function is similar to Texture::SetSmooth.
|
||||
/// This function is similar to Texture::setSmooth.
|
||||
/// This parameter is disabled by default.
|
||||
///
|
||||
/// \param smooth True to enable smoothing, false to disable it
|
||||
///
|
||||
/// \see IsSmooth
|
||||
/// \see isSmooth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSmooth(bool smooth);
|
||||
void setSmooth(bool smooth);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether the smooth filtering is enabled or not
|
||||
///
|
||||
/// \return True if texture smoothing is enabled
|
||||
///
|
||||
/// \see SetSmooth
|
||||
/// \see setSmooth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsSmooth() const;
|
||||
bool isSmooth() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Activate of deactivate the render-texture for rendering
|
||||
|
@ -123,7 +123,7 @@ public :
|
|||
/// \return True if operation was successful, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SetActive(bool active = true);
|
||||
bool setActive(bool active = true);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the contents of the target texture
|
||||
|
@ -134,18 +134,18 @@ public :
|
|||
/// it may leave the texture in an undefined state.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Display();
|
||||
void display();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the size of the rendering region of the texture
|
||||
///
|
||||
/// The returned value is the size that you passed to
|
||||
/// the Create function.
|
||||
/// the create function.
|
||||
///
|
||||
/// \return Size in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2u GetSize() const;
|
||||
virtual Vector2u getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a read-only reference to the target texture
|
||||
|
@ -161,7 +161,7 @@ public :
|
|||
/// \return Const reference to the texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Texture& GetTexture() const;
|
||||
const Texture& getTexture() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -176,7 +176,7 @@ private :
|
|||
/// \return True if the function succeeded
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
virtual bool activate(bool active);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -215,35 +215,35 @@ private :
|
|||
///
|
||||
/// // Create a new render-texture
|
||||
/// sf::RenderTexture texture;
|
||||
/// if (!texture.Create(500, 500))
|
||||
/// if (!texture.create(500, 500))
|
||||
/// return -1
|
||||
///
|
||||
/// // The main loop
|
||||
/// while (window.IsOpen())
|
||||
/// while (window.isOpen())
|
||||
/// {
|
||||
/// // Event processing
|
||||
/// // ...
|
||||
///
|
||||
/// // Clear the whole texture with red color
|
||||
/// texture.Clear(sf::Color::Red);
|
||||
/// texture.clear(sf::Color::Red);
|
||||
///
|
||||
/// // Draw stuff to the texture
|
||||
/// texture.Draw(sprite); // sprite is a sf::Sprite
|
||||
/// texture.Draw(shape); // shape is a sf::Shape
|
||||
/// texture.Draw(text); // text is a sf::Text
|
||||
/// texture.draw(sprite); // sprite is a sf::Sprite
|
||||
/// texture.draw(shape); // shape is a sf::Shape
|
||||
/// texture.draw(text); // text is a sf::Text
|
||||
///
|
||||
/// // We're done drawing to the texture
|
||||
/// texture.Display();
|
||||
/// texture.display();
|
||||
///
|
||||
/// // Now we start rendering to the window, clear it first
|
||||
/// window.Clear();
|
||||
/// window.clear();
|
||||
///
|
||||
/// // Draw the texture
|
||||
/// sf::Sprite sprite(texture.GetTexture());
|
||||
/// window.Draw(sprite);
|
||||
/// sf::Sprite sprite(texture.getTexture());
|
||||
/// window.draw(sprite);
|
||||
///
|
||||
/// // End the current frame and display its contents on screen
|
||||
/// window.Display();
|
||||
/// window.display();
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -109,7 +109,7 @@ public :
|
|||
/// \return Size in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2u GetSize() const;
|
||||
virtual Vector2u getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Copy the current contents of the window to an image
|
||||
|
@ -118,14 +118,14 @@ public :
|
|||
/// screenshots of the application. If you want to update an
|
||||
/// image with the contents of the window and then use it for
|
||||
/// drawing, you should rather use a sf::Texture and its
|
||||
/// Update(Window&) function.
|
||||
/// update(Window&) function.
|
||||
/// You can also draw things directly to a texture with the
|
||||
/// sf::RenderTexture class.
|
||||
///
|
||||
/// \return Image containing the captured contents
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Image Capture() const;
|
||||
Image capture() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -137,7 +137,7 @@ private :
|
|||
/// the window is created.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnCreate();
|
||||
virtual void onCreate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Function called after the window has been resized
|
||||
|
@ -146,7 +146,7 @@ private :
|
|||
/// perform custom actions when the size of the window changes.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnResize();
|
||||
virtual void onResize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Activate the target for rendering
|
||||
|
@ -156,7 +156,7 @@ private :
|
|||
/// \return True if the function succeeded
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
virtual bool activate(bool active);
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -188,30 +188,30 @@ private :
|
|||
/// sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
|
||||
///
|
||||
/// // Limit the framerate to 60 frames per second (this step is optional)
|
||||
/// window.SetFramerateLimit(60);
|
||||
/// window.setFramerateLimit(60);
|
||||
///
|
||||
/// // The main loop - ends as soon as the window is closed
|
||||
/// while (window.IsOpen())
|
||||
/// while (window.isOpen())
|
||||
/// {
|
||||
/// // Event processing
|
||||
/// sf::Event event;
|
||||
/// while (window.PollEvent(event))
|
||||
/// while (window.pollEvent(event))
|
||||
/// {
|
||||
/// // Request for closing the window
|
||||
/// if (event.Type == sf::Event::Closed)
|
||||
/// window.Close();
|
||||
/// if (event.type == sf::Event::Closed)
|
||||
/// window.close();
|
||||
/// }
|
||||
///
|
||||
/// // Clear the whole window before rendering a new frame
|
||||
/// window.Clear();
|
||||
/// window.clear();
|
||||
///
|
||||
/// // Draw some graphical entities
|
||||
/// window.Draw(sprite);
|
||||
/// window.Draw(circle);
|
||||
/// window.Draw(text);
|
||||
/// window.draw(sprite);
|
||||
/// window.draw(circle);
|
||||
/// window.draw(text);
|
||||
///
|
||||
/// // End the current frame and display its contents on screen
|
||||
/// window.Display();
|
||||
/// window.display();
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
@ -233,15 +233,15 @@ private :
|
|||
/// ...
|
||||
///
|
||||
/// // Start the rendering loop
|
||||
/// while (window.IsOpen())
|
||||
/// while (window.isOpen())
|
||||
/// {
|
||||
/// // Process events
|
||||
/// ...
|
||||
///
|
||||
/// // Draw a background sprite
|
||||
/// window.PushGLStates();
|
||||
/// window.Draw(sprite);
|
||||
/// window.PopGLStates();
|
||||
/// window.pushGLStates();
|
||||
/// window.draw(sprite);
|
||||
/// window.popGLStates();
|
||||
///
|
||||
/// // Draw a 3D object using OpenGL
|
||||
/// glBegin(GL_QUADS);
|
||||
|
@ -250,12 +250,12 @@ private :
|
|||
/// glEnd();
|
||||
///
|
||||
/// // Draw text on top of the 3D object
|
||||
/// window.PushGLStates();
|
||||
/// window.Draw(text);
|
||||
/// window.PopGLStates();
|
||||
/// window.pushGLStates();
|
||||
/// window.draw(text);
|
||||
/// window.popGLStates();
|
||||
///
|
||||
/// // Finally, display the rendered frame on screen
|
||||
/// window.Display();
|
||||
/// window.display();
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -63,7 +63,7 @@ public :
|
|||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Special type/value that can be passed to SetParameter,
|
||||
/// \brief Special type/value that can be passed to setParameter,
|
||||
/// and that represents the texture of the object being drawn
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -102,10 +102,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromMemory, LoadFromStream
|
||||
/// \see loadFromMemory, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromFile(const std::string& filename, Type type);
|
||||
bool loadFromFile(const std::string& filename, Type type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load both the vertex and fragment shaders from files
|
||||
|
@ -123,10 +123,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromMemory, LoadFromStream
|
||||
/// \see loadFromMemory, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
|
||||
bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load either the vertex or fragment shader from a source code in memory
|
||||
|
@ -143,10 +143,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromStream
|
||||
/// \see loadFromFile, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromMemory(const std::string& shader, Type type);
|
||||
bool loadFromMemory(const std::string& shader, Type type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load both the vertex and fragment shaders from source codes in memory
|
||||
|
@ -164,10 +164,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromStream
|
||||
/// \see loadFromFile, loadFromStream
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
|
||||
bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load either the vertex or fragment shader from a custom stream
|
||||
|
@ -184,10 +184,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory
|
||||
/// \see loadFromFile, loadFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromStream(InputStream& stream, Type type);
|
||||
bool loadFromStream(InputStream& stream, Type type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load both the vertex and fragment shaders from custom streams
|
||||
|
@ -205,10 +205,10 @@ public :
|
|||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory
|
||||
/// \see loadFromFile, loadFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);
|
||||
bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a float parameter of the shader
|
||||
|
@ -222,14 +222,14 @@ public :
|
|||
/// uniform float myparam; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("myparam", 5.2f);
|
||||
/// shader.setParameter("myparam", 5.2f);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
/// \param x Value to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, float x);
|
||||
void setParameter(const std::string& name, float x);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a 2-components vector parameter of the shader
|
||||
|
@ -243,7 +243,7 @@ public :
|
|||
/// uniform vec2 myparam; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("myparam", 5.2f, 6.0f);
|
||||
/// shader.setParameter("myparam", 5.2f, 6.0f);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
|
@ -251,7 +251,7 @@ public :
|
|||
/// \param y Second component of the value to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, float x, float y);
|
||||
void setParameter(const std::string& name, float x, float y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a 3-components vector parameter of the shader
|
||||
|
@ -265,7 +265,7 @@ public :
|
|||
/// uniform vec3 myparam; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("myparam", 5.2f, 6.0f, -8.1f);
|
||||
/// shader.setParameter("myparam", 5.2f, 6.0f, -8.1f);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
|
@ -274,7 +274,7 @@ public :
|
|||
/// \param z Third component of the value to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, float x, float y, float z);
|
||||
void setParameter(const std::string& name, float x, float y, float z);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a 4-components vector parameter of the shader
|
||||
|
@ -288,7 +288,7 @@ public :
|
|||
/// uniform vec4 myparam; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("myparam", 5.2f, 6.0f, -8.1f, 0.4f);
|
||||
/// shader.setParameter("myparam", 5.2f, 6.0f, -8.1f, 0.4f);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
|
@ -298,7 +298,7 @@ public :
|
|||
/// \param w Fourth component of the value to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, float x, float y, float z, float w);
|
||||
void setParameter(const std::string& name, float x, float y, float z, float w);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a 2-components vector parameter of the shader
|
||||
|
@ -312,14 +312,14 @@ public :
|
|||
/// uniform vec2 myparam; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("myparam", sf::Vector2f(5.2f, 6.0f));
|
||||
/// shader.setParameter("myparam", sf::Vector2f(5.2f, 6.0f));
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
/// \param vector Vector to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, const Vector2f& vector);
|
||||
void setParameter(const std::string& name, const Vector2f& vector);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a 3-components vector parameter of the shader
|
||||
|
@ -333,14 +333,14 @@ public :
|
|||
/// uniform vec3 myparam; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("myparam", sf::Vector3f(5.2f, 6.0f, -8.1f));
|
||||
/// shader.setParameter("myparam", sf::Vector3f(5.2f, 6.0f, -8.1f));
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
/// \param vector Vector to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, const Vector3f& vector);
|
||||
void setParameter(const std::string& name, const Vector3f& vector);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a color parameter of the shader
|
||||
|
@ -360,14 +360,14 @@ public :
|
|||
/// uniform vec4 color; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("color", sf::Color(255, 128, 0, 255));
|
||||
/// shader.setParameter("color", sf::Color(255, 128, 0, 255));
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
/// \param color Color to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, const Color& color);
|
||||
void setParameter(const std::string& name, const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a matrix parameter of the shader
|
||||
|
@ -383,14 +383,14 @@ public :
|
|||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Translate(5, 10);
|
||||
/// shader.SetParameter("matrix", transform);
|
||||
/// shader.setParameter("matrix", transform);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the parameter in the shader
|
||||
/// \param transform Transform to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, const sf::Transform& transform);
|
||||
void setParameter(const std::string& name, const sf::Transform& transform);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a texture parameter of the shader
|
||||
|
@ -406,7 +406,7 @@ public :
|
|||
/// \code
|
||||
/// sf::Texture texture;
|
||||
/// ...
|
||||
/// shader.SetParameter("the_texture", texture);
|
||||
/// shader.setParameter("the_texture", texture);
|
||||
/// \endcode
|
||||
/// It is important to note that \a texture must remain alive as long
|
||||
/// as the shader uses it, no copy is made internally.
|
||||
|
@ -415,14 +415,14 @@ public :
|
|||
/// known in advance, you can pass the special value
|
||||
/// sf::Shader::CurrentTexture:
|
||||
/// \code
|
||||
/// shader.SetParameter("the_texture", sf::Shader::CurrentTexture).
|
||||
/// shader.setParameter("the_texture", sf::Shader::CurrentTexture).
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the texture in the shader
|
||||
/// \param texture Texture to assign
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, const Texture& texture);
|
||||
void setParameter(const std::string& name, const Texture& texture);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change a texture parameter of the shader
|
||||
|
@ -439,13 +439,13 @@ public :
|
|||
/// uniform sampler2D current; // this is the variable in the shader
|
||||
/// \endcode
|
||||
/// \code
|
||||
/// shader.SetParameter("current", sf::Shader::CurrentTexture);
|
||||
/// shader.setParameter("current", sf::Shader::CurrentTexture);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param name Name of the texture in the shader
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetParameter(const std::string& name, CurrentTextureType);
|
||||
void setParameter(const std::string& name, CurrentTextureType);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Bind the shader for rendering (activate it)
|
||||
|
@ -454,16 +454,16 @@ public :
|
|||
/// you want to use the shader with a custom OpenGL rendering
|
||||
/// instead of a SFML drawable.
|
||||
/// \code
|
||||
/// window.SetActive();
|
||||
/// shader.Bind();
|
||||
/// window.setActive();
|
||||
/// shader.bind();
|
||||
/// ... render OpenGL geometry ...
|
||||
/// shader.Unbind();
|
||||
/// shader.unbind();
|
||||
/// \endcode
|
||||
///
|
||||
/// \see Unbind
|
||||
/// \see unbind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Bind() const;
|
||||
void bind() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Unbind the shader (deactivate it)
|
||||
|
@ -472,10 +472,10 @@ public :
|
|||
/// you want to use the shader with a custom OpenGL rendering
|
||||
/// instead of a SFML drawable.
|
||||
///
|
||||
/// \see Bind
|
||||
/// \see bind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Unbind() const;
|
||||
void unbind() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether or not the system supports shaders
|
||||
|
@ -487,7 +487,7 @@ public :
|
|||
/// \return True if shaders are supported, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsAvailable();
|
||||
static bool isAvailable();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -503,7 +503,7 @@ private :
|
|||
/// \return True on success, false if any error happened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Compile(const char* vertexShaderCode, const char* fragmentShaderCode);
|
||||
bool compile(const char* vertexShaderCode, const char* fragmentShaderCode);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Bind all the textures used by the shader
|
||||
|
@ -512,7 +512,7 @@ private :
|
|||
/// updates the corresponding variables in the shader accordingly.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void BindTextures() const;
|
||||
void bindTextures() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -563,13 +563,13 @@ private :
|
|||
/// \li transforms (matrices)
|
||||
///
|
||||
/// The value of the variables can be changed at any time
|
||||
/// with either the various overloads of the SetParameter function:
|
||||
/// with either the various overloads of the setParameter function:
|
||||
/// \code
|
||||
/// shader.SetParameter("offset", 2.f);
|
||||
/// shader.SetParameter("color", 0.5f, 0.8f, 0.3f);
|
||||
/// shader.SetParameter("matrix", transform); // transform is a sf::Transform
|
||||
/// shader.SetParameter("overlay", texture); // texture is a sf::Texture
|
||||
/// shader.SetParameter("texture", sf::Shader::CurrentTexture);
|
||||
/// shader.setParameter("offset", 2.f);
|
||||
/// shader.setParameter("color", 0.5f, 0.8f, 0.3f);
|
||||
/// shader.setParameter("matrix", transform); // transform is a sf::Transform
|
||||
/// shader.setParameter("overlay", texture); // texture is a sf::Texture
|
||||
/// shader.setParameter("texture", sf::Shader::CurrentTexture);
|
||||
/// \endcode
|
||||
///
|
||||
/// The special Shader::CurrentTexture argument maps the
|
||||
|
@ -579,14 +579,14 @@ private :
|
|||
/// To apply a shader to a drawable, you must pass it as an
|
||||
/// additional parameter to the Draw function:
|
||||
/// \code
|
||||
/// window.Draw(sprite, shader);
|
||||
/// window.draw(sprite, shader);
|
||||
/// \endcode
|
||||
///
|
||||
/// ... which is in fact just a shortcut for this:
|
||||
/// \code
|
||||
/// sf::RenderStates states;
|
||||
/// states.Shader = shader;
|
||||
/// window.Draw(sprite, states);
|
||||
/// states.shader = shader;
|
||||
/// window.draw(sprite, states);
|
||||
/// \endcode
|
||||
///
|
||||
/// Shaders can be used on any drawable, but some combinations are
|
||||
|
@ -605,7 +605,7 @@ private :
|
|||
/// \li draw everything to a sf::RenderTexture, then draw it to
|
||||
/// the main target using the shader
|
||||
/// \li draw everything directly to the main target, then use
|
||||
/// sf::Texture::Update(Window&) to copy its contents to a texture
|
||||
/// sf::Texture::update(Window&) to copy its contents to a texture
|
||||
/// and draw it to the main target using the shader
|
||||
///
|
||||
/// The first technique is more optimized because it doesn't involve
|
||||
|
@ -617,10 +617,10 @@ private :
|
|||
/// sf::Shader can also be used directly as a raw shader for
|
||||
/// custom OpenGL geometry.
|
||||
/// \code
|
||||
/// window.SetActive();
|
||||
/// shader.Bind();
|
||||
/// window.setActive();
|
||||
/// shader.bind();
|
||||
/// ... render OpenGL geometry ...
|
||||
/// shader.Unbind();
|
||||
/// shader.unbind();
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -68,10 +68,10 @@ public :
|
|||
/// \param texture New texture
|
||||
/// \param resetRect Should the texture rect be reset to the size of the new texture?
|
||||
///
|
||||
/// \see GetTexture, SetTextureRect
|
||||
/// \see getTexture, setTextureRect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetTexture(const Texture* texture, bool resetRect = false);
|
||||
void setTexture(const Texture* texture, bool resetRect = false);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the sub-rectangle of the texture that the shape will display
|
||||
|
@ -82,10 +82,10 @@ public :
|
|||
///
|
||||
/// \param rect Rectangle defining the region of the texture to display
|
||||
///
|
||||
/// \see GetTextureRect, SetTexture
|
||||
/// \see getTextureRect, setTexture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetTextureRect(const IntRect& rect);
|
||||
void setTextureRect(const IntRect& rect);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the fill color of the shape
|
||||
|
@ -99,10 +99,10 @@ public :
|
|||
///
|
||||
/// \param color New color of the shape
|
||||
///
|
||||
/// \see GetFillColor, SetOutlineColor
|
||||
/// \see getFillColor, setOutlineColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetFillColor(const Color& color);
|
||||
void setFillColor(const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the outline color of the shape
|
||||
|
@ -112,10 +112,10 @@ public :
|
|||
///
|
||||
/// \param color New outline color of the shape
|
||||
///
|
||||
/// \see GetOutlineColor, SetFillColor
|
||||
/// \see getOutlineColor, setFillColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetOutlineColor(const Color& color);
|
||||
void setOutlineColor(const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the thickness of the shape's outline
|
||||
|
@ -126,10 +126,10 @@ public :
|
|||
///
|
||||
/// \param thickness New outline thickness
|
||||
///
|
||||
/// \see GetOutlineThickness
|
||||
/// \see getOutlineThickness
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetOutlineThickness(float thickness);
|
||||
void setOutlineThickness(float thickness);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the source texture of the shape
|
||||
|
@ -140,58 +140,60 @@ public :
|
|||
///
|
||||
/// \return Pointer to the shape's texture
|
||||
///
|
||||
/// \see SetTexture
|
||||
/// \see setTexture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Texture* GetTexture() const;
|
||||
const Texture* getTexture() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sub-rectangle of the texture displayed by the shape
|
||||
///
|
||||
/// \return Texture rectangle of the shape
|
||||
///
|
||||
/// \see SetTextureRect
|
||||
/// \see setTextureRect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const IntRect& GetTextureRect() const;
|
||||
const IntRect& getTextureRect() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the fill color of the shape
|
||||
///
|
||||
/// \return Fill color of the shape
|
||||
///
|
||||
/// \see SetFillColor
|
||||
/// \see setFillColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Color& GetFillColor() const;
|
||||
const Color& getFillColor() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the outline color of the shape
|
||||
///
|
||||
/// \return Outline color of the shape
|
||||
///
|
||||
/// \see SetOutlineColor
|
||||
/// \see setOutlineColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Color& GetOutlineColor() const;
|
||||
const Color& getOutlineColor() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the outline thickness of the shape
|
||||
///
|
||||
/// \return Outline thickness of the shape
|
||||
///
|
||||
/// \see SetOutlineThickness
|
||||
/// \see setOutlineThickness
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetOutlineThickness() const;
|
||||
float getOutlineThickness() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total number of points of the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
/// \see getPoint
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointCount() const = 0;
|
||||
virtual unsigned int getPointCount() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
|
@ -202,8 +204,10 @@ public :
|
|||
///
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
/// \see getPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetPoint(unsigned int index) const = 0;
|
||||
virtual Vector2f getPoint(unsigned int index) const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the local bounding rectangle of the entity
|
||||
|
@ -217,7 +221,7 @@ public :
|
|||
/// \return Local bounding rectangle of the entity
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetLocalBounds() const;
|
||||
FloatRect getLocalBounds() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the global bounding rectangle of the entity
|
||||
|
@ -231,7 +235,7 @@ public :
|
|||
/// \return Global bounding rectangle of the entity
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetGlobalBounds() const;
|
||||
FloatRect getGlobalBounds() const;
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -246,10 +250,10 @@ protected :
|
|||
///
|
||||
/// This function must be called by the derived class everytime
|
||||
/// the shape's points change (ie. the result of either
|
||||
/// GetPointCount or GetPoint is different).
|
||||
/// getPointCount or getPoint is different).
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update();
|
||||
void update();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -260,31 +264,31 @@ private :
|
|||
/// \param states Current render states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void Draw(RenderTarget& target, RenderStates states) const;
|
||||
virtual void draw(RenderTarget& target, RenderStates states) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the fill vertices' color
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdateFillColors();
|
||||
void updateFillColors();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the fill vertices' texture coordinates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdateTexCoords();
|
||||
void updateTexCoords();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the outline vertices' position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdateOutline();
|
||||
void updateOutline();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the outline vertices' color
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdateOutlineColors();
|
||||
void updateOutlineColors();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -333,8 +337,8 @@ private :
|
|||
///
|
||||
/// You can write your own derived shape class, there are only
|
||||
/// two virtual functions to override:
|
||||
/// \li GetOutlinePointCount must return the number of points of the shape
|
||||
/// \li GetOutlinePoint must return the points of the shape
|
||||
/// \li getPointCount must return the number of points of the shape
|
||||
/// \li getPoint must return the points of the shape
|
||||
///
|
||||
/// \see sf::RectangleShape, sf::CircleShape, sf::ConvexShape, sf::Transformable
|
||||
///
|
||||
|
|
|
@ -61,7 +61,7 @@ public :
|
|||
///
|
||||
/// \param texture Source texture
|
||||
///
|
||||
/// \see SetTexture
|
||||
/// \see setTexture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit Sprite(const Texture& texture);
|
||||
|
@ -72,7 +72,7 @@ public :
|
|||
/// \param texture Source texture
|
||||
/// \param rectangle Sub-rectangle of the texture to assign to the sprite
|
||||
///
|
||||
/// \see SetTexture, SetTextureRect
|
||||
/// \see setTexture, setTextureRect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Sprite(const Texture& texture, const IntRect& rectangle);
|
||||
|
@ -93,10 +93,10 @@ public :
|
|||
/// \param texture New texture
|
||||
/// \param resetRect Should the texture rect be reset to the size of the new texture?
|
||||
///
|
||||
/// \see GetTexture, SetTextureRect
|
||||
/// \see getTexture, setTextureRect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetTexture(const Texture& texture, bool resetRect = false);
|
||||
void setTexture(const Texture& texture, bool resetRect = false);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the sub-rectangle of the texture that the sprite will display
|
||||
|
@ -107,10 +107,10 @@ public :
|
|||
///
|
||||
/// \param rectangle Rectangle defining the region of the texture to display
|
||||
///
|
||||
/// \see GetTextureRect, SetTexture
|
||||
/// \see getTextureRect, setTexture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetTextureRect(const IntRect& rectangle);
|
||||
void setTextureRect(const IntRect& rectangle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the global color of the sprite
|
||||
|
@ -122,10 +122,10 @@ public :
|
|||
///
|
||||
/// \param color New color of the sprite
|
||||
///
|
||||
/// \see GetColor
|
||||
/// \see getColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetColor(const Color& color);
|
||||
void setColor(const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the source texture of the sprite
|
||||
|
@ -136,30 +136,30 @@ public :
|
|||
///
|
||||
/// \return Pointer to the sprite's texture
|
||||
///
|
||||
/// \see SetTexture
|
||||
/// \see setTexture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Texture* GetTexture() const;
|
||||
const Texture* getTexture() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sub-rectangle of the texture displayed by the sprite
|
||||
///
|
||||
/// \return Texture rectangle of the sprite
|
||||
///
|
||||
/// \see SetTextureRect
|
||||
/// \see setTextureRect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const IntRect& GetTextureRect() const;
|
||||
const IntRect& getTextureRect() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the global color of the sprite
|
||||
///
|
||||
/// \return Global color of the sprite
|
||||
///
|
||||
/// \see SetColor
|
||||
/// \see setColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Color& GetColor() const;
|
||||
const Color& getColor() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the local bounding rectangle of the entity
|
||||
|
@ -173,7 +173,7 @@ public :
|
|||
/// \return Local bounding rectangle of the entity
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetLocalBounds() const;
|
||||
FloatRect getLocalBounds() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the global bounding rectangle of the entity
|
||||
|
@ -187,7 +187,7 @@ public :
|
|||
/// \return Global bounding rectangle of the entity
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetGlobalBounds() const;
|
||||
FloatRect getGlobalBounds() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -198,19 +198,19 @@ private :
|
|||
/// \param states Current render states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void Draw(RenderTarget& target, RenderStates states) const;
|
||||
virtual void draw(RenderTarget& target, RenderStates states) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the vertices' positions
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdatePositions();
|
||||
void updatePositions();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the vertices' texture coordinates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdateTexCoords();
|
||||
void updateTexCoords();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -259,17 +259,17 @@ private :
|
|||
/// \code
|
||||
/// // Declare and load a texture
|
||||
/// sf::Texture texture;
|
||||
/// texture.LoadFromFile("texture.png");
|
||||
/// texture.loadFromFile("texture.png");
|
||||
///
|
||||
/// // Create a sprite
|
||||
/// sf::Sprite sprite;
|
||||
/// sprite.SetTexture(texture);
|
||||
/// sprite.SetTextureRect(sf::IntRect(10, 10, 50, 30));
|
||||
/// sprite.SetColor(sf::Color(255, 255, 255, 200));
|
||||
/// sprite.SetPosition(100, 25);
|
||||
/// sprite.setTexture(texture);
|
||||
/// sprite.setTextureRect(sf::IntRect(10, 10, 50, 30));
|
||||
/// sprite.setColor(sf::Color(255, 255, 255, 200));
|
||||
/// sprite.setPosition(100, 25);
|
||||
///
|
||||
/// // Draw it
|
||||
/// window.Draw(sprite);
|
||||
/// window.draw(sprite);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Texture, sf::Transformable
|
||||
|
|
|
@ -77,7 +77,7 @@ public :
|
|||
/// \param characterSize Base size of characters, in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit Text(const String& string, const Font& font = Font::GetDefaultFont(), unsigned int characterSize = 30);
|
||||
explicit Text(const String& string, const Font& font = Font::getDefaultFont(), unsigned int characterSize = 30);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the text's string
|
||||
|
@ -95,10 +95,10 @@ public :
|
|||
///
|
||||
/// \param string New string
|
||||
///
|
||||
/// \see GetString
|
||||
/// \see getString
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetString(const String& string);
|
||||
void setString(const String& string);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the text's font
|
||||
|
@ -110,14 +110,14 @@ public :
|
|||
/// If the font is destroyed and the text tries to
|
||||
/// use it, the behaviour is undefined.
|
||||
/// Texts have a valid font by default, which the built-in
|
||||
/// Font::GetDefaultFont().
|
||||
/// Font::getDefaultFont().
|
||||
///
|
||||
/// \param font New font
|
||||
///
|
||||
/// \see GetFont
|
||||
/// \see getFont
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetFont(const Font& font);
|
||||
void setFont(const Font& font);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the character size
|
||||
|
@ -126,10 +126,10 @@ public :
|
|||
///
|
||||
/// \param size New character size, in pixels
|
||||
///
|
||||
/// \see GetCharacterSize
|
||||
/// \see getCharacterSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetCharacterSize(unsigned int size);
|
||||
void setCharacterSize(unsigned int size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the text's style
|
||||
|
@ -140,10 +140,10 @@ public :
|
|||
///
|
||||
/// \param style New style
|
||||
///
|
||||
/// \see GetStyle
|
||||
/// \see getStyle
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetStyle(Uint32 style);
|
||||
void setStyle(Uint32 style);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the global color of the text
|
||||
|
@ -152,10 +152,10 @@ public :
|
|||
///
|
||||
/// \param color New color of the text
|
||||
///
|
||||
/// \see GetColor
|
||||
/// \see getColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetColor(const Color& color);
|
||||
void setColor(const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the text's string
|
||||
|
@ -164,17 +164,17 @@ public :
|
|||
/// be converted to standard string types. So, the following
|
||||
/// lines of code are all valid:
|
||||
/// \code
|
||||
/// sf::String s1 = text.GetString();
|
||||
/// std::string s2 = text.GetString();
|
||||
/// std::wstring s3 = text.GetString();
|
||||
/// sf::String s1 = text.getString();
|
||||
/// std::string s2 = text.getString();
|
||||
/// std::wstring s3 = text.getString();
|
||||
/// \endcode
|
||||
///
|
||||
/// \return Text's string
|
||||
///
|
||||
/// \see GetString
|
||||
/// \see setString
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const String& GetString() const;
|
||||
const String& getString() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the text's font
|
||||
|
@ -184,40 +184,40 @@ public :
|
|||
///
|
||||
/// \return Text's font
|
||||
///
|
||||
/// \see SetFont
|
||||
/// \see setFont
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Font& GetFont() const;
|
||||
const Font& getFont() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the character size
|
||||
///
|
||||
/// \return Size of the characters, in pixels
|
||||
///
|
||||
/// \see SetCharacterSize
|
||||
/// \see setCharacterSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetCharacterSize() const;
|
||||
unsigned int getCharacterSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the text's style
|
||||
///
|
||||
/// \return Text's style
|
||||
///
|
||||
/// \see SetStyle
|
||||
/// \see setStyle
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint32 GetStyle() const;
|
||||
Uint32 getStyle() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the global color of the text
|
||||
///
|
||||
/// \return Global color of the text
|
||||
///
|
||||
/// \see SetColor
|
||||
/// \see setColor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Color& GetColor() const;
|
||||
const Color& getColor() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the position of the \a index-th character
|
||||
|
@ -234,7 +234,7 @@ public :
|
|||
/// \return Position of the character
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f FindCharacterPos(std::size_t index) const;
|
||||
Vector2f findCharacterPos(std::size_t index) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the local bounding rectangle of the entity
|
||||
|
@ -248,7 +248,7 @@ public :
|
|||
/// \return Local bounding rectangle of the entity
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetLocalBounds() const;
|
||||
FloatRect getLocalBounds() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the global bounding rectangle of the entity
|
||||
|
@ -262,7 +262,7 @@ public :
|
|||
/// \return Global bounding rectangle of the entity
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetGlobalBounds() const;
|
||||
FloatRect getGlobalBounds() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -273,13 +273,13 @@ private :
|
|||
/// \param states Current render states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void Draw(RenderTarget& target, RenderStates states) const;
|
||||
virtual void draw(RenderTarget& target, RenderStates states) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the text's geometry
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void UpdateGeometry();
|
||||
void updateGeometry();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -335,17 +335,17 @@ private :
|
|||
/// \code
|
||||
/// // Declare and load a font
|
||||
/// sf::Font font;
|
||||
/// font.LoadFromFile("arial.ttf");
|
||||
/// font.loadFromFile("arial.ttf");
|
||||
///
|
||||
/// // Create a text
|
||||
/// sf::Text text("hello");
|
||||
/// text.SetFont(font);
|
||||
/// text.SetCharacterSize(30);
|
||||
/// text.SetStyle(sf::Text::Bold);
|
||||
/// text.SetColor(sf::Color::Red);
|
||||
/// text.setFont(font);
|
||||
/// text.setCharacterSize(30);
|
||||
/// text.setStyle(sf::Text::Bold);
|
||||
/// text.setColor(sf::Color::Red);
|
||||
///
|
||||
/// // Draw it
|
||||
/// window.Draw(text);
|
||||
/// window.draw(text);
|
||||
/// \endcode
|
||||
///
|
||||
/// Note that you don't need to load a font to draw text,
|
||||
|
|
|
@ -93,7 +93,7 @@ public :
|
|||
/// \return True if creation was successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Create(unsigned int width, unsigned int height);
|
||||
bool create(unsigned int width, unsigned int height);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the texture from a file on disk
|
||||
|
@ -101,8 +101,8 @@ public :
|
|||
/// This function is a shortcut for the following code:
|
||||
/// \code
|
||||
/// sf::Image image;
|
||||
/// image.LoadFromFile(filename);
|
||||
/// texture.LoadFromImage(image, area);
|
||||
/// image.loadFromFile(filename);
|
||||
/// texture.loadFromImage(image, area);
|
||||
/// \endcode
|
||||
///
|
||||
/// The \a area argument can be used to load only a sub-rectangle
|
||||
|
@ -112,7 +112,7 @@ public :
|
|||
/// is adjusted to fit the image size.
|
||||
///
|
||||
/// The maximum size for a texture depends on the graphics
|
||||
/// driver and can be retrieved with the GetMaximumSize function.
|
||||
/// driver and can be retrieved with the getMaximumSize function.
|
||||
///
|
||||
/// If this function fails, the texture is left unchanged.
|
||||
///
|
||||
|
@ -121,10 +121,10 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromMemory, LoadFromStream, LoadFromImage
|
||||
/// \see loadFromMemory, loadFromStream, loadFromImage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromFile(const std::string& filename, const IntRect& area = IntRect());
|
||||
bool loadFromFile(const std::string& filename, const IntRect& area = IntRect());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the texture from a file in memory
|
||||
|
@ -132,8 +132,8 @@ public :
|
|||
/// This function is a shortcut for the following code:
|
||||
/// \code
|
||||
/// sf::Image image;
|
||||
/// image.LoadFromMemory(data, size);
|
||||
/// texture.LoadFromImage(image, area);
|
||||
/// image.loadFromMemory(data, size);
|
||||
/// texture.loadFromImage(image, area);
|
||||
/// \endcode
|
||||
///
|
||||
/// The \a area argument can be used to load only a sub-rectangle
|
||||
|
@ -143,7 +143,7 @@ public :
|
|||
/// is adjusted to fit the image size.
|
||||
///
|
||||
/// The maximum size for a texture depends on the graphics
|
||||
/// driver and can be retrieved with the GetMaximumSize function.
|
||||
/// driver and can be retrieved with the getMaximumSize function.
|
||||
///
|
||||
/// If this function fails, the texture is left unchanged.
|
||||
///
|
||||
|
@ -153,10 +153,10 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromStream, LoadFromImage
|
||||
/// \see loadFromFile, loadFromStream, loadFromImage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());
|
||||
bool loadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the texture from a file in memory
|
||||
|
@ -164,8 +164,8 @@ public :
|
|||
/// This function is a shortcut for the following code:
|
||||
/// \code
|
||||
/// sf::Image image;
|
||||
/// image.LoadFromStream(stream);
|
||||
/// texture.LoadFromImage(image, area);
|
||||
/// image.loadFromStream(stream);
|
||||
/// texture.loadFromImage(image, area);
|
||||
/// \endcode
|
||||
///
|
||||
/// The \a area argument can be used to load only a sub-rectangle
|
||||
|
@ -175,7 +175,7 @@ public :
|
|||
/// is adjusted to fit the image size.
|
||||
///
|
||||
/// The maximum size for a texture depends on the graphics
|
||||
/// driver and can be retrieved with the GetMaximumSize function.
|
||||
/// driver and can be retrieved with the getMaximumSize function.
|
||||
///
|
||||
/// If this function fails, the texture is left unchanged.
|
||||
///
|
||||
|
@ -184,10 +184,10 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory, LoadFromImage
|
||||
/// \see loadFromFile, loadFromMemory, loadFromImage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromStream(sf::InputStream& stream, const IntRect& area = IntRect());
|
||||
bool loadFromStream(sf::InputStream& stream, const IntRect& area = IntRect());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Load the texture from an image
|
||||
|
@ -199,7 +199,7 @@ public :
|
|||
/// is adjusted to fit the image size.
|
||||
///
|
||||
/// The maximum size for a texture depends on the graphics
|
||||
/// driver and can be retrieved with the GetMaximumSize function.
|
||||
/// driver and can be retrieved with the getMaximumSize function.
|
||||
///
|
||||
/// If this function fails, the texture is left unchanged.
|
||||
///
|
||||
|
@ -208,30 +208,30 @@ public :
|
|||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory
|
||||
/// \see loadFromFile, loadFromMemory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromImage(const Image& image, const IntRect& area = IntRect());
|
||||
bool loadFromImage(const Image& image, const IntRect& area = IntRect());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the width of the texture
|
||||
///
|
||||
/// \return Width in pixels
|
||||
///
|
||||
/// \see GetHeight
|
||||
/// \see getHeight
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int getWidth() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the height of the texture
|
||||
///
|
||||
/// \return Height in pixels
|
||||
///
|
||||
/// \see GetWidth
|
||||
/// \see getWidth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetHeight() const;
|
||||
unsigned int getHeight() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Copy the texture pixels to an image
|
||||
|
@ -243,10 +243,10 @@ public :
|
|||
///
|
||||
/// \return Image containing the texture's pixels
|
||||
///
|
||||
/// \see LoadFromImage
|
||||
/// \see loadFromImage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Image CopyToImage() const;
|
||||
Image copyToImage() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the whole texture from an array of pixels
|
||||
|
@ -264,7 +264,7 @@ public :
|
|||
/// \param pixels Array of pixels to copy to the texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update(const Uint8* pixels);
|
||||
void update(const Uint8* pixels);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update a part of the texture from an array of pixels
|
||||
|
@ -286,7 +286,7 @@ public :
|
|||
/// \param y Y offset in the texture where to copy the source pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
|
||||
void update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the texture from an image
|
||||
|
@ -306,7 +306,7 @@ public :
|
|||
/// \param image Image to copy to the texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update(const Image& image);
|
||||
void update(const Image& image);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update a part of the texture from an image
|
||||
|
@ -323,7 +323,7 @@ public :
|
|||
/// \param y Y offset in the texture where to copy the source image
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update(const Image& image, unsigned int x, unsigned int y);
|
||||
void update(const Image& image, unsigned int x, unsigned int y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the texture from the contents of a window
|
||||
|
@ -343,7 +343,7 @@ public :
|
|||
/// \param window Window to copy to the texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update(const Window& window);
|
||||
void update(const Window& window);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update a part of the texture from the contents of a window
|
||||
|
@ -360,7 +360,7 @@ public :
|
|||
/// \param y Y offset in the texture where to copy the source window
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update(const Window& window, unsigned int x, unsigned int y);
|
||||
void update(const Window& window, unsigned int x, unsigned int y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Activate the texture for rendering
|
||||
|
@ -382,7 +382,7 @@ public :
|
|||
/// \param coordinateType Type of texture coordinates to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Bind(CoordinateType coordinateType = Normalized) const;
|
||||
void bind(CoordinateType coordinateType = Normalized) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the smooth filter
|
||||
|
@ -395,20 +395,20 @@ public :
|
|||
///
|
||||
/// \param smooth True to enable smoothing, false to disable it
|
||||
///
|
||||
/// \see IsSmooth
|
||||
/// \see isSmooth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSmooth(bool smooth);
|
||||
void setSmooth(bool smooth);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether the smooth filter is enabled or not
|
||||
///
|
||||
/// \return True if smoothing is enabled, false if it is disabled
|
||||
///
|
||||
/// \see SetSmooth
|
||||
/// \see setSmooth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsSmooth() const;
|
||||
bool isSmooth() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable repeating
|
||||
|
@ -429,20 +429,20 @@ public :
|
|||
///
|
||||
/// \param repeated True to repeat the texture, false to disable repeating
|
||||
///
|
||||
/// \see IsRepeated
|
||||
/// \see isRepeated
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetRepeated(bool repeated);
|
||||
void setRepeated(bool repeated);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether the texture is repeated or not
|
||||
///
|
||||
/// \return True if repeat mode is enabled, false if it is disabled
|
||||
///
|
||||
/// \see SetRepeated
|
||||
/// \see setRepeated
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsRepeated() const;
|
||||
bool isRepeated() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -464,7 +464,7 @@ public :
|
|||
/// \return Maximum size allowed for textures, in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static unsigned int GetMaximumSize();
|
||||
static unsigned int getMaximumSize();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -484,7 +484,7 @@ private :
|
|||
/// \return Valid nearest size (greater than or equal to specified size)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static unsigned int getValidSize(unsigned int size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -518,7 +518,7 @@ private :
|
|||
/// Being stored in the graphics card memory has some drawbacks.
|
||||
/// A texture cannot be manipulated as freely as a sf::Image,
|
||||
/// you need to prepare the pixels first and then upload them
|
||||
/// to the texture in a single operation (see Texture::Update).
|
||||
/// to the texture in a single operation (see Texture::update).
|
||||
///
|
||||
/// sf::Texture makes it easy to convert from/to sf::Image, but
|
||||
/// keep in mind that these calls require transfers between
|
||||
|
@ -531,7 +531,7 @@ private :
|
|||
/// However, if you want to perform some modifications on the pixels
|
||||
/// before creating the final texture, you can load your file to a
|
||||
/// sf::Image, do whatever you need with the pixels, and then call
|
||||
/// Texture::LoadFromImage.
|
||||
/// Texture::loadFromImage.
|
||||
///
|
||||
/// Since they live in the graphics card memory, the pixels of a texture
|
||||
/// cannot be accessed without a slow copy first. And they cannot be
|
||||
|
@ -552,15 +552,15 @@ private :
|
|||
///
|
||||
/// // Load a texture from a file
|
||||
/// sf::Texture texture;
|
||||
/// if (!texture.LoadFromFile("texture.png"))
|
||||
/// if (!texture.loadFromFile("texture.png"))
|
||||
/// return -1;
|
||||
///
|
||||
/// // Assign it to a sprite
|
||||
/// sf::Sprite sprite;
|
||||
/// sprite.SetTexture(texture);
|
||||
/// sprite.setTexture(texture);
|
||||
///
|
||||
/// // Draw the textured sprite
|
||||
/// window.Draw(sprite);
|
||||
/// window.draw(sprite);
|
||||
/// \endcode
|
||||
///
|
||||
/// \code
|
||||
|
@ -569,7 +569,7 @@ private :
|
|||
///
|
||||
/// // Create an empty texture
|
||||
/// sf::Texture texture;
|
||||
/// if (!texture.Create(640, 480))
|
||||
/// if (!texture.create(640, 480))
|
||||
/// return -1;
|
||||
///
|
||||
/// // Create a sprite that will display the texture
|
||||
|
@ -581,10 +581,10 @@ private :
|
|||
///
|
||||
/// // update the texture
|
||||
/// sf::Uint8* pixels = ...; // get a fresh chunk of pixels (the next frame of a movie, for example)
|
||||
/// texture.Update(pixels);
|
||||
/// texture.update(pixels);
|
||||
///
|
||||
/// // draw it
|
||||
/// window.Draw(sprite);
|
||||
/// window.draw(sprite);
|
||||
///
|
||||
/// ...
|
||||
/// }
|
||||
|
|
|
@ -78,13 +78,13 @@ public :
|
|||
///
|
||||
/// \code
|
||||
/// sf::Transform transform = ...;
|
||||
/// glLoadMatrixf(transform.GetMatrix());
|
||||
/// glLoadMatrixf(transform.getMatrix());
|
||||
/// \endcode
|
||||
///
|
||||
/// \return Pointer to a 4x4 matrix
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const float* GetMatrix() const;
|
||||
const float* getMatrix() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the inverse of the transform
|
||||
|
@ -95,7 +95,7 @@ public :
|
|||
/// \return A new transform which is the inverse of self
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform GetInverse() const;
|
||||
Transform getInverse() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Transform a 2D point
|
||||
|
@ -106,7 +106,7 @@ public :
|
|||
/// \return Transformed point
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f TransformPoint(float x, float y) const;
|
||||
Vector2f transformPoint(float x, float y) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Transform a 2D point
|
||||
|
@ -116,7 +116,7 @@ public :
|
|||
/// \return Transformed point
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f TransformPoint(const Vector2f& point) const;
|
||||
Vector2f transformPoint(const Vector2f& point) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Transform a rectangle
|
||||
|
@ -132,7 +132,7 @@ public :
|
|||
/// \return Transformed rectangle
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect TransformRect(const FloatRect& rectangle) const;
|
||||
FloatRect transformRect(const FloatRect& rectangle) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with another one
|
||||
|
@ -146,7 +146,7 @@ public :
|
|||
/// \return Reference to *this
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Combine(const Transform& transform);
|
||||
Transform& combine(const Transform& transform);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a translation
|
||||
|
@ -155,7 +155,7 @@ public :
|
|||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Translate(100, 200).Rotate(45);
|
||||
/// transform.translate(100, 200).rotate(45);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param x Offset to apply on X axis
|
||||
|
@ -163,10 +163,10 @@ public :
|
|||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Rotate, Scale
|
||||
/// \see rotate, scale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Translate(float x, float y);
|
||||
Transform& translate(float x, float y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a translation
|
||||
|
@ -175,17 +175,17 @@ public :
|
|||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Translate(sf::Vector2f(100, 200)).Rotate(45);
|
||||
/// transform.translate(sf::Vector2f(100, 200)).rotate(45);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param offset Translation offset to apply
|
||||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Rotate, Scale
|
||||
/// \see rotate, scale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Translate(const Vector2f& offset);
|
||||
Transform& translate(const Vector2f& offset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a rotation
|
||||
|
@ -194,17 +194,17 @@ public :
|
|||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Rotate(90).Translate(50, 20);
|
||||
/// transform.rotate(90).translate(50, 20);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param angle Rotation angle, in degrees
|
||||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Scale
|
||||
/// \see translate, scale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Rotate(float angle);
|
||||
Transform& rotate(float angle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a rotation
|
||||
|
@ -212,13 +212,13 @@ public :
|
|||
/// The center of rotation is provided for convenience as a second
|
||||
/// argument, so that you can build rotations around arbitrary points
|
||||
/// more easily (and efficiently) than the usual
|
||||
/// Translate(-center).Rotate(angle).Translate(center).
|
||||
/// translate(-center).rotate(angle).translate(center).
|
||||
///
|
||||
/// This function returns a reference to *this, so that calls
|
||||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Rotate(90, 8, 3).Translate(50, 20);
|
||||
/// transform.rotate(90, 8, 3).translate(50, 20);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param angle Rotation angle, in degrees
|
||||
|
@ -227,10 +227,10 @@ public :
|
|||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Scale
|
||||
/// \see translate, scale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Rotate(float angle, float centerX, float centerY);
|
||||
Transform& rotate(float angle, float centerX, float centerY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a rotation
|
||||
|
@ -238,13 +238,13 @@ public :
|
|||
/// The center of rotation is provided for convenience as a second
|
||||
/// argument, so that you can build rotations around arbitrary points
|
||||
/// more easily (and efficiently) than the usual
|
||||
/// Translate(-center).Rotate(angle).Translate(center).
|
||||
/// translate(-center).rotate(angle).translate(center).
|
||||
///
|
||||
/// This function returns a reference to *this, so that calls
|
||||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Rotate(90, sf::Vector2f(8, 3)).Translate(sf::Vector2f(50, 20));
|
||||
/// transform.rotate(90, sf::Vector2f(8, 3)).translate(sf::Vector2f(50, 20));
|
||||
/// \endcode
|
||||
///
|
||||
/// \param angle Rotation angle, in degrees
|
||||
|
@ -252,10 +252,10 @@ public :
|
|||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Scale
|
||||
/// \see translate, scale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Rotate(float angle, const Vector2f& center);
|
||||
Transform& rotate(float angle, const Vector2f& center);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a scaling
|
||||
|
@ -264,7 +264,7 @@ public :
|
|||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Scale(2, 1).Rotate(45);
|
||||
/// transform.scale(2, 1).rotate(45);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param scaleX Scaling factor on the X axis
|
||||
|
@ -272,10 +272,10 @@ public :
|
|||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Rotate
|
||||
/// \see translate, rotate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Scale(float scaleX, float scaleY);
|
||||
Transform& scale(float scaleX, float scaleY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a scaling
|
||||
|
@ -283,13 +283,13 @@ public :
|
|||
/// The center of scaling is provided for convenience as a second
|
||||
/// argument, so that you can build scaling around arbitrary points
|
||||
/// more easily (and efficiently) than the usual
|
||||
/// Translate(-center).Scale(factors).Translate(center).
|
||||
/// translate(-center).scale(factors).translate(center).
|
||||
///
|
||||
/// This function returns a reference to *this, so that calls
|
||||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Scale(2, 1, 8, 3).Rotate(45);
|
||||
/// transform.scale(2, 1, 8, 3).rotate(45);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param scaleX Scaling factor on X axis
|
||||
|
@ -299,10 +299,10 @@ public :
|
|||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Rotate
|
||||
/// \see translate, rotate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Scale(float scaleX, float scaleY, float centerX, float centerY);
|
||||
Transform& scale(float scaleX, float scaleY, float centerX, float centerY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a scaling
|
||||
|
@ -311,17 +311,17 @@ public :
|
|||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Scale(sf::Vector2f(2, 1)).Rotate(45);
|
||||
/// transform.scale(sf::Vector2f(2, 1)).rotate(45);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param factors Scaling factors
|
||||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Rotate
|
||||
/// \see translate, rotate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Scale(const Vector2f& factors);
|
||||
Transform& scale(const Vector2f& factors);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Combine the current transform with a scaling
|
||||
|
@ -329,13 +329,13 @@ public :
|
|||
/// The center of scaling is provided for convenience as a second
|
||||
/// argument, so that you can build scaling around arbitrary points
|
||||
/// more easily (and efficiently) than the usual
|
||||
/// Translate(-center).Scale(factors).Translate(center).
|
||||
/// translate(-center).scale(factors).translate(center).
|
||||
///
|
||||
/// This function returns a reference to *this, so that calls
|
||||
/// can be chained.
|
||||
/// \code
|
||||
/// sf::Transform transform;
|
||||
/// transform.Scale(sf::Vector2f(2, 1), sf::Vector2f(8, 3)).Rotate(45);
|
||||
/// transform.scale(sf::Vector2f(2, 1), sf::Vector2f(8, 3)).rotate(45);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param factors Scaling factors
|
||||
|
@ -343,10 +343,10 @@ public :
|
|||
///
|
||||
/// \return Reference to *this
|
||||
///
|
||||
/// \see Translate, Rotate
|
||||
/// \see translate, rotate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Transform& Scale(const Vector2f& factors, const Vector2f& center);
|
||||
Transform& scale(const Vector2f& factors, const Vector2f& center);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static member data
|
||||
|
@ -365,7 +365,7 @@ private:
|
|||
/// \relates sf::Transform
|
||||
/// \brief Overload of binary operator * to combine two transforms
|
||||
///
|
||||
/// This call is equivalent to calling Transform(left).Combine(right).
|
||||
/// This call is equivalent to calling Transform(left).combine(right).
|
||||
///
|
||||
/// \param left Left operand (the first transform)
|
||||
/// \param right Right operand (the second transform)
|
||||
|
@ -379,7 +379,7 @@ SFML_GRAPHICS_API Transform operator *(const Transform& left, const Transform& r
|
|||
/// \relates sf::Transform
|
||||
/// \brief Overload of binary operator *= to combine two transforms
|
||||
///
|
||||
/// This call is equivalent to calling left.Combine(right).
|
||||
/// This call is equivalent to calling left.combine(right).
|
||||
///
|
||||
/// \param left Left operand (the first transform)
|
||||
/// \param right Right operand (the second transform)
|
||||
|
@ -393,7 +393,7 @@ SFML_GRAPHICS_API Transform& operator *=(Transform& left, const Transform& right
|
|||
/// \relates sf::Transform
|
||||
/// \brief Overload of binary operator * to transform a point
|
||||
///
|
||||
/// This call is equivalent to calling left.TransformPoint(right).
|
||||
/// This call is equivalent to calling left.transformPoint(right).
|
||||
///
|
||||
/// \param left Left operand (the transform)
|
||||
/// \param right Right operand (the point to transform)
|
||||
|
@ -431,18 +431,18 @@ SFML_GRAPHICS_API Vector2f operator *(const Transform& left, const Vector2f& rig
|
|||
/// \code
|
||||
/// // define a translation transform
|
||||
/// sf::Transform translation;
|
||||
/// translation.Translate(20, 50);
|
||||
/// translation.translate(20, 50);
|
||||
///
|
||||
/// // define a rotation transform
|
||||
/// sf::Transform rotation;
|
||||
/// rotation.Rotate(45);
|
||||
/// rotation.rotate(45);
|
||||
///
|
||||
/// // combine them
|
||||
/// sf::Transform transform = translation * rotation;
|
||||
///
|
||||
/// // use the result to transform stuff...
|
||||
/// sf::Vector2f point = transform.TransformPoint(10, 20);
|
||||
/// sf::FloatRect rect = transform.TransformRect(sf::FloatRect(0, 0, 10, 100));
|
||||
/// sf::Vector2f point = transform.transformPoint(10, 20);
|
||||
/// sf::FloatRect rect = transform.transformRect(sf::FloatRect(0, 0, 10, 100));
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Transformable, sf::RenderStates
|
||||
|
|
|
@ -55,7 +55,7 @@ public :
|
|||
virtual ~Transformable();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of the object
|
||||
/// \brief set the position of the object
|
||||
///
|
||||
/// This function completely overwrites the previous position.
|
||||
/// See Move to apply an offset based on the previous position instead.
|
||||
|
@ -64,13 +64,13 @@ public :
|
|||
/// \param x X coordinate of the new position
|
||||
/// \param y Y coordinate of the new position
|
||||
///
|
||||
/// \see Move, GetPosition
|
||||
/// \see move, getPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPosition(float x, float y);
|
||||
void setPosition(float x, float y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of the object
|
||||
/// \brief set the position of the object
|
||||
///
|
||||
/// This function completely overwrites the previous position.
|
||||
/// See Move to apply an offset based on the previous position instead.
|
||||
|
@ -78,13 +78,13 @@ public :
|
|||
///
|
||||
/// \param position New position
|
||||
///
|
||||
/// \see Move, GetPosition
|
||||
/// \see move, getPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPosition(const Vector2f& position);
|
||||
void setPosition(const Vector2f& position);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the orientation of the object
|
||||
/// \brief set the orientation of the object
|
||||
///
|
||||
/// This function completely overwrites the previous rotation.
|
||||
/// See Rotate to add an angle based on the previous rotation instead.
|
||||
|
@ -92,13 +92,13 @@ public :
|
|||
///
|
||||
/// \param angle New rotation, in degrees
|
||||
///
|
||||
/// \see Rotate, GetRotation
|
||||
/// \see rotate, getRotation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetRotation(float angle);
|
||||
void setRotation(float angle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the scale factors of the object
|
||||
/// \brief set the scale factors of the object
|
||||
///
|
||||
/// This function completely overwrites the previous scale.
|
||||
/// See Scale to add a factor based on the previous scale instead.
|
||||
|
@ -107,13 +107,13 @@ public :
|
|||
/// \param factorX New horizontal scale factor
|
||||
/// \param factorY New vertical scale factor
|
||||
///
|
||||
/// \see Scale, GetScale
|
||||
/// \see scale, getScale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetScale(float factorX, float factorY);
|
||||
void setScale(float factorX, float factorY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the scale factors of the object
|
||||
/// \brief set the scale factors of the object
|
||||
///
|
||||
/// This function completely overwrites the previous scale.
|
||||
/// See Scale to add a factor based on the previous scale instead.
|
||||
|
@ -121,13 +121,13 @@ public :
|
|||
///
|
||||
/// \param factors New scale factors
|
||||
///
|
||||
/// \see Scale, GetScale
|
||||
/// \see scale, getScale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetScale(const Vector2f& factors);
|
||||
void setScale(const Vector2f& factors);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the local origin of the object
|
||||
/// \brief set the local origin of the object
|
||||
///
|
||||
/// The origin of an object defines the center point for
|
||||
/// all transformations (position, scale, rotation).
|
||||
|
@ -139,13 +139,13 @@ public :
|
|||
/// \param x X coordinate of the new origin
|
||||
/// \param y Y coordinate of the new origin
|
||||
///
|
||||
/// \see GetOrigin
|
||||
/// \see getOrigin
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetOrigin(float x, float y);
|
||||
void setOrigin(float x, float y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the local origin of the object
|
||||
/// \brief set the local origin of the object
|
||||
///
|
||||
/// The origin of an object defines the center point for
|
||||
/// all transformations (position, scale, rotation).
|
||||
|
@ -156,160 +156,160 @@ public :
|
|||
///
|
||||
/// \param origin New origin
|
||||
///
|
||||
/// \see GetOrigin
|
||||
/// \see getOrigin
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetOrigin(const Vector2f& origin);
|
||||
void setOrigin(const Vector2f& origin);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the position of the object
|
||||
/// \brief get the position of the object
|
||||
///
|
||||
/// \return Current position
|
||||
///
|
||||
/// \see SetPosition
|
||||
/// \see setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetPosition() const;
|
||||
const Vector2f& getPosition() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the orientation of the object
|
||||
/// \brief get the orientation of the object
|
||||
///
|
||||
/// The rotation is always in the range [0, 360].
|
||||
///
|
||||
/// \return Current rotation, in degrees
|
||||
///
|
||||
/// \see SetRotation
|
||||
/// \see setRotation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetRotation() const;
|
||||
float getRotation() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current scale of the object
|
||||
/// \brief get the current scale of the object
|
||||
///
|
||||
/// \return Current scale factors
|
||||
///
|
||||
/// \see SetScale
|
||||
/// \see setScale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetScale() const;
|
||||
const Vector2f& getScale() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the local origin of the object
|
||||
/// \brief get the local origin of the object
|
||||
///
|
||||
/// \return Current origin
|
||||
///
|
||||
/// \see SetOrigin
|
||||
/// \see setOrigin
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetOrigin() const;
|
||||
const Vector2f& getOrigin() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Move the object by a given offset
|
||||
///
|
||||
/// This function adds to the current position of the object,
|
||||
/// unlike SetPosition which overwrites it.
|
||||
/// unlike setPosition which overwrites it.
|
||||
/// Thus, it is equivalent to the following code:
|
||||
/// \code
|
||||
/// sf::Vector2f pos = object.GetPosition();
|
||||
/// object.SetPosition(pos.x + offsetX, pos.y + offsetY);
|
||||
/// sf::Vector2f pos = object.getPosition();
|
||||
/// object.setPosition(pos.x + offsetX, pos.y + offsetY);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param offsetX X offset
|
||||
/// \param offsetY Y offset
|
||||
///
|
||||
/// \see SetPosition
|
||||
/// \see setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Move(float offsetX, float offsetY);
|
||||
void move(float offsetX, float offsetY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Move the object by a given offset
|
||||
///
|
||||
/// This function adds to the current position of the object,
|
||||
/// unlike SetPosition which overwrites it.
|
||||
/// unlike setPosition which overwrites it.
|
||||
/// Thus, it is equivalent to the following code:
|
||||
/// \code
|
||||
/// object.SetPosition(object.GetPosition() + offset);
|
||||
/// object.setPosition(object.getPosition() + offset);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param offset Offset
|
||||
///
|
||||
/// \see SetPosition
|
||||
/// \see setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Move(const Vector2f& offset);
|
||||
void move(const Vector2f& offset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Rotate the object
|
||||
///
|
||||
/// This function adds to the current rotation of the object,
|
||||
/// unlike SetRotation which overwrites it.
|
||||
/// unlike setRotation which overwrites it.
|
||||
/// Thus, it is equivalent to the following code:
|
||||
/// \code
|
||||
/// object.SetRotation(object.GetRotation() + angle);
|
||||
/// object.setRotation(object.getRotation() + angle);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param angle Angle of rotation, in degrees
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Rotate(float angle);
|
||||
void rotate(float angle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Scale the object
|
||||
///
|
||||
/// This function multiplies the current scale of the object,
|
||||
/// unlike SetScale which overwrites it.
|
||||
/// unlike setScale which overwrites it.
|
||||
/// Thus, it is equivalent to the following code:
|
||||
/// \code
|
||||
/// sf::Vector2f scale = object.GetScale();
|
||||
/// object.SetScale(scale.x * factorX, scale.y * factorY);
|
||||
/// sf::Vector2f scale = object.getScale();
|
||||
/// object.setScale(scale.x * factorX, scale.y * factorY);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param factorX Horizontal scale factor
|
||||
/// \param factorY Vertical scale factor
|
||||
///
|
||||
/// \see SetScale
|
||||
/// \see setScale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Scale(float factorX, float factorY);
|
||||
void scale(float factorX, float factorY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Scale the object
|
||||
///
|
||||
/// This function multiplies the current scale of the object,
|
||||
/// unlike SetScale which overwrites it.
|
||||
/// unlike setScale which overwrites it.
|
||||
/// Thus, it is equivalent to the following code:
|
||||
/// \code
|
||||
/// sf::Vector2f scale = object.GetScale();
|
||||
/// object.SetScale(scale.x * factor.x, scale.y * factor.y);
|
||||
/// sf::Vector2f scale = object.getScale();
|
||||
/// object.setScale(scale.x * factor.x, scale.y * factor.y);
|
||||
/// \endcode
|
||||
///
|
||||
/// \param factor Scale factors
|
||||
///
|
||||
/// \see SetScale
|
||||
/// \see setScale
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Scale(const Vector2f& factor);
|
||||
void scale(const Vector2f& factor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the combined transform of the object
|
||||
/// \brief get the combined transform of the object
|
||||
///
|
||||
/// \return Transform combining the position/rotation/scale/origin of the object
|
||||
///
|
||||
/// \see GetInverseTransform
|
||||
/// \see getInverseTransform
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Transform& GetTransform() const;
|
||||
const Transform& getTransform() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the inverse of the combined transform of the object
|
||||
/// \brief get the inverse of the combined transform of the object
|
||||
///
|
||||
/// \return Inverse of the combined transformations applied to the object
|
||||
///
|
||||
/// \see GetTransform
|
||||
/// \see getTransform
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Transform& GetInverseTransform() const;
|
||||
const Transform& getInverseTransform() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -377,17 +377,17 @@ private :
|
|||
/// \code
|
||||
/// class MyEntity : public sf::Transformable, public sf::Drawable
|
||||
/// {
|
||||
/// virtual void Draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
/// virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
/// {
|
||||
/// states.Transform *= GetTransform();
|
||||
/// target.Draw(..., states);
|
||||
/// states.transform *= getTransform();
|
||||
/// target.draw(..., states);
|
||||
/// }
|
||||
/// };
|
||||
///
|
||||
/// MyEntity entity;
|
||||
/// entity.SetPosition(10, 20);
|
||||
/// entity.SetRotation(45);
|
||||
/// window.Draw(entity);
|
||||
/// entity.setPosition(10, 20);
|
||||
/// entity.setRotation(45);
|
||||
/// window.draw(entity);
|
||||
/// \endcode
|
||||
///
|
||||
/// It can also be used as a member, if you don't want to use
|
||||
|
@ -397,18 +397,18 @@ private :
|
|||
/// class MyEntity
|
||||
/// {
|
||||
/// public :
|
||||
/// void setPosition(const MyVector& v)
|
||||
/// void SetPosition(const MyVector& v)
|
||||
/// {
|
||||
/// m_transform.SetPosition(v.x(), v.y());
|
||||
/// myTransform.setPosition(v.x(), v.y());
|
||||
/// }
|
||||
///
|
||||
/// void draw(sf::RenderTarget& target) const
|
||||
/// void Draw(sf::RenderTarget& target) const
|
||||
/// {
|
||||
/// target.Draw(..., m_transform.GetTransform());
|
||||
/// target.draw(..., myTransform.getTransform());
|
||||
/// }
|
||||
///
|
||||
/// private :
|
||||
/// sf::Transformable m_transform;
|
||||
/// sf::Transformable myTransform;
|
||||
/// };
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -68,7 +68,7 @@ public :
|
|||
/// \param color Vertex color
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex(const Vector2f& position, const sf::Color& color);
|
||||
Vertex(const Vector2f& position, const Color& color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the vertex from its position and texture coordinates
|
||||
|
@ -89,14 +89,14 @@ public :
|
|||
/// \param texCoords Vertex texture coordinates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex(const Vector2f& position, const sf::Color& color, const Vector2f& texCoords);
|
||||
Vertex(const Vector2f& position, const Color& color, const Vector2f& texCoords);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f Position; ///< 2D position of the vertex
|
||||
sf::Color Color; ///< Color of the vertex
|
||||
Vector2f TexCoords; ///< Coordinates of the texture's pixel to map to the vertex
|
||||
Vector2f position; ///< 2D position of the vertex
|
||||
Color color; ///< Color of the vertex
|
||||
Vector2f texCoords; ///< Coordinates of the texture's pixel to map to the vertex
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -136,7 +136,7 @@ public :
|
|||
/// };
|
||||
///
|
||||
/// // draw it
|
||||
/// window.Draw(vertices, 4, sf::Quads);
|
||||
/// window.draw(vertices, 4, sf::Quads);
|
||||
/// \endcode
|
||||
///
|
||||
/// Note: although texture coordinates are supposed to be an integer
|
||||
|
|
|
@ -69,7 +69,7 @@ public :
|
|||
/// \return Number of vertices in the array
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetVertexCount() const;
|
||||
unsigned int getVertexCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a read-write access to a vertex by its index
|
||||
|
@ -82,7 +82,7 @@ public :
|
|||
///
|
||||
/// \return Reference to the index-th vertex
|
||||
///
|
||||
/// \see GetVertexCount
|
||||
/// \see getVertexCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex& operator [](unsigned int index);
|
||||
|
@ -98,7 +98,7 @@ public :
|
|||
///
|
||||
/// \return Const reference to the index-th vertex
|
||||
///
|
||||
/// \see GetVertexCount
|
||||
/// \see getVertexCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vertex& operator [](unsigned int index) const;
|
||||
|
@ -112,7 +112,7 @@ public :
|
|||
/// reallocating all the memory.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Resize the vertex array
|
||||
|
@ -126,7 +126,7 @@ public :
|
|||
/// \param vertexCount New size of the array (number of vertices)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Resize(unsigned int vertexCount);
|
||||
void resize(unsigned int vertexCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Add a vertex to the array
|
||||
|
@ -134,7 +134,7 @@ public :
|
|||
/// \param vertex Vertex to add
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Append(const Vertex& vertex);
|
||||
void append(const Vertex& vertex);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the type of primitives to draw
|
||||
|
@ -150,7 +150,7 @@ public :
|
|||
/// \param type Type of primitive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPrimitiveType(PrimitiveType type);
|
||||
void setPrimitiveType(PrimitiveType type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the type of primitives drawn by the vertex array
|
||||
|
@ -158,7 +158,7 @@ public :
|
|||
/// \return Primitive type
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
PrimitiveType GetPrimitiveType() const;
|
||||
PrimitiveType getPrimitiveType() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Compute the bounding rectangle of the vertex array
|
||||
|
@ -169,7 +169,7 @@ public :
|
|||
/// \return Bounding rectangle of the vertex array
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect GetBounds() const;
|
||||
FloatRect getBounds() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -180,7 +180,7 @@ private :
|
|||
/// \param states Current render states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void Draw(RenderTarget& target, RenderStates states) const;
|
||||
virtual void draw(RenderTarget& target, RenderStates states) const;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -210,12 +210,12 @@ private:
|
|||
/// Example:
|
||||
/// \code
|
||||
/// sf::VertexArray lines(sf::LinesStrip, 4);
|
||||
/// lines[0].Position = sf::Vector2f(10, 0);
|
||||
/// lines[1].Position = sf::Vector2f(20, 0);
|
||||
/// lines[2].Position = sf::Vector2f(30, 5);
|
||||
/// lines[3].Position = sf::Vector2f(40, 2);
|
||||
/// lines[0].position = sf::Vector2f(10, 0);
|
||||
/// lines[1].position = sf::Vector2f(20, 0);
|
||||
/// lines[2].position = sf::Vector2f(30, 5);
|
||||
/// lines[3].position = sf::Vector2f(40, 2);
|
||||
///
|
||||
/// window.Draw(lines);
|
||||
/// window.draw(lines);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Vertex
|
||||
|
|
|
@ -75,20 +75,20 @@ public :
|
|||
/// \param x X coordinate of the new center
|
||||
/// \param y Y coordinate of the new center
|
||||
///
|
||||
/// \see SetSize, GetCenter
|
||||
/// \see setSize, getCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetCenter(float x, float y);
|
||||
void setCenter(float x, float y);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the center of the view
|
||||
///
|
||||
/// \param center New center
|
||||
///
|
||||
/// \see SetSize, GetCenter
|
||||
/// \see setSize, getCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetCenter(const Vector2f& center);
|
||||
void setCenter(const Vector2f& center);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the size of the view
|
||||
|
@ -96,20 +96,20 @@ public :
|
|||
/// \param width New width of the view
|
||||
/// \param height New height of the view
|
||||
///
|
||||
/// \see SetCenter, GetCenter
|
||||
/// \see setCenter, getCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSize(float width, float height);
|
||||
void setSize(float width, float height);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the size of the view
|
||||
///
|
||||
/// \param size New size
|
||||
///
|
||||
/// \see SetCenter, GetCenter
|
||||
/// \see setCenter, getCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSize(const Vector2f& size);
|
||||
void setSize(const Vector2f& size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the orientation of the view
|
||||
|
@ -118,10 +118,10 @@ public :
|
|||
///
|
||||
/// \param angle New angle, in degrees
|
||||
///
|
||||
/// \see GetRotation
|
||||
/// \see getRotation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetRotation(float angle);
|
||||
void setRotation(float angle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the target viewport
|
||||
|
@ -130,15 +130,15 @@ public :
|
|||
/// view are displayed, expressed as a factor (between 0 and 1)
|
||||
/// of the size of the RenderTarget to which the view is applied.
|
||||
/// For example, a view which takes the left side of the target would
|
||||
/// be defined with View.SetViewport(sf::FloatRect(0, 0, 0.5, 1)).
|
||||
/// be defined with View.setViewport(sf::FloatRect(0, 0, 0.5, 1)).
|
||||
/// By default, a view has a viewport which covers the entire target.
|
||||
///
|
||||
/// \param viewport New viewport rectangle
|
||||
///
|
||||
/// \see GetViewport
|
||||
/// \see getViewport
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetViewport(const FloatRect& viewport);
|
||||
void setViewport(const FloatRect& viewport);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Reset the view to the given rectangle
|
||||
|
@ -147,50 +147,50 @@ public :
|
|||
///
|
||||
/// \param rectangle Rectangle defining the zone to display
|
||||
///
|
||||
/// \see SetCenter, SetSize, SetRotation
|
||||
/// \see setCenter, setSize, setRotation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Reset(const FloatRect& rectangle);
|
||||
void reset(const FloatRect& rectangle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the center of the view
|
||||
///
|
||||
/// \return Center of the view
|
||||
///
|
||||
/// \see GetSize, SetCenter
|
||||
/// \see getSize, setCenter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetCenter() const;
|
||||
const Vector2f& getCenter() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the view
|
||||
///
|
||||
/// \return Size of the view
|
||||
///
|
||||
/// \see GetCenter, SetSize
|
||||
/// \see getCenter, setSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetSize() const;
|
||||
const Vector2f& getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current orientation of the view
|
||||
///
|
||||
/// \return Rotation angle of the view, in degrees
|
||||
///
|
||||
/// \see SetRotation
|
||||
/// \see setRotation
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetRotation() const;
|
||||
float getRotation() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the target viewport rectangle of the view
|
||||
///
|
||||
/// \return Viewport rectangle, expressed as a factor of the target size
|
||||
///
|
||||
/// \see SetViewport
|
||||
/// \see setViewport
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const FloatRect& GetViewport() const;
|
||||
const FloatRect& getViewport() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Move the view relatively to its current position
|
||||
|
@ -198,30 +198,30 @@ public :
|
|||
/// \param offsetX X coordinate of the move offset
|
||||
/// \param offsetY Y coordinate of the move offset
|
||||
///
|
||||
/// \see SetCenter, Rotate, Zoom
|
||||
/// \see setCenter, rotate, zoom
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Move(float offsetX, float offsetY);
|
||||
void move(float offsetX, float offsetY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Move the view relatively to its current position
|
||||
///
|
||||
/// \param offset Move offset
|
||||
///
|
||||
/// \see SetCenter, Rotate, Zoom
|
||||
/// \see setCenter, rotate, zoom
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Move(const Vector2f& offset);
|
||||
void move(const Vector2f& offset);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Rotate the view relatively to its current orientation
|
||||
///
|
||||
/// \param angle Angle to rotate, in degrees
|
||||
///
|
||||
/// \see SetRotation, Move, Zoom
|
||||
/// \see setRotation, move, zoom
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Rotate(float angle);
|
||||
void rotate(float angle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Resize the view rectangle relatively to its current size
|
||||
|
@ -235,10 +235,10 @@ public :
|
|||
///
|
||||
/// \param factor Zoom factor to apply
|
||||
///
|
||||
/// \see SetSize, Move, Rotate
|
||||
/// \see setSize, move, rotate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Zoom(float factor);
|
||||
void zoom(float factor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the projection transform of the view
|
||||
|
@ -247,10 +247,10 @@ public :
|
|||
///
|
||||
/// \return Projection transform defining the view
|
||||
///
|
||||
/// \see GetInverseTransform
|
||||
/// \see getInverseTransform
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Transform& GetTransform() const;
|
||||
const Transform& getTransform() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the inverse projection transform of the view
|
||||
|
@ -259,10 +259,10 @@ public :
|
|||
///
|
||||
/// \return Inverse of the projection transform defining the view
|
||||
///
|
||||
/// \see GetTransform
|
||||
/// \see getTransform
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Transform& GetInverseTransform() const;
|
||||
const Transform& getInverseTransform() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -315,25 +315,25 @@ private :
|
|||
/// sf::View view;
|
||||
///
|
||||
/// // Initialize the view to a rectangle located at (100, 100) and with a size of 400x200
|
||||
/// view.Reset(sf::FloatRect(100, 100, 400, 200));
|
||||
/// view.reset(sf::FloatRect(100, 100, 400, 200));
|
||||
///
|
||||
/// // Rotate it by 45 degrees
|
||||
/// view.Rotate(45);
|
||||
/// view.rotate(45);
|
||||
///
|
||||
/// // Set its target viewport to be half of the window
|
||||
/// view.SetViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
|
||||
/// view.setViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
|
||||
///
|
||||
/// // Apply it
|
||||
/// window.SetView(view);
|
||||
/// window.setView(view);
|
||||
///
|
||||
/// // Render stuff
|
||||
/// window.Draw(someSprite);
|
||||
/// window.draw(someSprite);
|
||||
///
|
||||
/// // Set the default view back
|
||||
/// window.SetView(window.GetDefaultView());
|
||||
/// window.setView(window.getDefaultView());
|
||||
///
|
||||
/// // Render stuff not affected by the view
|
||||
/// window.Draw(someText);
|
||||
/// window.draw(someText);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::RenderWindow, sf::RenderTexture
|
||||
|
|
|
@ -154,7 +154,7 @@ public :
|
|||
/// \return True if the status is a success, false if it is a failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsOk() const;
|
||||
bool isOk() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the status code of the response
|
||||
|
@ -162,7 +162,7 @@ public :
|
|||
/// \return Status code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the full message contained in the response
|
||||
|
@ -170,7 +170,7 @@ public :
|
|||
/// \return The response message
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetMessage() const;
|
||||
const std::string& getMessage() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -203,7 +203,7 @@ public :
|
|||
/// \return Directory name
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetDirectory() const;
|
||||
const std::string& getDirectory() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -237,7 +237,7 @@ public :
|
|||
/// \return Array containing the requested filenames
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::vector<std::string>& GetFilenames() const;
|
||||
const std::vector<std::string>& getFilenames() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -275,20 +275,20 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Disconnect
|
||||
/// \see disconnect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero);
|
||||
Response connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the connection with the server
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Connect
|
||||
/// \see connect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Disconnect();
|
||||
Response disconnect();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Log in using an anonymous account
|
||||
|
@ -299,7 +299,7 @@ public :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Login();
|
||||
Response login();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Log in using a username and a password
|
||||
|
@ -313,7 +313,7 @@ public :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Login(const std::string& name, const std::string& password);
|
||||
Response login(const std::string& name, const std::string& password);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a null command to keep the connection alive
|
||||
|
@ -324,7 +324,7 @@ public :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response KeepAlive();
|
||||
Response keepAlive();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current working directory
|
||||
|
@ -334,10 +334,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetDirectoryListing, ChangeDirectory, ParentDirectory
|
||||
/// \see getDirectoryListing, changeDirectory, parentDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
DirectoryResponse GetWorkingDirectory();
|
||||
DirectoryResponse getWorkingDirectory();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the contents of the given directory
|
||||
|
@ -351,10 +351,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetWorkingDirectory, ChangeDirectory, ParentDirectory
|
||||
/// \see getWorkingDirectory, changeDirectory, parentDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ListingResponse GetDirectoryListing(const std::string& directory = "");
|
||||
ListingResponse getDirectoryListing(const std::string& directory = "");
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current working directory
|
||||
|
@ -365,20 +365,20 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetWorkingDirectory, GetDirectoryListing, ParentDirectory
|
||||
/// \see getWorkingDirectory, getDirectoryListing, parentDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response ChangeDirectory(const std::string& directory);
|
||||
Response changeDirectory(const std::string& directory);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Go to the parent directory of the current one
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetWorkingDirectory, GetDirectoryListing, ChangeDirectory
|
||||
/// \see getWorkingDirectory, getDirectoryListing, changeDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response ParentDirectory();
|
||||
Response parentDirectory();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create a new directory
|
||||
|
@ -390,10 +390,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see DeleteDirectory
|
||||
/// \see deleteDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response CreateDirectory(const std::string& name);
|
||||
Response createDirectory(const std::string& name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove an existing directory
|
||||
|
@ -407,10 +407,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see CreateDirectory
|
||||
/// \see createDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response DeleteDirectory(const std::string& name);
|
||||
Response deleteDirectory(const std::string& name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Rename an existing file
|
||||
|
@ -423,10 +423,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see DeleteFile
|
||||
/// \see deleteFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response RenameFile(const std::string& file, const std::string& newName);
|
||||
Response renameFile(const std::string& file, const std::string& newName);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove an existing file
|
||||
|
@ -440,10 +440,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see RenameFile
|
||||
/// \see renameFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response DeleteFile(const std::string& name);
|
||||
Response deleteFile(const std::string& name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Download a file from the server
|
||||
|
@ -459,10 +459,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Upload
|
||||
/// \see upload
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
|
||||
Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Upload a file to the server
|
||||
|
@ -478,8 +478,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see download
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);
|
||||
Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -492,7 +494,7 @@ private :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response SendCommand(const std::string& command, const std::string& parameter = "");
|
||||
Response sendCommand(const std::string& command, const std::string& parameter = "");
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive a response from the server
|
||||
|
@ -503,7 +505,7 @@ private :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response GetResponse();
|
||||
Response getResponse();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Utility class for exchanging datas with the server
|
||||
|
@ -543,11 +545,11 @@ private :
|
|||
///
|
||||
/// Every command returns a FTP response, which contains the
|
||||
/// status code as well as a message from the server. Some
|
||||
/// commands such as GetWorkingDirectory and GetDirectoryListing
|
||||
/// commands such as getWorkingDirectory and getDirectoryListing
|
||||
/// return additional data, and use a class derived from
|
||||
/// sf::Ftp::Response to provide this data.
|
||||
///
|
||||
/// All commands, especially Upload and Download, may take some
|
||||
/// All commands, especially upload and download, may take some
|
||||
/// time to complete. This is important to know if you don't want
|
||||
/// to block your application while the server is completing
|
||||
/// the task.
|
||||
|
@ -558,32 +560,32 @@ private :
|
|||
/// sf::Ftp ftp;
|
||||
///
|
||||
/// // Connect to the server
|
||||
/// sf::Ftp::Response response = ftp.Connect("ftp://ftp.myserver.com");
|
||||
/// if (response.IsOk())
|
||||
/// sf::Ftp::Response response = ftp.connect("ftp://ftp.myserver.com");
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "Connected" << std::endl;
|
||||
///
|
||||
/// // Log in
|
||||
/// response = ftp.Login("laurent", "dF6Zm89D");
|
||||
/// if (response.IsOk())
|
||||
/// response = ftp.login("laurent", "dF6Zm89D");
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "Logged in" << std::endl;
|
||||
///
|
||||
/// // Print the working directory
|
||||
/// sf::Ftp::DirectoryResponse directory = ftp.GetWorkingDirectory();
|
||||
/// if (directory.IsOk())
|
||||
/// std::cout << "Working directory: " << directory.GetDirectory() << std::endl;
|
||||
/// sf::Ftp::DirectoryResponse directory = ftp.getWorkingDirectory();
|
||||
/// if (directory.isOk())
|
||||
/// std::cout << "Working directory: " << directory.getDirectory() << std::endl;
|
||||
///
|
||||
/// // Create a new directory
|
||||
/// response = ftp.CreateDirectory("files");
|
||||
/// if (response.IsOk())
|
||||
/// response = ftp.createDirectory("files");
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "Created new directory" << std::endl;
|
||||
///
|
||||
/// // Upload a file to this new directory
|
||||
/// response = ftp.Upload("local-path/file.txt", "files", sf::Ftp::Ascii);
|
||||
/// if (response.IsOk())
|
||||
/// response = ftp.upload("local-path/file.txt", "files", sf::Ftp::Ascii);
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "File uploaded" << std::endl;
|
||||
///
|
||||
/// // Disconnect from the server (optional)
|
||||
/// ftp.Disconnect();
|
||||
/// ftp.disconnect();
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -92,7 +92,7 @@ public :
|
|||
/// \param value Value of the field
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetField(const std::string& field, const std::string& value);
|
||||
void setField(const std::string& field, const std::string& value);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the request method
|
||||
|
@ -104,7 +104,7 @@ public :
|
|||
/// \param method Method to use for the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetMethod(Method method);
|
||||
void setMethod(Method method);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the requested URI
|
||||
|
@ -116,7 +116,7 @@ public :
|
|||
/// \param uri URI to request, relative to the host
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetUri(const std::string& uri);
|
||||
void setUri(const std::string& uri);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the HTTP version for the request
|
||||
|
@ -127,7 +127,7 @@ public :
|
|||
/// \param minor Minor HTTP version number
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetHttpVersion(unsigned int major, unsigned int minor);
|
||||
void setHttpVersion(unsigned int major, unsigned int minor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the body of the request
|
||||
|
@ -139,7 +139,7 @@ public :
|
|||
/// \param body Content of the body
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetBody(const std::string& body);
|
||||
void setBody(const std::string& body);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -154,7 +154,7 @@ public :
|
|||
/// \return String containing the request, ready to be sent
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::string Prepare() const;
|
||||
std::string prepare() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the request defines a field
|
||||
|
@ -166,7 +166,7 @@ public :
|
|||
/// \return True if the field exists, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool HasField(const std::string& field) const;
|
||||
bool hasField(const std::string& field) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -178,7 +178,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
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
|
||||
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
|
||||
|
@ -252,7 +252,7 @@ public :
|
|||
/// \return Value of the field, or empty string if not found
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetField(const std::string& field) const;
|
||||
const std::string& getField(const std::string& field) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the response status code
|
||||
|
@ -265,27 +265,27 @@ public :
|
|||
/// \return Status code of the response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the major HTTP version number of the response
|
||||
///
|
||||
/// \return Major HTTP version number
|
||||
///
|
||||
/// \see GetMinorHttpVersion
|
||||
/// \see getMinorHttpVersion
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetMajorHttpVersion() const;
|
||||
unsigned int getMajorHttpVersion() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the minor HTTP version number of the response
|
||||
///
|
||||
/// \return Minor HTTP version number
|
||||
///
|
||||
/// \see GetMajorHttpVersion
|
||||
/// \see getMajorHttpVersion
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetMinorHttpVersion() const;
|
||||
unsigned int getMinorHttpVersion() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the body of the response
|
||||
|
@ -299,7 +299,7 @@ public :
|
|||
/// \return The response body
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetBody() const;
|
||||
const std::string& getBody() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -314,7 +314,7 @@ public :
|
|||
/// \param data Content of the response to parse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Parse(const std::string& data);
|
||||
void parse(const std::string& data);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -368,7 +368,7 @@ public :
|
|||
/// \param port Port to use for connection
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetHost(const std::string& host, unsigned short port = 0);
|
||||
void setHost(const std::string& host, unsigned short port = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a HTTP request and return the server's response.
|
||||
|
@ -388,7 +388,7 @@ public :
|
|||
/// \return Server's response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response SendRequest(const Request& request, Time timeout = Time::Zero);
|
||||
Response sendRequest(const Request& request, Time timeout = Time::Zero);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -444,19 +444,19 @@ private :
|
|||
/// sf::Http http;
|
||||
///
|
||||
/// // We'll work on http://www.sfml-dev.org
|
||||
/// http.SetHost("http://www.sfml-dev.org");
|
||||
/// http.setHost("http://www.sfml-dev.org");
|
||||
///
|
||||
/// // Prepare a request to get the 'features.php' page
|
||||
/// sf::Http::Request request("features.php");
|
||||
///
|
||||
/// // Send the request
|
||||
/// sf::Http::Response response = http.SendRequest(request);
|
||||
/// sf::Http::Response response = http.sendRequest(request);
|
||||
///
|
||||
/// // Check the status code and display the result
|
||||
/// sf::Http::Response::Status status = response.GetStatus();
|
||||
/// sf::Http::Response::Status status = response.getStatus();
|
||||
/// if (status == sf::Http::Response::Ok)
|
||||
/// {
|
||||
/// std::cout << response.GetBody() << std::endl;
|
||||
/// std::cout << response.getBody() << std::endl;
|
||||
/// }
|
||||
/// else
|
||||
/// {
|
||||
|
|
|
@ -103,7 +103,7 @@ public :
|
|||
///
|
||||
/// \param address 4 bytes of the address packed into a 32-bits integer
|
||||
///
|
||||
/// \see ToInteger
|
||||
/// \see toInteger
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit IpAddress(Uint32 address);
|
||||
|
@ -117,10 +117,10 @@ public :
|
|||
///
|
||||
/// \return String representation of the address
|
||||
///
|
||||
/// \see ToInteger
|
||||
/// \see toInteger
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::string ToString() const;
|
||||
std::string toString() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get an integer representation of the address
|
||||
|
@ -133,10 +133,10 @@ public :
|
|||
///
|
||||
/// \return 32-bits unsigned integer representation of the address
|
||||
///
|
||||
/// \see ToString
|
||||
/// \see toString
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint32 ToInteger() const;
|
||||
Uint32 toInteger() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the computer's local address
|
||||
|
@ -144,15 +144,15 @@ public :
|
|||
/// The local address is the address of the computer from the
|
||||
/// LAN point of view, i.e. something like 192.168.1.56. It is
|
||||
/// meaningful only for communications over the local network.
|
||||
/// Unlike GetPublicAddress, this function is fast and may be
|
||||
/// Unlike getPublicAddress, this function is fast and may be
|
||||
/// used safely anywhere.
|
||||
///
|
||||
/// \return Local IP address of the computer
|
||||
///
|
||||
/// \see GetPublicAddress
|
||||
/// \see getPublicAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static IpAddress GetLocalAddress();
|
||||
static IpAddress getLocalAddress();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the computer's public address
|
||||
|
@ -173,10 +173,10 @@ public :
|
|||
///
|
||||
/// \return Public IP address of the computer
|
||||
///
|
||||
/// \see GetLocalAddress
|
||||
/// \see getLocalAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static IpAddress GetPublicAddress(Time timeout = Time::Zero);
|
||||
static IpAddress getPublicAddress(Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static member data
|
||||
|
@ -306,8 +306,8 @@ SFML_NETWORK_API std::ostream& operator <<(std::ostream& stream, const IpAddress
|
|||
/// sf::IpAddress a5("my_computer"); // a local address created from a network name
|
||||
/// sf::IpAddress a6("89.54.1.169"); // a distant address
|
||||
/// sf::IpAddress a7("www.google.com"); // a distant address created from a network name
|
||||
/// sf::IpAddress a8 = sf::IpAddress::GetLocalAddress(); // my address on the local network
|
||||
/// sf::IpAddress a9 = sf::IpAddress::GetPublicAddress(); // my address on the internet
|
||||
/// sf::IpAddress a8 = sf::IpAddress::getLocalAddress(); // my address on the local network
|
||||
/// sf::IpAddress a9 = sf::IpAddress::getPublicAddress(); // my address on the internet
|
||||
/// \endcode
|
||||
///
|
||||
/// Note that sf::IpAddress currently doesn't support IPv6
|
||||
|
|
|
@ -71,20 +71,20 @@ public :
|
|||
/// \param data Pointer to the sequence of bytes to append
|
||||
/// \param sizeInBytes Number of bytes to append
|
||||
///
|
||||
/// \see Clear
|
||||
/// \see clear
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Append(const void* data, std::size_t sizeInBytes);
|
||||
void append(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Clear the packet
|
||||
///
|
||||
/// After calling Clear, the packet is empty.
|
||||
///
|
||||
/// \see Append
|
||||
/// \see append
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a pointer to the data contained in the packet
|
||||
|
@ -96,23 +96,23 @@ public :
|
|||
///
|
||||
/// \return Pointer to the data
|
||||
///
|
||||
/// \see GetDataSize
|
||||
/// \see getDataSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* GetData() const;
|
||||
const char* getData() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the data contained in the packet
|
||||
///
|
||||
/// This function returns the number of bytes pointed to by
|
||||
/// what GetData returns.
|
||||
/// what getData returns.
|
||||
///
|
||||
/// \return Data size, in bytes
|
||||
///
|
||||
/// \see GetData
|
||||
/// \see getData
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetDataSize() const;
|
||||
std::size_t getDataSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell if the reading position has reached the
|
||||
|
@ -126,7 +126,7 @@ public :
|
|||
/// \see operator bool
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool EndOfPacket() const;
|
||||
bool endOfPacket() const;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
///
|
||||
/// \return True if last data extraction from packet was successful
|
||||
///
|
||||
/// \see EndOfPacket
|
||||
/// \see endOfPacket
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
operator BoolType() const;
|
||||
|
@ -230,7 +230,7 @@ private :
|
|||
/// \return True if \a size bytes can be read from the packet
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool CheckSize(std::size_t size);
|
||||
bool checkSize(std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called before the packet is sent over the network
|
||||
|
@ -247,10 +247,10 @@ private :
|
|||
///
|
||||
/// \return Pointer to the array of bytes to send
|
||||
///
|
||||
/// \see OnReceive
|
||||
/// \see onReceive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual const char* OnSend(std::size_t& size);
|
||||
virtual const char* onSend(std::size_t& size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called after the packet is received over the network
|
||||
|
@ -266,8 +266,10 @@ private :
|
|||
/// \param data Pointer to the received bytes
|
||||
/// \param size Number of bytes
|
||||
///
|
||||
/// \see onSend
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnReceive(const char* data, std::size_t size);
|
||||
virtual void onReceive(const char* data, std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -316,13 +318,13 @@ private :
|
|||
/// packet << x << s << d;
|
||||
///
|
||||
/// // Send it over the network (socket is a valid sf::TcpSocket)
|
||||
/// socket.Send(packet);
|
||||
/// socket.send(packet);
|
||||
///
|
||||
/// -----------------------------------------------------------------
|
||||
///
|
||||
/// // Receive the packet at the other end
|
||||
/// sf::Packet packet;
|
||||
/// socket.Receive(packet);
|
||||
/// socket.receive(packet);
|
||||
///
|
||||
/// // Extract the variables contained in the packet
|
||||
/// sf::Uint32 x;
|
||||
|
@ -369,26 +371,26 @@ private :
|
|||
/// and after it is received. This is typically used to
|
||||
/// handle automatic compression or encryption of the data.
|
||||
/// This is achieved by inheriting from sf::Packet, and overriding
|
||||
/// the OnSend and OnReceive functions.
|
||||
/// the onSend and onReceive functions.
|
||||
///
|
||||
/// Here is an example:
|
||||
/// \code
|
||||
/// class ZipPacket : public sf::Packet
|
||||
/// {
|
||||
/// virtual const char* OnSend(std::size_t& size)
|
||||
/// virtual const char* onSend(std::size_t& size)
|
||||
/// {
|
||||
/// const char* srcData = GetData();
|
||||
/// std::size_t srcSize = GetDataSize();
|
||||
/// const char* srcData = getData();
|
||||
/// std::size_t srcSize = getDataSize();
|
||||
///
|
||||
/// return MySuperZipFunction(srcData, srcSize, &size);
|
||||
/// }
|
||||
///
|
||||
/// virtual void OnReceive(const char* data, std::size_t size)
|
||||
/// virtual void onReceive(const char* data, std::size_t size)
|
||||
/// {
|
||||
/// std::size_t dstSize;
|
||||
/// const char* dstData = MySuperUnzipFunction(data, size, &dstSize);
|
||||
///
|
||||
/// Append(dstData, dstSize);
|
||||
/// append(dstData, dstSize);
|
||||
/// }
|
||||
/// };
|
||||
///
|
||||
|
|
|
@ -89,20 +89,20 @@ public :
|
|||
///
|
||||
/// \param blocking True to set the socket as blocking, false for non-blocking
|
||||
///
|
||||
/// \see IsBlocking
|
||||
/// \see isBlocking
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetBlocking(bool blocking);
|
||||
void setBlocking(bool blocking);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether the socket is in blocking or non-blocking mode
|
||||
///
|
||||
/// \return True if the socket is blocking, false otherwise
|
||||
///
|
||||
/// \see SetBlocking
|
||||
/// \see setBlocking
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsBlocking() const;
|
||||
bool isBlocking() const;
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -136,7 +136,7 @@ protected :
|
|||
/// \return The internal (OS-specific) handle of the socket
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SocketHandle GetHandle() const;
|
||||
SocketHandle getHandle() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create the internal representation of the socket
|
||||
|
@ -144,7 +144,7 @@ protected :
|
|||
/// This function can only be accessed by derived classes.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create();
|
||||
void create();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create the internal representation of the socket
|
||||
|
@ -155,7 +155,7 @@ protected :
|
|||
/// \param handle OS-specific handle of the socket to wrap
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(SocketHandle handle);
|
||||
void create(SocketHandle handle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the socket gracefully
|
||||
|
@ -163,7 +163,7 @@ protected :
|
|||
/// This function can only be accessed by derived classes.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Close();
|
||||
void close();
|
||||
|
||||
private :
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ public :
|
|||
///
|
||||
/// \param socket Reference to the socket to add
|
||||
///
|
||||
/// \see Remove, Clear
|
||||
/// \see remove, clear
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Add(Socket& socket);
|
||||
void add(Socket& socket);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove a socket from the selector
|
||||
|
@ -86,10 +86,10 @@ public :
|
|||
///
|
||||
/// \param socket Reference to the socket to remove
|
||||
///
|
||||
/// \see Add, Clear
|
||||
/// \see add, clear
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Remove(Socket& socket);
|
||||
void remove(Socket& socket);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove all the sockets stored in the selector
|
||||
|
@ -98,17 +98,17 @@ public :
|
|||
/// removes all the references that the selector has to
|
||||
/// external sockets.
|
||||
///
|
||||
/// \see Add, Remove
|
||||
/// \see add, remove
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Wait until one or more sockets are ready to receive
|
||||
///
|
||||
/// This function returns as soon as at least one socket has
|
||||
/// some data available to be received. To know which sockets are
|
||||
/// ready, use the IsReady function.
|
||||
/// ready, use the isReady function.
|
||||
/// If you use a timeout and no socket is ready before the timeout
|
||||
/// is over, the function returns false.
|
||||
///
|
||||
|
@ -116,17 +116,17 @@ public :
|
|||
///
|
||||
/// \return True if there are sockets ready, false otherwise
|
||||
///
|
||||
/// \see IsReady
|
||||
/// \see isReady
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Wait(Time timeout = Time::Zero);
|
||||
bool wait(Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Test a socket to know if it is ready to receive data
|
||||
///
|
||||
/// This function must be used after a call to Wait, to know
|
||||
/// which sockets are ready to receive data. If a socket is
|
||||
/// ready, a call to Receive will never block because we know
|
||||
/// ready, a call to receive will never block because we know
|
||||
/// that there is data available to read.
|
||||
/// Note that if this function returns true for a TcpListener,
|
||||
/// this means that it is ready to accept a new connection.
|
||||
|
@ -135,10 +135,10 @@ public :
|
|||
///
|
||||
/// \return True if the socket is ready to read, false otherwise
|
||||
///
|
||||
/// \see IsReady
|
||||
/// \see isReady
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsReady(Socket& socket) const;
|
||||
bool isReady(Socket& socket) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -199,7 +199,7 @@ private :
|
|||
/// \code
|
||||
/// // Create a socket to listen to new connections
|
||||
/// sf::TcpListener listener;
|
||||
/// listener.Listen(55001);
|
||||
/// listener.listen(55001);
|
||||
///
|
||||
/// // Create a list to store the future clients
|
||||
/// std::list<sf::TcpSocket*> clients;
|
||||
|
@ -208,16 +208,16 @@ private :
|
|||
/// sf::SocketSelector selector;
|
||||
///
|
||||
/// // Add the listener to the selector
|
||||
/// selector.Add(listener);
|
||||
/// selector.add(listener);
|
||||
///
|
||||
/// // Endless loop that waits for new connections
|
||||
/// while (running)
|
||||
/// {
|
||||
/// // Make the selector wait for data on any socket
|
||||
/// if (selector.Wait())
|
||||
/// if (selector.wait())
|
||||
/// {
|
||||
/// // Test the listener
|
||||
/// if (selector.IsReady(listener))
|
||||
/// if (selector.isReady(listener))
|
||||
/// {
|
||||
/// // The listener is ready: there is a pending connection
|
||||
/// sf::TcpSocket* client = new sf::TcpSocket;
|
||||
|
@ -228,7 +228,7 @@ private :
|
|||
///
|
||||
/// // Add the new client to the selector so that we will
|
||||
/// // be notified when he sends something
|
||||
/// selector.Add(*client);
|
||||
/// selector.add(*client);
|
||||
/// }
|
||||
/// }
|
||||
/// else
|
||||
|
@ -237,11 +237,11 @@ private :
|
|||
/// for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
|
||||
/// {
|
||||
/// sf::TcpSocket& client = **it;
|
||||
/// if (selector.IsReady(client))
|
||||
/// if (selector.isReady(client))
|
||||
/// {
|
||||
/// // The client has sent some data, we can receive it
|
||||
/// sf::Packet packet;
|
||||
/// if (client.Receive(packet) == sf::Socket::Done)
|
||||
/// if (client.receive(packet) == sf::Socket::Done)
|
||||
/// {
|
||||
/// ...
|
||||
/// }
|
||||
|
|
|
@ -58,10 +58,10 @@ public :
|
|||
///
|
||||
/// \return Port to which the socket is bound
|
||||
///
|
||||
/// \see Listen
|
||||
/// \see listen
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetLocalPort() const;
|
||||
unsigned short getLocalPort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Start listening for connections
|
||||
|
@ -75,10 +75,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Accept, Close
|
||||
/// \see accept, close
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Listen(unsigned short port);
|
||||
Status listen(unsigned short port);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop listening and close the socket
|
||||
|
@ -86,10 +86,10 @@ public :
|
|||
/// This function gracefully stops the listener. If the
|
||||
/// socket is not listening, this function has no effect.
|
||||
///
|
||||
/// \see Listen
|
||||
/// \see listen
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Close();
|
||||
void close();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Accept a new connection
|
||||
|
@ -101,10 +101,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Listen
|
||||
/// \see listen
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Accept(TcpSocket& socket);
|
||||
Status accept(TcpSocket& socket);
|
||||
};
|
||||
|
||||
|
||||
|
@ -122,7 +122,7 @@ public :
|
|||
/// a given port and waits for connections on that port.
|
||||
/// This is all it can do.
|
||||
///
|
||||
/// When a new connection is received, you must call Accept and
|
||||
/// When a new connection is received, you must call accept and
|
||||
/// the listener returns a new instance of sf::TcpSocket that
|
||||
/// is properly initialized and can be used to communicate with
|
||||
/// the new client.
|
||||
|
@ -134,7 +134,7 @@ public :
|
|||
///
|
||||
/// A listener is automatically closed on destruction, like all
|
||||
/// other types of socket. However if you want to stop listening
|
||||
/// before the socket is destroyed, you can call its Close()
|
||||
/// before the socket is destroyed, you can call its close()
|
||||
/// function.
|
||||
///
|
||||
/// Usage example:
|
||||
|
@ -142,17 +142,17 @@ public :
|
|||
/// // Create a listener socket and make it wait for new
|
||||
/// // connections on port 55001
|
||||
/// sf::TcpListener listener;
|
||||
/// listener.Listen(55001);
|
||||
/// listener.listen(55001);
|
||||
///
|
||||
/// // Endless loop that waits for new connections
|
||||
/// while (running)
|
||||
/// {
|
||||
/// sf::TcpSocket client;
|
||||
/// if (listener.Accept(client) == sf::Socket::Done)
|
||||
/// if (listener.accept(client) == sf::Socket::Done)
|
||||
/// {
|
||||
/// // A new client just connected!
|
||||
/// std::cout << "New connection received from " << client.GetRemoteAddress() << std::endl;
|
||||
/// DoSomethingWith(client);
|
||||
/// std::cout << "New connection received from " << client.getRemoteAddress() << std::endl;
|
||||
/// doSomethingWith(client);
|
||||
/// }
|
||||
/// }
|
||||
/// \endcode
|
||||
|
|
|
@ -60,10 +60,10 @@ public :
|
|||
///
|
||||
/// \return Port to which the socket is bound
|
||||
///
|
||||
/// \see Connect, GetRemotePort
|
||||
/// \see connect, getRemotePort
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetLocalPort() const;
|
||||
unsigned short getLocalPort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the address of the connected peer
|
||||
|
@ -73,10 +73,10 @@ public :
|
|||
///
|
||||
/// \return Address of the remote peer
|
||||
///
|
||||
/// \see GetRemotePort
|
||||
/// \see getRemotePort
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
IpAddress GetRemoteAddress() const;
|
||||
IpAddress getRemoteAddress() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the port of the connected peer to which
|
||||
|
@ -86,10 +86,10 @@ public :
|
|||
///
|
||||
/// \return Remote port to which the socket is connected
|
||||
///
|
||||
/// \see GetRemoteAddress
|
||||
/// \see getRemoteAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetRemotePort() const;
|
||||
unsigned short getRemotePort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Connect the socket to a remote peer
|
||||
|
@ -105,10 +105,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Disconnect
|
||||
/// \see disconnect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero);
|
||||
Status connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Disconnect the socket from its remote peer
|
||||
|
@ -119,7 +119,7 @@ public :
|
|||
/// \see Connect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Disconnect();
|
||||
void disconnect();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send raw data to the remote peer
|
||||
|
@ -131,10 +131,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(const char* data, std::size_t size);
|
||||
Status send(const char* data, std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive raw data from the remote peer
|
||||
|
@ -149,10 +149,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(char* data, std::size_t size, std::size_t& received);
|
||||
Status receive(char* data, std::size_t size, std::size_t& received);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a formatted packet of data to the remote peer
|
||||
|
@ -163,10 +163,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(Packet& packet);
|
||||
Status send(Packet& packet);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive a formatted packet of data from the remote peer
|
||||
|
@ -179,10 +179,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(Packet& packet);
|
||||
Status receive(Packet& packet);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -227,10 +227,10 @@ private:
|
|||
///
|
||||
/// When a socket is connected to a remote host, you can
|
||||
/// retrieve informations about this host with the
|
||||
/// GetRemoteAddress and GetRemotePort functions. You can
|
||||
/// getRemoteAddress and GetRemotePort functions. You can
|
||||
/// also get the local port to which the socket is bound
|
||||
/// (which is automatically chosen when the socket is connected),
|
||||
/// with the GetLocalPort function.
|
||||
/// with the getLocalPort function.
|
||||
///
|
||||
/// Sending and receiving data can use either the low-level
|
||||
/// or the high-level functions. The low-level functions
|
||||
|
@ -245,7 +245,7 @@ private:
|
|||
///
|
||||
/// The socket is automatically disconnected when it is destroyed,
|
||||
/// but if you want to explicitely close the connection while
|
||||
/// the socket instance is still alive, you can call Disconnect.
|
||||
/// the socket instance is still alive, you can call disconnect.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
|
@ -253,38 +253,38 @@ private:
|
|||
///
|
||||
/// // Create a socket and connect it to 192.168.1.50 on port 55001
|
||||
/// sf::TcpSocket socket;
|
||||
/// socket.Connect("192.168.1.50", 55001);
|
||||
/// socket.connect("192.168.1.50", 55001);
|
||||
///
|
||||
/// // Send a message to the connected host
|
||||
/// std::string message = "Hi, I am a client";
|
||||
/// socket.Send(message.c_str(), message.size() + 1);
|
||||
/// socket.send(message.c_str(), message.size() + 1);
|
||||
///
|
||||
/// // Receive an answer from the server
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received);
|
||||
/// socket.receive(buffer, sizeof(buffer), received);
|
||||
/// std::cout << "The server said: " << buffer << std::endl;
|
||||
///
|
||||
/// // ----- The server -----
|
||||
///
|
||||
/// // Create a listener to wait for incoming connections on port 55001
|
||||
/// sf::TcpListener listener;
|
||||
/// listener.Listen(55001);
|
||||
/// listener.listen(55001);
|
||||
///
|
||||
/// // Wait for a connection
|
||||
/// sf::TcpSocket socket;
|
||||
/// listener.Accept(socket);
|
||||
/// std::cout << "New client connected: " << socket.GetRemoteAddress() << std::endl;
|
||||
/// listener.accept(socket);
|
||||
/// std::cout << "New client connected: " << socket.getRemoteAddress() << std::endl;
|
||||
///
|
||||
/// // Receive a message from the client
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received);
|
||||
/// socket.receive(buffer, sizeof(buffer), received);
|
||||
/// std::cout << "The client said: " << buffer << std::endl;
|
||||
///
|
||||
/// // Send an answer
|
||||
/// std::string message = "Welcome, client";
|
||||
/// socket.Send(message.c_str(), message.size() + 1);
|
||||
/// socket.send(message.c_str(), message.size() + 1);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Socket, sf::UdpSocket, sf::Packet
|
||||
|
|
|
@ -68,10 +68,10 @@ public :
|
|||
///
|
||||
/// \return Port to which the socket is bound
|
||||
///
|
||||
/// \see Bind
|
||||
/// \see bind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetLocalPort() const;
|
||||
unsigned short getLocalPort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Bind the socket to a specific port
|
||||
|
@ -80,16 +80,16 @@ public :
|
|||
/// able to receive data on that port.
|
||||
/// You can use the special value Socket::AnyPort to tell the
|
||||
/// system to automatically pick an available port, and then
|
||||
/// call GetLocalPort to retrieve the chosen port.
|
||||
/// call getLocalPort to retrieve the chosen port.
|
||||
///
|
||||
/// \param port Port to bind the socket to
|
||||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Unbind, GetLocalPort
|
||||
/// \see unbind, getLocalPort
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Bind(unsigned short port);
|
||||
Status bind(unsigned short port);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Unbind the socket from the local port to which it is bound
|
||||
|
@ -98,10 +98,10 @@ public :
|
|||
/// available after this function is called. If the
|
||||
/// socket is not bound to a port, this function has no effect.
|
||||
///
|
||||
/// \see Bind
|
||||
/// \see bind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Unbind();
|
||||
void unbind();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send raw data to a remote peer
|
||||
|
@ -117,10 +117,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(const char* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
Status send(const char* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive raw data from a remote peer
|
||||
|
@ -140,10 +140,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(char* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
Status receive(char* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a formatted packet of data to a remote peer
|
||||
|
@ -158,18 +158,16 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
Status send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive a formatted packet of data from a remote peer
|
||||
///
|
||||
/// In blocking mode, this function will wait until the whole packet
|
||||
/// has been received.
|
||||
/// Warning: this functon doesn't properly handle mixed data
|
||||
/// received from multiple peers.
|
||||
///
|
||||
/// \param packet Packet to fill with the received data
|
||||
/// \param remoteAddress Address of the peer that sent the data
|
||||
|
@ -177,10 +175,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
Status receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -206,8 +204,8 @@ private:
|
|||
///
|
||||
/// It is a datagram protocol: bounded blocks of data (datagrams)
|
||||
/// are transfered over the network rather than a continuous
|
||||
/// stream of data (TCP). Therefore, one call to Send will always
|
||||
/// match one call to Receive (if the datagram is not lost),
|
||||
/// stream of data (TCP). Therefore, one call to send will always
|
||||
/// match one call to receive (if the datagram is not lost),
|
||||
/// with the same data that was sent.
|
||||
///
|
||||
/// The UDP protocol is lightweight but unreliable. Unreliable
|
||||
|
@ -247,37 +245,37 @@ private:
|
|||
///
|
||||
/// // Create a socket and bind it to the port 55001
|
||||
/// sf::UdpSocket socket;
|
||||
/// socket.Bind(55001);
|
||||
/// socket.bind(55001);
|
||||
///
|
||||
/// // Send a message to 192.168.1.50 on port 55002
|
||||
/// std::string message = "Hi, I am " + sf::IpAddress::GetLocalAddress().ToString();
|
||||
/// socket.Send(message.c_str(), message.size() + 1, "192.168.1.50", 55002);
|
||||
/// std::string message = "Hi, I am " + sf::IpAddress::getLocalAddress().toString();
|
||||
/// socket.send(message.c_str(), message.size() + 1, "192.168.1.50", 55002);
|
||||
///
|
||||
/// // Receive an answer (most likely from 192.168.1.50, but could be anyone else)
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// sf::IpAddress sender;
|
||||
/// unsigned short port;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// socket.receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// std::cout << sender.ToString() << " said: " << buffer << std::endl;
|
||||
///
|
||||
/// // ----- The server -----
|
||||
///
|
||||
/// // Create a socket and bind it to the port 55002
|
||||
/// sf::UdpSocket socket;
|
||||
/// socket.Bind(55002);
|
||||
/// socket.bind(55002);
|
||||
///
|
||||
/// // Receive a message from anyone
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// sf::IpAddress sender;
|
||||
/// unsigned short port;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// socket.receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// std::cout << sender.ToString() << " said: " << buffer << std::endl;
|
||||
///
|
||||
/// // Send an answer
|
||||
/// std::string message = "Welcome " + sender.ToString();
|
||||
/// socket.Send(message.c_str(), message.size() + 1, sender, port);
|
||||
/// std::string message = "Welcome " + sender.toString();
|
||||
/// socket.send(message.c_str(), message.size() + 1, sender, port);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Socket, sf::TcpSocket, sf::Packet
|
||||
|
|
|
@ -54,13 +54,13 @@ public :
|
|||
/// \brief Get the elapsed time
|
||||
///
|
||||
/// This function returns the time elapsed since the last call
|
||||
/// to Restart() (or the construction of the instance if Restart()
|
||||
/// to restart() (or the construction of the instance if restart()
|
||||
/// has not been called).
|
||||
///
|
||||
/// \return Time elapsed
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time GetElapsedTime() const;
|
||||
Time getElapsedTime() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Restart the clock
|
||||
|
@ -71,7 +71,7 @@ public :
|
|||
/// \return Time elapsed
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time Restart();
|
||||
Time restart();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -103,9 +103,9 @@ private :
|
|||
/// \code
|
||||
/// sf::Clock clock;
|
||||
/// ...
|
||||
/// Time time1 = clock.GetElapsedTime();
|
||||
/// Time time1 = clock.getElapsedTime();
|
||||
/// ...
|
||||
/// Time time2 = clock.Restart();
|
||||
/// Time time2 = clock.restart();
|
||||
/// \endcode
|
||||
///
|
||||
/// The sf::Time value returned by the clock can then be
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace sf
|
|||
/// \brief Standard stream used by SFML to output warnings and errors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SFML_SYSTEM_API std::ostream& Err();
|
||||
SFML_SYSTEM_API std::ostream& err();
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
@ -50,7 +50,7 @@ SFML_SYSTEM_API std::ostream& Err();
|
|||
/// \fn sf::Err
|
||||
/// \ingroup system
|
||||
///
|
||||
/// By default, sf::Err() outputs to the same location as std::cerr,
|
||||
/// By default, sf::err() outputs to the same location as std::cerr,
|
||||
/// (-> the stderr descriptor) which is the console if there's
|
||||
/// one available.
|
||||
///
|
||||
|
@ -58,7 +58,7 @@ SFML_SYSTEM_API std::ostream& Err();
|
|||
/// insertion operations defined by the STL
|
||||
/// (operator <<, manipulators, etc.).
|
||||
///
|
||||
/// sf::Err() can be redirected to write to another output, independantly
|
||||
/// sf::err() can be redirected to write to another output, independantly
|
||||
/// of std::cerr, by using the rdbuf() function provided by the
|
||||
/// std::ostream class.
|
||||
///
|
||||
|
@ -66,13 +66,13 @@ SFML_SYSTEM_API std::ostream& Err();
|
|||
/// \code
|
||||
/// // Redirect to a file
|
||||
/// std::ofstream file("sfml-log.txt");
|
||||
/// std::streambuf* previous = sf::Err().rdbuf(file.rdbuf());
|
||||
/// std::streambuf* previous = sf::err().rdbuf(file.rdbuf());
|
||||
///
|
||||
/// // Redirect to nothing
|
||||
/// sf::Err().rdbuf(NULL);
|
||||
/// sf::err().rdbuf(NULL);
|
||||
///
|
||||
/// // Restore the original output
|
||||
/// sf::Err().rdbuf(previous);
|
||||
/// sf::err().rdbuf(previous);
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -56,7 +56,7 @@ public :
|
|||
/// \return The number of bytes actually read
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Int64 Read(char* data, Int64 size) = 0;
|
||||
virtual Int64 read(char* data, Int64 size) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current reading position
|
||||
|
@ -66,7 +66,7 @@ public :
|
|||
/// \return The position actually sought to, or -1 on error
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Int64 Seek(Int64 position) = 0;
|
||||
virtual Int64 seek(Int64 position) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current reading position in the stream
|
||||
|
@ -74,7 +74,7 @@ public :
|
|||
/// \return The current position, or -1 on error.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Int64 Tell() = 0;
|
||||
virtual Int64 tell() = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the size of the stream
|
||||
|
@ -82,7 +82,7 @@ public :
|
|||
/// \return The total number of bytes available in the stream, or -1 on error
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Int64 GetSize() = 0;
|
||||
virtual Int64 getSize() = 0;
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -99,12 +99,12 @@ public :
|
|||
/// from which SFML can load resources.
|
||||
///
|
||||
/// SFML resource classes like sf::Texture and
|
||||
/// sf::SoundBuffer provide LoadFromFile and LoadFromMemory functions,
|
||||
/// sf::SoundBuffer provide loadFromFile and loadFromMemory functions,
|
||||
/// which read data from conventional sources. However, if you
|
||||
/// have data coming from a different source (over a network,
|
||||
/// embedded, encrypted, compressed, etc) you can derive your
|
||||
/// own class from sf::InputStream and load SFML resources with
|
||||
/// their LoadFromStream function.
|
||||
/// their loadFromStream function.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
|
@ -115,15 +115,15 @@ public :
|
|||
///
|
||||
/// ZipStream(std::string archive);
|
||||
///
|
||||
/// bool Open(std::string filename);
|
||||
/// bool open(std::string filename);
|
||||
///
|
||||
/// Int64 Read(char* data, Int64 size);
|
||||
/// Int64 read(char* data, Int64 size);
|
||||
///
|
||||
/// Int64 Seek(Int64 position);
|
||||
/// Int64 seek(Int64 position);
|
||||
///
|
||||
/// Int64 Tell();
|
||||
/// Int64 tell();
|
||||
///
|
||||
/// Int64 GetSize();
|
||||
/// Int64 getSize();
|
||||
///
|
||||
/// private :
|
||||
///
|
||||
|
@ -133,14 +133,14 @@ public :
|
|||
/// // now you can load textures...
|
||||
/// sf::Texture texture;
|
||||
/// ZipStream stream("resources.zip");
|
||||
/// stream.Open("images/img.png");
|
||||
/// texture.LoadFromStream(stream);
|
||||
/// stream.open("images/img.png");
|
||||
/// texture.loadFromStream(stream);
|
||||
///
|
||||
/// // musics...
|
||||
/// sf::Music music;
|
||||
/// ZipStream stream("resources.zip");
|
||||
/// stream.Open("musics/msc.ogg");
|
||||
/// music.OpenFromStream(stream);
|
||||
/// stream.open("musics/msc.ogg");
|
||||
/// music.openFromStream(stream);
|
||||
///
|
||||
/// // etc.
|
||||
/// \endcode
|
||||
|
|
|
@ -70,7 +70,7 @@ public :
|
|||
/// \see Unlock
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Lock();
|
||||
void lock();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Unlock the mutex
|
||||
|
@ -78,7 +78,7 @@ public :
|
|||
/// \see Lock
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Unlock();
|
||||
void unlock();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -115,16 +115,16 @@ private :
|
|||
///
|
||||
/// void thread1()
|
||||
/// {
|
||||
/// mutex.Lock(); // this call will block the thread if the mutex is already locked by thread2
|
||||
/// mutex.lock(); // this call will block the thread if the mutex is already locked by thread2
|
||||
/// database.write(...);
|
||||
/// mutex.Unlock(); // if thread2 was waiting, it will now be unblocked
|
||||
/// mutex.unlock(); // if thread2 was waiting, it will now be unblocked
|
||||
/// }
|
||||
///
|
||||
/// void thread2()
|
||||
/// {
|
||||
/// mutex.Lock(); // this call will block the thread if the mutex is already locked by thread1
|
||||
/// mutex.lock(); // this call will block the thread if the mutex is already locked by thread1
|
||||
/// database.write(...);
|
||||
/// mutex.Unlock(); // if thread1 was waiting, it will now be unblocked
|
||||
/// mutex.unlock(); // if thread1 was waiting, it will now be unblocked
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
@ -140,8 +140,8 @@ private :
|
|||
/// a mutex multiple times in the same thread without creating
|
||||
/// a deadlock. In this case, the first call to Lock() behaves
|
||||
/// as usual, and the following ones have no effect.
|
||||
/// However, you must call Unlock() exactly as many times as you
|
||||
/// called Lock(). If you don't, the mutex won't be released.
|
||||
/// However, you must call unlock() exactly as many times as you
|
||||
/// called lock(). If you don't, the mutex won't be released.
|
||||
///
|
||||
/// \see sf::Lock
|
||||
///
|
||||
|
|
|
@ -38,13 +38,13 @@ namespace sf
|
|||
/// \ingroup system
|
||||
/// \brief Make the current thread sleep for a given duration
|
||||
///
|
||||
/// sf::Sleep is the best way to block a program or one of its
|
||||
/// sf::sleep is the best way to block a program or one of its
|
||||
/// threads, as it doesn't consume any CPU power.
|
||||
///
|
||||
/// \param duration Time to sleep
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SFML_SYSTEM_API Sleep(Time duration);
|
||||
void SFML_SYSTEM_API sleep(Time duration);
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
|
|
@ -159,15 +159,15 @@ public :
|
|||
/// \brief Implicit cast operator to std::string (ANSI string)
|
||||
///
|
||||
/// The current global locale is used for conversion. If you
|
||||
/// want to explicitely specify a locale, see ToAnsiString.
|
||||
/// want to explicitely specify a locale, see toAnsiString.
|
||||
/// Characters that do not fit in the target encoding are
|
||||
/// discarded from the returned string.
|
||||
/// This operator is defined for convenience, and is equivalent
|
||||
/// to calling ToAnsiString().
|
||||
/// to calling toAnsiString().
|
||||
///
|
||||
/// \return Converted ANSI string
|
||||
///
|
||||
/// \see ToAnsiString, operator std::wstring
|
||||
/// \see toAnsiString, operator std::wstring
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
operator std::string() const;
|
||||
|
@ -178,11 +178,11 @@ public :
|
|||
/// Characters that do not fit in the target encoding are
|
||||
/// discarded from the returned string.
|
||||
/// This operator is defined for convenience, and is equivalent
|
||||
/// to calling ToWideString().
|
||||
/// to calling toWideString().
|
||||
///
|
||||
/// \return Converted wide string
|
||||
///
|
||||
/// \see ToWideString, operator std::string
|
||||
/// \see toWideString, operator std::string
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
operator std::wstring() const;
|
||||
|
@ -199,10 +199,10 @@ public :
|
|||
///
|
||||
/// \return Converted ANSI string
|
||||
///
|
||||
/// \see ToWideString, operator std::string
|
||||
/// \see toWideString, operator std::string
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::string ToAnsiString(const std::locale& locale = std::locale()) const;
|
||||
std::string toAnsiString(const std::locale& locale = std::locale()) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert the unicode string to a wide string
|
||||
|
@ -212,10 +212,10 @@ public :
|
|||
///
|
||||
/// \return Converted wide string
|
||||
///
|
||||
/// \see ToAnsiString, operator std::wstring
|
||||
/// \see toAnsiString, operator std::wstring
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::wstring ToWideString() const;
|
||||
std::wstring toWideString() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -268,30 +268,30 @@ public :
|
|||
///
|
||||
/// This function removes all the characters from the string.
|
||||
///
|
||||
/// \see IsEmpty, Erase
|
||||
/// \see isEmpty, erase
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the string
|
||||
///
|
||||
/// \return Number of characters in the string
|
||||
///
|
||||
/// \see IsEmpty
|
||||
/// \see isEmpty
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetSize() const;
|
||||
std::size_t getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check whether the string is empty or not
|
||||
///
|
||||
/// \return True if the string is empty (i.e. contains no character)
|
||||
///
|
||||
/// \see Clear, GetSize
|
||||
/// \see clear, getSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsEmpty() const;
|
||||
bool isEmpty() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Erase one or more characters from the string
|
||||
|
@ -303,7 +303,7 @@ public :
|
|||
/// \param count Number of characters to erase
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Erase(std::size_t position, std::size_t count = 1);
|
||||
void erase(std::size_t position, std::size_t count = 1);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Insert one or more characters into the string
|
||||
|
@ -315,7 +315,7 @@ public :
|
|||
/// \param str Characters to insert
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Insert(std::size_t position, const String& str);
|
||||
void insert(std::size_t position, const String& str);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Find a sequence of one or more characters in the string
|
||||
|
@ -329,7 +329,7 @@ public :
|
|||
/// \return Position of \a str in the string, or String::InvalidPos if not found
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t Find(const String& str, std::size_t start = 0) const;
|
||||
std::size_t find(const String& str, std::size_t start = 0) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a pointer to the C-style array of characters
|
||||
|
@ -342,27 +342,27 @@ public :
|
|||
/// \return Read-only pointer to the array of characters
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Uint32* GetData() const;
|
||||
const Uint32* getData() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return an iterator to the beginning of the string
|
||||
///
|
||||
/// \return Read-write iterator to the beginning of the string characters
|
||||
///
|
||||
/// \see End
|
||||
/// \see end
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Iterator Begin();
|
||||
Iterator begin();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return an iterator to the beginning of the string
|
||||
///
|
||||
/// \return Read-only iterator to the beginning of the string characters
|
||||
///
|
||||
/// \see End
|
||||
/// \see end
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ConstIterator Begin() const;
|
||||
ConstIterator begin() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return an iterator to the beginning of the string
|
||||
|
@ -373,10 +373,10 @@ public :
|
|||
///
|
||||
/// \return Read-write iterator to the end of the string characters
|
||||
///
|
||||
/// \see Begin
|
||||
/// \see begin
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Iterator End();
|
||||
Iterator end();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return an iterator to the beginning of the string
|
||||
|
@ -387,10 +387,10 @@ public :
|
|||
///
|
||||
/// \return Read-only iterator to the end of the string characters
|
||||
///
|
||||
/// \see Begin
|
||||
/// \see begin
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ConstIterator End() const;
|
||||
ConstIterator end() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -524,7 +524,7 @@ SFML_SYSTEM_API String operator +(const String& left, const String& right);
|
|||
/// std::locale locale;
|
||||
/// sf::String s;
|
||||
/// ...
|
||||
/// std::string s1 = s.ToAnsiString(locale);
|
||||
/// std::string s1 = s.toAnsiString(locale);
|
||||
/// s = sf::String("hello", locale);
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -143,7 +143,7 @@ public :
|
|||
/// running in parallel to the calling code.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Launch();
|
||||
void launch();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Wait until the thread finishes
|
||||
|
@ -156,7 +156,7 @@ public :
|
|||
/// returns without doing anything.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Wait();
|
||||
void wait();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Terminate the thread
|
||||
|
@ -169,7 +169,7 @@ public :
|
|||
/// the thread function terminate by itself.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Terminate();
|
||||
void terminate();
|
||||
|
||||
private :
|
||||
|
||||
|
@ -181,7 +181,7 @@ private :
|
|||
/// This function is called by the thread implementation.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Run();
|
||||
void run();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -224,19 +224,19 @@ private :
|
|||
///
|
||||
/// The thread ends when its function is terminated. If the
|
||||
/// owner sf::Thread instance is destroyed before the
|
||||
/// thread is finished, the destructor will wait (see Wait())
|
||||
/// thread is finished, the destructor will wait (see wait())
|
||||
///
|
||||
/// Usage examples:
|
||||
/// \code
|
||||
/// // example 1: non member function with one argument
|
||||
///
|
||||
/// void ThreadFunc(int argument)
|
||||
/// void threadFunc(int argument)
|
||||
/// {
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// sf::Thread thread(&ThreadFunc, 5);
|
||||
/// thread.Launch(); // start the thread (internally calls ThreadFunc(5))
|
||||
/// sf::Thread thread(&threadFunc, 5);
|
||||
/// thread.launch(); // start the thread (internally calls threadFunc(5))
|
||||
/// \endcode
|
||||
///
|
||||
/// \code
|
||||
|
@ -245,15 +245,15 @@ private :
|
|||
/// class Task
|
||||
/// {
|
||||
/// public :
|
||||
/// void Run()
|
||||
/// void run()
|
||||
/// {
|
||||
/// ...
|
||||
/// }
|
||||
/// };
|
||||
///
|
||||
/// Task task;
|
||||
/// sf::Thread thread(&Task::Run, &task);
|
||||
/// thread.Launch(); // start the thread (internally calls task.run())
|
||||
/// sf::Thread thread(&Task::run, &task);
|
||||
/// thread.launch(); // start the thread (internally calls task.run())
|
||||
/// \endcode
|
||||
///
|
||||
/// \code
|
||||
|
@ -268,7 +268,7 @@ private :
|
|||
/// };
|
||||
///
|
||||
/// sf::Thread thread(Task());
|
||||
/// thread.Launch(); // start the thread (internally calls operator() on the Task instance)
|
||||
/// thread.launch(); // start the thread (internally calls operator() on the Task instance)
|
||||
/// \endcode
|
||||
///
|
||||
/// Creating parallel threads of execution can be dangerous:
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace priv
|
|||
struct ThreadFunc
|
||||
{
|
||||
virtual ~ThreadFunc() {}
|
||||
virtual void Run() = 0;
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
// Specialization using a functor (including free functions) with no argument
|
||||
|
@ -36,7 +36,7 @@ template <typename T>
|
|||
struct ThreadFunctor : ThreadFunc
|
||||
{
|
||||
ThreadFunctor(T functor) : m_functor(functor) {}
|
||||
virtual void Run() {m_functor();}
|
||||
virtual void run() {m_functor();}
|
||||
T m_functor;
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ template <typename F, typename A>
|
|||
struct ThreadFunctorWithArg : ThreadFunc
|
||||
{
|
||||
ThreadFunctorWithArg(F function, A arg) : m_function(function), m_arg(arg) {}
|
||||
virtual void Run() {m_function(m_arg);}
|
||||
virtual void run() {m_function(m_arg);}
|
||||
F m_function;
|
||||
A m_arg;
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ template <typename C>
|
|||
struct ThreadMemberFunc : ThreadFunc
|
||||
{
|
||||
ThreadMemberFunc(void(C::*function)(), C* object) : m_function(function), m_object(object) {}
|
||||
virtual void Run() {(m_object->*m_function)();}
|
||||
virtual void run() {(m_object->*m_function)();}
|
||||
void(C::*m_function)();
|
||||
C* m_object;
|
||||
};
|
||||
|
|
|
@ -68,7 +68,7 @@ public :
|
|||
/// \param value Value of the variable for the current thread
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetValue(void* value);
|
||||
void setValue(void* value);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Retrieve the thread-specific value of the variable
|
||||
|
@ -76,7 +76,7 @@ public :
|
|||
/// \return Value of the variable for the current thread
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void* GetValue() const;
|
||||
void* getValue() const;
|
||||
|
||||
private :
|
||||
|
||||
|
|
|
@ -128,25 +128,25 @@ public :
|
|||
/// MyClass object2;
|
||||
/// sf::ThreadLocalPtr<MyClass> objectPtr;
|
||||
///
|
||||
/// void Thread1()
|
||||
/// void thread1()
|
||||
/// {
|
||||
/// objectPtr = &object1; // doesn't impact Thread2
|
||||
/// objectPtr = &object1; // doesn't impact thread2
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// void Thread2()
|
||||
/// void thread2()
|
||||
/// {
|
||||
/// objectPtr = &object2; // doesn't impact Thread1
|
||||
/// objectPtr = &object2; // doesn't impact thread1
|
||||
/// ...
|
||||
/// }
|
||||
///
|
||||
/// int main()
|
||||
/// {
|
||||
/// // Create and launch the two threads
|
||||
/// sf::Thread thread1(&Thread1);
|
||||
/// sf::Thread thread2(&Thread2);
|
||||
/// thread1.Launch();
|
||||
/// thread2.Launch();
|
||||
/// sf::Thread t1(&thread1);
|
||||
/// sf::Thread t2(&thread2);
|
||||
/// t1.launch();
|
||||
/// t2.launch();
|
||||
///
|
||||
/// return 0;
|
||||
/// }
|
||||
|
|
|
@ -37,7 +37,7 @@ ThreadLocal(value)
|
|||
template <typename T>
|
||||
T& ThreadLocalPtr<T>::operator *() const
|
||||
{
|
||||
return *static_cast<T*>(GetValue());
|
||||
return *static_cast<T*>(getValue());
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ T& ThreadLocalPtr<T>::operator *() const
|
|||
template <typename T>
|
||||
T* ThreadLocalPtr<T>::operator ->() const
|
||||
{
|
||||
return static_cast<T*>(GetValue());
|
||||
return static_cast<T*>(getValue());
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ T* ThreadLocalPtr<T>::operator ->() const
|
|||
template <typename T>
|
||||
ThreadLocalPtr<T>::operator T*() const
|
||||
{
|
||||
return static_cast<T*>(GetValue());
|
||||
return static_cast<T*>(getValue());
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ ThreadLocalPtr<T>::operator T*() const
|
|||
template <typename T>
|
||||
ThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(T* value)
|
||||
{
|
||||
SetValue(value);
|
||||
setValue(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ ThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(T* value)
|
|||
template <typename T>
|
||||
ThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(const ThreadLocalPtr<T>& right)
|
||||
{
|
||||
SetValue(right.GetValue());
|
||||
setValue(right.getValue());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,30 +54,30 @@ public :
|
|||
///
|
||||
/// \return Time in seconds
|
||||
///
|
||||
/// \see AsMilliseconds, AsMicroseconds
|
||||
/// \see asMilliseconds, asMicroseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float AsSeconds() const;
|
||||
float asSeconds() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the time value as a number of milliseconds
|
||||
///
|
||||
/// \return Time in milliseconds
|
||||
///
|
||||
/// \see AsSeconds, AsMicroseconds
|
||||
/// \see asSeconds, asMicroseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Int32 AsMilliseconds() const;
|
||||
Int32 asMilliseconds() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the time value as a number of microseconds
|
||||
///
|
||||
/// \return Time in microseconds
|
||||
///
|
||||
/// \see AsSeconds, AsMilliseconds
|
||||
/// \see asSeconds, asMilliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Int64 AsMicroseconds() const;
|
||||
Int64 asMicroseconds() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static member data
|
||||
|
@ -86,15 +86,15 @@ public :
|
|||
|
||||
private :
|
||||
|
||||
friend SFML_SYSTEM_API Time Seconds(float);
|
||||
friend SFML_SYSTEM_API Time Milliseconds(Int32);
|
||||
friend SFML_SYSTEM_API Time Microseconds(Int64);
|
||||
friend SFML_SYSTEM_API Time seconds(float);
|
||||
friend SFML_SYSTEM_API Time milliseconds(Int32);
|
||||
friend SFML_SYSTEM_API Time microseconds(Int64);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct from a number of microseconds
|
||||
///
|
||||
/// This function is internal. To construct time values,
|
||||
/// use sf::Seconds, sf::Milliseconds or sf::Microseconds instead.
|
||||
/// use sf::seconds, sf::milliseconds or sf::microseconds instead.
|
||||
///
|
||||
/// \param microseconds Number of microseconds
|
||||
///
|
||||
|
@ -117,10 +117,10 @@ private :
|
|||
///
|
||||
/// \return Time value constructed from the amount of seconds
|
||||
///
|
||||
/// \see Milliseconds, Microseconds
|
||||
/// \see milliseconds, microseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SFML_SYSTEM_API Time Seconds(float amount);
|
||||
SFML_SYSTEM_API Time seconds(float amount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Time
|
||||
|
@ -130,10 +130,10 @@ SFML_SYSTEM_API Time Seconds(float amount);
|
|||
///
|
||||
/// \return Time value constructed from the amount of milliseconds
|
||||
///
|
||||
/// \see Seconds, Microseconds
|
||||
/// \see seconds, microseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SFML_SYSTEM_API Time Milliseconds(Int32 amount);
|
||||
SFML_SYSTEM_API Time milliseconds(Int32 amount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Time
|
||||
|
@ -143,10 +143,10 @@ SFML_SYSTEM_API Time Milliseconds(Int32 amount);
|
|||
///
|
||||
/// \return Time value constructed from the amount of microseconds
|
||||
///
|
||||
/// \see Seconds, Milliseconds
|
||||
/// \see seconds, milliseconds
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SFML_SYSTEM_API Time Microseconds(Int64 amount);
|
||||
SFML_SYSTEM_API Time microseconds(Int64 amount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \relates Time
|
||||
|
@ -428,23 +428,23 @@ SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);
|
|||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::Time t1 = sf::Seconds(0.1f);
|
||||
/// Int32 milli = t1.AsMilliseconds(); // 100
|
||||
/// sf::Time t1 = sf::seconds(0.1f);
|
||||
/// Int32 milli = t1.asMilliseconds(); // 100
|
||||
///
|
||||
/// sf::Time t2 = sf::Milliseconds(30);
|
||||
/// Int64 micro = t2.AsMicroseconds(); // 30000
|
||||
/// sf::Time t2 = sf::milliseconds(30);
|
||||
/// Int64 micro = t2.asMicroseconds(); // 30000
|
||||
///
|
||||
/// sf::Time t3 = sf::Microseconds(-800000);
|
||||
/// float sec = t3.AsSeconds(); // -0.8
|
||||
/// sf::Time t3 = sf::microseconds(-800000);
|
||||
/// float sec = t3.asSeconds(); // -0.8
|
||||
/// \endcode
|
||||
///
|
||||
/// \code
|
||||
/// void Update(sf::Time elapsed)
|
||||
/// void update(sf::Time elapsed)
|
||||
/// {
|
||||
/// position += speed * elapsed.AsSeconds();
|
||||
/// position += speed * elapsed.asSeconds();
|
||||
/// }
|
||||
///
|
||||
/// Update(sf::Milliseconds(100));
|
||||
/// Update(sf::milliseconds(100));
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Clock
|
||||
|
|
|
@ -64,7 +64,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
|
||||
static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Encode a single UTF-8 character
|
||||
|
@ -80,7 +80,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
static Out Encode(Uint32 input, Out output, Uint8 replacement = 0);
|
||||
static Out encode(Uint32 input, Out output, Uint8 replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Advance to the next UTF-8 character
|
||||
|
@ -95,7 +95,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static In Next(In begin, In end);
|
||||
static In next(In begin, In end);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Count the number of characters of a UTF-8 sequence
|
||||
|
@ -111,7 +111,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static std::size_t Count(In begin, In end);
|
||||
static std::size_t count(In begin, In end);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an ANSI characters range to UTF-8
|
||||
|
@ -128,7 +128,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
|
||||
static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a wide characters range to UTF-8
|
||||
|
@ -141,7 +141,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromWide(In begin, In end, Out output);
|
||||
static Out fromWide(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8
|
||||
|
@ -154,7 +154,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromLatin1(In begin, In end, Out output);
|
||||
static Out fromLatin1(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-8 characters range to ANSI characters
|
||||
|
@ -172,7 +172,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-8 characters range to wide characters
|
||||
|
@ -186,7 +186,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
|
||||
static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters
|
||||
|
@ -200,7 +200,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
|
||||
static Out toLatin1(In begin, In end, Out output, char replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-8 characters range to UTF-8
|
||||
|
@ -218,7 +218,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf8(In begin, In end, Out output);
|
||||
static Out toUtf8(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-8 characters range to UTF-16
|
||||
|
@ -231,7 +231,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf16(In begin, In end, Out output);
|
||||
static Out toUtf16(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-8 characters range to UTF-32
|
||||
|
@ -244,7 +244,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf32(In begin, In end, Out output);
|
||||
static Out toUtf32(In begin, In end, Out output);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -271,7 +271,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
|
||||
static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Encode a single UTF-16 character
|
||||
|
@ -287,7 +287,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
static Out Encode(Uint32 input, Out output, Uint16 replacement = 0);
|
||||
static Out encode(Uint32 input, Out output, Uint16 replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Advance to the next UTF-16 character
|
||||
|
@ -302,7 +302,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static In Next(In begin, In end);
|
||||
static In next(In begin, In end);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Count the number of characters of a UTF-16 sequence
|
||||
|
@ -318,7 +318,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static std::size_t Count(In begin, In end);
|
||||
static std::size_t count(In begin, In end);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an ANSI characters range to UTF-16
|
||||
|
@ -335,7 +335,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
|
||||
static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a wide characters range to UTF-16
|
||||
|
@ -348,7 +348,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromWide(In begin, In end, Out output);
|
||||
static Out fromWide(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16
|
||||
|
@ -361,7 +361,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromLatin1(In begin, In end, Out output);
|
||||
static Out fromLatin1(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-16 characters range to ANSI characters
|
||||
|
@ -379,7 +379,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-16 characters range to wide characters
|
||||
|
@ -393,7 +393,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
|
||||
static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters
|
||||
|
@ -407,7 +407,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
|
||||
static Out toLatin1(In begin, In end, Out output, char replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-16 characters range to UTF-8
|
||||
|
@ -420,7 +420,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf8(In begin, In end, Out output);
|
||||
static Out toUtf8(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-16 characters range to UTF-16
|
||||
|
@ -438,7 +438,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf16(In begin, In end, Out output);
|
||||
static Out toUtf16(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-16 characters range to UTF-32
|
||||
|
@ -451,7 +451,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf32(In begin, In end, Out output);
|
||||
static Out toUtf32(In begin, In end, Out output);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -479,7 +479,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
|
||||
static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Encode a single UTF-32 character
|
||||
|
@ -496,7 +496,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
static Out Encode(Uint32 input, Out output, Uint32 replacement = 0);
|
||||
static Out encode(Uint32 input, Out output, Uint32 replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Advance to the next UTF-32 character
|
||||
|
@ -511,7 +511,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static In Next(In begin, In end);
|
||||
static In next(In begin, In end);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Count the number of characters of a UTF-32 sequence
|
||||
|
@ -526,7 +526,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static std::size_t Count(In begin, In end);
|
||||
static std::size_t count(In begin, In end);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an ANSI characters range to UTF-32
|
||||
|
@ -543,7 +543,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
|
||||
static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a wide characters range to UTF-32
|
||||
|
@ -556,7 +556,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromWide(In begin, In end, Out output);
|
||||
static Out fromWide(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32
|
||||
|
@ -569,7 +569,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out FromLatin1(In begin, In end, Out output);
|
||||
static Out fromLatin1(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-32 characters range to ANSI characters
|
||||
|
@ -587,7 +587,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-32 characters range to wide characters
|
||||
|
@ -601,7 +601,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
|
||||
static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters
|
||||
|
@ -615,7 +615,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
|
||||
static Out toLatin1(In begin, In end, Out output, char replacement = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-32 characters range to UTF-8
|
||||
|
@ -628,7 +628,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf8(In begin, In end, Out output);
|
||||
static Out toUtf8(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-32 characters range to UTF-16
|
||||
|
@ -641,7 +641,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf16(In begin, In end, Out output);
|
||||
static Out toUtf16(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a UTF-32 characters range to UTF-32
|
||||
|
@ -659,7 +659,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
static Out ToUtf32(In begin, In end, Out output);
|
||||
static Out toUtf32(In begin, In end, Out output);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Decode a single ANSI character to UTF-32
|
||||
|
@ -675,7 +675,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale());
|
||||
static Uint32 decodeAnsi(In input, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Decode a single wide character to UTF-32
|
||||
|
@ -690,7 +690,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
static Uint32 DecodeWide(In input);
|
||||
static Uint32 decodeWide(In input);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Encode a single UTF-32 character to ANSI
|
||||
|
@ -708,7 +708,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
static Out encodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Encode a single UTF-32 character to wide
|
||||
|
@ -725,7 +725,7 @@ public :
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);
|
||||
static Out encodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);
|
||||
};
|
||||
|
||||
#include <SFML/System/Utf.inl>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
{
|
||||
// Some useful precomputed data
|
||||
static const int trailing[256] =
|
||||
|
@ -55,7 +55,7 @@ In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
|
|||
0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080
|
||||
};
|
||||
|
||||
// Decode the character
|
||||
// decode the character
|
||||
int trailingBytes = trailing[static_cast<Uint8>(*begin)];
|
||||
if (begin + trailingBytes < end)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement)
|
||||
Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
|
||||
{
|
||||
// Some useful precomputed data
|
||||
static const Uint8 firstBytes[7] =
|
||||
|
@ -92,7 +92,7 @@ Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement)
|
|||
0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
|
||||
};
|
||||
|
||||
// Encode the character
|
||||
// encode the character
|
||||
if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))
|
||||
{
|
||||
// Invalid character
|
||||
|
@ -104,25 +104,25 @@ Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement)
|
|||
// Valid character
|
||||
|
||||
// Get the number of bytes to write
|
||||
int bytesToWrite = 1;
|
||||
if (input < 0x80) bytesToWrite = 1;
|
||||
else if (input < 0x800) bytesToWrite = 2;
|
||||
else if (input < 0x10000) bytesToWrite = 3;
|
||||
else if (input <= 0x0010FFFF) bytesToWrite = 4;
|
||||
int bytestoWrite = 1;
|
||||
if (input < 0x80) bytestoWrite = 1;
|
||||
else if (input < 0x800) bytestoWrite = 2;
|
||||
else if (input < 0x10000) bytestoWrite = 3;
|
||||
else if (input <= 0x0010FFFF) bytestoWrite = 4;
|
||||
|
||||
// Extract the bytes to write
|
||||
Uint8 bytes[4];
|
||||
switch (bytesToWrite)
|
||||
switch (bytestoWrite)
|
||||
{
|
||||
case 4 : bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
|
||||
case 3 : bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
|
||||
case 2 : bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
|
||||
case 1 : bytes[0] = static_cast<Uint8> (input | firstBytes[bytesToWrite]);
|
||||
case 1 : bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
|
||||
}
|
||||
|
||||
// Add them to the output
|
||||
const Uint8* currentByte = bytes;
|
||||
switch (bytesToWrite)
|
||||
switch (bytestoWrite)
|
||||
{
|
||||
case 4 : *output++ = *currentByte++;
|
||||
case 3 : *output++ = *currentByte++;
|
||||
|
@ -137,21 +137,21 @@ Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
In Utf<8>::Next(In begin, In end)
|
||||
In Utf<8>::next(In begin, In end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
return Decode(begin, end, codepoint);
|
||||
return decode(begin, end, codepoint);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
std::size_t Utf<8>::Count(In begin, In end)
|
||||
std::size_t Utf<8>::count(In begin, In end)
|
||||
{
|
||||
std::size_t length = 0;
|
||||
while (begin < end)
|
||||
{
|
||||
begin = Next(begin, end);
|
||||
begin = next(begin, end);
|
||||
++length;
|
||||
}
|
||||
|
||||
|
@ -161,12 +161,12 @@ std::size_t Utf<8>::Count(In begin, In end)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
|
||||
Out Utf<8>::fromAnsi(In begin, In end, Out output, const std::locale& locale)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale);
|
||||
output = Encode(codepoint, output);
|
||||
Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale);
|
||||
output = encode(codepoint, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -175,12 +175,12 @@ Out Utf<8>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::FromWide(In begin, In end, Out output)
|
||||
Out Utf<8>::fromWide(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint = Utf<32>::DecodeWide(*begin++);
|
||||
output = Encode(codepoint, output);
|
||||
Uint32 codepoint = Utf<32>::decodeWide(*begin++);
|
||||
output = encode(codepoint, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -189,12 +189,12 @@ Out Utf<8>::FromWide(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::FromLatin1(In begin, In end, Out output)
|
||||
Out Utf<8>::fromLatin1(In begin, In end, Out output)
|
||||
{
|
||||
// Latin-1 is directly compatible with Unicode encodings,
|
||||
// and can thus be treated as (a sub-range of) UTF-32
|
||||
while (begin < end)
|
||||
output = Encode(*begin++, output);
|
||||
output = encode(*begin++, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -202,13 +202,13 @@ Out Utf<8>::FromLatin1(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
|
||||
Out Utf<8>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale);
|
||||
begin = decode(begin, end, codepoint);
|
||||
output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -217,13 +217,13 @@ Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::lo
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement)
|
||||
Out Utf<8>::toWide(In begin, In end, Out output, wchar_t replacement)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
output = Utf<32>::EncodeWide(codepoint, output, replacement);
|
||||
begin = decode(begin, end, codepoint);
|
||||
output = Utf<32>::encodeWide(codepoint, output, replacement);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -232,14 +232,14 @@ Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::ToLatin1(In begin, In end, Out output, char replacement)
|
||||
Out Utf<8>::toLatin1(In begin, In end, Out output, char replacement)
|
||||
{
|
||||
// Latin-1 is directly compatible with Unicode encodings,
|
||||
// and can thus be treated as (a sub-range of) UTF-32
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
begin = decode(begin, end, codepoint);
|
||||
*output++ = codepoint < 256 ? static_cast<char>(codepoint) : replacement;
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ Out Utf<8>::ToLatin1(In begin, In end, Out output, char replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::ToUtf8(In begin, In end, Out output)
|
||||
Out Utf<8>::toUtf8(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
*output++ = *begin++;
|
||||
|
@ -260,13 +260,13 @@ Out Utf<8>::ToUtf8(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::ToUtf16(In begin, In end, Out output)
|
||||
Out Utf<8>::toUtf16(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
output = Utf<16>::Encode(codepoint, output);
|
||||
begin = decode(begin, end, codepoint);
|
||||
output = Utf<16>::encode(codepoint, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -275,12 +275,12 @@ Out Utf<8>::ToUtf16(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<8>::ToUtf32(In begin, In end, Out output)
|
||||
Out Utf<8>::toUtf32(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
begin = decode(begin, end, codepoint);
|
||||
*output++ = codepoint;
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ Out Utf<8>::ToUtf32(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
In Utf<16>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement)
|
||||
{
|
||||
Uint16 first = *begin++;
|
||||
|
||||
|
@ -330,7 +330,7 @@ In Utf<16>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
Out Utf<16>::Encode(Uint32 input, Out output, Uint16 replacement)
|
||||
Out Utf<16>::encode(Uint32 input, Out output, Uint16 replacement)
|
||||
{
|
||||
if (input < 0xFFFF)
|
||||
{
|
||||
|
@ -367,21 +367,21 @@ Out Utf<16>::Encode(Uint32 input, Out output, Uint16 replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
In Utf<16>::Next(In begin, In end)
|
||||
In Utf<16>::next(In begin, In end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
return Decode(begin, end, codepoint);
|
||||
return decode(begin, end, codepoint);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
std::size_t Utf<16>::Count(In begin, In end)
|
||||
std::size_t Utf<16>::count(In begin, In end)
|
||||
{
|
||||
std::size_t length = 0;
|
||||
while (begin < end)
|
||||
{
|
||||
begin = Next(begin, end);
|
||||
begin = next(begin, end);
|
||||
++length;
|
||||
}
|
||||
|
||||
|
@ -391,12 +391,12 @@ std::size_t Utf<16>::Count(In begin, In end)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
|
||||
Out Utf<16>::fromAnsi(In begin, In end, Out output, const std::locale& locale)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale);
|
||||
output = Encode(codepoint, output);
|
||||
Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale);
|
||||
output = encode(codepoint, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -405,12 +405,12 @@ Out Utf<16>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::FromWide(In begin, In end, Out output)
|
||||
Out Utf<16>::fromWide(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint = Utf<32>::DecodeWide(*begin++);
|
||||
output = Encode(codepoint, output);
|
||||
Uint32 codepoint = Utf<32>::decodeWide(*begin++);
|
||||
output = encode(codepoint, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -419,7 +419,7 @@ Out Utf<16>::FromWide(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::FromLatin1(In begin, In end, Out output)
|
||||
Out Utf<16>::fromLatin1(In begin, In end, Out output)
|
||||
{
|
||||
// Latin-1 is directly compatible with Unicode encodings,
|
||||
// and can thus be treated as (a sub-range of) UTF-32
|
||||
|
@ -432,13 +432,13 @@ Out Utf<16>::FromLatin1(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
|
||||
Out Utf<16>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale);
|
||||
begin = decode(begin, end, codepoint);
|
||||
output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -447,13 +447,13 @@ Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::l
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement)
|
||||
Out Utf<16>::toWide(In begin, In end, Out output, wchar_t replacement)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
output = Utf<32>::EncodeWide(codepoint, output, replacement);
|
||||
begin = decode(begin, end, codepoint);
|
||||
output = Utf<32>::encodeWide(codepoint, output, replacement);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -462,7 +462,7 @@ Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::ToLatin1(In begin, In end, Out output, char replacement)
|
||||
Out Utf<16>::toLatin1(In begin, In end, Out output, char replacement)
|
||||
{
|
||||
// Latin-1 is directly compatible with Unicode encodings,
|
||||
// and can thus be treated as (a sub-range of) UTF-32
|
||||
|
@ -478,13 +478,13 @@ Out Utf<16>::ToLatin1(In begin, In end, Out output, char replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::ToUtf8(In begin, In end, Out output)
|
||||
Out Utf<16>::toUtf8(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
output = Utf<8>::Encode(codepoint, output);
|
||||
begin = decode(begin, end, codepoint);
|
||||
output = Utf<8>::encode(codepoint, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -493,7 +493,7 @@ Out Utf<16>::ToUtf8(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::ToUtf16(In begin, In end, Out output)
|
||||
Out Utf<16>::toUtf16(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
*output++ = *begin++;
|
||||
|
@ -504,12 +504,12 @@ Out Utf<16>::ToUtf16(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<16>::ToUtf32(In begin, In end, Out output)
|
||||
Out Utf<16>::toUtf32(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
Uint32 codepoint;
|
||||
begin = Decode(begin, end, codepoint);
|
||||
begin = decode(begin, end, codepoint);
|
||||
*output++ = codepoint;
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ Out Utf<16>::ToUtf32(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
In Utf<32>::Decode(In begin, In end, Uint32& output, Uint32)
|
||||
In Utf<32>::decode(In begin, In end, Uint32& output, Uint32)
|
||||
{
|
||||
output = *begin++;
|
||||
return begin;
|
||||
|
@ -528,7 +528,7 @@ In Utf<32>::Decode(In begin, In end, Uint32& output, Uint32)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
Out Utf<32>::Encode(Uint32 input, Out output, Uint32 replacement)
|
||||
Out Utf<32>::encode(Uint32 input, Out output, Uint32 replacement)
|
||||
{
|
||||
*output++ = input;
|
||||
return output;
|
||||
|
@ -537,7 +537,7 @@ Out Utf<32>::Encode(Uint32 input, Out output, Uint32 replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
In Utf<32>::Next(In begin, In end)
|
||||
In Utf<32>::next(In begin, In end)
|
||||
{
|
||||
return ++begin;
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ In Utf<32>::Next(In begin, In end)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
std::size_t Utf<32>::Count(In begin, In end)
|
||||
std::size_t Utf<32>::count(In begin, In end)
|
||||
{
|
||||
return begin - end;
|
||||
}
|
||||
|
@ -553,10 +553,10 @@ std::size_t Utf<32>::Count(In begin, In end)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
|
||||
Out Utf<32>::fromAnsi(In begin, In end, Out output, const std::locale& locale)
|
||||
{
|
||||
while (begin < end)
|
||||
*output++ = DecodeAnsi(*begin++, locale);
|
||||
*output++ = decodeAnsi(*begin++, locale);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -564,10 +564,10 @@ Out Utf<32>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::FromWide(In begin, In end, Out output)
|
||||
Out Utf<32>::fromWide(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
*output++ = DecodeWide(*begin++);
|
||||
*output++ = decodeWide(*begin++);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ Out Utf<32>::FromWide(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::FromLatin1(In begin, In end, Out output)
|
||||
Out Utf<32>::fromLatin1(In begin, In end, Out output)
|
||||
{
|
||||
// Latin-1 is directly compatible with Unicode encodings,
|
||||
// and can thus be treated as (a sub-range of) UTF-32
|
||||
|
@ -588,10 +588,10 @@ Out Utf<32>::FromLatin1(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
|
||||
Out Utf<32>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
|
||||
{
|
||||
while (begin < end)
|
||||
output = EncodeAnsi(*begin++, output, replacement, locale);
|
||||
output = encodeAnsi(*begin++, output, replacement, locale);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -599,10 +599,10 @@ Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::l
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement)
|
||||
Out Utf<32>::toWide(In begin, In end, Out output, wchar_t replacement)
|
||||
{
|
||||
while (begin < end)
|
||||
output = EncodeWide(*begin++, output, replacement);
|
||||
output = encodeWide(*begin++, output, replacement);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::ToLatin1(In begin, In end, Out output, char replacement)
|
||||
Out Utf<32>::toLatin1(In begin, In end, Out output, char replacement)
|
||||
{
|
||||
// Latin-1 is directly compatible with Unicode encodings,
|
||||
// and can thus be treated as (a sub-range of) UTF-32
|
||||
|
@ -626,20 +626,20 @@ Out Utf<32>::ToLatin1(In begin, In end, Out output, char replacement)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::ToUtf8(In begin, In end, Out output)
|
||||
Out Utf<32>::toUtf8(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
output = Utf<8>::Encode(*begin++, output);
|
||||
output = Utf<8>::encode(*begin++, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::ToUtf16(In begin, In end, Out output)
|
||||
Out Utf<32>::toUtf16(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
output = Utf<16>::Encode(*begin++, output);
|
||||
output = Utf<16>::encode(*begin++, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ Out Utf<32>::ToUtf16(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In, typename Out>
|
||||
Out Utf<32>::ToUtf32(In begin, In end, Out output)
|
||||
Out Utf<32>::toUtf32(In begin, In end, Out output)
|
||||
{
|
||||
while (begin < end)
|
||||
*output++ = *begin++;
|
||||
|
@ -658,7 +658,7 @@ Out Utf<32>::ToUtf32(In begin, In end, Out output)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale)
|
||||
Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)
|
||||
{
|
||||
// On Windows, gcc's standard library (glibc++) has almost
|
||||
// no support for Unicode stuff. As a consequence, in this
|
||||
|
@ -687,7 +687,7 @@ Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
Uint32 Utf<32>::DecodeWide(In input)
|
||||
Uint32 Utf<32>::decodeWide(In input)
|
||||
{
|
||||
// The encoding of wide characters is not well defined and is left to the system;
|
||||
// however we can safely assume that it is UCS-2 on Windows and
|
||||
|
@ -701,7 +701,7 @@ Uint32 Utf<32>::DecodeWide(In input)
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale)
|
||||
Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale)
|
||||
{
|
||||
// On Windows, gcc's standard library (glibc++) has almost
|
||||
// no support for Unicode stuff. As a consequence, in this
|
||||
|
@ -736,7 +736,7 @@ Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const st
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
Out Utf<32>::EncodeWide(Uint32 codepoint, Out output, wchar_t replacement)
|
||||
Out Utf<32>::encodeWide(Uint32 codepoint, Out output, wchar_t replacement)
|
||||
{
|
||||
// The encoding of wide characters is not well defined and is left to the system;
|
||||
// however we can safely assume that it is UCS-2 on Windows and
|
||||
|
|
|
@ -73,7 +73,7 @@ public :
|
|||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SetActive(bool active);
|
||||
bool setActive(bool active);
|
||||
|
||||
public :
|
||||
|
||||
|
@ -125,7 +125,7 @@ private :
|
|||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// void ThreadFunction(void*)
|
||||
/// void threadFunction(void*)
|
||||
/// {
|
||||
/// sf::Context context;
|
||||
/// // from now on, you have a valid context
|
||||
|
|
|
@ -46,22 +46,22 @@ struct ContextSettings
|
|||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 2, unsigned int minor = 0) :
|
||||
DepthBits (depth),
|
||||
StencilBits (stencil),
|
||||
AntialiasingLevel(antialiasing),
|
||||
MajorVersion (major),
|
||||
MinorVersion (minor)
|
||||
depthBits (depth),
|
||||
stencilBits (stencil),
|
||||
antialiasingLevel(antialiasing),
|
||||
majorVersion (major),
|
||||
minorVersion (minor)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int DepthBits; ///< Bits of the depth buffer
|
||||
unsigned int StencilBits; ///< Bits of the stencil buffer
|
||||
unsigned int AntialiasingLevel; ///< Level of antialiasing
|
||||
unsigned int MajorVersion; ///< Major number of the context version to create
|
||||
unsigned int MinorVersion; ///< Minor number of the context version to create
|
||||
unsigned int depthBits; ///< Bits of the depth buffer
|
||||
unsigned int stencilBits; ///< Bits of the stencil buffer
|
||||
unsigned int antialiasingLevel; ///< Level of antialiasing
|
||||
unsigned int majorVersion; ///< Major number of the context version to create
|
||||
unsigned int minorVersion; ///< Minor number of the context version to create
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -81,14 +81,14 @@ struct ContextSettings
|
|||
/// you may need to use this structure only if you're using
|
||||
/// SFML as a windowing system for custom OpenGL rendering.
|
||||
///
|
||||
/// The DepthBits and StencilBits members define the number
|
||||
/// The depthBits and stencilBits members define the number
|
||||
/// of bits per pixel requested for the (respectively) depth
|
||||
/// and stencil buffers.
|
||||
///
|
||||
/// AntialiasingLevel represents the requested number of
|
||||
/// antialiasingLevel represents the requested number of
|
||||
/// multisampling levels for anti-aliasing.
|
||||
///
|
||||
/// MajorVersion and MinorVersion define the version of the
|
||||
/// majorVersion and minorVersion define the version of the
|
||||
/// OpenGL context that you want. Only versions greater or
|
||||
/// equal to 3.0 are relevant; versions lesser than 3.0 are
|
||||
/// all handled the same way (i.e. you can use any version
|
||||
|
@ -99,6 +99,6 @@ struct ContextSettings
|
|||
/// are not supported by the system; instead, SFML will try to
|
||||
/// find the closest valid match. You can then retrieve the
|
||||
/// settings that the window actually used to create its context,
|
||||
/// with Window::GetSettings().
|
||||
/// with Window::getSettings().
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -50,8 +50,8 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct SizeEvent
|
||||
{
|
||||
unsigned int Width; ///< New width, in pixels
|
||||
unsigned int Height; ///< New height, in pixels
|
||||
unsigned int width; ///< New width, in pixels
|
||||
unsigned int height; ///< New height, in pixels
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -60,11 +60,11 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct KeyEvent
|
||||
{
|
||||
Keyboard::Key Code; ///< Code of the key that has been pressed
|
||||
bool Alt; ///< Is the Alt key pressed?
|
||||
bool Control; ///< Is the Control key pressed?
|
||||
bool Shift; ///< Is the Shift key pressed?
|
||||
bool System; ///< Is the System key pressed?
|
||||
Keyboard::Key code; ///< Code of the key that has been pressed
|
||||
bool alt; ///< Is the Alt key pressed?
|
||||
bool control; ///< Is the Control key pressed?
|
||||
bool shift; ///< Is the Shift key pressed?
|
||||
bool system; ///< Is the System key pressed?
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -73,7 +73,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct TextEvent
|
||||
{
|
||||
Uint32 Unicode; ///< UTF-32 unicode value of the character
|
||||
Uint32 unicode; ///< UTF-32 unicode value of the character
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -82,8 +82,8 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct MouseMoveEvent
|
||||
{
|
||||
int X; ///< X position of the mouse pointer, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse pointer, relative to the top of the owner window
|
||||
int x; ///< X position of the mouse pointer, relative to the left of the owner window
|
||||
int y; ///< Y position of the mouse pointer, relative to the top of the owner window
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -93,9 +93,9 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct MouseButtonEvent
|
||||
{
|
||||
Mouse::Button Button; ///< Code of the button that has been pressed
|
||||
int X; ///< X position of the mouse pointer, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse pointer, relative to the top of the owner window
|
||||
Mouse::Button button; ///< Code of the button that has been pressed
|
||||
int x; ///< X position of the mouse pointer, relative to the left of the owner window
|
||||
int y; ///< Y position of the mouse pointer, relative to the top of the owner window
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -104,9 +104,9 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct MouseWheelEvent
|
||||
{
|
||||
int Delta; ///< Number of ticks the wheel has moved (positive is up, negative is down)
|
||||
int X; ///< X position of the mouse pointer, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse pointer, relative to the top of the owner window
|
||||
int delta; ///< Number of ticks the wheel has moved (positive is up, negative is down)
|
||||
int x; ///< X position of the mouse pointer, relative to the left of the owner window
|
||||
int y; ///< Y position of the mouse pointer, relative to the top of the owner window
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -116,7 +116,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct JoystickConnectEvent
|
||||
{
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -125,9 +125,9 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct JoystickMoveEvent
|
||||
{
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
Joystick::Axis Axis; ///< Axis on which the joystick moved
|
||||
float Position; ///< New position on the axis (in range [-100 .. 100])
|
||||
unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
Joystick::Axis axis; ///< Axis on which the joystick moved
|
||||
float position; ///< New position on the axis (in range [-100 .. 100])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -137,8 +137,8 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct JoystickButtonEvent
|
||||
{
|
||||
unsigned int JoystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
unsigned int Button; ///< Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])
|
||||
unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
|
||||
unsigned int button; ///< Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -172,19 +172,19 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
EventType Type; ///< Type of the event
|
||||
EventType type; ///< Type of the event
|
||||
|
||||
union
|
||||
{
|
||||
SizeEvent Size; ///< Size event parameters
|
||||
KeyEvent Key; ///< Key event parameters
|
||||
TextEvent Text; ///< Text event parameters
|
||||
MouseMoveEvent MouseMove; ///< Mouse move event parameters
|
||||
MouseButtonEvent MouseButton; ///< Mouse button event parameters
|
||||
MouseWheelEvent MouseWheel; ///< Mouse wheel event parameters
|
||||
JoystickMoveEvent JoystickMove; ///< Joystick move event parameters
|
||||
JoystickButtonEvent JoystickButton; ///< Joystick button event parameters
|
||||
JoystickConnectEvent JoystickConnect; ///< Joystick (dis)connect event parameters
|
||||
SizeEvent size; ///< Size event parameters
|
||||
KeyEvent key; ///< Key event parameters
|
||||
TextEvent text; ///< Text event parameters
|
||||
MouseMoveEvent mouseMove; ///< Mouse move event parameters
|
||||
MouseButtonEvent mouseButton; ///< Mouse button event parameters
|
||||
MouseWheelEvent mouseWheel; ///< Mouse wheel event parameters
|
||||
JoystickMoveEvent joystickMove; ///< Joystick move event parameters
|
||||
JoystickButtonEvent joystickButton; ///< Joystick button event parameters
|
||||
JoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -200,7 +200,7 @@ public :
|
|||
///
|
||||
/// sf::Event holds all the informations about a system event
|
||||
/// that just happened. Events are retrieved using the
|
||||
/// sf::Window::PollEvent and sf::Window::WaitEvent functions.
|
||||
/// sf::Window::pollEvent and sf::Window::waitEvent functions.
|
||||
///
|
||||
/// A sf::Event instance contains the type of the event
|
||||
/// (mouse moved, key pressed, window closed, ...) as well
|
||||
|
@ -210,25 +210,25 @@ public :
|
|||
/// filled; all other members will have undefined values and must not
|
||||
/// be read if the type of the event doesn't match. For example,
|
||||
/// if you received a KeyPressed event, then you must read the
|
||||
/// event.Key member, all other members such as event.MouseMove
|
||||
/// or event.Text will have undefined values.
|
||||
/// event.key member, all other members such as event.MouseMove
|
||||
/// or event.text will have undefined values.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::Event event;
|
||||
/// while (window.PollEvent(event))
|
||||
/// while (window.pollEvent(event))
|
||||
/// {
|
||||
/// // Request for closing the window
|
||||
/// if (event.Type == sf::Event::Closed)
|
||||
/// window.Close();
|
||||
/// if (event.type == sf::Event::Closed)
|
||||
/// window.close();
|
||||
///
|
||||
/// // The escape key was pressed
|
||||
/// if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape))
|
||||
/// window.Close();
|
||||
/// if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
|
||||
/// window.close();
|
||||
///
|
||||
/// // The window was resized
|
||||
/// if (event.Type == sf::Event::Resized)
|
||||
/// DoSomethingWithTheNewSize(event.Size.Width, event.Size.Height);
|
||||
/// if (event.type == sf::Event::Resized)
|
||||
/// doSomethingWithTheNewSize(event.size.width, event.size.height);
|
||||
///
|
||||
/// // etc ...
|
||||
/// }
|
||||
|
|
|
@ -53,7 +53,11 @@ protected :
|
|||
////////////////////////////////////////////////////////////
|
||||
~GlResource();
|
||||
|
||||
static void EnsureGlContext();
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Make sure that a valid OpenGL context exists in the current thread
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void ensureGlContext();
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -76,7 +76,7 @@ public :
|
|||
/// \return True if the joystick is connected, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsConnected(unsigned int joystick);
|
||||
static bool isConnected(unsigned int joystick);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the number of buttons supported by a joystick
|
||||
|
@ -88,7 +88,7 @@ public :
|
|||
/// \return Number of buttons supported by the joystick
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static unsigned int GetButtonCount(unsigned int joystick);
|
||||
static unsigned int getButtonCount(unsigned int joystick);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a joystick supports a given axis
|
||||
|
@ -101,7 +101,7 @@ public :
|
|||
/// \return True if the joystick supports the axis, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool HasAxis(unsigned int joystick, Axis axis);
|
||||
static bool hasAxis(unsigned int joystick, Axis axis);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a joystick button is pressed
|
||||
|
@ -114,7 +114,7 @@ public :
|
|||
/// \return True if the button is pressed, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsButtonPressed(unsigned int joystick, unsigned int button);
|
||||
static bool isButtonPressed(unsigned int joystick, unsigned int button);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current position of a joystick axis
|
||||
|
@ -127,7 +127,7 @@ public :
|
|||
/// \return Current position of the axis, in range [-100 .. 100]
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static float GetAxisPosition(unsigned int joystick, Axis axis);
|
||||
static float getAxisPosition(unsigned int joystick, Axis axis);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the states of all joysticks
|
||||
|
@ -138,7 +138,7 @@ public :
|
|||
/// in this case the joysticks states are not updated automatically.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void Update();
|
||||
static void update();
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -173,29 +173,29 @@ public :
|
|||
/// \li 8 axes per joystick (sf::Joystick::AxisCount)
|
||||
///
|
||||
/// Unlike the keyboard or mouse, the state of joysticks is sometimes
|
||||
/// not directly available (depending on the OS), therefore an Update()
|
||||
/// not directly available (depending on the OS), therefore an update()
|
||||
/// function must be called in order to update the current state of
|
||||
/// joysticks. When you have a window with event handling, this is done
|
||||
/// automatically, you don't need to call anything. But if you have no
|
||||
/// window, or if you want to check joysticks state before creating one,
|
||||
/// you must call sf::Joystick::Update explicitely.
|
||||
/// you must call sf::Joystick::update explicitely.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// // Is joystick #0 connected?
|
||||
/// bool connected = sf::Joystick::IsConnected(0);
|
||||
/// bool connected = sf::Joystick::isConnected(0);
|
||||
///
|
||||
/// // How many buttons does joystick #0 support?
|
||||
/// unsigned int buttons = sf::Joystick::GetButtonCount(0);
|
||||
/// unsigned int buttons = sf::Joystick::getButtonCount(0);
|
||||
///
|
||||
/// // Does joystick #0 define a X axis?
|
||||
/// bool hasX = sf::Joystick::HasAxis(0, sf::Joystick::X);
|
||||
/// bool hasX = sf::Joystick::hasAxis(0, sf::Joystick::X);
|
||||
///
|
||||
/// // Is button #2 pressed on joystick #0?
|
||||
/// bool pressed = sf::Joystick::IsButtonPressed(0, 2);
|
||||
/// bool pressed = sf::Joystick::isButtonPressed(0, 2);
|
||||
///
|
||||
/// // What's the current position of the Y axis on joystick #0?
|
||||
/// float position = sf::Joystick::GetAxisPosition(0, sf::Joystick::Y);
|
||||
/// float position = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Keyboard, sf::Mouse
|
||||
|
|
|
@ -160,7 +160,7 @@ public :
|
|||
/// \return True if the key is pressed, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsKeyPressed(Key key);
|
||||
static bool isKeyPressed(Key key);
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -189,15 +189,15 @@ public :
|
|||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Left))
|
||||
/// if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
|
||||
/// {
|
||||
/// // move left...
|
||||
/// }
|
||||
/// else if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Right))
|
||||
/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
|
||||
/// {
|
||||
/// // move right...
|
||||
/// }
|
||||
/// else if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Escape))
|
||||
/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
|
||||
/// {
|
||||
/// // quit...
|
||||
/// }
|
||||
|
|
|
@ -67,7 +67,7 @@ public :
|
|||
/// \return True if the button is pressed, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsButtonPressed(Button button);
|
||||
static bool isButtonPressed(Button button);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current position of the mouse in desktop coordinates
|
||||
|
@ -78,7 +78,7 @@ public :
|
|||
/// \return Current position of the mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Vector2i GetPosition();
|
||||
static Vector2i getPosition();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current position of the mouse in window coordinates
|
||||
|
@ -91,7 +91,7 @@ public :
|
|||
/// \return Current position of the mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Vector2i GetPosition(const Window& relativeTo);
|
||||
static Vector2i getPosition(const Window& relativeTo);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the current position of the mouse in desktop coordinates
|
||||
|
@ -102,7 +102,7 @@ public :
|
|||
/// \param position New position of the mouse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetPosition(const Vector2i& position);
|
||||
static void setPosition(const Vector2i& position);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the current position of the mouse in window coordinates
|
||||
|
@ -114,7 +114,7 @@ public :
|
|||
/// \param relativeTo Reference window
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void SetPosition(const Vector2i& position, const Window& relativeTo);
|
||||
static void setPosition(const Vector2i& position, const Window& relativeTo);
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -150,16 +150,16 @@ public :
|
|||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// if (sf::Mouse::IsButtonPressed(sf::Mouse::Left))
|
||||
/// if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
|
||||
/// {
|
||||
/// // left click...
|
||||
/// }
|
||||
///
|
||||
/// // get global mouse position
|
||||
/// sf::Vector2i position = sf::Mouse::GetPosition();
|
||||
/// sf::Vector2i position = sf::Mouse::getPosition();
|
||||
///
|
||||
/// // set mouse position relative to a window
|
||||
/// sf::Mouse::SetPosition(sf::Vector2i(100, 200), window);
|
||||
/// sf::Mouse::setPosition(sf::Vector2i(100, 200), window);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Joystick, sf::Keyboard
|
||||
|
|
|
@ -66,7 +66,7 @@ public :
|
|||
/// \return Current desktop video mode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static VideoMode GetDesktopMode();
|
||||
static VideoMode getDesktopMode();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Retrieve all the video modes supported in fullscreen mode
|
||||
|
@ -82,7 +82,7 @@ public :
|
|||
/// \return Array containing all the supported fullscreen modes
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static const std::vector<VideoMode>& GetFullscreenModes();
|
||||
static const std::vector<VideoMode>& getFullscreenModes();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether or not the video mode is valid
|
||||
|
@ -94,14 +94,14 @@ public :
|
|||
/// \return True if the video mode is valid for fullscreen mode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsValid() const;
|
||||
bool isValid() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Width; ///< Video mode width, in pixels
|
||||
unsigned int Height; ///< Video mode height, in pixels
|
||||
unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels
|
||||
unsigned int width; ///< Video mode width, in pixels
|
||||
unsigned int height; ///< Video mode height, in pixels
|
||||
unsigned int bitsPerPixel; ///< Video mode pixel depth, in bits per pixels
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -198,31 +198,31 @@ SFML_WINDOW_API bool operator >=(const VideoMode& left, const VideoMode& right);
|
|||
///
|
||||
/// sf::VideoMode provides a static function for retrieving
|
||||
/// the list of all the video modes supported by the system:
|
||||
/// GetFullscreenModes().
|
||||
/// getFullscreenModes().
|
||||
///
|
||||
/// A custom video mode can also be checked directly for
|
||||
/// fullscreen compatibility with its IsValid() function.
|
||||
///
|
||||
/// Additionnally, sf::VideoMode provides a static function
|
||||
/// to get the mode currently used by the desktop: GetDesktopMode().
|
||||
/// to get the mode currently used by the desktop: getDesktopMode().
|
||||
/// This allows to build windows with the same size or pixel
|
||||
/// depth as the current resolution.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// // Display the list of all the video modes available for fullscreen
|
||||
/// std::vector<sf::VideoMode> modes = sf::VideoMode::GetFullscreenModes();
|
||||
/// std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
|
||||
/// for (std::size_t i = 0; i < modes.size(); ++i)
|
||||
/// {
|
||||
/// sf::VideoMode mode = modes[i];
|
||||
/// std::cout << "Mode #" << i << ": "
|
||||
/// << mode.Width << "x" << mode.Height << " - "
|
||||
/// << mode.BitsPerPixel << " bpp" << std::endl;
|
||||
/// << mode.width << "x" << mode.height << " - "
|
||||
/// << mode.bitsPerPixel << " bpp" << std::endl;
|
||||
/// }
|
||||
///
|
||||
/// // Create a window with the same pixel depth as the desktop
|
||||
/// sf::VideoMode desktop = sf::VideoMode::GetDesktopMode();
|
||||
/// window.Create(sf::VideoMode(1024, 768, desktop.BitsPerPixel), "SFML window");
|
||||
/// sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||
/// window.create(sf::VideoMode(1024, 768, desktop.bitsPerPixel), "SFML window");
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -62,7 +62,7 @@ public :
|
|||
/// \brief Default constructor
|
||||
///
|
||||
/// This constructor doesn't actually create the window,
|
||||
/// use the other constructors or call Create to do so.
|
||||
/// use the other constructors or call create to do so.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Window();
|
||||
|
@ -125,7 +125,7 @@ public :
|
|||
/// \param settings Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(VideoMode mode, const std::string& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
|
||||
void create(VideoMode mode, const std::string& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create (or recreate) the window from an existing control
|
||||
|
@ -138,44 +138,44 @@ public :
|
|||
/// \param settings Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(WindowHandle handle, const ContextSettings& settings = ContextSettings());
|
||||
void create(WindowHandle handle, const ContextSettings& settings = ContextSettings());
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the window and destroy all the attached resources
|
||||
///
|
||||
/// After calling this function, the sf::Window instance remains
|
||||
/// valid and you can call Create() to recreate the window.
|
||||
/// All other functions such as PollEvent() or Display() will
|
||||
/// still work (i.e. you don't have to test IsOpen() every time),
|
||||
/// valid and you can call create() to recreate the window.
|
||||
/// All other functions such as pollEvent() or display() will
|
||||
/// still work (i.e. you don't have to test isOpen() every time),
|
||||
/// and will have no effect on closed windows.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Close();
|
||||
void close();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether or not the window is open
|
||||
///
|
||||
/// This function returns whether or not the window exists.
|
||||
/// Note that a hidden window (SetVisible(false)) is open
|
||||
/// Note that a hidden window (setVisible(false)) is open
|
||||
/// (therefore this function would return true).
|
||||
///
|
||||
/// \return True if the window is open, false if it has been closed
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsOpen() const;
|
||||
bool isOpen() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the settings of the OpenGL context of the window
|
||||
///
|
||||
/// Note that these settings may be different from what was
|
||||
/// passed to the constructor or the Create() function,
|
||||
/// passed to the constructor or the create() function,
|
||||
/// if one or more settings were not supported. In this case,
|
||||
/// SFML chose the closest match.
|
||||
///
|
||||
/// \return Structure containing the OpenGL context settings
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const ContextSettings& GetSettings() const;
|
||||
const ContextSettings& getSettings() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Pop the event on top of events stack, if any, and return it
|
||||
|
@ -187,7 +187,7 @@ public :
|
|||
/// to make sure that you process every pending event.
|
||||
/// \code
|
||||
/// sf::Event event;
|
||||
/// while (window.PollEvent(event))
|
||||
/// while (window.pollEvent(event))
|
||||
/// {
|
||||
/// // process event...
|
||||
/// }
|
||||
|
@ -197,10 +197,10 @@ public :
|
|||
///
|
||||
/// \return True if an event was returned, or false if the events stack was empty
|
||||
///
|
||||
/// \see WaitEvent
|
||||
/// \see waitEvent
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool PollEvent(Event& event);
|
||||
bool pollEvent(Event& event);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Wait for an event and return it
|
||||
|
@ -214,7 +214,7 @@ public :
|
|||
/// sleep as long as no new event is received.
|
||||
/// \code
|
||||
/// sf::Event event;
|
||||
/// if (window.WaitEvent(event))
|
||||
/// if (window.waitEvent(event))
|
||||
/// {
|
||||
/// // process event...
|
||||
/// }
|
||||
|
@ -224,20 +224,20 @@ public :
|
|||
///
|
||||
/// \return False if any error occured
|
||||
///
|
||||
/// \see PollEvent
|
||||
/// \see pollEvent
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool WaitEvent(Event& event);
|
||||
bool waitEvent(Event& event);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the position of the window
|
||||
///
|
||||
/// \return Position of the window, in pixels
|
||||
///
|
||||
/// \see SetPosition
|
||||
/// \see setPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2i GetPosition() const;
|
||||
Vector2i getPosition() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the position of the window on screen
|
||||
|
@ -248,10 +248,10 @@ public :
|
|||
///
|
||||
/// \param position New position, in pixels
|
||||
///
|
||||
/// \see GetPosition
|
||||
/// \see getPosition
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPosition(const Vector2i& position);
|
||||
void setPosition(const Vector2i& position);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the rendering region of the window
|
||||
|
@ -261,30 +261,30 @@ public :
|
|||
///
|
||||
/// \return Size in pixels
|
||||
///
|
||||
/// \see SetSize
|
||||
/// \see setSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2u GetSize() const;
|
||||
Vector2u getSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the size of the rendering region of the window
|
||||
///
|
||||
/// \param size New size, in pixels
|
||||
///
|
||||
/// \see GetSize
|
||||
/// \see getSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSize(const Vector2u size);
|
||||
void setSize(const Vector2u size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the title of the window
|
||||
///
|
||||
/// \param title New title
|
||||
///
|
||||
/// \see SetIcon
|
||||
/// \see setIcon
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetTitle(const std::string& title);
|
||||
void setTitle(const std::string& title);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the window's icon
|
||||
|
@ -298,10 +298,10 @@ public :
|
|||
/// \param height Icon's height, in pixels
|
||||
/// \param pixels Pointer to the array of pixels in memory
|
||||
///
|
||||
/// \see SetTitle
|
||||
/// \see setTitle
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels);
|
||||
void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Show or hide the window
|
||||
|
@ -311,7 +311,7 @@ public :
|
|||
/// \param visible True to show the window, false to hide it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetVisible(bool visible);
|
||||
void setVisible(bool visible);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable vertical synchronization
|
||||
|
@ -326,7 +326,7 @@ public :
|
|||
/// \param enabled True to enable v-sync, false to deactivate it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetVerticalSyncEnabled(bool enabled);
|
||||
void setVerticalSyncEnabled(bool enabled);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Show or hide the mouse cursor
|
||||
|
@ -336,7 +336,7 @@ public :
|
|||
/// \param visible True to show the mouse cursor, false to hide it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetMouseCursorVisible(bool visible);
|
||||
void setMouseCursorVisible(bool visible);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable automatic key-repeat
|
||||
|
@ -350,16 +350,16 @@ public :
|
|||
/// \param enabled True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetKeyRepeatEnabled(bool enabled);
|
||||
void setKeyRepeatEnabled(bool enabled);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Limit the framerate to a maximum fixed frequency
|
||||
///
|
||||
/// If a limit is set, the window will use a small delay after
|
||||
/// each call to Display() to ensure that the current frame
|
||||
/// each call to display() to ensure that the current frame
|
||||
/// lasted long enough to match the framerate limit.
|
||||
/// SFML will try to match the given limit as much as it can,
|
||||
/// but since it internally uses sf::Sleep, whose precision
|
||||
/// but since it internally uses sf::sleep, whose precision
|
||||
/// depends on the underlying OS, the results may be a little
|
||||
/// unprecise as well (for example, you can get 65 FPS when
|
||||
/// requesting 60).
|
||||
|
@ -367,20 +367,20 @@ public :
|
|||
/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetFramerateLimit(unsigned int limit);
|
||||
void setFramerateLimit(unsigned int limit);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the joystick threshold
|
||||
///
|
||||
/// The joystick threshold is the value below which
|
||||
/// no JoyMoved event will be generated.
|
||||
/// no JoystickMoved event will be generated.
|
||||
///
|
||||
/// The threshold value is 0.1 by default.
|
||||
///
|
||||
/// \param threshold New threshold, in the range [0, 100]
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetJoystickThreshold(float threshold);
|
||||
void setJoystickThreshold(float threshold);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Activate or deactivate the window as the current target
|
||||
|
@ -397,7 +397,7 @@ public :
|
|||
/// \return True if operation was successful, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SetActive(bool active = true) const;
|
||||
bool setActive(bool active = true) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Display on screen what has been rendered to the window so far
|
||||
|
@ -407,7 +407,7 @@ public :
|
|||
/// it on screen.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Display();
|
||||
void display();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the OS-specific handle of the window
|
||||
|
@ -421,7 +421,7 @@ public :
|
|||
/// \return System handle of the window
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
WindowHandle GetSystemHandle() const;
|
||||
WindowHandle getSystemHandle() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -433,7 +433,7 @@ private :
|
|||
/// the window is created.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnCreate();
|
||||
virtual void onCreate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Function called after the window has been resized
|
||||
|
@ -442,13 +442,13 @@ private :
|
|||
/// perform custom actions when the size of the window changes.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnResize();
|
||||
virtual void onResize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Processes an event before it is sent to the user
|
||||
///
|
||||
/// This function is called every time an event is received
|
||||
/// from the internal window (through PollEvent or WaitEvent).
|
||||
/// from the internal window (through pollEvent or waitEvent).
|
||||
/// It filters out unwanted events, and performs whatever internal
|
||||
/// stuff the window needs before the event is returned to the
|
||||
/// user.
|
||||
|
@ -456,13 +456,13 @@ private :
|
|||
/// \param event Event to filter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool FilterEvent(const Event& event);
|
||||
bool filterEvent(const Event& event);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform some common internal initializations
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize();
|
||||
void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -487,7 +487,7 @@ private :
|
|||
/// an OS window that is able to receive an OpenGL rendering.
|
||||
///
|
||||
/// A sf::Window can create its own new window, or be embedded into
|
||||
/// an already existing control using the Create(handle) function.
|
||||
/// an already existing control using the create(handle) function.
|
||||
/// This can be useful for embedding an OpenGL rendering area into
|
||||
/// a view which is part of a bigger GUI with existing windows,
|
||||
/// controls, etc. It can also serve as embedding an OpenGL rendering
|
||||
|
@ -496,7 +496,7 @@ private :
|
|||
///
|
||||
/// The sf::Window class provides a simple interface for manipulating
|
||||
/// the window: move, resize, show/hide, control mouse cursor, etc.
|
||||
/// It also provides event handling through its PollEvent() and WaitEvent()
|
||||
/// It also provides event handling through its pollEvent() and waitEvent()
|
||||
/// functions.
|
||||
///
|
||||
/// Note that OpenGL experts can pass their own parameters (antialiasing
|
||||
|
@ -511,27 +511,27 @@ private :
|
|||
/// sf::Window window(sf::VideoMode(800, 600), "SFML window");
|
||||
///
|
||||
/// // Limit the framerate to 60 frames per second (this step is optional)
|
||||
/// window.SetFramerateLimit(60);
|
||||
/// window.setFramerateLimit(60);
|
||||
///
|
||||
/// // The main loop - ends as soon as the window is closed
|
||||
/// while (window.IsOpen())
|
||||
/// while (window.isOpen())
|
||||
/// {
|
||||
/// // Event processing
|
||||
/// sf::Event event;
|
||||
/// while (window.PollEvent(event))
|
||||
/// while (window.pollEvent(event))
|
||||
/// {
|
||||
/// // Request for closing the window
|
||||
/// if (event.Type == sf::Event::Closed)
|
||||
/// window.Close();
|
||||
/// if (event.type == sf::Event::Closed)
|
||||
/// window.close();
|
||||
/// }
|
||||
///
|
||||
/// // Activate the window for OpenGL rendering
|
||||
/// window.SetActive();
|
||||
/// window.setActive();
|
||||
///
|
||||
/// // OpenGL drawing commands go here...
|
||||
///
|
||||
/// // End the current frame and display its contents on screen
|
||||
/// window.Display();
|
||||
/// window.display();
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
#include <SFML/Audio/AudioDevice.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void ALCheckError(const std::string& file, unsigned int line)
|
||||
void alCheckError(const std::string& file, unsigned int line)
|
||||
{
|
||||
// Get the last error
|
||||
ALenum errorCode = alGetError();
|
||||
|
@ -84,7 +84,7 @@ void ALCheckError(const std::string& file, unsigned int line)
|
|||
}
|
||||
|
||||
// Log the error
|
||||
Err() << "An internal OpenAL call failed in "
|
||||
err() << "An internal OpenAL call failed in "
|
||||
<< file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : "
|
||||
<< error << ", " << description
|
||||
<< std::endl;
|
||||
|
@ -95,7 +95,7 @@ void ALCheckError(const std::string& file, unsigned int line)
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Make sure that OpenAL is initialized
|
||||
////////////////////////////////////////////////////////////
|
||||
void EnsureALInit()
|
||||
void ensureALInit()
|
||||
{
|
||||
// The audio device is instanciated on demand rather than at global startup,
|
||||
// which solves a lot of weird crashes and errors.
|
||||
|
|
|
@ -40,18 +40,17 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Let's define a macro to quickly check every OpenAL
|
||||
/// API calls
|
||||
/// Let's define a macro to quickly check every OpenAL API calls
|
||||
////////////////////////////////////////////////////////////
|
||||
#ifdef SFML_DEBUG
|
||||
|
||||
// If in debug mode, perform a test on every call
|
||||
#define ALCheck(Func) ((Func), priv::ALCheckError(__FILE__, __LINE__))
|
||||
#define alCheck(Func) ((Func), priv::alCheckError(__FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
|
||||
// Else, we don't add any overhead
|
||||
#define ALCheck(Func) (Func)
|
||||
#define alCheck(Func) (Func)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -63,13 +62,13 @@ namespace priv
|
|||
/// \param line Line number of the source file where the call is located
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void ALCheckError(const std::string& file, unsigned int line);
|
||||
void alCheckError(const std::string& file, unsigned int line);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make sure that OpenAL is initialized
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void EnsureALInit();
|
||||
void ensureALInit();
|
||||
|
||||
} // namespace priv
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/AudioDevice.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
#include <SFML/Audio/Listener.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
@ -59,12 +59,12 @@ AudioDevice::AudioDevice()
|
|||
}
|
||||
else
|
||||
{
|
||||
Err() << "Failed to create the audio context" << std::endl;
|
||||
err() << "Failed to create the audio context" << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Err() << "Failed to open the audio device" << std::endl;
|
||||
err() << "Failed to open the audio device" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ AudioDevice::~AudioDevice()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool AudioDevice::IsExtensionSupported(const std::string& extension)
|
||||
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
||||
{
|
||||
EnsureALInit();
|
||||
ensureALInit();
|
||||
|
||||
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
||||
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
||||
|
@ -96,9 +96,9 @@ bool AudioDevice::IsExtensionSupported(const std::string& extension)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int AudioDevice::GetFormatFromChannelCount(unsigned int channelCount)
|
||||
int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||
{
|
||||
EnsureALInit();
|
||||
ensureALInit();
|
||||
|
||||
// Find the good format according to the number of channels
|
||||
switch (channelCount)
|
||||
|
|
|
@ -70,7 +70,7 @@ public :
|
|||
/// \return True if the extension is supported, false if not
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool IsExtensionSupported(const std::string& extension);
|
||||
static bool isExtensionSupported(const std::string& extension);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the OpenAL format that matches the given number of channels
|
||||
|
@ -80,7 +80,7 @@ public :
|
|||
/// \return Corresponding format
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static int GetFormatFromChannelCount(unsigned int channelCount);
|
||||
static int getFormatFromChannelCount(unsigned int channelCount);
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
|
|
@ -26,84 +26,84 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/Listener.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void Listener::SetGlobalVolume(float volume)
|
||||
void Listener::setGlobalVolume(float volume)
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
ALCheck(alListenerf(AL_GAIN, volume * 0.01f));
|
||||
alCheck(alListenerf(AL_GAIN, volume * 0.01f));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float Listener::GetGlobalVolume()
|
||||
float Listener::getGlobalVolume()
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
float volume = 0.f;
|
||||
ALCheck(alGetListenerf(AL_GAIN, &volume));
|
||||
alCheck(alGetListenerf(AL_GAIN, &volume));
|
||||
|
||||
return volume * 100;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Listener::SetPosition(float x, float y, float z)
|
||||
void Listener::setPosition(float x, float y, float z)
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
ALCheck(alListener3f(AL_POSITION, x, y, z));
|
||||
alCheck(alListener3f(AL_POSITION, x, y, z));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Listener::SetPosition(const Vector3f& position)
|
||||
void Listener::setPosition(const Vector3f& position)
|
||||
{
|
||||
SetPosition(position.x, position.y, position.z);
|
||||
setPosition(position.x, position.y, position.z);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f Listener::GetPosition()
|
||||
Vector3f Listener::getPosition()
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
Vector3f position;
|
||||
ALCheck(alGetListener3f(AL_POSITION, &position.x, &position.y, &position.z));
|
||||
alCheck(alGetListener3f(AL_POSITION, &position.x, &position.y, &position.z));
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Listener::SetDirection(float x, float y, float z)
|
||||
void Listener::setDirection(float x, float y, float z)
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
float orientation[] = {x, y, z, 0.f, 1.f, 0.f};
|
||||
ALCheck(alListenerfv(AL_ORIENTATION, orientation));
|
||||
alCheck(alListenerfv(AL_ORIENTATION, orientation));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Listener::SetDirection(const Vector3f& direction)
|
||||
void Listener::setDirection(const Vector3f& direction)
|
||||
{
|
||||
SetDirection(direction.x, direction.y, direction.z);
|
||||
setDirection(direction.x, direction.y, direction.z);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f Listener::GetDirection()
|
||||
Vector3f Listener::getDirection()
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
float orientation[6];
|
||||
ALCheck(alGetListenerfv(AL_ORIENTATION, orientation));
|
||||
alCheck(alGetListenerfv(AL_ORIENTATION, orientation));
|
||||
|
||||
return Vector3f(orientation[0], orientation[1], orientation[2]);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/Music.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
#include <SFML/Audio/SoundFile.hpp>
|
||||
#include <SFML/System/Lock.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
@ -48,104 +48,104 @@ m_duration()
|
|||
Music::~Music()
|
||||
{
|
||||
// We must stop before destroying the file :)
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
delete m_file;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OpenFromFile(const std::string& filename)
|
||||
bool Music::openFromFile(const std::string& filename)
|
||||
{
|
||||
// First stop the music if it was already running
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
// Open the underlying sound file
|
||||
if (!m_file->OpenRead(filename))
|
||||
if (!m_file->openRead(filename))
|
||||
return false;
|
||||
|
||||
// Perform common initializations
|
||||
Initialize();
|
||||
initialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
bool Music::openFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
{
|
||||
// First stop the music if it was already running
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
// Open the underlying sound file
|
||||
if (!m_file->OpenRead(data, sizeInBytes))
|
||||
if (!m_file->openRead(data, sizeInBytes))
|
||||
return false;
|
||||
|
||||
// Perform common initializations
|
||||
Initialize();
|
||||
initialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OpenFromStream(InputStream& stream)
|
||||
bool Music::openFromStream(InputStream& stream)
|
||||
{
|
||||
// First stop the music if it was already running
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
// Open the underlying sound file
|
||||
if (!m_file->OpenRead(stream))
|
||||
if (!m_file->openRead(stream))
|
||||
return false;
|
||||
|
||||
// Perform common initializations
|
||||
Initialize();
|
||||
initialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Time Music::GetDuration() const
|
||||
Time Music::getDuration() const
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Music::OnGetData(SoundStream::Chunk& data)
|
||||
bool Music::onGetData(SoundStream::Chunk& data)
|
||||
{
|
||||
Lock lock(m_mutex);
|
||||
|
||||
// Fill the chunk parameters
|
||||
data.Samples = &m_samples[0];
|
||||
data.SampleCount = m_file->Read(&m_samples[0], m_samples.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 == m_samples.size();
|
||||
return data.sampleCount == m_samples.size();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Music::OnSeek(Time timeOffset)
|
||||
void Music::onSeek(Time timeOffset)
|
||||
{
|
||||
Lock lock(m_mutex);
|
||||
|
||||
m_file->Seek(timeOffset);
|
||||
m_file->seek(timeOffset);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Music::Initialize()
|
||||
void Music::initialize()
|
||||
{
|
||||
// Compute the music duration
|
||||
m_duration = Seconds(static_cast<float>(m_file->GetSampleCount()) / m_file->GetSampleRate() / m_file->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
|
||||
m_samples.resize(m_file->GetSampleRate() * m_file->GetChannelCount());
|
||||
m_samples.resize(m_file->getSampleRate() * m_file->getChannelCount());
|
||||
|
||||
// Initialize the stream
|
||||
SoundStream::Initialize(m_file->GetChannelCount(), m_file->GetSampleRate());
|
||||
SoundStream::initialize(m_file->getChannelCount(), m_file->getSampleRate());
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/Sound.hpp>
|
||||
#include <SFML/Audio/SoundBuffer.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -43,7 +43,7 @@ m_buffer(NULL)
|
|||
Sound::Sound(const SoundBuffer& buffer) :
|
||||
m_buffer(NULL)
|
||||
{
|
||||
SetBuffer(buffer);
|
||||
setBuffer(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,103 +53,103 @@ SoundSource(copy),
|
|||
m_buffer (NULL)
|
||||
{
|
||||
if (copy.m_buffer)
|
||||
SetBuffer(*copy.m_buffer);
|
||||
SetLoop(copy.GetLoop());
|
||||
setBuffer(*copy.m_buffer);
|
||||
setLoop(copy.getLoop());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::~Sound()
|
||||
{
|
||||
Stop();
|
||||
stop();
|
||||
if (m_buffer)
|
||||
m_buffer->DetachSound(this);
|
||||
m_buffer->detachSound(this);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::Play()
|
||||
void Sound::play()
|
||||
{
|
||||
ALCheck(alSourcePlay(m_source));
|
||||
alCheck(alSourcePlay(m_source));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::Pause()
|
||||
void Sound::pause()
|
||||
{
|
||||
ALCheck(alSourcePause(m_source));
|
||||
alCheck(alSourcePause(m_source));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::Stop()
|
||||
void Sound::stop()
|
||||
{
|
||||
ALCheck(alSourceStop(m_source));
|
||||
alCheck(alSourceStop(m_source));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetBuffer(const SoundBuffer& buffer)
|
||||
void Sound::setBuffer(const SoundBuffer& buffer)
|
||||
{
|
||||
// First detach from the previous buffer
|
||||
if (m_buffer)
|
||||
{
|
||||
Stop();
|
||||
m_buffer->DetachSound(this);
|
||||
stop();
|
||||
m_buffer->detachSound(this);
|
||||
}
|
||||
|
||||
// Assign and use the new buffer
|
||||
m_buffer = &buffer;
|
||||
m_buffer->AttachSound(this);
|
||||
ALCheck(alSourcei(m_source, AL_BUFFER, m_buffer->m_buffer));
|
||||
m_buffer->attachSound(this);
|
||||
alCheck(alSourcei(m_source, AL_BUFFER, m_buffer->m_buffer));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetLoop(bool Loop)
|
||||
void Sound::setLoop(bool Loop)
|
||||
{
|
||||
ALCheck(alSourcei(m_source, AL_LOOPING, Loop));
|
||||
alCheck(alSourcei(m_source, AL_LOOPING, Loop));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::SetPlayingOffset(Time timeOffset)
|
||||
void Sound::setPlayingOffset(Time timeOffset)
|
||||
{
|
||||
ALCheck(alSourcef(m_source, AL_SEC_OFFSET, timeOffset.AsSeconds()));
|
||||
alCheck(alSourcef(m_source, AL_SEC_OFFSET, timeOffset.asSeconds()));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const SoundBuffer* Sound::GetBuffer() const
|
||||
const SoundBuffer* Sound::getBuffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Sound::GetLoop() const
|
||||
bool Sound::getLoop() const
|
||||
{
|
||||
ALint loop;
|
||||
ALCheck(alGetSourcei(m_source, AL_LOOPING, &loop));
|
||||
alCheck(alGetSourcei(m_source, AL_LOOPING, &loop));
|
||||
|
||||
return loop != 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Time Sound::GetPlayingOffset() const
|
||||
Time Sound::getPlayingOffset() const
|
||||
{
|
||||
ALfloat seconds = 0.f;
|
||||
ALCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &seconds));
|
||||
ALfloat secs = 0.f;
|
||||
alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
|
||||
|
||||
return Seconds(seconds);
|
||||
return seconds(secs);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound::Status Sound::GetStatus() const
|
||||
Sound::Status Sound::getStatus() const
|
||||
{
|
||||
return SoundSource::GetStatus();
|
||||
return SoundSource::getStatus();
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,34 +162,34 @@ Sound& Sound::operator =(const Sound& right)
|
|||
// Detach the sound instance from the previous buffer (if any)
|
||||
if (m_buffer)
|
||||
{
|
||||
Stop();
|
||||
m_buffer->DetachSound(this);
|
||||
stop();
|
||||
m_buffer->detachSound(this);
|
||||
m_buffer = NULL;
|
||||
}
|
||||
|
||||
// Copy the sound attributes
|
||||
if (right.m_buffer)
|
||||
SetBuffer(*right.m_buffer);
|
||||
SetLoop(right.GetLoop());
|
||||
SetPitch(right.GetPitch());
|
||||
SetVolume(right.GetVolume());
|
||||
SetPosition(right.GetPosition());
|
||||
SetRelativeToListener(right.IsRelativeToListener());
|
||||
SetMinDistance(right.GetMinDistance());
|
||||
SetAttenuation(right.GetAttenuation());
|
||||
setBuffer(*right.m_buffer);
|
||||
setLoop(right.getLoop());
|
||||
setPitch(right.getPitch());
|
||||
setVolume(right.getVolume());
|
||||
setPosition(right.getPosition());
|
||||
setRelativeToListener(right.isRelativeToListener());
|
||||
setMinDistance(right.getMinDistance());
|
||||
setAttenuation(right.getAttenuation());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sound::ResetBuffer()
|
||||
void Sound::resetBuffer()
|
||||
{
|
||||
// First stop the sound in case it is playing
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
// Detach the buffer
|
||||
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
alCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
m_buffer = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <SFML/Audio/SoundFile.hpp>
|
||||
#include <SFML/Audio/Sound.hpp>
|
||||
#include <SFML/Audio/AudioDevice.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
@ -41,10 +41,10 @@ SoundBuffer::SoundBuffer() :
|
|||
m_buffer (0),
|
||||
m_duration()
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
// Create the buffer
|
||||
ALCheck(alGenBuffers(1, &m_buffer));
|
||||
alCheck(alGenBuffers(1, &m_buffer));
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,10 +56,10 @@ m_duration(copy.m_duration),
|
|||
m_sounds () // don't copy the attached sounds
|
||||
{
|
||||
// Create the buffer
|
||||
ALCheck(alGenBuffers(1, &m_buffer));
|
||||
alCheck(alGenBuffers(1, &m_buffer));
|
||||
|
||||
// Update the internal buffer with the new samples
|
||||
Update(copy.GetChannelCount(), copy.GetSampleRate());
|
||||
update(copy.getChannelCount(), copy.getSampleRate());
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,49 +68,49 @@ SoundBuffer::~SoundBuffer()
|
|||
{
|
||||
// First detach the buffer from the sounds that use it (to avoid OpenAL errors)
|
||||
for (SoundList::const_iterator it = m_sounds.begin(); it != m_sounds.end(); ++it)
|
||||
(*it)->ResetBuffer();
|
||||
(*it)->resetBuffer();
|
||||
|
||||
// Destroy the buffer
|
||||
if (m_buffer)
|
||||
ALCheck(alDeleteBuffers(1, &m_buffer));
|
||||
alCheck(alDeleteBuffers(1, &m_buffer));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromFile(const std::string& filename)
|
||||
bool SoundBuffer::loadFromFile(const std::string& filename)
|
||||
{
|
||||
priv::SoundFile file;
|
||||
if (file.OpenRead(filename))
|
||||
return Initialize(file);
|
||||
if (file.openRead(filename))
|
||||
return initialize(file);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
bool SoundBuffer::loadFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
{
|
||||
priv::SoundFile file;
|
||||
if (file.OpenRead(data, sizeInBytes))
|
||||
return Initialize(file);
|
||||
if (file.openRead(data, sizeInBytes))
|
||||
return initialize(file);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromStream(InputStream& stream)
|
||||
bool SoundBuffer::loadFromStream(InputStream& stream)
|
||||
{
|
||||
priv::SoundFile file;
|
||||
if (file.OpenRead(stream))
|
||||
return Initialize(file);
|
||||
if (file.openRead(stream))
|
||||
return initialize(file);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
|
||||
bool SoundBuffer::loadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
if (samples && sampleCount && channelCount && sampleRate)
|
||||
{
|
||||
|
@ -118,12 +118,12 @@ bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t sampleCount,
|
|||
m_samples.assign(samples, samples + sampleCount);
|
||||
|
||||
// Update the internal buffer with the new samples
|
||||
return Update(channelCount, sampleRate);
|
||||
return update(channelCount, sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error...
|
||||
Err() << "Failed to load sound buffer from samples ("
|
||||
err() << "Failed to load sound buffer from samples ("
|
||||
<< "array: " << samples << ", "
|
||||
<< "count: " << sampleCount << ", "
|
||||
<< "channels: " << channelCount << ", "
|
||||
|
@ -136,14 +136,14 @@ bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t sampleCount,
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::SaveToFile(const std::string& filename) const
|
||||
bool SoundBuffer::saveToFile(const std::string& filename) const
|
||||
{
|
||||
// Create the sound file in write mode
|
||||
priv::SoundFile file;
|
||||
if (file.OpenWrite(filename, GetChannelCount(), GetSampleRate()))
|
||||
if (file.openWrite(filename, getChannelCount(), getSampleRate()))
|
||||
{
|
||||
// Write the samples to the opened file
|
||||
file.Write(&m_samples[0], m_samples.size());
|
||||
file.write(&m_samples[0], m_samples.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -155,41 +155,41 @@ bool SoundBuffer::SaveToFile(const std::string& filename) const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Int16* SoundBuffer::GetSamples() const
|
||||
const Int16* SoundBuffer::getSamples() const
|
||||
{
|
||||
return m_samples.empty() ? NULL : &m_samples[0];
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t SoundBuffer::GetSampleCount() const
|
||||
std::size_t SoundBuffer::getSampleCount() const
|
||||
{
|
||||
return m_samples.size();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundBuffer::GetSampleRate() const
|
||||
unsigned int SoundBuffer::getSampleRate() const
|
||||
{
|
||||
ALint sampleRate;
|
||||
ALCheck(alGetBufferi(m_buffer, AL_FREQUENCY, &sampleRate));
|
||||
alCheck(alGetBufferi(m_buffer, AL_FREQUENCY, &sampleRate));
|
||||
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundBuffer::GetChannelCount() const
|
||||
unsigned int SoundBuffer::getChannelCount() const
|
||||
{
|
||||
ALint channelCount;
|
||||
ALCheck(alGetBufferi(m_buffer, AL_CHANNELS, &channelCount));
|
||||
alCheck(alGetBufferi(m_buffer, AL_CHANNELS, &channelCount));
|
||||
|
||||
return channelCount;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Time SoundBuffer::GetDuration() const
|
||||
Time SoundBuffer::getDuration() const
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
|
@ -210,19 +210,19 @@ SoundBuffer& SoundBuffer::operator =(const SoundBuffer& right)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::Initialize(priv::SoundFile& file)
|
||||
bool SoundBuffer::initialize(priv::SoundFile& file)
|
||||
{
|
||||
// Retrieve the sound parameters
|
||||
std::size_t sampleCount = file.GetSampleCount();
|
||||
unsigned int channelCount = file.GetChannelCount();
|
||||
unsigned int sampleRate = file.GetSampleRate();
|
||||
std::size_t sampleCount = file.getSampleCount();
|
||||
unsigned int channelCount = file.getChannelCount();
|
||||
unsigned int sampleRate = file.getSampleRate();
|
||||
|
||||
// Read the samples from the provided file
|
||||
m_samples.resize(sampleCount);
|
||||
if (file.Read(&m_samples[0], sampleCount) == sampleCount)
|
||||
if (file.read(&m_samples[0], sampleCount) == sampleCount)
|
||||
{
|
||||
// Update the internal buffer with the new samples
|
||||
return Update(channelCount, sampleRate);
|
||||
return update(channelCount, sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -232,42 +232,42 @@ bool SoundBuffer::Initialize(priv::SoundFile& file)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::Update(unsigned int channelCount, unsigned int sampleRate)
|
||||
bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
// Check parameters
|
||||
if (!channelCount || !sampleRate || m_samples.empty())
|
||||
return false;
|
||||
|
||||
// Find the good format according to the number of channels
|
||||
ALenum format = priv::AudioDevice::GetFormatFromChannelCount(channelCount);
|
||||
ALenum format = priv::AudioDevice::getFormatFromChannelCount(channelCount);
|
||||
|
||||
// Check if the format is valid
|
||||
if (format == 0)
|
||||
{
|
||||
Err() << "Failed to load sound buffer (unsupported number of channels: " << channelCount << ")" << std::endl;
|
||||
err() << "Failed to load sound buffer (unsupported number of channels: " << channelCount << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fill the buffer
|
||||
ALsizei size = static_cast<ALsizei>(m_samples.size()) * sizeof(Int16);
|
||||
ALCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate));
|
||||
alCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate));
|
||||
|
||||
// Compute the duration
|
||||
m_duration = Milliseconds(1000 * m_samples.size() / sampleRate / channelCount);
|
||||
m_duration = milliseconds(1000 * m_samples.size() / sampleRate / channelCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundBuffer::AttachSound(Sound* sound) const
|
||||
void SoundBuffer::attachSound(Sound* sound) const
|
||||
{
|
||||
m_sounds.insert(sound);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundBuffer::DetachSound(Sound* sound) const
|
||||
void SoundBuffer::detachSound(Sound* sound) const
|
||||
{
|
||||
m_sounds.erase(sound);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBufferRecorder::OnStart()
|
||||
bool SoundBufferRecorder::onStart()
|
||||
{
|
||||
m_samples.clear();
|
||||
m_buffer = SoundBuffer();
|
||||
|
@ -43,7 +43,7 @@ bool SoundBufferRecorder::OnStart()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBufferRecorder::OnProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
bool SoundBufferRecorder::onProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
{
|
||||
std::copy(samples, samples + sampleCount, std::back_inserter(m_samples));
|
||||
|
||||
|
@ -52,15 +52,15 @@ bool SoundBufferRecorder::OnProcessSamples(const Int16* samples, std::size_t sam
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundBufferRecorder::OnStop()
|
||||
void SoundBufferRecorder::onStop()
|
||||
{
|
||||
if (!m_samples.empty())
|
||||
m_buffer.LoadFromSamples(&m_samples[0], m_samples.size(), 1, GetSampleRate());
|
||||
m_buffer.loadFromSamples(&m_samples[0], m_samples.size(), 1, getSampleRate());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const SoundBuffer& SoundBufferRecorder::GetBuffer() const
|
||||
const SoundBuffer& SoundBufferRecorder::getBuffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
namespace
|
||||
{
|
||||
// Convert a string to lower case
|
||||
std::string ToLower(std::string str)
|
||||
std::string toLower(std::string str)
|
||||
{
|
||||
for (std::string::iterator i = str.begin(); i != str.end(); ++i)
|
||||
*i = static_cast<char>(std::tolower(*i));
|
||||
|
@ -68,28 +68,28 @@ SoundFile::~SoundFile()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t SoundFile::GetSampleCount() const
|
||||
std::size_t SoundFile::getSampleCount() const
|
||||
{
|
||||
return m_sampleCount;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundFile::GetChannelCount() const
|
||||
unsigned int SoundFile::getChannelCount() const
|
||||
{
|
||||
return m_channelCount;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundFile::GetSampleRate() const
|
||||
unsigned int SoundFile::getSampleRate() const
|
||||
{
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundFile::OpenRead(const std::string& filename)
|
||||
bool SoundFile::openRead(const std::string& filename)
|
||||
{
|
||||
// If the file is already opened, first close it
|
||||
if (m_file)
|
||||
|
@ -100,7 +100,7 @@ bool SoundFile::OpenRead(const std::string& filename)
|
|||
m_file = sf_open(filename.c_str(), SFM_READ, &fileInfos);
|
||||
if (!m_file)
|
||||
{
|
||||
Err() << "Failed to open sound file \"" << filename << "\" (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
err() << "Failed to open sound file \"" << filename << "\" (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ bool SoundFile::OpenRead(const std::string& filename)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
|
||||
bool SoundFile::openRead(const void* data, std::size_t sizeInBytes)
|
||||
{
|
||||
// If the file is already opened, first close it
|
||||
if (m_file)
|
||||
|
@ -122,10 +122,10 @@ bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
|
|||
|
||||
// Prepare the memory I/O structure
|
||||
SF_VIRTUAL_IO io;
|
||||
io.get_filelen = &Memory::GetLength;
|
||||
io.read = &Memory::Read;
|
||||
io.seek = &Memory::Seek;
|
||||
io.tell = &Memory::Tell;
|
||||
io.get_filelen = &Memory::getLength;
|
||||
io.read = &Memory::read;
|
||||
io.seek = &Memory::seek;
|
||||
io.tell = &Memory::tell;
|
||||
|
||||
// Initialize the memory data
|
||||
m_memory.DataStart = static_cast<const char*>(data);
|
||||
|
@ -137,7 +137,7 @@ bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
|
|||
m_file = sf_open_virtual(&io, SFM_READ, &fileInfos, &m_memory);
|
||||
if (!m_file)
|
||||
{
|
||||
Err() << "Failed to open sound file from memory (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
err() << "Failed to open sound file from memory (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundFile::OpenRead(InputStream& stream)
|
||||
bool SoundFile::openRead(InputStream& stream)
|
||||
{
|
||||
// If the file is already opened, first close it
|
||||
if (m_file)
|
||||
|
@ -159,17 +159,17 @@ bool SoundFile::OpenRead(InputStream& stream)
|
|||
|
||||
// Prepare the memory I/O structure
|
||||
SF_VIRTUAL_IO io;
|
||||
io.get_filelen = &Stream::GetLength;
|
||||
io.read = &Stream::Read;
|
||||
io.seek = &Stream::Seek;
|
||||
io.tell = &Stream::Tell;
|
||||
io.get_filelen = &Stream::getLength;
|
||||
io.read = &Stream::read;
|
||||
io.seek = &Stream::seek;
|
||||
io.tell = &Stream::tell;
|
||||
|
||||
// Open the sound file
|
||||
SF_INFO fileInfos;
|
||||
m_file = sf_open_virtual(&io, SFM_READ, &fileInfos, &stream);
|
||||
if (!m_file)
|
||||
{
|
||||
Err() << "Failed to open sound file from stream (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
err() << "Failed to open sound file from stream (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -183,18 +183,18 @@ bool SoundFile::OpenRead(InputStream& stream)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate)
|
||||
bool SoundFile::openWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
// If the file is already opened, first close it
|
||||
if (m_file)
|
||||
sf_close(m_file);
|
||||
|
||||
// Find the right format according to the file extension
|
||||
int format = GetFormatFromFilename(filename);
|
||||
int format = getFormatFromFilename(filename);
|
||||
if (format == -1)
|
||||
{
|
||||
// Error : unrecognized extension
|
||||
Err() << "Failed to create sound file \"" << filename << "\" (unknown format)" << std::endl;
|
||||
err() << "Failed to create sound file \"" << filename << "\" (unknown format)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount
|
|||
m_file = sf_open(filename.c_str(), SFM_WRITE, &fileInfos);
|
||||
if (!m_file)
|
||||
{
|
||||
Err() << "Failed to create sound file \"" << filename << "\" (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
err() << "Failed to create sound file \"" << filename << "\" (" << sf_strerror(m_file) << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t SoundFile::Read(Int16* data, std::size_t sampleCount)
|
||||
std::size_t SoundFile::read(Int16* data, std::size_t sampleCount)
|
||||
{
|
||||
if (m_file && data && sampleCount)
|
||||
return static_cast<std::size_t>(sf_read_short(m_file, data, sampleCount));
|
||||
|
@ -232,7 +232,7 @@ std::size_t SoundFile::Read(Int16* data, std::size_t sampleCount)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundFile::Write(const Int16* data, std::size_t sampleCount)
|
||||
void SoundFile::write(const Int16* data, std::size_t sampleCount)
|
||||
{
|
||||
if (m_file && data && sampleCount)
|
||||
{
|
||||
|
@ -250,18 +250,18 @@ void SoundFile::Write(const Int16* data, std::size_t sampleCount)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundFile::Seek(Time timeOffset)
|
||||
void SoundFile::seek(Time timeOffset)
|
||||
{
|
||||
if (m_file)
|
||||
{
|
||||
sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.AsSeconds() * m_sampleRate);
|
||||
sf_count_t frameOffset = static_cast<sf_count_t>(timeOffset.asSeconds() * m_sampleRate);
|
||||
sf_seek(m_file, frameOffset, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int SoundFile::GetFormatFromFilename(const std::string& filename)
|
||||
int SoundFile::getFormatFromFilename(const std::string& filename)
|
||||
{
|
||||
// Extract the extension
|
||||
std::string ext = "wav";
|
||||
|
@ -270,38 +270,38 @@ int SoundFile::GetFormatFromFilename(const std::string& filename)
|
|||
ext = filename.substr(pos + 1);
|
||||
|
||||
// Match every supported extension with its format constant
|
||||
if (ToLower(ext) == "wav" ) return SF_FORMAT_WAV;
|
||||
if (ToLower(ext) == "aif" ) return SF_FORMAT_AIFF;
|
||||
if (ToLower(ext) == "aiff" ) return SF_FORMAT_AIFF;
|
||||
if (ToLower(ext) == "au" ) return SF_FORMAT_AU;
|
||||
if (ToLower(ext) == "raw" ) return SF_FORMAT_RAW;
|
||||
if (ToLower(ext) == "paf" ) return SF_FORMAT_PAF;
|
||||
if (ToLower(ext) == "svx" ) return SF_FORMAT_SVX;
|
||||
if (ToLower(ext) == "nist" ) return SF_FORMAT_NIST;
|
||||
if (ToLower(ext) == "voc" ) return SF_FORMAT_VOC;
|
||||
if (ToLower(ext) == "sf" ) return SF_FORMAT_IRCAM;
|
||||
if (ToLower(ext) == "w64" ) return SF_FORMAT_W64;
|
||||
if (ToLower(ext) == "mat4" ) return SF_FORMAT_MAT4;
|
||||
if (ToLower(ext) == "mat5" ) return SF_FORMAT_MAT5;
|
||||
if (ToLower(ext) == "pvf" ) return SF_FORMAT_PVF;
|
||||
if (ToLower(ext) == "xi" ) return SF_FORMAT_XI;
|
||||
if (ToLower(ext) == "htk" ) return SF_FORMAT_HTK;
|
||||
if (ToLower(ext) == "sds" ) return SF_FORMAT_SDS;
|
||||
if (ToLower(ext) == "avr" ) return SF_FORMAT_AVR;
|
||||
if (ToLower(ext) == "sd2" ) return SF_FORMAT_SD2;
|
||||
if (ToLower(ext) == "flac" ) return SF_FORMAT_FLAC;
|
||||
if (ToLower(ext) == "caf" ) return SF_FORMAT_CAF;
|
||||
if (ToLower(ext) == "wve" ) return SF_FORMAT_WVE;
|
||||
if (ToLower(ext) == "ogg" ) return SF_FORMAT_OGG;
|
||||
if (ToLower(ext) == "mpc2k") return SF_FORMAT_MPC2K;
|
||||
if (ToLower(ext) == "rf64" ) return SF_FORMAT_RF64;
|
||||
if (toLower(ext) == "wav" ) return SF_FORMAT_WAV;
|
||||
if (toLower(ext) == "aif" ) return SF_FORMAT_AIFF;
|
||||
if (toLower(ext) == "aiff" ) return SF_FORMAT_AIFF;
|
||||
if (toLower(ext) == "au" ) return SF_FORMAT_AU;
|
||||
if (toLower(ext) == "raw" ) return SF_FORMAT_RAW;
|
||||
if (toLower(ext) == "paf" ) return SF_FORMAT_PAF;
|
||||
if (toLower(ext) == "svx" ) return SF_FORMAT_SVX;
|
||||
if (toLower(ext) == "nist" ) return SF_FORMAT_NIST;
|
||||
if (toLower(ext) == "voc" ) return SF_FORMAT_VOC;
|
||||
if (toLower(ext) == "sf" ) return SF_FORMAT_IRCAM;
|
||||
if (toLower(ext) == "w64" ) return SF_FORMAT_W64;
|
||||
if (toLower(ext) == "mat4" ) return SF_FORMAT_MAT4;
|
||||
if (toLower(ext) == "mat5" ) return SF_FORMAT_MAT5;
|
||||
if (toLower(ext) == "pvf" ) return SF_FORMAT_PVF;
|
||||
if (toLower(ext) == "xi" ) return SF_FORMAT_XI;
|
||||
if (toLower(ext) == "htk" ) return SF_FORMAT_HTK;
|
||||
if (toLower(ext) == "sds" ) return SF_FORMAT_SDS;
|
||||
if (toLower(ext) == "avr" ) return SF_FORMAT_AVR;
|
||||
if (toLower(ext) == "sd2" ) return SF_FORMAT_SD2;
|
||||
if (toLower(ext) == "flac" ) return SF_FORMAT_FLAC;
|
||||
if (toLower(ext) == "caf" ) return SF_FORMAT_CAF;
|
||||
if (toLower(ext) == "wve" ) return SF_FORMAT_WVE;
|
||||
if (toLower(ext) == "ogg" ) return SF_FORMAT_OGG;
|
||||
if (toLower(ext) == "mpc2k") return SF_FORMAT_MPC2K;
|
||||
if (toLower(ext) == "rf64" ) return SF_FORMAT_RF64;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Memory::GetLength(void* user)
|
||||
sf_count_t SoundFile::Memory::getLength(void* user)
|
||||
{
|
||||
Memory* memory = static_cast<Memory*>(user);
|
||||
return memory->TotalSize;
|
||||
|
@ -309,7 +309,7 @@ sf_count_t SoundFile::Memory::GetLength(void* user)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Memory::Read(void* ptr, sf_count_t count, void* user)
|
||||
sf_count_t SoundFile::Memory::read(void* ptr, sf_count_t count, void* user)
|
||||
{
|
||||
Memory* memory = static_cast<Memory*>(user);
|
||||
|
||||
|
@ -324,7 +324,7 @@ sf_count_t SoundFile::Memory::Read(void* ptr, sf_count_t count, void* user)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Memory::Seek(sf_count_t offset, int whence, void* user)
|
||||
sf_count_t SoundFile::Memory::seek(sf_count_t offset, int whence, void* user)
|
||||
{
|
||||
Memory* memory = static_cast<Memory*>(user);
|
||||
sf_count_t position = 0;
|
||||
|
@ -347,7 +347,7 @@ sf_count_t SoundFile::Memory::Seek(sf_count_t offset, int whence, void* user)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Memory::Tell(void* user)
|
||||
sf_count_t SoundFile::Memory::tell(void* user)
|
||||
{
|
||||
Memory* memory = static_cast<Memory*>(user);
|
||||
return memory->DataPtr - memory->DataStart;
|
||||
|
@ -355,40 +355,40 @@ sf_count_t SoundFile::Memory::Tell(void* user)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Stream::GetLength(void* userData)
|
||||
sf_count_t SoundFile::Stream::getLength(void* userData)
|
||||
{
|
||||
sf::InputStream* stream = static_cast<sf::InputStream*>(userData);
|
||||
return stream->GetSize();
|
||||
return stream->getSize();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Stream::Read(void* ptr, sf_count_t count, void* userData)
|
||||
sf_count_t SoundFile::Stream::read(void* ptr, sf_count_t count, void* userData)
|
||||
{
|
||||
sf::InputStream* stream = static_cast<sf::InputStream*>(userData);
|
||||
return stream->Read(reinterpret_cast<char*>(ptr), count);
|
||||
return stream->read(reinterpret_cast<char*>(ptr), count);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Stream::Seek(sf_count_t offset, int whence, void* userData)
|
||||
sf_count_t SoundFile::Stream::seek(sf_count_t offset, int whence, void* userData)
|
||||
{
|
||||
sf::InputStream* stream = static_cast<sf::InputStream*>(userData);
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET : return stream->Seek(offset);
|
||||
case SEEK_CUR : return stream->Seek(stream->Tell() + offset);
|
||||
case SEEK_END : return stream->Seek(stream->GetSize() - offset);
|
||||
default : return stream->Seek(0);
|
||||
case SEEK_SET : return stream->seek(offset);
|
||||
case SEEK_CUR : return stream->seek(stream->tell() + offset);
|
||||
case SEEK_END : return stream->seek(stream->getSize() - offset);
|
||||
default : return stream->seek(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sf_count_t SoundFile::Stream::Tell(void* userData)
|
||||
sf_count_t SoundFile::Stream::tell(void* userData)
|
||||
{
|
||||
sf::InputStream* stream = static_cast<sf::InputStream*>(userData);
|
||||
return stream->Tell();
|
||||
return stream->tell();
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
|
|
@ -66,7 +66,7 @@ public :
|
|||
/// \return Number of samples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetSampleCount() const;
|
||||
std::size_t getSampleCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of channels used by the sound
|
||||
|
@ -74,7 +74,7 @@ public :
|
|||
/// \return Number of channels (1 = mono, 2 = stereo)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetChannelCount() const;
|
||||
unsigned int getChannelCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sample rate of the sound
|
||||
|
@ -82,7 +82,7 @@ public :
|
|||
/// \return Sample rate, in samples per second
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetSampleRate() const;
|
||||
unsigned int getSampleRate() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Open a sound file for reading
|
||||
|
@ -92,7 +92,7 @@ public :
|
|||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenRead(const std::string& filename);
|
||||
bool openRead(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Open a sound file in memory for reading
|
||||
|
@ -103,7 +103,7 @@ public :
|
|||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenRead(const void* data, std::size_t sizeInBytes);
|
||||
bool openRead(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Open a sound file from a custom stream for reading
|
||||
|
@ -113,7 +113,7 @@ public :
|
|||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenRead(InputStream& stream);
|
||||
bool openRead(InputStream& stream);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief a the sound file for writing
|
||||
|
@ -125,7 +125,7 @@ public :
|
|||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate);
|
||||
bool openWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Read audio samples from the loaded sound
|
||||
|
@ -136,7 +136,7 @@ public :
|
|||
/// \return Number of samples actually read (may be less than \a sampleCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t Read(Int16* data, std::size_t sampleCount);
|
||||
std::size_t read(Int16* data, std::size_t sampleCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Write audio samples to the file
|
||||
|
@ -145,7 +145,7 @@ public :
|
|||
/// \param sampleCount Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Write(const Int16* data, std::size_t sampleCount);
|
||||
void write(const Int16* data, std::size_t sampleCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position in the file
|
||||
|
@ -153,7 +153,7 @@ public :
|
|||
/// \param timeOffset New playing position, from the beginning of the file
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Seek(Time timeOffset);
|
||||
void seek(Time timeOffset);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -166,7 +166,7 @@ private :
|
|||
/// \return Internal format matching the filename (-1 if no match)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static int GetFormatFromFilename(const std::string& filename);
|
||||
static int getFormatFromFilename(const std::string& filename);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Data and callbacks for opening from memory
|
||||
|
@ -178,10 +178,10 @@ private :
|
|||
const char* DataPtr;
|
||||
sf_count_t TotalSize;
|
||||
|
||||
static sf_count_t GetLength(void* user);
|
||||
static sf_count_t Read(void* ptr, sf_count_t count, void* user);
|
||||
static sf_count_t Seek(sf_count_t offset, int whence, void* user);
|
||||
static sf_count_t Tell(void* user);
|
||||
static sf_count_t getLength(void* user);
|
||||
static sf_count_t read(void* ptr, sf_count_t count, void* user);
|
||||
static sf_count_t seek(sf_count_t offset, int whence, void* user);
|
||||
static sf_count_t tell(void* user);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -190,10 +190,10 @@ private :
|
|||
////////////////////////////////////////////////////////////
|
||||
struct Stream
|
||||
{
|
||||
static sf_count_t GetLength(void* user);
|
||||
static sf_count_t Read(void* ptr, sf_count_t count, void* user);
|
||||
static sf_count_t Seek(sf_count_t offset, int whence, void* user);
|
||||
static sf_count_t Tell(void* user);
|
||||
static sf_count_t getLength(void* user);
|
||||
static sf_count_t read(void* ptr, sf_count_t count, void* user);
|
||||
static sf_count_t seek(sf_count_t offset, int whence, void* user);
|
||||
static sf_count_t tell(void* user);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/SoundRecorder.hpp>
|
||||
#include <SFML/Audio/AudioDevice.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
#include <SFML/System/Sleep.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
@ -45,11 +45,11 @@ namespace sf
|
|||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundRecorder::SoundRecorder() :
|
||||
m_thread (&SoundRecorder::Record, this),
|
||||
m_thread (&SoundRecorder::record, this),
|
||||
m_sampleRate (0),
|
||||
m_isCapturing(false)
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,19 +61,19 @@ SoundRecorder::~SoundRecorder()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundRecorder::Start(unsigned int sampleRate)
|
||||
void SoundRecorder::start(unsigned int sampleRate)
|
||||
{
|
||||
// Check if the device can do audio capture
|
||||
if (!IsAvailable())
|
||||
if (!isAvailable())
|
||||
{
|
||||
Err() << "Failed to start capture : your system cannot capture audio data (call SoundRecorder::IsAvailable to check it)" << std::endl;
|
||||
err() << "Failed to start capture : your system cannot capture audio data (call SoundRecorder::IsAvailable to check it)" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that another capture is not already running
|
||||
if (captureDevice)
|
||||
{
|
||||
Err() << "Trying to start audio capture, but another capture is already running" << std::endl;
|
||||
err() << "Trying to start audio capture, but another capture is already running" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ void SoundRecorder::Start(unsigned int sampleRate)
|
|||
captureDevice = alcCaptureOpenDevice(NULL, sampleRate, AL_FORMAT_MONO16, sampleRate);
|
||||
if (!captureDevice)
|
||||
{
|
||||
Err() << "Failed to open the audio capture device" << std::endl;
|
||||
err() << "Failed to open the audio capture device" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -92,44 +92,44 @@ void SoundRecorder::Start(unsigned int sampleRate)
|
|||
m_sampleRate = sampleRate;
|
||||
|
||||
// Notify derived class
|
||||
if (OnStart())
|
||||
if (onStart())
|
||||
{
|
||||
// Start the capture
|
||||
alcCaptureStart(captureDevice);
|
||||
|
||||
// Start the capture in a new thread, to avoid blocking the main thread
|
||||
m_isCapturing = true;
|
||||
m_thread.Launch();
|
||||
m_thread.launch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundRecorder::Stop()
|
||||
void SoundRecorder::stop()
|
||||
{
|
||||
// Stop the capturing thread
|
||||
m_isCapturing = false;
|
||||
m_thread.Wait();
|
||||
m_thread.wait();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundRecorder::GetSampleRate() const
|
||||
unsigned int SoundRecorder::getSampleRate() const
|
||||
{
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundRecorder::IsAvailable()
|
||||
bool SoundRecorder::isAvailable()
|
||||
{
|
||||
return (priv::AudioDevice::IsExtensionSupported("ALC_EXT_CAPTURE") != AL_FALSE) ||
|
||||
(priv::AudioDevice::IsExtensionSupported("ALC_EXT_capture") != AL_FALSE); // "bug" in Mac OS X 10.5 and 10.6
|
||||
return (priv::AudioDevice::isExtensionSupported("ALC_EXT_CAPTURE") != AL_FALSE) ||
|
||||
(priv::AudioDevice::isExtensionSupported("ALC_EXT_capture") != AL_FALSE); // "bug" in Mac OS X 10.5 and 10.6
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundRecorder::OnStart()
|
||||
bool SoundRecorder::onStart()
|
||||
{
|
||||
// Nothing to do
|
||||
return true;
|
||||
|
@ -137,34 +137,34 @@ bool SoundRecorder::OnStart()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundRecorder::OnStop()
|
||||
void SoundRecorder::onStop()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundRecorder::Record()
|
||||
void SoundRecorder::record()
|
||||
{
|
||||
while (m_isCapturing)
|
||||
{
|
||||
// Process available samples
|
||||
ProcessCapturedSamples();
|
||||
processCapturedSamples();
|
||||
|
||||
// Don't bother the CPU while waiting for more captured data
|
||||
Sleep(Milliseconds(100));
|
||||
sleep(milliseconds(100));
|
||||
}
|
||||
|
||||
// Capture is finished : clean up everything
|
||||
CleanUp();
|
||||
cleanup();
|
||||
|
||||
// Notify derived class
|
||||
OnStop();
|
||||
onStop();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundRecorder::ProcessCapturedSamples()
|
||||
void SoundRecorder::processCapturedSamples()
|
||||
{
|
||||
// Get the number of samples available
|
||||
ALCint samplesAvailable;
|
||||
|
@ -177,7 +177,7 @@ void SoundRecorder::ProcessCapturedSamples()
|
|||
alcCaptureSamples(captureDevice, &m_samples[0], samplesAvailable);
|
||||
|
||||
// Forward them to the derived class
|
||||
if (!OnProcessSamples(&m_samples[0], m_samples.size()))
|
||||
if (!onProcessSamples(&m_samples[0], m_samples.size()))
|
||||
{
|
||||
// The user wants to stop the capture
|
||||
m_isCapturing = false;
|
||||
|
@ -187,13 +187,13 @@ void SoundRecorder::ProcessCapturedSamples()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundRecorder::CleanUp()
|
||||
void SoundRecorder::cleanup()
|
||||
{
|
||||
// Stop the capture
|
||||
alcCaptureStop(captureDevice);
|
||||
|
||||
// Get the samples left in the buffer
|
||||
ProcessCapturedSamples();
|
||||
processCapturedSamples();
|
||||
|
||||
// Close the device
|
||||
alcCaptureCloseDevice(captureDevice);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/SoundSource.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
|
@ -34,151 +34,151 @@ namespace sf
|
|||
////////////////////////////////////////////////////////////
|
||||
SoundSource::SoundSource()
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
ALCheck(alGenSources(1, &m_source));
|
||||
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
alCheck(alGenSources(1, &m_source));
|
||||
alCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundSource::SoundSource(const SoundSource& copy)
|
||||
{
|
||||
priv::EnsureALInit();
|
||||
priv::ensureALInit();
|
||||
|
||||
ALCheck(alGenSources(1, &m_source));
|
||||
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
alCheck(alGenSources(1, &m_source));
|
||||
alCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
|
||||
SetPitch(copy.GetPitch());
|
||||
SetVolume(copy.GetVolume());
|
||||
SetPosition(copy.GetPosition());
|
||||
SetRelativeToListener(copy.IsRelativeToListener());
|
||||
SetMinDistance(copy.GetMinDistance());
|
||||
SetAttenuation(copy.GetAttenuation());
|
||||
setPitch(copy.getPitch());
|
||||
setVolume(copy.getVolume());
|
||||
setPosition(copy.getPosition());
|
||||
setRelativeToListener(copy.isRelativeToListener());
|
||||
setMinDistance(copy.getMinDistance());
|
||||
setAttenuation(copy.getAttenuation());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundSource::~SoundSource()
|
||||
{
|
||||
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
ALCheck(alDeleteSources(1, &m_source));
|
||||
alCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
alCheck(alDeleteSources(1, &m_source));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetPitch(float pitch)
|
||||
void SoundSource::setPitch(float pitch)
|
||||
{
|
||||
ALCheck(alSourcef(m_source, AL_PITCH, pitch));
|
||||
alCheck(alSourcef(m_source, AL_PITCH, pitch));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetVolume(float volume)
|
||||
void SoundSource::setVolume(float volume)
|
||||
{
|
||||
ALCheck(alSourcef(m_source, AL_GAIN, volume * 0.01f));
|
||||
alCheck(alSourcef(m_source, AL_GAIN, volume * 0.01f));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetPosition(float x, float y, float z)
|
||||
void SoundSource::setPosition(float x, float y, float z)
|
||||
{
|
||||
ALCheck(alSource3f(m_source, AL_POSITION, x, y, z));
|
||||
alCheck(alSource3f(m_source, AL_POSITION, x, y, z));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetPosition(const Vector3f& position)
|
||||
void SoundSource::setPosition(const Vector3f& position)
|
||||
{
|
||||
SetPosition(position.x, position.y, position.z);
|
||||
setPosition(position.x, position.y, position.z);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetRelativeToListener(bool relative)
|
||||
void SoundSource::setRelativeToListener(bool relative)
|
||||
{
|
||||
ALCheck(alSourcei(m_source, AL_SOURCE_RELATIVE, relative));
|
||||
alCheck(alSourcei(m_source, AL_SOURCE_RELATIVE, relative));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetMinDistance(float distance)
|
||||
void SoundSource::setMinDistance(float distance)
|
||||
{
|
||||
ALCheck(alSourcef(m_source, AL_REFERENCE_DISTANCE, distance));
|
||||
alCheck(alSourcef(m_source, AL_REFERENCE_DISTANCE, distance));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundSource::SetAttenuation(float attenuation)
|
||||
void SoundSource::setAttenuation(float attenuation)
|
||||
{
|
||||
ALCheck(alSourcef(m_source, AL_ROLLOFF_FACTOR, attenuation));
|
||||
alCheck(alSourcef(m_source, AL_ROLLOFF_FACTOR, attenuation));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundSource::GetPitch() const
|
||||
float SoundSource::getPitch() const
|
||||
{
|
||||
ALfloat pitch;
|
||||
ALCheck(alGetSourcef(m_source, AL_PITCH, &pitch));
|
||||
alCheck(alGetSourcef(m_source, AL_PITCH, &pitch));
|
||||
|
||||
return pitch;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundSource::GetVolume() const
|
||||
float SoundSource::getVolume() const
|
||||
{
|
||||
ALfloat gain;
|
||||
ALCheck(alGetSourcef(m_source, AL_GAIN, &gain));
|
||||
alCheck(alGetSourcef(m_source, AL_GAIN, &gain));
|
||||
|
||||
return gain * 100.f;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f SoundSource::GetPosition() const
|
||||
Vector3f SoundSource::getPosition() const
|
||||
{
|
||||
Vector3f position;
|
||||
ALCheck(alGetSource3f(m_source, AL_POSITION, &position.x, &position.y, &position.z));
|
||||
alCheck(alGetSource3f(m_source, AL_POSITION, &position.x, &position.y, &position.z));
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundSource::IsRelativeToListener() const
|
||||
bool SoundSource::isRelativeToListener() const
|
||||
{
|
||||
ALint relative;
|
||||
ALCheck(alGetSourcei(m_source, AL_SOURCE_RELATIVE, &relative));
|
||||
alCheck(alGetSourcei(m_source, AL_SOURCE_RELATIVE, &relative));
|
||||
|
||||
return relative != 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundSource::GetMinDistance() const
|
||||
float SoundSource::getMinDistance() const
|
||||
{
|
||||
ALfloat distance;
|
||||
ALCheck(alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &distance));
|
||||
alCheck(alGetSourcef(m_source, AL_REFERENCE_DISTANCE, &distance));
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float SoundSource::GetAttenuation() const
|
||||
float SoundSource::getAttenuation() const
|
||||
{
|
||||
ALfloat attenuation;
|
||||
ALCheck(alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &attenuation));
|
||||
alCheck(alGetSourcef(m_source, AL_ROLLOFF_FACTOR, &attenuation));
|
||||
|
||||
return attenuation;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundSource::Status SoundSource::GetStatus() const
|
||||
SoundSource::Status SoundSource::getStatus() const
|
||||
{
|
||||
ALint status;
|
||||
ALCheck(alGetSourcei(m_source, AL_SOURCE_STATE, &status));
|
||||
alCheck(alGetSourcei(m_source, AL_SOURCE_STATE, &status));
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/SoundStream.hpp>
|
||||
#include <SFML/Audio/AudioDevice.hpp>
|
||||
#include <SFML/Audio/ALCheck.hpp>
|
||||
#include <SFML/Audio/alCheck.hpp>
|
||||
#include <SFML/System/Sleep.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace sf
|
|||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundStream::SoundStream() :
|
||||
m_thread (&SoundStream::Stream, this),
|
||||
m_thread (&SoundStream::stream, this),
|
||||
m_isStreaming (false),
|
||||
m_channelCount (0),
|
||||
m_sampleRate (0),
|
||||
|
@ -56,92 +56,92 @@ m_samplesProcessed(0)
|
|||
SoundStream::~SoundStream()
|
||||
{
|
||||
// Stop the sound if it was playing
|
||||
Stop();
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::Initialize(unsigned int channelCount, unsigned int sampleRate)
|
||||
void SoundStream::initialize(unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
m_channelCount = channelCount;
|
||||
m_sampleRate = sampleRate;
|
||||
|
||||
// Deduce the format from the number of channels
|
||||
m_format = priv::AudioDevice::GetFormatFromChannelCount(channelCount);
|
||||
m_format = priv::AudioDevice::getFormatFromChannelCount(channelCount);
|
||||
|
||||
// Check if the format is valid
|
||||
if (m_format == 0)
|
||||
{
|
||||
m_channelCount = 0;
|
||||
m_sampleRate = 0;
|
||||
Err() << "Unsupported number of channels (" << m_channelCount << ")" << std::endl;
|
||||
err() << "Unsupported number of channels (" << m_channelCount << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::Play()
|
||||
void SoundStream::play()
|
||||
{
|
||||
// Check if the sound parameters have been set
|
||||
if (m_format == 0)
|
||||
{
|
||||
Err() << "Failed to play audio stream: sound parameters have not been initialized (call Initialize first)" << std::endl;
|
||||
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 (m_isStreaming)
|
||||
{
|
||||
ALCheck(alSourcePlay(m_source));
|
||||
alCheck(alSourcePlay(m_source));
|
||||
return;
|
||||
}
|
||||
|
||||
// Move to the beginning
|
||||
OnSeek(Time::Zero);
|
||||
onSeek(Time::Zero);
|
||||
|
||||
// Start updating the stream in a separate thread to avoid blocking the application
|
||||
m_samplesProcessed = 0;
|
||||
m_isStreaming = true;
|
||||
m_thread.Launch();
|
||||
m_thread.launch();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::Pause()
|
||||
void SoundStream::pause()
|
||||
{
|
||||
ALCheck(alSourcePause(m_source));
|
||||
alCheck(alSourcePause(m_source));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::Stop()
|
||||
void SoundStream::stop()
|
||||
{
|
||||
// Wait for the thread to terminate
|
||||
m_isStreaming = false;
|
||||
m_thread.Wait();
|
||||
m_thread.wait();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundStream::GetChannelCount() const
|
||||
unsigned int SoundStream::getChannelCount() const
|
||||
{
|
||||
return m_channelCount;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundStream::GetSampleRate() const
|
||||
unsigned int SoundStream::getSampleRate() const
|
||||
{
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundStream::Status SoundStream::GetStatus() const
|
||||
SoundStream::Status SoundStream::getStatus() const
|
||||
{
|
||||
Status status = SoundSource::GetStatus();
|
||||
Status status = SoundSource::getStatus();
|
||||
|
||||
// To compensate for the lag between Play() and alSourcePlay()
|
||||
// To compensate for the lag between play() and alSourceplay()
|
||||
if ((status == Stopped) && m_isStreaming)
|
||||
status = Playing;
|
||||
|
||||
|
@ -150,68 +150,68 @@ SoundStream::Status SoundStream::GetStatus() const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::SetPlayingOffset(Time timeOffset)
|
||||
void SoundStream::setPlayingOffset(Time timeOffset)
|
||||
{
|
||||
// Stop the stream
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
// Let the derived class update the current position
|
||||
OnSeek(timeOffset);
|
||||
onSeek(timeOffset);
|
||||
|
||||
// Restart streaming
|
||||
m_samplesProcessed = static_cast<Uint64>(timeOffset.AsSeconds() * m_sampleRate * m_channelCount);
|
||||
m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * m_sampleRate * m_channelCount);
|
||||
m_isStreaming = true;
|
||||
m_thread.Launch();
|
||||
m_thread.launch();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Time SoundStream::GetPlayingOffset() const
|
||||
Time SoundStream::getPlayingOffset() const
|
||||
{
|
||||
ALfloat seconds = 0.f;
|
||||
ALCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &seconds));
|
||||
ALfloat secs = 0.f;
|
||||
alCheck(alGetSourcef(m_source, AL_SEC_OFFSET, &secs));
|
||||
|
||||
return Seconds(seconds + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
|
||||
return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::SetLoop(bool loop)
|
||||
void SoundStream::setLoop(bool loop)
|
||||
{
|
||||
m_loop = loop;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundStream::GetLoop() const
|
||||
bool SoundStream::getLoop() const
|
||||
{
|
||||
return m_loop;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::Stream()
|
||||
void SoundStream::stream()
|
||||
{
|
||||
// Create the buffers
|
||||
ALCheck(alGenBuffers(BufferCount, m_buffers));
|
||||
alCheck(alGenBuffers(BufferCount, m_buffers));
|
||||
for (int i = 0; i < BufferCount; ++i)
|
||||
m_endBuffers[i] = false;
|
||||
|
||||
// Fill the queue
|
||||
bool requestStop = FillQueue();
|
||||
bool requestStop = fillQueue();
|
||||
|
||||
// Play the sound
|
||||
ALCheck(alSourcePlay(m_source));
|
||||
alCheck(alSourcePlay(m_source));
|
||||
|
||||
while (m_isStreaming)
|
||||
{
|
||||
// The stream has been interrupted!
|
||||
if (SoundSource::GetStatus() == Stopped)
|
||||
if (SoundSource::getStatus() == Stopped)
|
||||
{
|
||||
if (!requestStop)
|
||||
{
|
||||
// Just continue
|
||||
ALCheck(alSourcePlay(m_source));
|
||||
alCheck(alSourcePlay(m_source));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -222,13 +222,13 @@ void SoundStream::Stream()
|
|||
|
||||
// Get the number of buffers that have been processed (ie. ready for reuse)
|
||||
ALint nbProcessed = 0;
|
||||
ALCheck(alGetSourcei(m_source, 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(m_source, 1, &buffer));
|
||||
alCheck(alSourceUnqueueBuffers(m_source, 1, &buffer));
|
||||
|
||||
// Find its number
|
||||
unsigned int bufferNum = 0;
|
||||
|
@ -249,44 +249,44 @@ void SoundStream::Stream()
|
|||
else
|
||||
{
|
||||
ALint size, bits;
|
||||
ALCheck(alGetBufferi(buffer, AL_SIZE, &size));
|
||||
ALCheck(alGetBufferi(buffer, AL_BITS, &bits));
|
||||
alCheck(alGetBufferi(buffer, AL_SIZE, &size));
|
||||
alCheck(alGetBufferi(buffer, AL_BITS, &bits));
|
||||
m_samplesProcessed += size / (bits / 8);
|
||||
}
|
||||
|
||||
// Fill it and push it back into the playing queue
|
||||
if (!requestStop)
|
||||
{
|
||||
if (FillAndPushBuffer(bufferNum))
|
||||
if (fillAndPushBuffer(bufferNum))
|
||||
requestStop = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Leave some time for the other threads if the stream is still playing
|
||||
if (SoundSource::GetStatus() != Stopped)
|
||||
Sleep(Milliseconds(10));
|
||||
if (SoundSource::getStatus() != Stopped)
|
||||
sleep(milliseconds(10));
|
||||
}
|
||||
|
||||
// Stop the playback
|
||||
ALCheck(alSourceStop(m_source));
|
||||
alCheck(alSourceStop(m_source));
|
||||
|
||||
// Unqueue any buffer left in the queue
|
||||
ClearQueue();
|
||||
clearQueue();
|
||||
|
||||
// Delete the buffers
|
||||
ALCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
ALCheck(alDeleteBuffers(BufferCount, m_buffers));
|
||||
alCheck(alSourcei(m_source, AL_BUFFER, 0));
|
||||
alCheck(alDeleteBuffers(BufferCount, m_buffers));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
|
||||
bool SoundStream::fillAndPushBuffer(unsigned int bufferNum)
|
||||
{
|
||||
bool requestStop = false;
|
||||
|
||||
// Acquire audio data
|
||||
Chunk data = {NULL, 0};
|
||||
if (!OnGetData(data))
|
||||
if (!onGetData(data))
|
||||
{
|
||||
// Mark the buffer as the last one (so that we know when to reset the playing position)
|
||||
m_endBuffers[bufferNum] = true;
|
||||
|
@ -295,12 +295,12 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
|
|||
if (m_loop)
|
||||
{
|
||||
// Return to the beginning of the stream source
|
||||
OnSeek(Time::Zero);
|
||||
onSeek(Time::Zero);
|
||||
|
||||
// If we previously had no data, try to fill the buffer once again
|
||||
if (!data.Samples || (data.SampleCount == 0))
|
||||
if (!data.samples || (data.sampleCount == 0))
|
||||
{
|
||||
return FillAndPushBuffer(bufferNum);
|
||||
return fillAndPushBuffer(bufferNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -311,16 +311,16 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
|
|||
}
|
||||
|
||||
// Fill the buffer if some data was returned
|
||||
if (data.Samples && data.SampleCount)
|
||||
if (data.samples && data.sampleCount)
|
||||
{
|
||||
unsigned int buffer = m_buffers[bufferNum];
|
||||
|
||||
// Fill the buffer
|
||||
ALsizei size = static_cast<ALsizei>(data.SampleCount) * sizeof(Int16);
|
||||
ALCheck(alBufferData(buffer, m_format, data.Samples, size, m_sampleRate));
|
||||
ALsizei size = static_cast<ALsizei>(data.sampleCount) * sizeof(Int16);
|
||||
alCheck(alBufferData(buffer, m_format, data.samples, size, m_sampleRate));
|
||||
|
||||
// Push it into the sound queue
|
||||
ALCheck(alSourceQueueBuffers(m_source, 1, &buffer));
|
||||
alCheck(alSourceQueueBuffers(m_source, 1, &buffer));
|
||||
}
|
||||
|
||||
return requestStop;
|
||||
|
@ -328,13 +328,13 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundStream::FillQueue()
|
||||
bool SoundStream::fillQueue()
|
||||
{
|
||||
// Fill and enqueue all the available buffers
|
||||
bool requestStop = false;
|
||||
for (int i = 0; (i < BufferCount) && !requestStop; ++i)
|
||||
{
|
||||
if (FillAndPushBuffer(i))
|
||||
if (fillAndPushBuffer(i))
|
||||
requestStop = true;
|
||||
}
|
||||
|
||||
|
@ -343,16 +343,16 @@ bool SoundStream::FillQueue()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::ClearQueue()
|
||||
void SoundStream::clearQueue()
|
||||
{
|
||||
// Get the number of buffers still in the queue
|
||||
ALint nbQueued;
|
||||
ALCheck(alGetSourcei(m_source, 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(m_source, 1, &buffer));
|
||||
alCheck(alSourceUnqueueBuffers(m_source, 1, &buffer));
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -36,41 +36,41 @@ CircleShape::CircleShape(float radius, unsigned int pointCount) :
|
|||
m_radius (radius),
|
||||
m_pointCount(pointCount)
|
||||
{
|
||||
Update();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void CircleShape::SetRadius(float radius)
|
||||
void CircleShape::setRadius(float radius)
|
||||
{
|
||||
m_radius = radius;
|
||||
Update();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float CircleShape::GetRadius() const
|
||||
float CircleShape::getRadius() const
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void CircleShape::SetPointCount(unsigned int count)
|
||||
void CircleShape::setPointCount(unsigned int count)
|
||||
{
|
||||
m_pointCount = count;
|
||||
Update();
|
||||
update();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int CircleShape::GetPointCount() const
|
||||
unsigned int CircleShape::getPointCount() const
|
||||
{
|
||||
return m_pointCount;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f CircleShape::GetPoint(unsigned int index) const
|
||||
Vector2f CircleShape::getPoint(unsigned int index) const
|
||||
{
|
||||
static const float pi = 3.141592654f;
|
||||
|
||||
|
|
|
@ -33,35 +33,35 @@ namespace sf
|
|||
////////////////////////////////////////////////////////////
|
||||
ConvexShape::ConvexShape(unsigned int pointCount)
|
||||
{
|
||||
SetPointCount(pointCount);
|
||||
setPointCount(pointCount);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void ConvexShape::SetPointCount(unsigned int count)
|
||||
void ConvexShape::setPointCount(unsigned int count)
|
||||
{
|
||||
m_points.resize(count);
|
||||
Update();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int ConvexShape::GetPointCount() const
|
||||
unsigned int ConvexShape::getPointCount() const
|
||||
{
|
||||
return static_cast<unsigned int>(m_points.size());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void ConvexShape::SetPoint(unsigned int index, const Vector2f& point)
|
||||
void ConvexShape::setPoint(unsigned int index, const Vector2f& point)
|
||||
{
|
||||
m_points[index] = point;
|
||||
Update();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f ConvexShape::GetPoint(unsigned int index) const
|
||||
Vector2f ConvexShape::getPoint(unsigned int index) const
|
||||
{
|
||||
return m_points[index];
|
||||
}
|
||||
|
|
|
@ -40,20 +40,20 @@
|
|||
namespace
|
||||
{
|
||||
// FreeType callbacks that operate on a sf::InputStream
|
||||
unsigned long Read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count)
|
||||
unsigned long read(FT_Stream rec, unsigned long offset, unsigned char* buffer, unsigned long count)
|
||||
{
|
||||
sf::InputStream* stream = static_cast<sf::InputStream*>(rec->descriptor.pointer);
|
||||
if (static_cast<unsigned long>(stream->Seek(offset)) == offset)
|
||||
if (static_cast<unsigned long>(stream->seek(offset)) == offset)
|
||||
{
|
||||
if (count > 0)
|
||||
return static_cast<unsigned long>(stream->Read(reinterpret_cast<char*>(buffer), count));
|
||||
return static_cast<unsigned long>(stream->read(reinterpret_cast<char*>(buffer), count));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return count > 0 ? 0 : 1; // error code is 0 if we're reading, or nonzero if we're seeking
|
||||
}
|
||||
void Close(FT_Stream)
|
||||
void close(FT_Stream)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -92,15 +92,15 @@ m_pixelBuffer(copy.m_pixelBuffer)
|
|||
////////////////////////////////////////////////////////////
|
||||
Font::~Font()
|
||||
{
|
||||
Cleanup();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Font::LoadFromFile(const std::string& filename)
|
||||
bool Font::loadFromFile(const std::string& filename)
|
||||
{
|
||||
// Cleanup the previous resources
|
||||
Cleanup();
|
||||
cleanup();
|
||||
m_refCount = new int(1);
|
||||
|
||||
// Initialize FreeType
|
||||
|
@ -109,7 +109,7 @@ bool Font::LoadFromFile(const std::string& filename)
|
|||
FT_Library library;
|
||||
if (FT_Init_FreeType(&library) != 0)
|
||||
{
|
||||
Err() << "Failed to load font \"" << filename << "\" (failed to initialize FreeType)" << std::endl;
|
||||
err() << "Failed to load font \"" << filename << "\" (failed to initialize FreeType)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
m_library = library;
|
||||
|
@ -118,14 +118,14 @@ bool Font::LoadFromFile(const std::string& filename)
|
|||
FT_Face face;
|
||||
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;
|
||||
err() << "Failed to load font \"" << filename << "\" (failed to create the font face)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select the unicode character map
|
||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
||||
{
|
||||
Err() << "Failed to load font \"" << filename << "\" (failed to set the Unicode character set)" << std::endl;
|
||||
err() << "Failed to load font \"" << filename << "\" (failed to set the Unicode character set)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -137,10 +137,10 @@ bool Font::LoadFromFile(const std::string& filename)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
bool Font::loadFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
{
|
||||
// Cleanup the previous resources
|
||||
Cleanup();
|
||||
cleanup();
|
||||
m_refCount = new int(1);
|
||||
|
||||
// Initialize FreeType
|
||||
|
@ -149,7 +149,7 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
|||
FT_Library library;
|
||||
if (FT_Init_FreeType(&library) != 0)
|
||||
{
|
||||
Err() << "Failed to load font from memory (failed to initialize FreeType)" << std::endl;
|
||||
err() << "Failed to load font from memory (failed to initialize FreeType)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
m_library = library;
|
||||
|
@ -158,14 +158,14 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
|||
FT_Face face;
|
||||
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;
|
||||
err() << "Failed to load font from memory (failed to create the font face)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select the unicode character map
|
||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
||||
{
|
||||
Err() << "Failed to load font from memory (failed to set the Unicode character set)" << std::endl;
|
||||
err() << "Failed to load font from memory (failed to set the Unicode character set)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -177,10 +177,10 @@ bool Font::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Font::LoadFromStream(InputStream& stream)
|
||||
bool Font::loadFromStream(InputStream& stream)
|
||||
{
|
||||
// Cleanup the previous resources
|
||||
Cleanup();
|
||||
cleanup();
|
||||
m_refCount = new int(1);
|
||||
|
||||
// Initialize FreeType
|
||||
|
@ -189,7 +189,7 @@ bool Font::LoadFromStream(InputStream& stream)
|
|||
FT_Library library;
|
||||
if (FT_Init_FreeType(&library) != 0)
|
||||
{
|
||||
Err() << "Failed to load font from stream (failed to initialize FreeType)" << std::endl;
|
||||
err() << "Failed to load font from stream (failed to initialize FreeType)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
m_library = library;
|
||||
|
@ -198,11 +198,11 @@ bool Font::LoadFromStream(InputStream& stream)
|
|||
FT_StreamRec* rec = new FT_StreamRec;
|
||||
std::memset(rec, 0, sizeof(*rec));
|
||||
rec->base = NULL;
|
||||
rec->size = static_cast<unsigned long>(stream.GetSize());
|
||||
rec->size = static_cast<unsigned long>(stream.getSize());
|
||||
rec->pos = 0;
|
||||
rec->descriptor.pointer = &stream;
|
||||
rec->read = &Read;
|
||||
rec->close = &Close;
|
||||
rec->read = &read;
|
||||
rec->close = &close;
|
||||
|
||||
// Setup the FreeType callbacks that will read our stream
|
||||
FT_Open_Args args;
|
||||
|
@ -214,14 +214,14 @@ bool Font::LoadFromStream(InputStream& stream)
|
|||
FT_Face face;
|
||||
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;
|
||||
err() << "Failed to load font from stream (failed to create the font face)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select the unicode character map
|
||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
||||
{
|
||||
Err() << "Failed to load font from stream (failed to set the Unicode character set)" << std::endl;
|
||||
err() << "Failed to load font from stream (failed to set the Unicode character set)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -234,10 +234,10 @@ bool Font::LoadFromStream(InputStream& stream)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Glyph& Font::GetGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
|
||||
const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
|
||||
{
|
||||
// Get the page corresponding to the character size
|
||||
GlyphTable& glyphs = m_pages[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;
|
||||
|
@ -252,14 +252,14 @@ const Glyph& Font::GetGlyph(Uint32 codePoint, unsigned int characterSize, bool b
|
|||
else
|
||||
{
|
||||
// Not found: we have to load it
|
||||
Glyph glyph = LoadGlyph(codePoint, characterSize, bold);
|
||||
Glyph glyph = loadGlyph(codePoint, characterSize, bold);
|
||||
return glyphs.insert(std::make_pair(key, glyph)).first->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int Font::GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) const
|
||||
int Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const
|
||||
{
|
||||
// Special case where first or second is 0 (null character)
|
||||
if (first == 0 || second == 0)
|
||||
|
@ -267,7 +267,7 @@ int Font::GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) co
|
|||
|
||||
FT_Face face = static_cast<FT_Face>(m_face);
|
||||
|
||||
if (face && FT_HAS_KERNING(face) && SetCurrentSize(characterSize))
|
||||
if (face && FT_HAS_KERNING(face) && setCurrentSize(characterSize))
|
||||
{
|
||||
// Convert the characters to indices
|
||||
FT_UInt index1 = FT_Get_Char_Index(face, first);
|
||||
|
@ -289,11 +289,11 @@ int Font::GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) co
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int Font::GetLineSpacing(unsigned int characterSize) const
|
||||
int Font::getLineSpacing(unsigned int characterSize) const
|
||||
{
|
||||
FT_Face face = static_cast<FT_Face>(m_face);
|
||||
|
||||
if (face && SetCurrentSize(characterSize))
|
||||
if (face && setCurrentSize(characterSize))
|
||||
{
|
||||
return (face->size->metrics.height >> 6);
|
||||
}
|
||||
|
@ -305,9 +305,9 @@ int Font::GetLineSpacing(unsigned int characterSize) const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Texture& Font::GetTexture(unsigned int characterSize) const
|
||||
const Texture& Font::getTexture(unsigned int characterSize) const
|
||||
{
|
||||
return m_pages[characterSize].Texture;
|
||||
return m_pages[characterSize].texture;
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,7 +327,7 @@ Font& Font::operator =(const Font& right)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Font& Font::GetDefaultFont()
|
||||
const Font& Font::getDefaultFont()
|
||||
{
|
||||
static Font font;
|
||||
static bool loaded = false;
|
||||
|
@ -340,7 +340,7 @@ const Font& Font::GetDefaultFont()
|
|||
#include <SFML/Graphics/Arial.hpp>
|
||||
};
|
||||
|
||||
font.LoadFromMemory(data, sizeof(data));
|
||||
font.loadFromMemory(data, sizeof(data));
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ const Font& Font::GetDefaultFont()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Font::Cleanup()
|
||||
void Font::cleanup()
|
||||
{
|
||||
// Check if we must destroy the FreeType pointers
|
||||
if (m_refCount)
|
||||
|
@ -388,7 +388,7 @@ void Font::Cleanup()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
|
||||
Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
|
||||
{
|
||||
// The glyph to return
|
||||
Glyph glyph;
|
||||
|
@ -399,7 +399,7 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
|
|||
return glyph;
|
||||
|
||||
// Set the character size
|
||||
if (!SetCurrentSize(characterSize))
|
||||
if (!setCurrentSize(characterSize))
|
||||
return glyph;
|
||||
|
||||
// Load the glyph corresponding to the code point
|
||||
|
@ -432,9 +432,9 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
|
|||
}
|
||||
|
||||
// Compute the glyph's advance offset
|
||||
glyph.Advance = glyphDesc->advance.x >> 16;
|
||||
glyph.advance = glyphDesc->advance.x >> 16;
|
||||
if (bold)
|
||||
glyph.Advance += weight >> 6;
|
||||
glyph.advance += weight >> 6;
|
||||
|
||||
int width = bitmap.width;
|
||||
int height = bitmap.rows;
|
||||
|
@ -448,13 +448,13 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
|
|||
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);
|
||||
glyph.textureRect = findGlyphRect(page, width + 2 * padding, height + 2 * padding);
|
||||
|
||||
// Compute the glyph's bounding box
|
||||
glyph.Bounds.Left = bitmapGlyph->left - padding;
|
||||
glyph.Bounds.Top = -bitmapGlyph->top - padding;
|
||||
glyph.Bounds.Width = width + 2 * padding;
|
||||
glyph.Bounds.Height = height + 2 * padding;
|
||||
glyph.bounds.left = bitmapGlyph->left - padding;
|
||||
glyph.bounds.top = -bitmapGlyph->top - padding;
|
||||
glyph.bounds.width = width + 2 * padding;
|
||||
glyph.bounds.height = height + 2 * padding;
|
||||
|
||||
// Extract the glyph's pixels from the bitmap
|
||||
m_pixelBuffer.resize(width * height * 4, 255);
|
||||
|
@ -489,11 +489,11 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
|
|||
}
|
||||
|
||||
// Write the pixels to the texture
|
||||
unsigned int x = glyph.TextureRect.Left + padding;
|
||||
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(&m_pixelBuffer[0], width, height, x, y);
|
||||
unsigned int x = glyph.textureRect.left + padding;
|
||||
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(&m_pixelBuffer[0], width, height, x, y);
|
||||
}
|
||||
|
||||
// Delete the FT glyph
|
||||
|
@ -505,21 +505,21 @@ Glyph Font::LoadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
IntRect Font::FindGlyphRect(Page& page, unsigned int width, unsigned int height) const
|
||||
IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height) const
|
||||
{
|
||||
// Find the line that fits well the glyph
|
||||
Row* row = NULL;
|
||||
float bestRatio = 0;
|
||||
for (std::vector<Row>::iterator it = page.Rows.begin(); it != page.Rows.end() && !row; ++it)
|
||||
for (std::vector<Row>::iterator it = page.rows.begin(); it != page.rows.end() && !row; ++it)
|
||||
{
|
||||
float ratio = static_cast<float>(height) / it->Height;
|
||||
float ratio = static_cast<float>(height) / it->height;
|
||||
|
||||
// Ignore rows that are either too small or too high
|
||||
if ((ratio < 0.7f) || (ratio > 1.f))
|
||||
continue;
|
||||
|
||||
// Check if there's enough horizontal space left in the row
|
||||
if (width > page.Texture.GetWidth() - it->Width)
|
||||
if (width > page.texture.getWidth() - it->width)
|
||||
continue;
|
||||
|
||||
// Make sure that this new row is the best found so far
|
||||
|
@ -535,44 +535,44 @@ IntRect Font::FindGlyphRect(Page& page, unsigned int width, unsigned int height)
|
|||
if (!row)
|
||||
{
|
||||
int rowHeight = height + height / 10;
|
||||
if (page.NextRow + rowHeight >= page.Texture.GetHeight())
|
||||
if (page.nextRow + rowHeight >= page.texture.getHeight())
|
||||
{
|
||||
// Not enough space: resize the texture if possible
|
||||
unsigned int textureWidth = page.Texture.GetWidth();
|
||||
unsigned int textureHeight = page.Texture.GetHeight();
|
||||
if ((textureWidth * 2 <= Texture::GetMaximumSize()) && (textureHeight * 2 <= Texture::GetMaximumSize()))
|
||||
unsigned int textureWidth = page.texture.getWidth();
|
||||
unsigned int textureHeight = page.texture.getHeight();
|
||||
if ((textureWidth * 2 <= Texture::getMaximumSize()) && (textureHeight * 2 <= Texture::getMaximumSize()))
|
||||
{
|
||||
// Make the texture 2 times bigger
|
||||
sf::Image pixels = page.Texture.CopyToImage();
|
||||
page.Texture.Create(textureWidth * 2, textureHeight * 2);
|
||||
page.Texture.Update(pixels);
|
||||
sf::Image pixels = page.texture.copyToImage();
|
||||
page.texture.create(textureWidth * 2, textureHeight * 2);
|
||||
page.texture.update(pixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Oops, we've reached the maximum texture size...
|
||||
Err() << "Failed to add a new character to the font: the maximum texture size has been reached" << std::endl;
|
||||
err() << "Failed to add a new character to the font: the maximum texture size has been reached" << std::endl;
|
||||
return IntRect(0, 0, 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// We can now create the new row
|
||||
page.Rows.push_back(Row(page.NextRow, rowHeight));
|
||||
page.NextRow += rowHeight;
|
||||
row = &page.Rows.back();
|
||||
page.rows.push_back(Row(page.nextRow, rowHeight));
|
||||
page.nextRow += rowHeight;
|
||||
row = &page.rows.back();
|
||||
}
|
||||
|
||||
// Find the glyph's rectangle on the selected row
|
||||
IntRect rect(row->Width, row->Top, width, height);
|
||||
IntRect rect(row->width, row->top, width, height);
|
||||
|
||||
// Update the row informations
|
||||
row->Width += width;
|
||||
row->width += width;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Font::SetCurrentSize(unsigned int characterSize) const
|
||||
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
|
||||
|
@ -593,20 +593,20 @@ bool Font::SetCurrentSize(unsigned int characterSize) const
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
Font::Page::Page() :
|
||||
NextRow(2)
|
||||
nextRow(2)
|
||||
{
|
||||
// Make sure that the texture is initialized by default
|
||||
sf::Image image;
|
||||
image.Create(128, 128, Color(255, 255, 255, 0));
|
||||
image.create(128, 128, Color(255, 255, 255, 0));
|
||||
|
||||
// Reserve a 2x2 white square for texturing underlines
|
||||
for (int x = 0; x < 2; ++x)
|
||||
for (int y = 0; y < 2; ++y)
|
||||
image.SetPixel(x, y, Color(255, 255, 255, 255));
|
||||
image.setPixel(x, y, Color(255, 255, 255, 255));
|
||||
|
||||
// Create the texture
|
||||
Texture.LoadFromImage(image);
|
||||
Texture.SetSmooth(true);
|
||||
texture.loadFromImage(image);
|
||||
texture.setSmooth(true);
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Graphics/GLCheck.hpp>
|
||||
#include <SFML/Graphics/glCheck.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void GLCheckError(const std::string& file, unsigned int line)
|
||||
void glCheckError(const std::string& file, unsigned int line)
|
||||
{
|
||||
// Get the last error
|
||||
GLenum errorCode = glGetError();
|
||||
|
@ -98,7 +98,7 @@ void GLCheckError(const std::string& file, unsigned int line)
|
|||
}
|
||||
|
||||
// Log the error
|
||||
Err() << "An internal OpenGL call failed in "
|
||||
err() << "An internal OpenGL call failed in "
|
||||
<< file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : "
|
||||
<< error << ", " << description
|
||||
<< std::endl;
|
||||
|
@ -107,7 +107,7 @@ void GLCheckError(const std::string& file, unsigned int line)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void EnsureGlewInit()
|
||||
void ensureGlewInit()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (!initialized)
|
||||
|
@ -119,7 +119,7 @@ void EnsureGlewInit()
|
|||
}
|
||||
else
|
||||
{
|
||||
Err() << "Failed to initialize GLEW, " << glewGetErrorString(status) << std::endl;
|
||||
err() << "Failed to initialize GLEW, " << glewGetErrorString(status) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,18 +38,17 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Let's define a macro to quickly check every OpenGL
|
||||
/// API calls
|
||||
/// Let's define a macro to quickly check every OpenGL API calls
|
||||
////////////////////////////////////////////////////////////
|
||||
#ifdef SFML_DEBUG
|
||||
|
||||
// In debug mode, perform a test on every OpenGL call
|
||||
#define GLCheck(call) ((call), sf::priv::GLCheckError(__FILE__, __LINE__))
|
||||
#define glCheck(call) ((call), sf::priv::glCheckError(__FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
|
||||
// Else, we don't add any overhead
|
||||
#define GLCheck(call) (call)
|
||||
#define glCheck(call) (call)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -60,13 +59,13 @@ namespace priv
|
|||
/// \param line Line number of the source file where the call is located
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void GLCheckError(const std::string& file, unsigned int line);
|
||||
void glCheckError(const std::string& file, unsigned int line);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Make sure that GLEW is initialized
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void EnsureGlewInit();
|
||||
void ensureGlewInit();
|
||||
|
||||
} // namespace priv
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ m_height(0)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::Create(unsigned int width, unsigned int height, const Color& color)
|
||||
void Image::create(unsigned int width, unsigned int height, const Color& color)
|
||||
{
|
||||
// Assign the new size
|
||||
m_width = width;
|
||||
|
@ -67,7 +67,7 @@ void Image::Create(unsigned int width, unsigned int height, const Color& color)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::Create(unsigned int width, unsigned int height, const Uint8* pixels)
|
||||
void Image::create(unsigned int width, unsigned int height, const Uint8* pixels)
|
||||
{
|
||||
if (pixels)
|
||||
{
|
||||
|
@ -91,49 +91,49 @@ void Image::Create(unsigned int width, unsigned int height, const Uint8* pixels)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::LoadFromFile(const std::string& filename)
|
||||
bool Image::loadFromFile(const std::string& filename)
|
||||
{
|
||||
return priv::ImageLoader::GetInstance().LoadImageFromFile(filename, m_pixels, m_width, m_height);
|
||||
return priv::ImageLoader::getInstance().loadImageFromFile(filename, m_pixels, m_width, m_height);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::LoadFromMemory(const void* data, std::size_t size)
|
||||
bool Image::loadFromMemory(const void* data, std::size_t size)
|
||||
{
|
||||
return priv::ImageLoader::GetInstance().LoadImageFromMemory(data, size, m_pixels, m_width, m_height);
|
||||
return priv::ImageLoader::getInstance().loadImageFromMemory(data, size, m_pixels, m_width, m_height);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::LoadFromStream(InputStream& stream)
|
||||
bool Image::loadFromStream(InputStream& stream)
|
||||
{
|
||||
return priv::ImageLoader::GetInstance().LoadImageFromStream(stream, m_pixels, m_width, m_height);
|
||||
return priv::ImageLoader::getInstance().loadImageFromStream(stream, m_pixels, m_width, m_height);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::SaveToFile(const std::string& filename) const
|
||||
bool Image::saveToFile(const std::string& filename) const
|
||||
{
|
||||
return priv::ImageLoader::GetInstance().SaveImageToFile(filename, m_pixels, m_width, m_height);
|
||||
return priv::ImageLoader::getInstance().saveImageToFile(filename, m_pixels, m_width, m_height);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Image::GetWidth() const
|
||||
unsigned int Image::getWidth() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Image::GetHeight() const
|
||||
unsigned int Image::getHeight() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::CreateMaskFromColor(const Color& color, Uint8 alpha)
|
||||
void Image::createMaskFromColor(const Color& color, Uint8 alpha)
|
||||
{
|
||||
// Make sure that the image is not empty
|
||||
if (!m_pixels.empty())
|
||||
|
@ -152,7 +152,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)
|
||||
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.m_width == 0) || (source.m_height == 0) || (m_width == 0) || (m_height == 0))
|
||||
|
@ -160,24 +160,24 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||
|
||||
// Adjust the source rectangle
|
||||
IntRect srcRect = sourceRect;
|
||||
if (srcRect.Width == 0 || (srcRect.Height == 0))
|
||||
if (srcRect.width == 0 || (srcRect.height == 0))
|
||||
{
|
||||
srcRect.Left = 0;
|
||||
srcRect.Top = 0;
|
||||
srcRect.Width = source.m_width;
|
||||
srcRect.Height = source.m_height;
|
||||
srcRect.left = 0;
|
||||
srcRect.top = 0;
|
||||
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.m_width)) srcRect.Width = source.m_width;
|
||||
if (srcRect.Height > static_cast<int>(source.m_height)) srcRect.Height = source.m_height;
|
||||
if (srcRect.left < 0) srcRect.left = 0;
|
||||
if (srcRect.top < 0) srcRect.top = 0;
|
||||
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;
|
||||
int width = srcRect.width;
|
||||
int height = srcRect.height;
|
||||
if (destX + width > m_width) width = m_width - destX;
|
||||
if (destY + height > m_height) height = m_height - destY;
|
||||
|
||||
|
@ -190,7 +190,7 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||
int rows = height;
|
||||
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;
|
||||
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
|
||||
|
@ -231,7 +231,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)
|
||||
void Image::setPixel(unsigned int x, unsigned int y, const Color& color)
|
||||
{
|
||||
Uint8* pixel = &m_pixels[(x + y * m_width) * 4];
|
||||
*pixel++ = color.r;
|
||||
|
@ -242,7 +242,7 @@ void Image::SetPixel(unsigned int x, unsigned int y, const Color& color)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Color Image::GetPixel(unsigned int x, unsigned int y) const
|
||||
Color Image::getPixel(unsigned int x, unsigned int y) const
|
||||
{
|
||||
const Uint8* pixel = &m_pixels[(x + y * m_width) * 4];
|
||||
return Color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||
|
@ -250,7 +250,7 @@ Color Image::GetPixel(unsigned int x, unsigned int y) const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Uint8* Image::GetPixelsPtr() const
|
||||
const Uint8* Image::getPixelsPtr() const
|
||||
{
|
||||
if (!m_pixels.empty())
|
||||
{
|
||||
|
@ -258,14 +258,14 @@ const Uint8* Image::GetPixelsPtr() const
|
|||
}
|
||||
else
|
||||
{
|
||||
Err() << "Trying to access the pixels of an empty image" << std::endl;
|
||||
err() << "Trying to access the pixels of an empty image" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::FlipHorizontally()
|
||||
void Image::flipHorizontally()
|
||||
{
|
||||
if (!m_pixels.empty())
|
||||
{
|
||||
|
@ -290,7 +290,7 @@ void Image::FlipHorizontally()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::FlipVertically()
|
||||
void Image::flipVertically()
|
||||
{
|
||||
if (!m_pixels.empty())
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue