Sign in to follow this  
BeanDog

OpenGL Software metaballs with memory surfaces [SDL]

Recommended Posts

I realize that this thread on efficient 2D metaballs is still on the front page of this forum, but it's going into discussions on how to speed the rendering of 2D metaballs using the GPU. I'm interested in finding an efficient way to render them directly onto an SDL surface in software--partially as an academic exercise, and partially to keep my 2D game from requiring any shaders, OpenGL libraries, etc. A while ago, I put together a reasonably quick additive-blit function for SDL. I could go about doing this in conceptually the same manner outlined in the other metaball thread--just additive-blend all the metaball influences together into an off-screen surface, and use it as a stencil with a low cutoff. The problem is that last part--is there a library or function I'm missing that could make that part quick and painless? I know I can set colorkeys easily on blits, but is there a way to do an alpha-tested blit? Or is it time to break out my SIMD-fu again?

Share this post


Link to post
Share on other sites
SDL_BlitSurface doesn't support alpha testing... Though the source code is available so you could just look at how the color key is done and make a version that checks alpha values instead of color. I doubt it would require changing more than a couple of lines of code.

Anyway, what kind of resolution are you thinking about? I did something like this with a naive, unoptimized all-C approach way back in the days of 300MHz Pentium2's and it ran just fine in 640x480 (and still does). On a modern computer, the same code would probably run in any resolution you can find on a desktop since CPU power has increased faster than screen resolutions. The single "alpha tested" blit shouldn't be a bottleneck like the drawing of the metaballs themselves (assuming there's significant overdraw like there usually is).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this