Page 1 of 1

SDL Culling?

Posted: Fri Oct 07, 2011 5:33 pm
by treyrust
I've read that SDL does culling for you? Image

I haven't found anything to back it up though... Does anyone here know about the it? From what I've researched, most people don't seem to know much about how some internal SDL stuff works (the infamous SDL_Surface copy problem, which is solved with "++surface->refcount;" on the copied surface... It's just by luck that I found that, most people blamed the programmers...)

http://www.libsdl.org/cgi/docwiki.cgi/SDL_BlitSurface << That's the SDL doc on SDL_BlitSurface.
Blits with negative dstrect coordinates will be clipped properly.
So, what exactly does that mean?

Re: SDL Culling?

Posted: Fri Oct 07, 2011 6:14 pm
by dandymcgee
treyrust wrote:I've read that SDL does culling for you? Image

I haven't found anything to back it up though... Does anyone here know about the it? From what I've researched, most people don't seem to know much about how some internal SDL stuff works (the infamous SDL_Surface copy problem, which is solved with "++surface->refcount;" on the copied surface... It's just by luck that I found that, most people blamed the programmers...)

http://www.libsdl.org/cgi/docwiki.cgi/SDL_BlitSurface << That's the SDL doc on SDL_BlitSurface.
Blits with negative dstrect coordinates will be clipped properly.
So, what exactly does that mean?
It sounds like it only does clipping to the left and above (where destination rectangle's coords would become negative). That would incredibly stupid if it turned out to be the case. I'm pretty sure whatever it's "clipping" isn't being done correctly, because when I've manually clipped in the past my application's frame rate skyrocketed and CPU usage plummeted. I would recommend you assume no clipping and handle it yourself, if only to save any extra calls to SDL_BlitSurface.

Re: SDL Culling?

Posted: Sat Oct 08, 2011 2:51 pm
by Ginto8
"Culling" means not drawing the backface of a polygon if it normally would be, and in SDL this is completely irrelevant; culling would only be necessary with a 3d rendering engine such as OpenGL. I believe what you meant to refer to was "clipping," which has multiple definitions but primarily means not drawing things that would be offscreen, and SDL does, in fact, do this.
What the SDL_BlitSurface documentation is referring to is when you are trying to draw partially off-screen. It's saying that if the dstrect coordinates are offscreen, it will do some calculation and determine which parts are on screen, if any, and will draw those parts which are actually visible. This is, in fact, a necessary thing for SDL to do, because if it doesn't it has the definite possibility of crashing the program by trying to write to parts of memory it doesn't have ownership of.