SDL_RenderSetClipRect()/SDL_RenderGetClipRect()

FYI, I’m adding clip (scissor) functionality to the SDL render API.

It doesn’t work completely yet, so yell if you have any quick fixes. I’m
moving to a new house tomorrow so I probably won’t get back to this for a
few days.

Thanks to Nate Fries for the first implementation of this functionality.

Cheers!

2013/5/4 Sam Lantinga

FYI, I’m adding clip (scissor) functionality to the SDL render API.

It doesn’t work completely yet, so yell if you have any quick fixes. I’m
moving to a new house tomorrow so I probably won’t get back to this for a
few days.

Thanks to Nate Fries for the first implementation of this functionality.

Cheers!

_

Two things that come up, comparing to the patch I had submitted here:
http://bugzilla.libsdl.org/attachment.cgi?id=1054&action=diff
(GL*_ScissorRegion
functions)

The definition of glScissor says: “glScissor defines a rectangle, called
the scissor box, in window coordinates. The first two arguments, x and y,
specify the lower left corner of the box. width and height specify the
width and height of the box.”

So, my first comment is, why are the coordinates scaled
in SDL_RenderSetClipRect ? Should you be passing windows coordinates there,
or something else?

Second, I think we have the convention that the rect’s x,y coordinates mean
the left,top in SDL. If that’s the case, there needs to be a conversion to
the coordinates GL uses, for example I used:

static int GL_ScissorRegion(SDL_Renderer * renderer, const SDL_Rect *region)
{
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
int w_width, w_height;
SDL_GetWindowSize(renderer->window, &w_width, &w_height);
data->glScissor(region->x, w_height - (region->y + region->h), region->w,
region->h);
return 0;
}–
Gabriel.

I am glad you’re finally getting to this! :D------------------------
Nate Fries