X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fnoof.c;h=c5328436985a60f4a09d715ac4708cc77500c901;hb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;hp=e273082058dfc9503fd305d1d6852a3060162c97;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/noof.c b/hacks/glx/noof.c index e2730820..c5328436 100644 --- a/hacks/glx/noof.c +++ b/hacks/glx/noof.c @@ -16,6 +16,7 @@ #define DEFAULTS "*delay: 10000 \n" \ "*showFPS: False \n" \ "*fpsSolid: True \n" \ + "*doubleBuffer: False \n" \ # define refresh_noof 0 # define release_noof 0 @@ -26,6 +27,10 @@ #define N_SHAPES 7 +/* For some reason this hack screws up on Cocoa if we try to double-buffer it. + It looks fine single-buffered, so let's just do that. */ +static int dbuf_p = 0; + ENTRYPOINT ModeSpecOpt noof_opts = {0, NULL, 0, NULL, NULL}; typedef struct { @@ -117,10 +122,10 @@ static const float bladeratio[] = 0.22824, 0.21256, 0.19891, 0.18693, 0.17633, 0.16687, }; -static void +static int drawleaf(noof_configuration *bp, int l) { - + int polys = 0; int b, blades; float x, y; float wobble; @@ -137,7 +142,7 @@ drawleaf(noof_configuration *bp, int l) initshapes(bp, l); /* let it become reborn as something else */ bp->tko++; - return; + return polys; } { float w1 = sin(bp->geep[l] * 15.3 * M_PI / 180.0); wobble = 3.0 + 2.00 * sin(bp->geep[l] * 0.4 * M_PI / 180.0) + 3.94261 * w1; @@ -174,6 +179,7 @@ drawleaf(noof_configuration *bp, int l) glVertex2f(x, y); glVertex2f(x, -y); /* C */ glVertex2f(0.3, 0.0); /* D */ + polys += 2; glEnd(); /** @@ -186,11 +192,13 @@ drawleaf(noof_configuration *bp, int l) glVertex2f(x, y); glVertex2f(0.3, 0.0); /* D */ glVertex2f(x, -y); /* C */ + polys += 3; glEnd(); glDisable(GL_BLEND); glPopMatrix(); } + return polys; } static void @@ -372,6 +380,7 @@ draw_noof (ModeInfo *mi) if (!bp->glx_context) return; glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context)); + mi->polygon_count = 0; /** if((random() & 0xff) == 0x34){ @@ -393,13 +402,14 @@ draw_noof (ModeInfo *mi) for (i = 0; i < N_SHAPES; i++) { motionUpdate(bp, i); colorUpdate(bp, i); - drawleaf(bp, i); + mi->polygon_count += drawleaf(bp, i); } if (mi->fps_p) do_fps (mi); glFinish(); - glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi)); + if (dbuf_p) + glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi)); } @@ -442,14 +452,13 @@ init_noof (ModeInfo *mi) fprintf(stderr, "%s: out of memory\n", progname); exit(1); } - bp = &bps[MI_SCREEN(mi)]; } bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); - glClearColor(0.0, 0.0, 0.0, 1.0); + glDrawBuffer(dbuf_p ? GL_BACK : GL_FRONT); glEnable(GL_LINE_SMOOTH); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);