diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-10-30 12:18:26 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-10-30 12:18:26 -0400 |
| commit | b23c94a522a36505b229399f7bfab4e73afdb8e8 (patch) | |
| tree | b6acc8cf1df3636b620709df850d661546ef8c3e /balls.c | |
| parent | 45a31f8146b7f8136bd22f7450ef64d2dabfebfc (diff) | |
| download | balls-b23c94a522a36505b229399f7bfab4e73afdb8e8.zip | |
random colors
Diffstat (limited to 'balls.c')
| -rw-r--r-- | balls.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -327,15 +327,19 @@ genVertexBuffer(void) { void setColors(void) { GLfloat (*colors)[3]; + GLfloat color[3]; int i, j; if ((colors = malloc(NBALLS*CIRCLE_POINTS*3*sizeof(GLfloat))) == NULL) sysfatal("Failed to allocate color array.\n"); for (i = 0; i < NBALLS; i++) { + color[0] = randFloat(0, 1); + color[1] = randFloat(0, 1); + color[2] = randFloat(0, 1); for (j = 0; j < CIRCLE_POINTS; j++) { - colors[i*CIRCLE_POINTS + j][0] = 1.0; - colors[i*CIRCLE_POINTS + j][1] = 0.0; - colors[i*CIRCLE_POINTS + j][2] = 0.0; + colors[i*CIRCLE_POINTS + j][0] = color[0]; + colors[i*CIRCLE_POINTS + j][1] = color[1]; + colors[i*CIRCLE_POINTS + j][2] = color[2]; } } |