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

Author Topic: A very strange case of flickering  (Read 5902 times)

0 Members and 1 Guest are viewing this topic.

praetoriaen

  • Newbie
  • *
  • Posts: 20
    • View Profile
A very strange case of flickering
« on: October 02, 2011, 12:15:02 am »
My first post here, so sorry if I'm posting in the wrong section :D

Anyway, I started using SFML to make a simple game, nothing special, just something to pass some time and learn SFML. Everything was fine until I started manipulating sprites that were already loaded. For example:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace std;


int main()
{


sf::RenderWindow App(sf::VideoMode(800, 600, 8), "I AM SLOWPOKE KING OF SLOW");

App.UseVerticalSync(true);

sf::Image Image;


sf::Sprite Sprite;

Image.LoadFromFile("slowpoke.png");
Sprite.SetImage(Image);

if(!Image.LoadFromFile("slowpoke.png"))
{
cout << "NO SLOWPOKE SPRITE PRESENT.\n";
cout << "ABORT!\n";

return 0;
}


while (App.IsOpened())
    {

sf::Event Event;

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

App.Draw(Sprite);

//ommit when posting to forum
Sprite.SetPosition(200.f, 100.f);

App.Display();

}

    return 0;
}



I get a weird flickering of the sprite's original position. BUT when I fullscreen the window or resize it, the flickering disappears and everything is as it should be. I tried it with V-Sync off but it was also flickering (albeit with a smaller frequency). I'm thinking this is a garbage problem... how can I fix it (if I'm correct, if I'm not, please help me).

Thanks in advance :)

PS will post screenshots if needed
Through passion I gain strength
Through strength I gain power
Through power I gain victory
Through victory my chains are broken
--------------------------------------------
On a scale from bloat to enterprise, how does my code rank?

praetoriaen

  • Newbie
  • *
  • Posts: 20
    • View Profile
Solved it
« Reply #1 on: October 02, 2011, 12:31:08 am »
Changed:
Code: [Select]

      App.Draw(Sprite);

      //ommit when posting to forum
      Sprite.SetPosition(200.f, 100.f);

      App.Display();

   }

    return 0;
}


to:
Code: [Select]


      App.Clear();

      App.Draw(Sprite);

      Sprite.SetPosition(200.f, 100.f);

      App.Display();

   }

    return 0;
}


and it works now... Mod, please lock this thread
Through passion I gain strength
Through strength I gain power
Through power I gain victory
Through victory my chains are broken
--------------------------------------------
On a scale from bloat to enterprise, how does my code rank?

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
A very strange case of flickering
« Reply #2 on: October 02, 2011, 12:55:46 am »
Quote
Mod, please lock this thread


??  why?

praetoriaen

  • Newbie
  • *
  • Posts: 20
    • View Profile
A very strange case of flickering
« Reply #3 on: October 02, 2011, 11:44:02 am »
I solved the problem... I mean, it's common courtesy when a problem is solved that the mod locks the thread. Or at least it was, haven't been on a proper forum in years :P
Through passion I gain strength
Through strength I gain power
Through power I gain victory
Through victory my chains are broken
--------------------------------------------
On a scale from bloat to enterprise, how does my code rank?

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
A very strange case of flickering
« Reply #4 on: October 02, 2011, 06:21:21 pm »
I don't think that was ever courtesy.  It just prevents other people from contributing.  No harm in leaving the thread open just in case.  If nobody has anything to contribute, they won't post so it'll have the same effect.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
A very strange case of flickering
« Reply #5 on: October 02, 2011, 08:43:41 pm »
Quote from: "praetoriaen"
I solved the problem... I mean, it's common courtesy when a problem is solved that the mod locks the thread. Or at least it was, haven't been on a proper forum in years :P
I've never seen this before, and I've been on web forums since NSider. In fact, this is considered rude in most places, since it prevents other people from asking for clarification, etc.
I use the latest build of SFML2

praetoriaen

  • Newbie
  • *
  • Posts: 20
    • View Profile
A very strange case of flickering
« Reply #6 on: October 02, 2011, 11:19:38 pm »
Quote from: "OniLink10"
Quote from: "praetoriaen"
I solved the problem... I mean, it's common courtesy when a problem is solved that the mod locks the thread. Or at least it was, haven't been on a proper forum in years :P
I've never seen this before, and I've been on web forums since NSider. In fact, this is considered rude in most places, since it prevents other people from asking for clarification, etc.


Oh, sorry then, my bad, as I said, I haven't been on a forum in a while :)
Through passion I gain strength
Through strength I gain power
Through power I gain victory
Through victory my chains are broken
--------------------------------------------
On a scale from bloat to enterprise, how does my code rank?

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
A very strange case of flickering
« Reply #7 on: October 03, 2011, 12:49:26 am »
S'all good.  At least you didn't delete your post after you got a solution.  That issue plagues another forum I frequent.

praetoriaen

  • Newbie
  • *
  • Posts: 20
    • View Profile
A very strange case of flickering
« Reply #8 on: October 03, 2011, 09:06:03 pm »
Quote from: "Disch"
S'all good.  At least you didn't delete your post after you got a solution.  That issue plagues another forum I frequent.


I've never had the need to delete a thread from a forum... forums exist as an archive of information, not as a quick "get solution" website. We have Yahoo answers for that :D
Through passion I gain strength
Through strength I gain power
Through power I gain victory
Through victory my chains are broken
--------------------------------------------
On a scale from bloat to enterprise, how does my code rank?

 

anything