SDL Culling?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
treyrust
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 36
Joined: Thu Jul 21, 2011 4:32 pm
Current Project: Between projects
Favorite Gaming Platforms: PS1/2/3/P, NES, Wii, Genesis, Dreamcast, GBA, DS
Programming Language of Choice: C++

SDL Culling?

Post 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?
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: SDL Culling?

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: SDL Culling?

Post 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.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Post Reply