Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Why can't I plot random pixels ? UPD8 - PROBLEM SOLVED!

This topic is 5750 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

This has been really frustrating. I posted my first questions about random floating point values in the general programming section but now I think the problem is opengl related. I want to plot random pixels all over the screen. Simple enough correct? Well.. The first thing I need to do is generate random floats... These are a couple of methods people told me to use:
          bgstars[i].x = ((float)rand()/(float)RAND_MAX * float(80)) * (float)30;
          bgstars[i].y = ((float)rand()/(float)RAND_MAX * float(80)) * (float)30;
          bgstars[i].x = (rand() % 100)/100.0 * 30 - 15;
          bgstars[i].y = (rand() % 100)/100.0 * 30 - 15;

And this is where I'm plotting the pixels:

        for(int i = 0; i < MAXSTARS; i++) {
          glVertex3f(bgstars[i].x, bgstars[i].y, -20);
Well... both of these methods seem to work... But EVERY pixel that is plotted is plotted at a whole integer coordinate... This is my problem... Every pixel is exactly one unit away from eachother when the formula above should and is generating random FLOATS... Pixels should fall within units, not on their edges... Any help would be greatly appreciated... Thanks... -Dennis [edited by - anachronism on December 23, 2002 11:53:34 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!