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

Author Topic: [Solved] Advantages in the usage of a RenderTexture  (Read 1674 times)

0 Members and 1 Guest are viewing this topic.

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
[Solved] Advantages in the usage of a RenderTexture
« on: October 02, 2012, 11:21:31 pm »
So I want to set a fixed static image that shows scores, lives and has a rectangular frame where the game will be used in. After reading the doc I thought of using a RenderTexture and after making tests so as to realize that they worked for me (I have intel graphics) and realizing they do work I chose to use the rendertexture and made it work well.


The question is: What is the optimization for using unmovable backgrounds on rendertextures? I could have perfectly done the setting of a background with a normal sprite, instead of having a sprite draw and display in the rendertexture and then having another sprite drawing in the window to make it visible. According to the doc, you are encouraged to do the latter, I'd just like to know what benefits does it give or if I am not using it properly.

I'd also like to propose the creation of a thread of general small questions. Making a thread for every detail I don't understand well isn't something I am fond with.
« Last Edit: October 03, 2012, 12:10:59 am by masskiller »
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Advantages in the usage of a RenderTexture
« Reply #1 on: October 02, 2012, 11:44:53 pm »
What is the optimization for using unmovable backgrounds on rendertextures?
I don't really understand what you want to know here (what is the optimization? ??? unmovable backgrounds? ??? ), but I hope my answer will go in the right direction...

The use of a RenderTexture is advised as soon as the static content that shall be drawn gets to a complex level. Hard to say what complex means, but for instance if you have a map generator, that needs to run once to create a map, it would be stupid to generate that map every single iteration.
But on the other hand if you have a text and a rectangle, then it doesn't nessecarily make sense to render that to a RenderTexture, since there won't be any performance issue on drawing one object (the RenderTexture) or drawing two objects (the rectangle and the text).

So the decision whether you should use a RenderTexture depends on the complexity and 'staticness' of the scene.

I'd also like to propose the creation of a thread of general small questions. Making a thread for every detail I don't understand well isn't something I am fond with.
One thread for everyone or one thread for each user?
If everyone would ask questions in one thread then we'd soon have quite a mess.

If you have many different small things to ask, then you might want to join the unofficial IRC channel. Many people hang around there and are happy to answer some of your questions. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: Advantages in the usage of a RenderTexture
« Reply #2 on: October 03, 2012, 12:10:25 am »
Quote
I don't really understand what you want to know here (what is the optimization? ??? unmovable backgrounds? ??? ), but I hope my answer will go in the right direction...

The answer did went well. I just made a bad use of words, tends to happen since my native language is spanish, not english.

Quote
But on the other hand if you have a text and a rectangle, then it doesn't nessecarily make sense to render that to a RenderTexture, since there won't be any performance issue on drawing one object (the RenderTexture) or drawing two objects (the rectangle and the text).

So in the end it's usage only makes sense when it's bound to performance.

Quote
One thread for everyone or one thread for each user?
If everyone would ask questions in one thread then we'd soon have quite a mess.

Surely, but I mean for small questions, not really issues about misplaced code or possible bugs, but rather a thread for questions about SFML itself. Things like: "Is it better to use X or Y in a given Z situation?" and the like. Then again I can almost assure it will be misused, given my experience in forums...

I didn't know about the IRC channel. I'll give it a check.

« Last Edit: October 03, 2012, 12:12:10 am by masskiller »
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

 

anything