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

Author Topic: Proper ways of handling GL states with mixed rendering  (Read 2691 times)

0 Members and 1 Guest are viewing this topic.

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Proper ways of handling GL states with mixed rendering
« on: March 20, 2012, 03:53:03 pm »
When using sfml with mixed rendering, as in you have your own implemented openGL rendering which happens before or/and after calls to the sfml draw() method, it might often mess things up. For instance I know many people who use sfml to handle events/creating a window and drawing text while taking care of the rest of the rendering by themselves. Most if not all of those people have run into problems with the text not displaying properly, or their own rendering breaking after trying to draw text. I myself too have had problems with this. Apparently this is due to openGL states becoming changed and not reset by the draw method.

This seems to me as a quite big limitation when you want to use sfml in any project which needs any form of rendering which is not able to do with the sfml shapes/sprites classes and this is not a rare case. Even now, knowing this problem I still don't know how to handle it properly; which states to set before and after the draw method and it is often frustrating to solve.

What is the thought behind this behaviour and is it fixable? Perhaps it is intended even? To me it would make sense that sfml would set the things it needs for rendering, and then reset it back to the states they had to not conflict with other components. If this would add too much of an overhead, perhaps the RenderWindow could have a flag for it? Or as the very least, would this be documented so that the users would properly know which states they should themselves reset after calling the sfml draw method? It is a way too common problem.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Proper ways of handling GL states with mixed rendering
« Reply #1 on: March 20, 2012, 04:15:14 pm »
SFML 1 or 2?
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Proper ways of handling GL states with mixed rendering
« Reply #2 on: March 20, 2012, 05:08:47 pm »
2.0. One of the latest snapshots from after the naming convention change.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Proper ways of handling GL states with mixed rendering
« Reply #3 on: March 20, 2012, 06:00:38 pm »
If you use push/popGlStates(), it should be ok, isn't it?
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Proper ways of handling GL states with mixed rendering
« Reply #4 on: March 20, 2012, 06:42:00 pm »
Nope. There seems to be problems with the push/pop in that case. Those are intended to fix everything? Like, with push before, and pop after, the sfml rendering will work and leave no traces to break other stuff? Because that's not what's happening. :/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Proper ways of handling GL states with mixed rendering
« Reply #5 on: March 20, 2012, 08:15:04 pm »
Yes, it should work (that's what their doc says, no?).

If not, please post a complete and minimal example that reproduces the problem.
Laurent Gomila - SFML developer

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Proper ways of handling GL states with mixed rendering
« Reply #6 on: March 21, 2012, 05:51:11 pm »
Alright. I will try to get such an example up whenever I get time to. Will post here then. :)

 

anything