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

Author Topic: Newbie: Can SFML do this? (Does it have graphic Layers?)  (Read 3098 times)

0 Members and 1 Guest are viewing this topic.

mioan

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • http://www.24Hsoftware.com
Newbie: Can SFML do this? (Does it have graphic Layers?)
« on: July 20, 2009, 09:26:28 am »
Hi,
I am searching for a cross platform library for simple graphics.
I am collecting my findings here:
http://www.24hsoftware.com/DevelopersForum/CrossPlatform-C-Library.html

SFML looks a very good solution but there is something I was not able to answer by reading the site.

My screensaver has about 4 layers of graphics (excuse me for not using the most appropriate graphics terms).
Layer 0 is a static background made of a tiling image.
Layer 1 to 3 display objects either by drawing them with pixels and lines or by puting bitmaps.
Every object has x,y,Layer, speed_x, xpeed_y. (they are moving inside their layer)
Objects in higher layers should be in front of object is lower layers.

Does SFML have layers to do such operations easily?
Any code samples?

Thank you very much for any help.

Mike
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
http://www.24Hsoftware.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Newbie: Can SFML do this? (Does it have graphic Layers?)
« Reply #1 on: July 20, 2009, 09:43:38 am »
SFML doesn't have an explicit support for layers, but it can be done easily.
Laurent Gomila - SFML developer

Kingdom of Fish

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Newbie: Can SFML do this? (Does it have graphic Layers?)
« Reply #2 on: July 20, 2009, 01:15:29 pm »
All you have to do is draw each "layer" in the bottom-top order, that is, each frame you draw layer 0-3 in that order.

mioan

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • http://www.24Hsoftware.com
flicker?
« Reply #3 on: July 20, 2009, 03:35:25 pm »
Thank you for answering.

If I draw them in the sequence of the layer, the screen will flicker, right?
E.g. if an object in layer 1 is partially coverred by an object in layer 2.

Should I put the whole screen in double buffer? Isn't that too much memory and CPU load to copy the whole screen?

Sorry for asking basic questions I am new to graphics.

I wish there was a way to assign all these "tasks" to a simple graphics engine and the engine would take care  of them. This is why I am searching for a graphics library.

Mike.
P.S. The graphics I will produce are very simple. See the screenshot of the night sky here to get an idea of what I am trying to achieve:
http://www.starmessage.info/screenshots.html
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
http://www.24Hsoftware.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Newbie: Can SFML do this? (Does it have graphic Layers?)
« Reply #4 on: July 20, 2009, 03:59:20 pm »
SFML takes care of all this stuff, you don't have to worry about flickering or double-buffering. Just draw your sprites in order and that's it.
Laurent Gomila - SFML developer

mioan

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • http://www.24Hsoftware.com
That's good news.
« Reply #5 on: July 20, 2009, 05:17:51 pm »
Thank you for giving me the "lights". I will try to merge it in to my software.
Mike
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
http://www.24Hsoftware.com

 

anything