Sign in to follow this  

[OPENGL] random multicolored lines

This topic is 3723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for an effective way to generate random multicolored lines. My random float function is this:
float FLOAT_RAND(float a, float b)
{
return static_cast<float>(((b-a)*((float)rand()/RAND_MAX))+a);
}




particle code:
glbegin...
glColor4f(FLOAT_RAND(0.0f,1.0f),FLOAT_RAND(0.0f,1.0f),FLOAT_RAND(0.0f,1.0f),FLOAT_RAND(0.5f,1.0f)
glend..




But the effect isn't nice. Is there any way to create nice looking colors? thanks!.

Share this post


Link to post
Share on other sites
Hmm , much better now! (i combined your ideas !:)thanks!

By the way here's how my app works:(maybe im doing something wrong here)


-create window (ortho mode)
-set up opengl
-extra opengl parameters:
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glEnable(GL_COLOR_MATERIAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
-draw some lines(GL_LINES).

Should i use GL_POINTs with (GL_POINT_SMOOTH) parameter active?

Share this post


Link to post
Share on other sites
Libraries like Microsoft's Crypto API and Mersenne Twister have functionality to fill arrays with random bits. That way if you know ahead of time how many you'll need, you can generate them all in one function call. Should save time.

Share this post


Link to post
Share on other sites

This topic is 3723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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