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

Author Topic: screen flicker - vsync or double buffering  (Read 17389 times)

0 Members and 1 Guest are viewing this topic.

armage

  • Newbie
  • *
  • Posts: 10
    • View Profile
screen flicker - vsync or double buffering
« on: February 19, 2008, 08:16:50 pm »
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

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
screen flicker - vsync or double buffering
« Reply #1 on: February 19, 2008, 08:52:12 pm »
Code: [Select]
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
App.UseVerticalSync(true);

armage

  • Newbie
  • *
  • Posts: 10
    • View Profile
screen flicker - vsync or double buffering
« Reply #2 on: February 19, 2008, 09:27:22 pm »
Thank you for your reponse. I tried your suggestion but there is no response.

How do I enable double buffering?

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
screen flicker - vsync or double buffering
« Reply #3 on: February 19, 2008, 09:58:41 pm »
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

armage

  • Newbie
  • *
  • Posts: 10
    • View Profile
screen flicker - vsync or double buffering
« Reply #4 on: February 19, 2008, 10:20:06 pm »
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?

armage

  • Newbie
  • *
  • Posts: 10
    • View Profile
screen flicker - vsync or double buffering
« Reply #5 on: February 19, 2008, 10:51:23 pm »
Just one question, when I do

Code: [Select]

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: [Select]
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
              PFD_DOUBLEBUFFER;
SwapBuffers( hDC );

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
screen flicker - vsync or double buffering
« Reply #6 on: February 20, 2008, 02:37:18 am »
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

retrogamer4ever

  • Newbie
  • *
  • Posts: 6
    • View Profile
I still get a bit of flicker....
« Reply #7 on: May 27, 2009, 07:52:33 pm »
I still see a bit of flickering, or it could just be that i am crazy... Here is my code
Code: [Select]

#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 :-P

 

anything