Recommended Posts

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
/*      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
bool    cfDirection;            // Color Fade Direction (FALSE=Decrease/TRUE=Increase)
int     colorSwitch;            // Used to Cycle Through Colors

// In InitGL()
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:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
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
else

not in reverse

if (colorSwitch<=5) {colorSwitch+=1;}		// Increment If Not At End Of Cycle
else
{colorSwitch=0;}		// Restart Cycle If It Is


[Edited by - Fubator on May 20, 2006 1:30:55 PM]

Share on other sites
lol, ok maybe its not as neat as i thought it was then.....

Share on other sites
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!

Create an account

Register a new account

• Forum Statistics

• Total Topics
628333
• Total Posts
2982139

• 9
• 24
• 9
• 9
• 13