SFML community forums

Help => Window => Topic started by: AdrianM on March 16, 2009, 05:07:39 am

Title: Choppy animation & sfml
Post by: AdrianM on March 16, 2009, 05:07:39 am
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:

Code: [Select]


#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;
}
Title: Choppy animation & sfml
Post by: Laurent on March 16, 2009, 07:43:40 am
Is it still choppy if you uncomment the event loop?
Title: Choppy animation & sfml
Post by: Ceylo on March 16, 2009, 12:12:25 pm
I could not notice any stuttering/freezing on my MacBook (with or without the event loop).

I had only noticed some stuttering with vertical synchronization enabled, but here you do not use it.


Edit: I can't actually even notice any stuttering with vertical synchronization enabled with your sample.
Title: Choppy animation & sfml
Post by: Tank on March 16, 2009, 03:06:40 pm
Your sample  runs absolutely smooth on my system, with or without event loop.

I'm running Debian GNU/Linux on an amd64, GTX260 graphics card.
Title: Choppy animation & sfml
Post by: AdrianM on March 16, 2009, 05:00:14 pm
Well, i guess it's something with my system then. The stuttering only happens sometimes, not all the time.
Title: Choppy animation & sfml
Post by: Daazku on March 16, 2009, 06:59:49 pm
Maybe it depend how much your cpu is used by other program? lol..
Title: Choppy animation & sfml
Post by: eleinvisible on March 23, 2009, 03:24:50 am
Quote from: "AdrianM"
Well, i guess it's something with my system then. The stuttering only happens sometimes, not all the time.
Intel integrated "media accelerators" are terrible with OpenGL, but probably not that bad. Probably as mentioned above, other tasks running.