View Full Version : mixing RGB colours
10-04-2005, 06:53 PM
my first post!
does anyone know of a function to mix 2 RGB(0,0,0) colours togther in c++ and output it as a single RGB(0,0,0) colour , and if this is possible is it done by the GPU or the CPU ??
well, of course... but if you don't know how to step through an array and perform a weighted (or otherwise) average of two numbers, then you probably want to read up on books on programming, first...
blending is entirely possible to do under OpenGL.
10-04-2005, 08:13 PM
thanks for that , im happy its very possible , ive been doing a couple of turorials and getting help from a friend with c++ for 2 years , is there spefic function when using opengl to mix the colours ?
yes... the blend function ;-)
and so on
btw, here is a code fragment that mixes two colours together;
const float bias=0.5;
float colour1, colour2, result;
for(unsigned int t=0; t<3; t++)
}this fragment mixes two colours and stores the result in result. bias determines how much of the result comes from the first colour: hence, you can mix red and green together and get blends from red (bias=1.0) to green (bias=0.0), and orange (bias=0.5)
good luck with your programming studies!
10-04-2005, 11:48 PM
thank you so much that helped me a lot im nearly finished , is the blending you use there calucate by the CPU or the GPU?
10-05-2005, 07:01 AM
That's calculated by the CPU (unless it's run as a fragment program).
The only way to get the GPU to do something is to exploit procedures that are hardware excelerated by graphics hardware.
This falls under GPGPU - you can Google it.
Most OpenGL calls are mapped to the graphics hardware and executed by the GPU. If they are not supported by the underlying hardware, they fall back to software and suffer a pretty heavy blow to performance - this is undesirable.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.