merging colours

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Energy
Posts: 133
Joined: Sat Mar 26, 2005 4:13 pm
Location: uk/beds/flitwick
Contact:

merging colours

Post by Energy »

Hey all,
I'm using a graphics.h that has some pretty useful functions in, and one of the features is to get a pixel color on the screen. This is perfect for what I need. It returns a value in the type Color...

typedef u32 Color;

Now what I want to do is give each colour a red tint, so tone down Green and Blue and bring up the Red. How would I do this?

Thanks for any help.
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

You're going about it all the wrong way. Instead of manually getting each pixel, manipulating its values, and setting it back, which would be HORRENDOUSLY slow, do this:

Make a quad, color it red, give it an alpha channel of like 40% or whatever, and draw it over your entire screen after your done drawing everything else.

Letting the hardware do it is literally a million times faster.
Energy
Posts: 133
Joined: Sat Mar 26, 2005 4:13 pm
Location: uk/beds/flitwick
Contact:

Post by Energy »

CyberBill wrote:You're going about it all the wrong way. Instead of manually getting each pixel, manipulating its values, and setting it back, which would be HORRENDOUSLY slow, do this:

Make a quad, color it red, give it an alpha channel of like 40% or whatever, and draw it over your entire screen after your done drawing everything else.

Letting the hardware do it is literally a million times faster.
I guessed this would be the slow way, but until I'm more versed in OpenGL I'm pretty stuffed on how I would do this.

I'm trying to draw an explosion, so far. any alpha values have had to be already in the image. I haven't worked out to change the values on the fly.

My idea for an explosion was to draw a circle that got larger and it was translucent. Any idea for code of what you're suggesting would be great.
CyberBill
Posts: 86
Joined: Tue Jul 26, 2005 3:53 pm
Location: Redmond, WA

Post by CyberBill »

It just relies on having both a 'material color' and an alpha blended texture.

The texture is of the explosion with an alpha mask, and then you can just make the textured quad get bigger over the course of 250ms or so, while also reducing the alpha of the material color. (So that the material color goes from 0xFFFFFFFF to 0x00FFFFFF).

I'm not exactly sure how to set it up, but I'm sure theres a sample of it... it'll also take a little bit of fooling around with to get it working right.

Experiment with it long enough and you'll figure it out. :)
Energy
Posts: 133
Joined: Sat Mar 26, 2005 4:13 pm
Location: uk/beds/flitwick
Contact:

Post by Energy »

CyberBill wrote:It just relies on having both a 'material color' and an alpha blended texture.

The texture is of the explosion with an alpha mask, and then you can just make the textured quad get bigger over the course of 250ms or so, while also reducing the alpha of the material color. (So that the material color goes from 0xFFFFFFFF to 0x00FFFFFF).

I'm not exactly sure how to set it up, but I'm sure theres a sample of it... it'll also take a little bit of fooling around with to get it working right.

Experiment with it long enough and you'll figure it out. :)
K that'll be my challenge for the week :D
Post Reply