Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Choppy animation & sfml  (Read 3275 times)

0 Members and 1 Guest are viewing this topic.

AdrianM

  • Newbie
  • *
  • Posts: 43
    • View Profile
Choppy animation & sfml
« 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;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32502
    • View Profile
    • SFML's website
    • Email
Choppy animation & sfml
« Reply #1 on: March 16, 2009, 07:43:40 am »
Is it still choppy if you uncomment the event loop?
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Choppy animation & sfml
« Reply #2 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.
Want to play movies in your SFML application? Check out sfeMovie!

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1483
    • View Profile
    • Blog
    • Email
Choppy animation & sfml
« Reply #3 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.

AdrianM

  • Newbie
  • *
  • Posts: 43
    • View Profile
Choppy animation & sfml
« Reply #4 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.

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
Choppy animation & sfml
« Reply #5 on: March 16, 2009, 06:59:49 pm »
Maybe it depend how much your cpu is used by other program? lol..
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
Choppy animation & sfml
« Reply #6 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.