X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fb_lockglue.c;h=a6236c64a9320cf4ec4a664323b8bf1984d8e22d;hp=7af0d628dd325bc4528ea6d02f5abba529a73f1a;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hpb=df7adbee81405e2849728a24b498ad2117784b1f diff --git a/hacks/glx/b_lockglue.c b/hacks/glx/b_lockglue.c index 7af0d628..a6236c64 100644 --- a/hacks/glx/b_lockglue.c +++ b/hacks/glx/b_lockglue.c @@ -1,6 +1,5 @@ -#if !defined( lint ) && !defined( SABER ) +#if 0 static const char sccsid[] = "@(#)b_lockglue.c 4.11 98/06/16 xlockmore"; - #endif /*- @@ -15,43 +14,36 @@ static const char sccsid[] = "@(#)b_lockglue.c 4.11 98/06/16 xlockmore"; */ struct glb_config glb_config = { + 0, /* transparent_p */ #if GLB_SLOW_GL 2, /* subdivision_depth */ #else 3, /* subdivision_depth */ #endif 5, /* nr_nudge_axes */ - 0.3, /* nudge_angle_factor */ - 0.15, /* nudge_factor */ + 0.01, /* nudge_angle_factor */ + 0.20, /* nudge_factor */ 0.1, /* rotation_factor */ 8, /* create_bubbles_every */ 8, /* max_bubbles */ {0.7, 0.8, 0.9, 1.0}, /* p_bubble_group */ 0.5, /* max_size */ 0.1, /* min_size */ - 0.1, /* max_speed */ - 0.03, /* min_speed */ + 0.03, /* max_speed */ + 0.005, /* min_speed */ 1.5, /* scale_factor */ -4, /* screen_bottom */ 4, /* screen_top */ -#if 0 - {0.1, 0.0, 0.4, 0.0}, /* bg_colour */ -#else - {0.0, 0.0, 0.0, 0.0}, /* bg_colour */ -#endif -#if 0 - {0.7, 0.7, 0.0, 0.3} /* bubble_colour */ -#else {0.0, 0.0, 0.7, 0.3} /* bubble_colour */ -#endif }; #ifdef STANDALONE -#define PROGCLASS "Bubble3D" -#define HACK_INIT init_bubble3d -#define HACK_DRAW draw_bubble3d -#define bubble3d_opts xlockmore_opts -# define DEFAULTS "" +# define DEFAULTS "*delay: 10000 \n" \ + "*showFPS: False \n" + +# define refresh_bubble3d 0 +# define release_bubble3d 0 +# define bubble3d_handle_event 0 #include "xlockmore.h" #else #include "xlock.h" @@ -60,15 +52,35 @@ struct glb_config glb_config = #ifdef USE_GL -ModeSpecOpt bubble3d_opts = -{0, NULL, 0, NULL, NULL}; + +#define DEF_TRANSPARENT "True" +#define DEF_BUBBLECOLOR "random" + +static Bool transparent_p; +static char *bubble_color_str; + +#undef countof +#define countof(x) (sizeof((x))/sizeof((*x))) + +static XrmOptionDescRec opts[] = { + { "-transparent", ".transparent", XrmoptionNoArg, "True" }, + { "+transparent", ".transparent", XrmoptionNoArg, "False" }, + { "-color", ".bubblecolor", XrmoptionSepArg, 0 }, +}; + +static argtype vars[] = { + {&transparent_p, "transparent", "Transparent", DEF_TRANSPARENT, t_Bool}, + {&bubble_color_str, "bubblecolor", "BubbleColor", DEF_BUBBLECOLOR, t_String}, +}; + +ENTRYPOINT ModeSpecOpt bubble3d_opts = {countof(opts), opts, countof(vars), vars, NULL}; #ifdef USE_MODULES ModStruct bubbles3d_description = {"bubbles3d", "init_bubble3d", "draw_bubble3d", - "release_bubble3d", + NULL, "change_bubble3d", "init_bubble3d", NULL, @@ -88,15 +100,46 @@ struct context { static struct context *contexts = 0; +static void +parse_color (ModeInfo *mi, const char *name, const char *s, GLfloat *a) +{ + XColor c; + + if (! XParseColor (MI_DISPLAY(mi), MI_COLORMAP(mi), s, &c)) + { + fprintf (stderr, "%s: can't parse %s color %s", progname, name, s); + exit (1); + } + a[0] = c.red / 65536.0; + a[1] = c.green / 65536.0; + a[2] = c.blue / 65536.0; +} + +static void +init_colors(ModeInfo *mi) +{ + if (strncasecmp(bubble_color_str, "auto", strlen("auto")) == 0) { + glb_config.bubble_colour[0] = ((float) (NRAND(100)) / 100.0); + glb_config.bubble_colour[1] = ((float) (NRAND(100)) / 100.0); + /* I keep more blue */ + glb_config.bubble_colour[2] = ((float) (NRAND(50)) / 100.0) + 0.50; + } else if (strncasecmp(bubble_color_str, "random", strlen("random")) == 0) { + glb_config.bubble_colour[0] = -1.0; + } else { + parse_color(mi, "bubble", bubble_color_str, glb_config.bubble_colour); + } +} + static void init(struct context *c) { + glb_config.transparent_p = transparent_p; glb_sphere_init(); c->draw_context = glb_draw_init(); } -static void -reshape(int w, int h) +ENTRYPOINT void +reshape_bubble3d(ModeInfo *mi, int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -113,7 +156,9 @@ do_display(struct context *c) glb_draw_step(c->draw_context); } -void +static void free_bubble3d(ModeInfo * mi); + +ENTRYPOINT void init_bubble3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); @@ -121,17 +166,13 @@ init_bubble3d(ModeInfo * mi) int screen = MI_SCREEN(mi); struct context *c; - if (contexts == 0) { - contexts = (struct context *) malloc(sizeof (struct context) * MI_NUM_SCREENS(mi)); - - if (contexts == 0) - return; - } + MI_INIT (mi, contexts, free_bubble3d); c = &contexts[screen]; c->glx_context = init_GL(mi); + init_colors(mi); if (c->glx_context != 0) { init(c); - reshape(MI_WIDTH(mi), MI_HEIGHT(mi)); + reshape_bubble3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); do_display(c); glFinish(); glXSwapBuffers(display, window); @@ -139,7 +180,7 @@ init_bubble3d(ModeInfo * mi) MI_CLEARWINDOW(mi); } -void +ENTRYPOINT void draw_bubble3d(ModeInfo * mi) { struct context *c = &contexts[MI_SCREEN(mi)]; @@ -153,29 +194,44 @@ draw_bubble3d(ModeInfo * mi) glXMakeCurrent(display, window, *(c->glx_context)); + glb_config.polygon_count = 0; + glPushMatrix(); + +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (1/h, 1/h, 1/h); + glRotatef(o, 0, 0, 1); + } +# endif + do_display(c); + glPopMatrix(); + mi->polygon_count = glb_config.polygon_count; + if (mi->fps_p) do_fps (mi); glFinish(); glXSwapBuffers(display, window); } -void +#ifndef STANDALONE +ENTRYPOINT void change_bubble3d(ModeInfo * mi) { /* nothing */ } +#endif /* !STANDALONE */ -void -release_bubble3d(ModeInfo * mi) +static void +free_bubble3d(ModeInfo * mi) { - struct context *c = &contexts[MI_SCREEN(mi)]; - - if (contexts != 0) { - glb_draw_end(c->draw_context); - (void) free((void *) contexts); - contexts = 0; - } - FreeAllGL(mi); + struct context *c = &contexts[MI_SCREEN(mi)]; + if (c->draw_context) + glb_draw_end(c->draw_context); } +XSCREENSAVER_MODULE ("Bubble3D", bubble3d) + #endif /* USE_GL */