Sign in to follow this  
Fubator

Hello, and whaddya think? lol

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
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



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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this