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

Author Topic: glScissor() before/after/between Draw() calls  (Read 3859 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
glScissor() before/after/between Draw() calls
« on: November 06, 2010, 06:03:24 pm »
Hey guys,

I'm currently stuck on implementing some simple clipping I need for SFGUI. When a widget gets rendered, it's done so by running a rendering chain which consists of one or more sf::Drawables.

My natural feeling was that it should be possible to use glScissor() to enable a clipping before the first drawable gets rendered and disable it when I'm done.

However this just doesn't seem to work which I think has to do with coordinates. Since Draw() does a lot of magic and doesn't care of my manipulations with OpenGL directly, I'm asking myself if there's a solution.

To summarize: I want to clip certain Draw() calls:
- glEnable( GL_SCISSOR_TEST )
- Call Draw() for some drawables.
- glDisable( GL_SCISSOR_TEST)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
glScissor() before/after/between Draw() calls
« Reply #1 on: November 06, 2010, 06:18:46 pm »
SFML 2?
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
glScissor() before/after/between Draw() calls
« Reply #2 on: November 06, 2010, 06:24:43 pm »
Yep.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
glScissor() before/after/between Draw() calls
« Reply #3 on: November 06, 2010, 06:29:37 pm »
SFML 2 is not like SFML 1, anything that you do with OpenGL outside SFML is ignored (unless you do it inside a drawable -- but at your own risks). So if you want to have some clipping you'll have to wait until it is implemented :D
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
glScissor() before/after/between Draw() calls
« Reply #4 on: November 06, 2010, 06:34:42 pm »
:( Any progress on that yet? I guess it depends on the major rendering change for SFML, right? If so, that means it will take some time, right? ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
glScissor() before/after/between Draw() calls
« Reply #5 on: November 06, 2010, 06:57:57 pm »
I even think that I scheduled it for SFML 2.1, as it's not going to break the public API (it's a pure addition).

But like I said, if you're drawing inside the Render function of a custom sf::Drawable, maybe you can do something.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
glScissor() before/after/between Draw() calls
« Reply #6 on: November 06, 2010, 07:51:47 pm »
I am inside a Render() method, unfortunately not in the one that needs the scissoring. ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
glScissor() before/after/between Draw() calls
« Reply #7 on: November 06, 2010, 08:35:29 pm »
Ok, there's a tricky way to emulate clipping in SFML 2, but be warned: it's really ugly and inefficient. I never thought that I would have to publicly tell about it :lol:

Bascially, the idea is to use a view with a size and viewport equal to the zone that you want to clip. It doesn't support rotation, but so as glScissor.
Laurent Gomila - SFML developer

 

anything