SOLVED..... C++ - how does alpha blending work?

Started by
16 comments, last by darenking 18 years, 8 months ago
If doing this over a large number of pixels, wouldn't using floating point maths be horribly slow? Or maybe it's just my love of horribly unreadable fixed-point maths with much &-ing and bit-shifting that's saying this. [rolleyes]
After all, if you are dealing with the 32-bit integer colour values in the first place, it makes more sense to stick with fixed-point maths than to cast to floats then back again.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Advertisement
It wouldn't necessarily be horribly slow (I mean, what do you buy an Athlon64 FX2 4400+ for?), and premature optimization IS the root of all programming evil, but this would be something to look at during profiling. Much of the FP code is helper functions anyway.

Cheers,
Twilight Dragon
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
Personally I'm only using these routines to create my character sprites at the start of each level, so even if it is horribly slow, I expect we're still talking about less than a second even if there were hundreds of sprites?
Quote:Original post by TDragon
...and premature optimization IS the root of all programming evil...
I'm an assembly programmer at heart. I've never had a "premature optimisation" problem, as such, seeing as I'm used to writing everything at a lower level anyway. [wink]

Quote:Original post by darenking
Personally I'm only using these routines to create my character sprites at the start of each level...
Ah, right. I thought you were writing these functions to be used in your renderer. I doubt the speed difference would be noticable if it's part of a loader.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Absolutely; depending on your CPU (anything with a decent FPU, which most modern CPUs have), I'd expect less than a millisecond total from these routines (for 100 sprites).
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
Much faster than a human could do it by hand, with coloured beads and pieces of cloth for example.
Well, that depends; have you ever watched some of those ladies from Uganda that weave baskets for a living?

;)
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
No but I've seen the Athlon Buddists in southern China. Boy do those women go!

This topic is closed to new replies.

Advertisement