Laurent,
I was going back through some Allegro files I had written from a tutorial book a long time ago and looked at their putPixel function. Is it simply a matter of taste that you decided not to include a similar function in SFML that didn't require a buffer, or is the same amount of work most likely being done by Allegro as SFML, just with more of a straightforward wrapper? Thank you for your time.
Colton
EDIT:
Also, I noticed that using the buffer is actually much slower than drawing Rectangles that are 1 x 1 pixel in size. Perhaps I'm doing it wrong? Here's my functional code:
#include <SFML/Graphics.hpp>
#include <cstdlib>
int main()
{
// Create main window
sf::RenderWindow App(sf::VideoMode(640, 480), "SFML Graphics");
// Buffer
sf::Image buffer(640, 480, sf::Color(0, 0, 0));
// Sprite buffer
sf::Sprite bufferSprite(buffer);
// Random seed
srand(10);
int randX, randY;
int r, g, b;
App.Clear();
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
randX = rand() % 640;
randY = rand() % 480;
r = rand() % 255;
g = rand() % 255;
b = rand() % 255;
buffer.SetPixel(randX, randY, sf::Color(r, g, b));
App.Draw(bufferSprite);
// Finally, display the rendered frame on screen
App.Display();
}
return EXIT_SUCCESS;
}
The Allegro putPixel function draws the pixels at lightning speed, so I'd like to know if this would be possible somehow with SFML :]