1
Graphics / sf::View not working in latest SFML 2 revision?
« on: April 19, 2010, 04:21:54 pm »
Excellent! That solved all the problems in my code.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#include <SFML/Graphics.hpp>
int main(){
sf::RenderWindow app;
app.Create(sf::VideoMode(500, 500, 32), "");
sf::View view(sf::FloatRect(1, 1, 2, 2));
app.SetView(view);
sf::Shape rect = sf::Shape::Rectangle(1, 1, 2, 2, sf::Color(250,0,0));
while (app.IsOpened()){
sf::Event event;
while (app.GetEvent(event)){
if (event.Type == sf::Event::Closed) app.Close();
}
app.Clear();
app.Draw(rect);
app.Display();
}
return EXIT_SUCCESS;
}
#include <SFML/Graphics.hpp>
int main(){
sf::RenderWindow window(sf::VideoMode(640, 480, 32), "");
sf::RenderImage buffer;
buffer.Create(640, 480);
sf::Sprite bufsprite;
bufsprite.SetImage(buffer.GetImage());
sf::Image image; image.Create(1, 1);
sf::Sprite sprite(image);
int mode = 0;
while (window.IsOpened()){
sf::Event event;
while (window.GetEvent(event)){
if (event.Type == sf::Event::KeyPressed){
if (event.Key.Code == sf::Key::Escape) window.Close();
else if (event.Key.Code == sf::Key::Space) mode = 1-mode;
}
}
buffer.Clear();
if (mode == 0){
buffer.Draw(sprite);
buffer.Draw(sf::Shape::Rectangle(0, 0, 200, 200, sf::Color(0,0,255)));
}else{
//buffer.Draw(sprite);
buffer.Draw(sf::Shape::Rectangle(0, 0, 200, 200, sf::Color(255,0,0)));
}
buffer.Display();
window.Draw(bufsprite);
window.Display();
}
return EXIT_SUCCESS;
}