summaryrefslogtreecommitdiffstats
path: root/balls.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-30 12:18:26 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-30 12:18:26 -0400
commitb23c94a522a36505b229399f7bfab4e73afdb8e8 (patch)
treeb6acc8cf1df3636b620709df850d661546ef8c3e /balls.c
parent45a31f8146b7f8136bd22f7450ef64d2dabfebfc (diff)
downloadballs-b23c94a522a36505b229399f7bfab4e73afdb8e8.zip
random colors
Diffstat (limited to 'balls.c')
-rw-r--r--balls.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/balls.c b/balls.c
index f40f64e..430a611 100644
--- a/balls.c
+++ b/balls.c
@@ -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];
}
}