| View previous topic :: View next topic |
| Author |
Message |
Energy
Joined: 26 Mar 2005 Posts: 133 Location: uk/beds/flitwick
|
Posted: Sun Jun 04, 2006 7:22 am Post subject: merging colours |
|
|
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. |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Jun 04, 2006 2:00 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Energy
Joined: 26 Mar 2005 Posts: 133 Location: uk/beds/flitwick
|
Posted: Sun Jun 04, 2006 6:47 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Jun 04, 2006 7:50 pm Post subject: |
|
|
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. :) |
|
| Back to top |
|
 |
Energy
Joined: 26 Mar 2005 Posts: 133 Location: uk/beds/flitwick
|
Posted: Sun Jun 04, 2006 8:56 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
|