Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#Actualphantom

Posted 06 April 2013 - 11:17 AM

Hey guys, I just started with the C++ library: SFML and while making my game-loop I noticed something disturbing.
 
Relevant part of the Header:
public:
    virtual const sf::Texture Draw();
protected:
    sf::RenderTexture sb;
 
When I try to call the "Draw" method I use this code:
currentRenderScreen->Draw();
 
Which do this:
const sf::Texture RenderScreen::Draw() {
    return sb.getTexture();
}
 
The reason I use a RenderTexture is because I want to draw multiple sprites and images on a texture, and then display the texture as it's whole (I think it's called backbuffer?). And I need to return a "Texture" to be able to draw it in my window.
However it's extremely slow if my "RenderTexture sb" is normally big (800 width 600 height), around 200 milliseconds per call (110 on my friend's computer), if the object sb is 100 px wide and 100 high or smaller it only takes a handful milliseconds to call.
 
I'm pretty sure I'm doing something wrong as using a RenderTexture should be the optimal way to draw stuff in a game?
If it really is this heavy to use, is there any better alternative?

: Reverting this back to the main post as it has an answer.


#2Equivalent

Posted 06 April 2013 - 10:59 AM

Sorry, I posted it in the wrong section

New post: http://www.gamedev.net/topic/641406-sfml-rendertexture-slow-performance/


#1Equivalent

Posted 06 April 2013 - 10:20 AM

Hey guys, I just started with the C++ library: SFML and while making my game-loop I noticed something disturbing.

 

Relevant part of the Header:

public:
    virtual const sf::Texture Draw();
protected:
    sf::RenderTexture sb;

 

When I try to call the "Draw" method I use this code:

currentRenderScreen->Draw();

 

Which do this:

const sf::Texture RenderScreen::Draw() {
    return sb.getTexture();
}

 

The reason I use a RenderTexture is because I want to draw multiple sprites and images on a texture, and then display the texture as it's whole (I think it's called backbuffer?). And I need to return a "Texture" to be able to draw it in my window.

However it's extremely slow if my "RenderTexture sb" is normally big (800 width 600 height), around 200 milliseconds per call (110 on my friend's computer), if the object sb is 100 px wide and 100 high or smaller it only takes a handful milliseconds to call.

 

I'm pretty sure I'm doing something wrong as using a RenderTexture should be the optimal way to draw stuff in a game?

If it really is this heavy to use, is there any better alternative?


PARTNERS