Qbasicnews.com

Full Version: Highlighting Effects
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In SDL, how would I go about making a sprite highlight as a certain color? For example, a selection in a menu being brighter shade of blue than the non-selected areas?
Probably the simplest way would be to load two different images or whatever for the sprite with one being a brighter shade. Then just draw with the brighter image when it is highlighted.

Or you could do it the hard way. During initial loading of the menu graphics, you could create another image and proceed to copy over the darker shade, increasing the brightness of the individual pixels as you copy them over.

http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSurface

If you notice, the surface structure has a "pixels" pointer. The data it points are the individual pixels on the surface. So simply modify that data and you directly modify the surface.

One other thing, you need to lock the surface before you directly access it. And, of course, unlock it once you are finished. :wink:
I went with the first method, as I told you in the PM, and it worked out perfectly. Thanks. =]