1
Graphics / Re: Fullscreen + Antialiasing = Slow
« on: September 20, 2013, 03:50:01 pm »
The code I used, to test it is:
#include <SFML/System.hpp>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include<stdio.h>
int main()
{ bool fullscreen;
std::cout<< "fullscreen"<< std::endl;
std::cin>> fullscreen;
int antialiasing;
std::cout<< "antialiasing"<< std::endl;
std::cin>> antialiasing;
sf::ContextSettings context;
context.antialiasingLevel = antialiasing;
std::vector<sf::VideoMode> modes;
modes = sf::VideoMode::getFullscreenModes();
sf::RenderWindow App;
if(!fullscreen)
App.create(sf::VideoMode(800,600),"Window",6,context);
else
App.create(modes[0],"Fullscreen",sf::Style::Fullscreen,context);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock Clock;
float t0;
float t;
sf::Font font;
if (!font.loadFromFile("C:/WINDOWS/Fonts/Arial.ttf"))
return EXIT_FAILURE;
while (App.isOpen())
{
t = Clock.getElapsedTime().asSeconds();
float tm = t-t0;
t0 = Clock.getElapsedTime().asSeconds();
//static int counter = 0;
//if(++counter % 100 == 0) std::cout<<1/tm<<std::endl;
sf::Event event;
while (App.pollEvent(event))
{
if (event.type == sf::Event::Closed)
App.close();
if (event.type == sf::Event::KeyPressed)
App.close();
}
char show_time[64];
sprintf(show_time,"Antialiasing %d FPS %f",antialiasing, 1/tm);
sf::Text Text(show_time, font);
Text.setPosition(50, 500);
Text.setColor(sf::Color(128, 128, 0));
App.draw(Text);
App.clear();
App.draw(Text);
App.draw(shape);
App.display();
}
return 0;
}
#include <SFML/System.hpp>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include<stdio.h>
int main()
{ bool fullscreen;
std::cout<< "fullscreen"<< std::endl;
std::cin>> fullscreen;
int antialiasing;
std::cout<< "antialiasing"<< std::endl;
std::cin>> antialiasing;
sf::ContextSettings context;
context.antialiasingLevel = antialiasing;
std::vector<sf::VideoMode> modes;
modes = sf::VideoMode::getFullscreenModes();
sf::RenderWindow App;
if(!fullscreen)
App.create(sf::VideoMode(800,600),"Window",6,context);
else
App.create(modes[0],"Fullscreen",sf::Style::Fullscreen,context);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock Clock;
float t0;
float t;
sf::Font font;
if (!font.loadFromFile("C:/WINDOWS/Fonts/Arial.ttf"))
return EXIT_FAILURE;
while (App.isOpen())
{
t = Clock.getElapsedTime().asSeconds();
float tm = t-t0;
t0 = Clock.getElapsedTime().asSeconds();
//static int counter = 0;
//if(++counter % 100 == 0) std::cout<<1/tm<<std::endl;
sf::Event event;
while (App.pollEvent(event))
{
if (event.type == sf::Event::Closed)
App.close();
if (event.type == sf::Event::KeyPressed)
App.close();
}
char show_time[64];
sprintf(show_time,"Antialiasing %d FPS %f",antialiasing, 1/tm);
sf::Text Text(show_time, font);
Text.setPosition(50, 500);
Text.setColor(sf::Color(128, 128, 0));
App.draw(Text);
App.clear();
App.draw(Text);
App.draw(shape);
App.display();
}
return 0;
}