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

Author Topic: UseVerticalSync problem  (Read 1582 times)

0 Members and 1 Guest are viewing this topic.

mb13

  • Newbie
  • *
  • Posts: 2
    • View Profile
UseVerticalSync problem
« on: December 23, 2008, 06:13:47 pm »
Hi!

I'm quite new to C++ programming and I'm trying to make yet another pong clone :)

I've tried SDL and SFML and so far I really like the second :), but there is some problems that I can't find solution.

1. Relates to UseVerticalSync.
2. Relates to game window moving across the desktop.

1.
I've got some weird bugs when I enable UseVerticalSync.
With UseVerticalSync enabled and FrameLimit disabled everything goes ok if mouse is not moved, but if I move mouse over game screen framerate jumps to either limit (if it's enabled), either about 5000 with framelimit disabled and antialiasing enabled at 4. And what's more important the ball goes out of screen borders despite the fact that border checking is in the game loop! If I disable verticalsync or mouse is being hold still the problem disappears. I really can't figure out where's the problem, but I suppose it's in UseVerticalSync...

2.
Second problem is quite similar and occurs when I move window with mouse. If i move window long enough to ball go out of borders it's just disappearing. Is there some way to stop program execution or clock at all while moving window? Or perhaps there is some way to reset clock when moving of window stops?

I've tried sf::Sleep(1.01f) - it's not helping. The ball goes out of screen less frequently but still sometimes does.

I'm using WindowsXP and Code::Blocks with MinGW.
The code and executable is uploaded here:
http://mb13.oos.cc/web/pong.zip

VerticalSync and FrameLimit is set in main.cpp.
Game loop is in game.cpp.

Any help is appreciated.
Thanx :)
MB

mb13

  • Newbie
  • *
  • Posts: 2
    • View Profile
Partially solved
« Reply #1 on: December 24, 2008, 05:18:39 pm »
I found why the ball was moving outside the screen :)
With high framerates ball movement step is so small that sometimes it stays in zone where angle recalculation (bounce) is made and it recalculates the angle even it is not needed. So I rounded ball position to window width/height (depends where the bounce happens) each time when it's more or equal to boundaries.

But framerate with vertical sync enabled still is very jumpy. Perhaps it's graphics driver related stuff?

And I got another question:
Is there some way to continue doing stuff (draw frames, loop etc.) while window is moved across desktop?

 

anything