X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fb_draw.c;h=a3e32179afa2660fa296207e01284c2f2814e43a;hb=6b1c86cf395f59389e4ece4ea8f4bea2c332745b;hp=18c89d9a49a8a65d35d4d16d6b3ef0e4106b59f2;hpb=df7adbee81405e2849728a24b498ad2117784b1f;p=xscreensaver diff --git a/hacks/glx/b_draw.c b/hacks/glx/b_draw.c index 18c89d9a..a3e32179 100644 --- a/hacks/glx/b_draw.c +++ b/hacks/glx/b_draw.c @@ -1,6 +1,5 @@ -#if !defined( lint ) && !defined( SABER ) +#if 0 static const char sccsid[] = "@(#)b_draw.c 4.11 98/06/16 xlockmore"; - #endif /*- @@ -18,6 +17,9 @@ typedef struct draw_context { /* When was the last time we created a new bubble? */ int bubble_count; + + glb_data *d; + } draw_context; void * @@ -63,54 +65,31 @@ glb_draw_init(void) glb_config.bg_colour[1], glb_config.bg_colour[2], glb_config.bg_colour[3]); -#if 0 + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, glb_config.bubble_colour); -#else - { - /* - * E. Lassauge - 98/06/29 - * Yeahh, cool ! Now that I know how to have random colors I - * patch this pretty beautiful mode too !! - */ - GLfloat fred, fgreen, fblue; - GLfloat params[4]; - - fred = ((float) (NRAND(100)) / 100.0); - fgreen = ((float) (NRAND(100)) / 100.0); - /* I keep more blue */ - fblue = ((float) (NRAND(50)) / 100.0) + 0.50; - - params[0] = fred; - params[1] = fgreen; - params[2] = fblue; - /* For the moment don't play with ALPHA channel */ - params[3] = glb_config.bubble_colour[3]; - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, params); - } -#endif glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mat_emission); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); -#if GLB_USE_BLENDING - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif + if (glb_config.transparent_p) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_LIGHT2); -#if GLB_USE_BLENDING - glEnable(GL_BLEND); -#else - glEnable(GL_DEPTH_TEST); -#endif + + if (glb_config.transparent_p) + glEnable(GL_BLEND); + else + glEnable(GL_DEPTH_TEST); + glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); -#if GLB_USE_BLENDING - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); -#endif + if (glb_config.transparent_p) + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_POSITION, light_position[0]); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse[0]); @@ -122,6 +101,8 @@ glb_draw_init(void) glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse[2]); glLightfv(GL_LIGHT2, GL_SPECULAR, light_specular[2]); + c->d = glb_sphere_init(); + return c; } @@ -148,6 +129,9 @@ glb_draw_end(void *cc) delete_bubble(c, i); i--; } + + glb_sphere_end (c->d); + (void) free((void *) c->bubble_list); (void) free((void *) c); } @@ -192,7 +176,7 @@ create_new_bubbles(draw_context * c) /* Create the bubble(s). */ for (i = 0; i < n; ++i) { - if ((b[i] = glb_bubble_new(x, y, z, size, speed, scale_incr)) == 0) { + if ((b[i] = glb_bubble_new(c->d, x, y, z, size, speed, scale_incr)) == 0) { /* Out of memory - recover. */ i--; while (i >= 0) @@ -249,7 +233,7 @@ glb_draw_step(void *cc) void *b = c->bubble_list[i]; glb_bubble_step(b); - glb_bubble_draw(b); + glb_bubble_draw(c->d, b); /* Has the bubble reached the top of the screen? */ if (glb_bubble_get_y(b) >= glb_config.screen_top) {