/* Color Fade/Cycle Code Added By Garry Jewell
Use: Rapidly Change Brightness In/Out On Colors And/Or
Cycle Objects Through Different Colors. Can be used pretty
easily to have some fun in about any program.
Is a first draft, feel free to edit/tweak it if ya like.
Can Contact Me At Fubator@sbcglobal.net If you wanna
make any suggestions/comments. Be Gentle tho ima noob lol
This is the first OpenGL i've realy written myself. I added
it to Lesson7, but seems like it should work in any.
*/
// Globals
GLfloat colorfade; // Color Brightness
bool cfDirection; // Color Fade Direction (FALSE=Decrease/TRUE=Increase)
int colorSwitch; // Used to Cycle Through Colors
// In InitGL()
colorfade=1.0f; // Start Color Fade At Full Intensity
colorSwitch=0; // Set Color Switch To the Begining of Its Cycle
cfDirection=FALSE; // Start Color Fade Decreasing
// In DrawGLScene() Place Code Before Drawing The Objects You Want Effected
switch (colorSwitch) // Select Color From Premade List With colorSwitch
{
case 0:
{glColor3f(colorfade,0.0f,0.0f);break;}
case 1:
{glColor3f(0.0f,colorfade,0.0f);break;}
case 2:
{glColor3f(0.0f,0.0f,colorfade);break;}
case 3:
{glColor3f(colorfade,colorfade,colorfade);break;}
case 4:
{glColor3f(colorfade,0.0f,colorfade);break;}
case 5:
{glColor3f(colorfade,colorfade,0.0f);break;}
case 6:
{glColor3f(0.0f,colorfade,colorfade);break;}
default:
{glColor3f(1.0f,1.0f,1.0f);break;} // Default To Full Intensity White
}
// In DrawGLScene() After Drawing Is Done And Before Returning
if (cfDirection==FALSE) // If Fade Is In Reverse Then
{ colorfade-=0.01f;} // Subtract colorFade
else
{ colorfade+=0.01f;} // Increase colorFade, Fade must be going forward if
not in reverse
if (colorfade<=0.1f|colorfade>=1.0f) {cfDirection=!cfDirection;} // Toggle Fade At Either Boundry
if (colorSwitch<=5) {colorSwitch+=1;} // Increment If Not At End Of Cycle
else
{colorSwitch=0;} // Restart Cycle If It Is
Hello, and whaddya think? lol
Hello everyone, Just signed up here so I figured i'd introduce myself and say hi. Also here is a little snippet of code that i've wrote(my first OpenGL), I made it in Lesson7 just playing around, but i think it will work in just about anything its pretty simple(but neat) :) . I'd like to know what anyone thinks about it. Thanks
[Edited by - Fubator on May 20, 2006 1:30:55 PM]
It is. If I'm correct, you could use something like this to make a fadein/fadeout technique.
It's just that it is probrably something people have already thought of or done.
But don't let that get you down! Find different things to do neat stuff with. You'll learn new tricks and get better!
It's just that it is probrably something people have already thought of or done.
But don't let that get you down! Find different things to do neat stuff with. You'll learn new tricks and get better!
.::WARNING!::. Axesor is a total newb or n00b! Beware his lack ofintellegence of OpenGL. Feel sorry for him and keep him in your thoughts.~Leader of the phsychoward
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement