I was playing with sfml the other day and found something rather peculiar.
I've written a small amount of code and watch it run for a 2-3 minutes: it shows a moving quad on screen. The moving quad sometimes stutters/freezes for a small amount of time. I've tested the code on windows and it freezes less often on my desktop system (GF 9600GT, 4GB RAM, intel pentium quadcore 2.4ghz) than on my macbook(2.1ghz intel pentium core 2 duo, 1gb sdram). On my macbook it stutters/freezes quite annoying and this is also present in a breakout clone i'm developing.
I've also checked the forums and notice someone else may have found the same issue, he called it: sfml is bucking.
I'm wondering what could be the cause of this.
Here's a minimal and complete example that i used to observe the problem:
#include <SFML/Graphics.hpp>
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
sf::WindowSettings as;
as.DepthBits = 8;
sf::RenderWindow* pApplication = new sf::RenderWindow;
pApplication->Create(sf::VideoMode(800, 600, 32),
"Ch-ch-choppy",sf::Style::Fullscreen,as);
bool isRunning = true;
while (isRunning && pApplication->IsOpened())
{
/*
sf::Event Event;
while (pApplication->GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed :
pApplication->Close();
break;
case sf::Event::KeyPressed :
{
if (Event.Key.Code == sf::Key::Escape)
isRunning = false;
}
break;
}
}*/
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.0f, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -6.0f);
static float timer = 0.0f;
timer += pApplication->GetFrameTime();
glTranslatef( sin(timer*4)*2, 0.0f, 0.0f);
float d = 0.4f;
glBegin(GL_QUADS);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex2f(-d, -d);
glColor3f(0.0f, 1.0f, 1.0f);
glVertex2f(d, -d);
glColor3f(1.0f, 1.0f, 0.0f);
glVertex2f(d, d);
glColor3f(1.0f, 0.0f, 1.0f);
glVertex2f(-d, d);
glEnd();
pApplication->Display();
}
delete pApplication;
}