PDA

View Full Version : Blinking/Flashing Colors



GD
02-15-2005, 07:29 AM
Is there a way to *blink* or *flash* colors using OpenGL. i.e a color blinking from red to green.

Thanks in advance and my apologies if this is an obvious question. I only started looking into Opengl yesterday :eek:

uruk
02-15-2005, 08:55 AM
assuming you use glColor*() function should be something like this (just a simple example):


void render_my_stuff()
{
glColor3ub(red,green,blue);

// draw your stuff here

ModifyColorsFunc();
}
in the ModifyColorsFunc() function you just modify the values of red, green and blue variables.
i.e.
for red to green transition
red=255 green=0 blue=0 (pure red)

red=0 green=255 blue=0 (pure green)

red variable decreses from 255 to 0
green variable increses from 0 to 255


void ModifyColorsFunc()
{
red--;
if (red<0) red=0;
green++;
if (green>255) green=255;
// blue is unchanged in this example
}

GD
02-15-2005, 09:28 AM
Sorry, What I meant to say was that I have a bunch of symbols displayed on screen, but I want some of the symbols to appear as if they are blinking or flashing...

Relic
02-16-2005, 02:40 AM
OpenGL is not VGA text mode. ;)
Nothing OpenGL can do for you automatically there. Everytime you want to change something in your display you need to draw it the way it should occur. Blinking objects need to be repainted with the colors you want in a timed interval you choose.

zukko
02-16-2005, 10:46 AM
you can make something like:


if(x%2==0)
glColor3f(1,0,0);
else
glColor3f(0,1,0);

x++;
// then goes whatever you are drawing