230 FPS is great, but I have a very good PC. I'm mainly wondering if I'm doing anything wrong because I'm concerned about others who might not have a PC as good as mine.
I took eXpl0it3r's advice and put together a terrible little test program. Assuming I didn't make any mistakes, it should draw a bunch of tiny 10x10 rectangles on an 800x600 screen. This one in release mode gives me 1,200 FPS, so I'm thinking I must have done something wrong in the original program.
#include <SFML/Graphics.hpp>
#include <sstream>
class FPS
{
private:
unsigned int Frame;
unsigned int Fps;
sf::Clock FpsClock;
public:
FPS();
void update();
const unsigned int getFPS();
};
//==================================
FPS::FPS()
{
Frame = 0;
Fps = 0;
FpsClock.restart();
}
//==================================
void FPS::update()
{
if (FpsClock.getElapsedTime().asSeconds() >= 1)
{
Fps = Frame;
Frame = 0;
FpsClock.restart();
}
Frame++;
}
//==================================
const unsigned int FPS::getFPS()
{
return Fps;
}
//==================================
int main()
{
sf::RenderWindow MainWindow;
sf::ContextSettings ContextSetter(0,0,0);
const int DEFAULT_SCREEN_WIDTH = 800;
const int DEFAULT_SCREEN_HEIGHT = 600;
MainWindow.create(sf::VideoMode(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32), "Primitive Drawing Test", sf::Style::Default, ContextSetter);
sf::Event Event;
sf::VertexArray VertArray;
VertArray.setPrimitiveType(sf::Quads);
const int CELL_SIZE = 10;
int NumOfHorizontalCells = DEFAULT_SCREEN_WIDTH / CELL_SIZE;
int NumOfVerticalCells = DEFAULT_SCREEN_HEIGHT / CELL_SIZE;
FPS Fps;
bool Quit = false;
while (Quit != true)
{
Fps.update();
std::stringstream ss;
ss << Fps.getFPS();
MainWindow.setTitle("Primitive Drawing Test -- FPS: " + ss.str());
while (MainWindow.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
{
Quit = true;
}
}
MainWindow.clear(sf::Color(60, 150, 90));
VertArray.clear();
for (int x = 0; x < NumOfHorizontalCells; x++)
for (int y = 0; y < NumOfVerticalCells; y++)
{
const float xLoc = (float)x * CELL_SIZE;
const float yLoc = (float)y * CELL_SIZE;
sf::Vertex Vertices[4] =
{
sf::Vertex(sf::Vector2f(xLoc, yLoc), sf::Color::Black), //top left
sf::Vertex(sf::Vector2f(xLoc + CELL_SIZE, yLoc), sf::Color::Black),//top right
sf::Vertex(sf::Vector2f(xLoc + CELL_SIZE, yLoc + CELL_SIZE), sf::Color::Black), //bottom right
sf::Vertex(sf::Vector2f(xLoc, yLoc + CELL_SIZE), sf::Color::Black) //bottom left
};
VertArray.append(Vertices[0]);
VertArray.append(Vertices[1]);
VertArray.append(Vertices[2]);
VertArray.append(Vertices[3]);
}
MainWindow.draw(VertArray);
MainWindow.display();
}
}