Jump to content
  • Advertisement
Sign in to follow this  
ms75214

solid background in sfml

This topic is 2504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Sf::RenderWindow::Clear(sf::Color Color);

That will clear the screen with the given color. So, it'd be used like this:


sf::RenderWindow App(sf::VideoMode(u32ScreenX, u32ScreenY, 32), "Game", sf::Style::Fullscreen);
.
.
.
// Clear to Green background
App.Clear(sf::Color(0, 200, 0, 255));

Share this post


Link to post
Share on other sites
The creator of SFML provides a basic tutorial on using render windows which covers this if you'd like a little more information -- it also covers an easy way of taking screen-shots from your application.

You can find all of the tutorials for the current version of SFML HERE; they're pretty basic, but they do cover the basics of everything the API can do. From there you're left on your own to turn that knowledge into an actual game.


Hope that's helpful! smile.png

Share this post


Link to post
Share on other sites

Sf::RenderWindow::Clear(sf::Color Color);

That will clear the screen with the given color. So, it'd be used like this:


sf::RenderWindow App(sf::VideoMode(u32ScreenX, u32ScreenY, 32), "Game", sf::Style::Fullscreen);
.
.
.
// Clear to Green background
App.Clear(sf::Color(0, 200, 0, 255));



when i said solid i meant an image with no holes.

Share this post


Link to post
Share on other sites
In that case, just draw a sprite; if you find later on that you're having performance problems and that drawing your background is a major cause of those problems you can look into faster ways of drawing your background.

Unless you already know from past experience that a particular technique will be a performance problem and that it is avoidable by choosing a different technique you should just do something that works and then fix it if your program is too slow and a profiler identifies the technique in question as a cause.


Displaying a large sprite as the background shouldn't be a problem for games of simple-to-medium complexity unless your window is pretty large. I'm not sure how sprites are implemented in SFML, but if you identify the drawing of your background as a problem some potential improvements might include cutting your background up into a series of smaller sprites (to avoid re-drawing the whole background when only a small section really needs to be done) or using OpenGL calls rather than the sprite class provided by SFML.


TL;DR:
Just draw a large sprite. If you then find it's too slow for your game you can investigate possible improvements.


Hope that helps! smile.png

Share this post


Link to post
Share on other sites

I'm not sure how sprites are implemented in SFML, but if you identify the drawing of your background as a problem some potential improvements might include cutting your background up into a series of smaller sprites (to avoid re-drawing the whole background when only a small section really needs to be done) or using OpenGL calls rather than the sprite class provided by SFML.



SFML uses OpenGl to draw all it's sprites.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!