hey sdlers,
i want to draw a simple transparent grey box, at like, 25%-50%
transparency on my main screen surface and was wondering what the
fastest way to do this is? the program runs on a 16bpp display, is
creating a surface, filling it grey, and setting the alpha the fastest
way to do it? wouldn’t this be slow to blit 40-50 times per second? is
there a faster way to do it, maybe do the pixel calculations myself
since it’s just a solid color i want?
– chris (@Christopher_Thielen)
Yes it is, because alphablending is often hardware-supported on
video-cards.
I’m afraid you’re wrong, or rather, SDL doesn’t make use of the alpha
blending on targets that have it. At least, the only “target” I’ve seen
doing alpha with h/w is glSDL, and that’s not yet an SDL backend.
Make sure however that no conversion has to be done by
making the surface’ format equal to the screens’ Call
SDL_CreateRGBsurface wisely…
That’s a good point either way. Even when there is acceleration, the
whole gain may be lost if SDL has to convert data on the fly internally.
//David Olofson - Programmer, Composer, Open Source Advocate
.- Coming soon from VaporWare Inc…------------------------.
| The Return of Audiality! Real, working software. Really! |
| Real time and off-line synthesis, scripting, MIDI, LGPL…|
-----------------------------------> (Public Release RSN) -' .- M A I A -------------------------------------------------. | The Multimedia Application Integration Architecture |
----------------------------> http://www.linuxdj.com/maia -’
— http://olofson.net — http://www.reologica.se —On Wednesday 02 October 2002 08:20, patrick at 2dgame-tutorial.com wrote:
actually, if it is a SDL_SWSURFACE, the wastest thing to do if you want
a gray-alpha box is probably:
for 50%
Uint32 mask = (surface->format->Rmask & (surface->format->Rmask >> 1))
| (surface->format->Gmask & (surface->format->Gmask >> 1))
| (surface->format->Bmask & (surface->format->Bmask >> 1));
then for each pixel:
pixel = (pixel >> 1) & mask;
for 75%
Uint32 mask1 =
(surface->format->Rmask & (surface->format->Rmask >> 1))
| (surface->format->Gmask & (surface->format->Gmask >> 1))
| (surface->format->Bmask & (surface->format->Bmask >> 1));
Uint32 mask2 =
(surface->format->Rmask & (surface->format->Rmask >> 2))
| (surface->format->Gmask & (surface->format->Gmask >> 2))
| (surface->format->Bmask & (surface->format->Bmask >> 2));
then for each pixel:
pixel = ((pixel >> 1) & mask1)+((pixel >> 2) & mask2);
For an SDL_HWSURFACE, the blitting a surface with a surface alpha is
probably fastest…
Cheers,
-LorenOn Tue, 2002-10-01 at 23:20, patrick at 2dgame-tutorial.com wrote:
Yes it is, because alphablending is often hardware-supported on video-cards. Make sure however
that no conversion has to be done by making the surface’ format equal to the screens’ Call
SDL_CreateRGBsurface wisely…
Patrick.
Chris Thielen chris at luethy.net schreef:
hey sdlers,
i want to draw a simple transparent grey box, at like, 25%-50%
transparency on my main screen surface and was wondering what the
fastest way to do this is? the program runs on a 16bpp display, is
creating a surface, filling it grey, and setting the alpha the fastest
way to do it? wouldn’t this be slow to blit 40-50 times per second? is
there a faster way to do it, maybe do the pixel calculations myself
since it’s just a solid color i want?
– chris (chris at luethy.net)
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl