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

Author Topic: RenderTexture passes its texture ovenership to Texture  (Read 8934 times)

0 Members and 1 Guest are viewing this topic.

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
RenderTexture passes its texture ovenership to Texture
« on: August 26, 2014, 06:35:21 pm »
Hello.
Id like to request a possibility of sf::RenderTexture swapping ownership of its texture with sf::Texture.
Reasons being,
Code: [Select]
std::cout << sizeof(sf::RenderTexture) << std::endl;//488
std::cout << sizeof(sf::Texture) << std::endl;//32
My thought are that RenderTexture was supposed to be used as a drawing board and sf::Texture would be the paper that you actually draw on.

Related to topics:
http://en.sfml-dev.org/forums/index.php?topic=16178.0
http://en.sfml-dev.org/forums/index.php?topic=16174.0
Is it possible to expect such a feature?
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #1 on: August 26, 2014, 06:48:38 pm »
what do you mean by 'swapping ownership'?
and i think sf::Texture would be the drawing itself, not a paper where you draw.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #2 on: August 26, 2014, 06:50:15 pm »
Copying (moving) a RenderTexture to a Texture is not enough?
Not sure I understand what you need/want that cannot already be done..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #3 on: August 26, 2014, 07:59:55 pm »
Would be nice to explain why you want such a feature.
Laurent Gomila - SFML developer

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #4 on: August 26, 2014, 08:51:14 pm »
Copying (moving) a RenderTexture to a Texture is not enough?
Not sure I understand what you need/want that cannot already be done..
Moving renderTexture to texture, is that possible? i tested, and failed to accomplish that.
Example please.

Would be nice to explain why you want such a feature.
It looks like the "feature already exists" i just failed to see it.

what do you mean by 'swapping ownership'?
and i think sf::Texture would be the drawing itself, not a paper where you draw.
I mean that i cannot extract the texture from sf::RenderWindow to sf::Texture.
The sf::RenderTexture has to have the texture pointer in GPU, texture has none and is in "invalid" state by default afaik.
Setting sf::Texture texture to sf::RenderTexture texture (meaning now they share it)
Then sf::RenderTexture texture to nothing. Meaning we swapped ownership of texture from sf::RenderTexture to sf::Texture without having to copy the texture around.
« Last Edit: August 26, 2014, 08:57:27 pm by BaneTrapper »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #5 on: August 26, 2014, 08:54:48 pm »
Copying is posible and if SFML 3.0 adds a move constructor and move assignment operator then we'll be all set for moving :)
But (besides performance implications) why is copying not enough? What super critical/performances sensitive operation are you doing?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #6 on: August 26, 2014, 09:20:16 pm »
Quote
Copying is posible and if SFML 3.0 adds a move constructor and move assignment operator then we'll be all set for moving
You can't move a const texture.
Laurent Gomila - SFML developer

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #7 on: August 26, 2014, 09:21:43 pm »
Argh. My bad. I'm an idiot. I forgot that it is const.
Sorry.
« Last Edit: August 26, 2014, 09:33:34 pm by Jesper Juhl »

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #8 on: August 27, 2014, 07:17:52 pm »
I no longer require such feature, tho having it would be improvement to performance.
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #9 on: August 28, 2014, 08:34:08 am »
Also, copying (or even moving) an internally managed resource out of sf::RenderWindow sounds like a really bad idea. Instead I'd suggest something like this:

sf::Texture texture;
sf::RenderTexture renderTexture(texture);

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: RenderTexture passes its texture ovenership to Texture
« Reply #10 on: August 28, 2014, 02:15:22 pm »
sf::RenderTexture renderTexture(texture);
What does this do?  :o
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #11 on: August 28, 2014, 02:17:27 pm »
Isn't it clear?

The render texture will instead of creating its own internal texture would use the texture passed in the overloaded constructor as the target for draw calls.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture passes its texture ovenership to Texture
« Reply #12 on: August 28, 2014, 02:29:18 pm »
This would be almost equivalent to the current code (the only difference is that you can change the texture properties before passing it to the RenderTexture). A more useful version would be a setTexture function, so that you can use the same RenderTexture to draw on multiple textures. But I wonder what kind of problem this would solve...
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: RenderTexture passes its texture ovenership to Texture
« Reply #13 on: August 28, 2014, 02:33:28 pm »
Isn't it clear?
It is not clear. It looks obvious, sure, but I wouldn't want to use it on an assumption.
I did try to find information on this in the documentation but, alas, I could not find any.
Does the render texture make a copy of the texture or point to the actual one?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: RenderTexture passes its texture ovenership to Texture
« Reply #14 on: August 28, 2014, 02:57:14 pm »
Does the render texture make a copy of the texture or point to the actual one?
I take from the discussion that it will simply point to the actual one, hence the equivalence to a .setTexture() method that is already part of some other classes. I can already see all the "white square RenderTexture" threads rolling in ::).
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).