X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fb_lockglue.c;h=1bb1e67979240ade1a3421ec6fbad7d82d0eaf8a;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=4f24c53f117c32e3913ef373b6646b45ea333386;hpb=3f438031d610c7e15fd33876a879b97e290e05fb;p=xscreensaver diff --git a/hacks/glx/b_lockglue.c b/hacks/glx/b_lockglue.c index 4f24c53f..1bb1e679 100644 --- a/hacks/glx/b_lockglue.c +++ b/hacks/glx/b_lockglue.c @@ -34,31 +34,15 @@ struct glb_config glb_config = 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_RESHAPE reshape_bubble3d -#define HACK_DRAW draw_bubble3d -#define bubble3d_opts xlockmore_opts - # define DEFAULTS "*delay: 10000 \n" \ "*showFPS: False \n" -#define DEF_TRANSPARENT "False" -#define DEF_COLOR "random" - +# define release_bubble3d 0 +# define bubble3d_handle_event xlockmore_no_events #include "xlockmore.h" #else #include "xlock.h" @@ -67,6 +51,10 @@ struct glb_config glb_config = #ifdef USE_GL + +#define DEF_TRANSPARENT "True" +#define DEF_BUBBLECOLOR "random" + static Bool transparent_p; static char *bubble_color_str; @@ -76,25 +64,25 @@ static char *bubble_color_str; static XrmOptionDescRec opts[] = { { "-transparent", ".transparent", XrmoptionNoArg, "True" }, { "+transparent", ".transparent", XrmoptionNoArg, "False" }, - { "-color", ".bubble3d.bubblecolor", XrmoptionSepArg, 0 }, + { "-color", ".bubblecolor", XrmoptionSepArg, 0 }, }; static argtype vars[] = { {&transparent_p, "transparent", "Transparent", DEF_TRANSPARENT, t_Bool}, - {&bubble_color_str, "bubblecolor", "BubbleColor", DEF_COLOR, t_String}, + {&bubble_color_str, "bubblecolor", "BubbleColor", DEF_BUBBLECOLOR, t_String}, }; -ModeSpecOpt bubble3d_opts = {countof(opts), opts, countof(vars), vars, NULL}; +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, + "free_bubble3d", &bubble3d_opts, 1000, 1, 2, 1, 64, 1.0, "", "Richard Jones's GL bubbles", @@ -149,16 +137,22 @@ init(struct context *c) c->draw_context = glb_draw_init(); } -void -reshape_bubble3d(ModeInfo *mi, int w, int h) +ENTRYPOINT void +reshape_bubble3d(ModeInfo *mi, int width, int height) { - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45, (GLdouble) w / (GLdouble) h, 3, 8); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0, 0, -5); + double h = (GLfloat) height / (GLfloat) width; + + if (width > height * 5) { /* tiny window: show middle */ + height = width * 9/16; + h = height / (GLfloat) width; + } + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45, 1/h, 3, 8); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0, 0, -5); } static void @@ -167,7 +161,7 @@ do_display(struct context *c) glb_draw_step(c->draw_context); } -void +ENTRYPOINT void init_bubble3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); @@ -175,12 +169,7 @@ 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); c = &contexts[screen]; c->glx_context = init_GL(mi); init_colors(mi); @@ -194,7 +183,7 @@ init_bubble3d(ModeInfo * mi) MI_CLEARWINDOW(mi); } -void +ENTRYPOINT void draw_bubble3d(ModeInfo * mi) { struct context *c = &contexts[MI_SCREEN(mi)]; @@ -209,7 +198,20 @@ 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); @@ -217,23 +219,22 @@ draw_bubble3d(ModeInfo * mi) glXSwapBuffers(display, window); } -void +#ifndef STANDALONE +ENTRYPOINT void change_bubble3d(ModeInfo * mi) { /* nothing */ } +#endif /* !STANDALONE */ -void -release_bubble3d(ModeInfo * mi) +ENTRYPOINT 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 */