X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fbubble3d.c;h=3e0062ec7ec95d103fa17afb93b01493027e11aa;hp=52dbc33e03b29843084a62de9c331ee99141f839;hb=3f438031d610c7e15fd33876a879b97e290e05fb;hpb=447db08c956099b3b183886729108bf5b364c4b8 diff --git a/hacks/glx/bubble3d.c b/hacks/glx/bubble3d.c index 52dbc33e..3e0062ec 100644 --- a/hacks/glx/bubble3d.c +++ b/hacks/glx/bubble3d.c @@ -47,6 +47,7 @@ typedef struct bubble { GLfloat *nudge_angle_incr; /* Amount by which we increase each nudge * angle in each frame. */ + GLfloat color[4]; } bubble; /* Should be taken care of already... but just in case */ @@ -98,6 +99,18 @@ glb_bubble_new(GLfloat x, GLfloat y, GLfloat z, GLfloat scale, if (b == 0) return 0; + if (glb_config.bubble_colour[0] == -1.0) { + b->color[0] = ((float) (NRAND(100)) / 100.0); + b->color[1] = ((float) (NRAND(100)) / 100.0); + b->color[2] = ((float) (NRAND(100)) / 100.0); + } else { + b->color[0] = glb_config.bubble_colour[0]; + b->color[1] = glb_config.bubble_colour[1]; + b->color[2] = glb_config.bubble_colour[2]; + } + b->color[3] = glb_config.bubble_colour[3]; + + b->contributions = (GLfloat *) malloc(sizeof (GLfloat) * nr_vertices * glb_config.nr_nudge_axes); if (b->contributions == 0) { @@ -240,6 +253,9 @@ glb_bubble_draw(void *bb) /* Draw the bubble. */ glBegin(GL_TRIANGLES); + + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, b->color); + for (i = 0; i < nr_triangles; ++i) { glNormal3fv(new_vertices[triangles[i][0]]); glVertex3fv(new_vertices[triangles[i][0]]); @@ -251,6 +267,7 @@ glb_bubble_draw(void *bb) glEnd(); glPopMatrix(); (void) free((void *) new_vertices); + glb_config.polygon_count += nr_triangles; } /* Return y value. */