GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


A Paste by Anonymous
1
 
void cloud_rain(int value)
{
    int i;
    float r_x, r_z;

    glDisable(GL_LIGHTING);
    glColor3f(0.0, 0.0, 1.0);
    glBegin(GL_POINTS);
    for (i = 0; i < NUM_DROPS; i++)
    {
        r_x = (float) ((rand() % NUM_DROPS) - NUM_DROPS / 2) / NUM_DROPS;
        r_z = (float) ((rand() % NUM_DROPS) - NUM_DROPS / 2) / NUM_DROPS;
        printf("Drawing drop at (%f, %f, %f)\n", cloud_x + r_x, cloud_y - drops[i], cloud_z + r_z);

        glVertex3f(cloud_x + r_x, cloud_y - drops[i], cloud_z + r_z);
        if (rand() % 2)
        {
            drops[i]++;
            if (drops[i] > cloud_y)
            {
                drops[i] = 0;
            }
        }
    }
    glEnd();
    glEnable(GL_LIGHTING);
    glutPostRedisplay();
    if (angry_rain)
    {
        glutTimerFunc(10, cloud_rain, 0);
    }
}