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

Author Topic: SFML startup image  (Read 6653 times)

0 Members and 1 Guest are viewing this topic.

AdrianM

  • Newbie
  • *
  • Posts: 43
    • View Profile
SFML startup image
« on: April 03, 2009, 08:26:24 pm »
I noticed than when i create a windows before drawing anything with opengl in it i see some weird images there (memory garbage). I wonder how can this be avoided?

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
SFML startup image
« Reply #1 on: April 03, 2009, 09:03:33 pm »
Maybe what you search is sf::Renderwindow::Clear() ?
Listen to my band: pencilcase.bandcamp.com

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML startup image
« Reply #2 on: April 03, 2009, 09:21:30 pm »
You have to use Clear before closing your window. Then, your next opened window won't have some waste from old instance.
SFML / OS X developer

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
SFML startup image
« Reply #3 on: April 03, 2009, 11:06:47 pm »
Quote from: "Hiura"
You have to use Clear before closing your window. Then, your next opened window won't have some waste from old instance.


you have to use clean before "draw" and "display" anyway...

while
{
Clear
Draw
Draw
Display
}
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.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML startup image
« Reply #4 on: April 04, 2009, 12:16:09 am »
or :
draw
display
clear

Rendering is the same. :wink:
SFML / OS X developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
SFML startup image
« Reply #5 on: April 04, 2009, 12:52:21 am »
Quote from: "Hiura"
or :
draw
display
clear
But I think the other order is more intuitive, since the first frame you have to clear too - just as you don't need to clear the last frame. It's a detail, I know. ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML startup image
« Reply #6 on: April 04, 2009, 10:47:21 am »
right :)
SFML / OS X developer

AdrianM

  • Newbie
  • *
  • Posts: 43
    • View Profile
SFML startup image
« Reply #7 on: April 04, 2009, 07:20:07 pm »
Thanks!

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML startup image
« Reply #8 on: April 06, 2009, 11:34:24 pm »
Well if you know that each "frame" will draw over the entire window then you don't need to waste good ol' cpu power on clearing since the drawing will clear the window. Like for instance if you are drawing an 3D world with a skybox.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
SFML startup image
« Reply #9 on: April 07, 2009, 02:37:57 pm »
Quote from: "Nexus"
Quote from: "Hiura"
or :
draw
display
clear
But I think the other order is more intuitive, since the first frame you have to clear too - just as you don't need to clear the last frame. It's a detail, I know. ;)


Hum it's more than that. The first frame you have can be some shit from memory so you need to clean before display anything (i think).
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.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML startup image
« Reply #10 on: April 07, 2009, 02:47:09 pm »
Quote from: "Daazku"
Quote from: "Nexus"
Quote from: "Hiura"
or :
draw
display
clear
But I think the other order is more intuitive, since the first frame you have to clear too - just as you don't need to clear the last frame. It's a detail, I know. ;)


Hum it's more than that. The first frame you have can be some shit from memory so you need to clean before display anything (i think).


Back to my point. If you know you will draw over the entire display/window then you don't need to worry about clearing. ^^
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML startup image
« Reply #11 on: April 07, 2009, 02:51:51 pm »
I thought about the problem again, and the good solution (on my opinion) is :

Code: [Select]
int main... {
  /// ...
  sf::RenderWindow w(...);
  w.Clear(); // Prevent waste in memory from other app.
  /// ...
  /// Main loop event ...
  {
    // ...
    // Quit event ...
    {
      w.Clear(); // Our application does not leave waste.
      w.Close();
    }
  /// ...
/// ...
SFML / OS X developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
SFML startup image
« Reply #12 on: April 07, 2009, 03:00:04 pm »
Quote from: "Hiura"
I thought about the problem again, and the good solution (on my opinion) is :

Code: [Select]
int main... {
  /// ...
  sf::RenderWindow w(...);
  w.Clear(); // Prevent waste in memory from other app.
  /// ...
  /// Main loop event ...
  {
    // ...
    // Quit event ...
    {
      w.Clear(); // Our application does not leave waste.
      w.Close();
    }
  /// ...
/// ...


Erhm. Just cause you "Clear" doesn't mean that it will not leave waste when it exits. The "Clear" actually just paints black over it all. So actually it's just black waste instead.

The Clear function is actually a paint action that will paint the entire display into one consistent colour where the default is black.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML startup image
« Reply #13 on: April 07, 2009, 04:55:48 pm »
I don't think that this "black" is some waste. It's the default color of the screen so...

Waste is for me some non solid pattern.

But we can discuss about that during hours and hours.  :wink:
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML startup image
« Reply #14 on: April 07, 2009, 05:01:21 pm »
There is no waste, it's just a matter of properly clearing the screen before any display, so that we know that what is actually displayed is not garbage from the video memory.

So any game loop calling Clear before Draw and Display is ok. You can even remove the call to Clear if the whole window area is covered with sprites.
Laurent Gomila - SFML developer

 

anything