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

Author Topic: Completely Resetting GL States  (Read 1981 times)

0 Members and 1 Guest are viewing this topic.

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Completely Resetting GL States
« on: December 30, 2015, 05:33:01 am »
Hello! I am currently working on upgrading my UI library (Coherent GT) and am running into a problem with rendering SFML stuff after calling the UI rendering function. I am passing a SFML created texture to the UI library, it renders to the texture and then I use that texture with a sf::Sprite. At least that is how it should work.

Right now it doesn't render anything after calling the UI paint function; however, I have verified that it correctly rendering to the texture (saved it to file). This has lead me to believe that there is something wrong with the GL state after the paint func. I am calling resetGLStates() after the paint func but it seems to be missing something. One really interesting thing about all of this is that sfml rendering works with the next frame.

The UI documentation is pretty good and they list out which GL states are changing but I'm not sure which ones SFML truly cares about. I was hoping I may get some guidance here. If not that is ok. I appreciate the help regardless. Thanks!

Coherent GT Rendering Documentation

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Completely Resetting GL States
« Reply #1 on: December 31, 2015, 11:27:58 pm »
Since Coherent seems to be self-contained (i.e. performs all of the state set up it needs itself as part of the render call), you can just create an auxiliary sf::Context object that you activate whenever you render with Coherent. sf::Texture objects are shared between all SFML contexts, so you can render to it in one and use it in another (such as the sf::RenderTarget's own context). You won't even have to clean up after Coherent is done, all state changes within the auxiliary context are isolated to it, so it won't bother anybody else. If there was a way for you to tell Coherent that you didn't touch any of its states since the last render, it could save even more time, but it doesn't seem like such a thing is available, Coherent just clobbers the current state every render no matter what.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

jmcmorris

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Completely Resetting GL States
« Reply #2 on: January 09, 2016, 07:07:02 pm »
Hey Binary, you are always so helpful! Thank you! What you said did just the trick. <3

 

anything