SFML logo SFML forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

screen flicker - vsync or double buffering

 
Post new topic   Reply to topic    SFML Forum Index -> General discussions
View previous topic :: View next topic  
Author Message
armage
Level-0
Level-0


Joined: 18 Feb 2008
Posts: 10

PostPosted: Tue Feb 19, 2008 7:16 pm    Post subject: screen flicker - vsync or double buffering Reply with quote

Hi,

My screen has a slight flicker due to the difference in refresh rates when I alternate the display of two sprites. This makes the rendering look a bit choppy.

How do I turn on vsync?

Some people use double buffering, check out this link
http://www.idevgames.com/forum/showthread.php?t=6750&page=2
http://www.esreality.com/?a=longpost&id=522789&page=1
Back to top
View user's profile Send private message
dabo
Level-3
Level-3


Joined: 16 Sep 2007
Posts: 257
Location: Sweden

PostPosted: Tue Feb 19, 2008 7:52 pm    Post subject: Reply with quote

Code:
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
App.UseVerticalSync(true);
Back to top
View user's profile Send private message Visit poster's website
armage
Level-0
Level-0


Joined: 18 Feb 2008
Posts: 10

PostPosted: Tue Feb 19, 2008 8:27 pm    Post subject: Reply with quote

Thank you for your reponse. I tried your suggestion but there is no response.

How do I enable double buffering?
Back to top
View user's profile Send private message
zarka
Level-1
Level-1


Joined: 20 Aug 2007
Posts: 81
Location: Sweden

PostPosted: Tue Feb 19, 2008 8:58 pm    Post subject: Reply with quote

i belive SFML uses double buffering by default ...

and if UseVerticalSync(true) didn't do anything you have most likely disabled v-sync in your graphics card drivers. You will probably be able to change v-sync settings in the settings program for your graphics driver.
_________________
//Zzzarka
Back to top
View user's profile Send private message
armage
Level-0
Level-0


Joined: 18 Feb 2008
Posts: 10

PostPosted: Tue Feb 19, 2008 9:20 pm    Post subject: Reply with quote

I tried looking up some GLUT double buffering examples. It is working on my computer with no flicker and seems pretty smooth.

In GLUT there is a way to initialize double buffering. How do I code double buffering anyway?
Back to top
View user's profile Send private message
armage
Level-0
Level-0


Joined: 18 Feb 2008
Posts: 10

PostPosted: Tue Feb 19, 2008 9:51 pm    Post subject: Reply with quote

Just one question, when I do

Code:

sf::RenderWindow App;

App.Create(sf::VideoMode(1280, 768, 32), "SFML Window",sf::Style::Fullscreen, 4);


Is this using the win32?

Meaning, did stuff like:
Code:
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
              PFD_DOUBLEBUFFER;
SwapBuffers( hDC );
Back to top
View user's profile Send private message
Laurent
Administrator
Administrator


Joined: 30 May 2007
Posts: 8386
Location: Metz, France

PostPosted: Wed Feb 20, 2008 1:37 am    Post subject: Reply with quote

You shouldn't care about internal behaviour of SFML. Of course it's using double-buffering, and of course it's using all the Win32 stuff it needs.

You should rather show us your code, and if possible, upload a compiled version of your app so that we can see what happens.
_________________
Laurent Gomila - SFML developer
Back to top
View user's profile Send private message Send e-mail Visit poster's website
retrogamer4ever
Level-0
Level-0


Joined: 06 May 2009
Posts: 6

PostPosted: Wed May 27, 2009 5:52 pm    Post subject: I still get a bit of flicker.... Reply with quote

I still see a bit of flickering, or it could just be that i am crazy... Here is my code
Code:

#include "stdafx.h"
#include "sfml.h"

using namespace sf;

int main()
{
   // Create the main window
   RenderWindow App(VideoMode(616, 387, 32), "SFML Window");
   App.UseVerticalSync(true);
   
   Image img_background;
   if(!img_background.LoadFromFile("c://background.png"))
      return -1;
   
   Image img_ball;
   if(!img_ball.LoadFromFile("c://ball.png"))
      return -1;

   Sprite background(img_background);
   Sprite ball(img_ball);

   ball.SetY(325);
   
   while (App.IsOpened())
   {   
      Event Event;

      while (App.GetEvent(Event))
      {
         if (Event.Type == Event::Closed)
            App.Close();

         if ((Event.Type == Event::KeyPressed) && (Event.Key.Code == Key::Escape))
            App.Close();
      }

      if (App.GetInput().IsKeyDown(Key::Right)) ball.Move(100, 0);
      if (App.GetInput().IsKeyDown(Key::Left))  ball.Move(-100, 0);

      App.Clear();
      App.Draw(background);
      App.Draw(ball);
      
      App.Display();
   }

    return EXIT_SUCCESS;
}



I basically just had two simple images, one background image colored red that was the size of the window, and a white ball image that I moved back and forth... The white ball tends to flicker sometimes though. Any idea why it would? I have solved this flickering issue in the past by just preforming some double buffering, but doesn't seem like you can easily add sprites with in sprites. Any idea what I might be doing wrong? Or is the flickering all in my head Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SFML Forum Index -> General discussions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Anti Bot Question MOD - phpBB MOD against Spam Bots
Blocked registrations / posts: 3306 / 0