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

Author Topic: RenderTexture won't clear properly  (Read 39776 times)

0 Members and 1 Guest are viewing this topic.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: RenderTexture won't clear properly
« Reply #45 on: April 28, 2014, 05:45:30 pm »
I tried out eXpl0it3r's test set up and it caused the same problem for me (just installed catalyst 14.4).

So having CodeXL at my disposal, I fired it up and checked the texture that was being rendered to. It was being cleared as expected... So the problem clearly wasn't that the RenderTexture wasn't clearing properly... it was something else.

I then went ahead and checked the default front- and backbuffers of the RenderWindow, and what do you know... they weren't being cleared, so it's really not the RenderTexture's fault.

Knowing that GL can get quite sensitive in certain situations, I just tried stuff out, and it seems that a resetGLStates() before clearing the RenderWindow fixed it. Then I went ahead and checked which call inside resetGLStates() would fix the problem. It seems that the RenderWindow won't clear properly if the texture that is used as the color attachment of the RenderTexture isn't unbound. A simple setTexture(NULL) inside the clear() method already fixes the problem. I don't know how the driver chose to do things, but it might be trying to access the texture in the RenderWindow's context while it was being written to in the RenderTexture's context, so unbinding it seems to have solved the problem.

I was going to fix it, but I didn't know where to and if calling setTexture(NULL) is the best solution for this problem. It has to be done somewhere, but it could decrease performance by incurring an extra bind per frame (if done while clearing) in the rare case that the user's code only uses a single texture ;). This is amortized when more textures are bound every frame. I can push a fix for this if Laurent agrees to unbind in clear.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture won't clear properly
« Reply #46 on: April 28, 2014, 07:18:56 pm »
This is not the cleanest fix ever, but I don't think it will ruin anyone's performances, so let's go for it. Good catch!
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: RenderTexture won't clear properly
« Reply #47 on: April 28, 2014, 07:49:35 pm »
Implemented this fix and a fix for issue #523 here. It just needs to be reviewed, merged and the issue closed ;).
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

kryx

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: RenderTexture won't clear properly
« Reply #48 on: June 12, 2014, 11:56:58 pm »
Up, I need really this update!

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: RenderTexture won't clear properly
« Reply #49 on: June 13, 2014, 12:33:27 am »
Up, I need really this update!

Uhhuh.... what do you expect us to do? It is fixed so go get it yourself.......... Or did you happen to not even bother to read the thread??  :P
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

kryx

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: RenderTexture won't clear properly
« Reply #50 on: June 13, 2014, 10:21:51 am »
It is fixed, but not merged to project. I work in jsfml and I canno't rebuild all versions of sfml, bot windows 32/64, mac , linux, etc... So I need an official update with this merge :/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture won't clear properly
« Reply #51 on: June 13, 2014, 12:07:54 pm »
And what? We're going to release SFML 2.2 right now because you up'd this topic? :P
Laurent Gomila - SFML developer

kryx

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: RenderTexture won't clear properly
« Reply #52 on: June 14, 2014, 08:13:19 pm »
no no, I don't need the sfml 2.2, but i read that "needs to be reviewed, merged and the issue closed".

So I only wait a review and a merge... But if merge mean release sfml 2.2, a review is nice :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture won't clear properly
« Reply #53 on: June 14, 2014, 08:59:11 pm »
It's available anyway. What difference does it make if it's in its own unmerged branch, or in master? Are you afraid it is not stable until reviewed and merged?
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: RenderTexture won't clear properly
« Reply #54 on: June 15, 2014, 03:18:10 am »
It was already merged a while ago: e6b5ce1f27d22aa0150c1376550b2e3f1baec09a
It can be considered as stable as a version bump release.
Grab the latest master, build and enjoy.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

kryx

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: RenderTexture won't clear properly
« Reply #55 on: June 16, 2014, 04:02:59 pm »
Thanks a lot.
yes, while this is not merged, I prefer not take it, to avoid bug due to this code.
But now it is merge, I'll take it, sure^^

 

anything