The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_RenderSetClipRect()/SDL_RenderGetClipRect()
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
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!
SDL_RenderSetClipRect()/SDL_RenderGetClipRect()
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2013/5/4 Sam Lantinga
Quote:
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.
Nathaniel J Fries


Joined: 30 Mar 2010
Posts: 444
I am glad you're finally getting to this! Very Happy