SFML community forums

Help => Graphics => Topic started by: Tank on November 06, 2010, 06:03:24 pm

Title: glScissor() before/after/between Draw() calls
Post by: Tank 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)
Title: glScissor() before/after/between Draw() calls
Post by: Laurent on November 06, 2010, 06:18:46 pm
SFML 2?
Title: glScissor() before/after/between Draw() calls
Post by: Tank on November 06, 2010, 06:24:43 pm
Yep.
Title: glScissor() before/after/between Draw() calls
Post by: Laurent 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
Title: glScissor() before/after/between Draw() calls
Post by: Tank 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? ;)
Title: glScissor() before/after/between Draw() calls
Post by: Laurent 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.
Title: glScissor() before/after/between Draw() calls
Post by: Tank on November 06, 2010, 07:51:47 pm
I am inside a Render() method, unfortunately not in the one that needs the scissoring. ;)
Title: glScissor() before/after/between Draw() calls
Post by: Laurent 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.