X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fsphere.c;h=dee4541cefa1405b15c098d73dd9386241c8cf43;hb=refs%2Fheads%2Fmaster2;hp=182d0084667359696ec672b4ecae56bef08fff88;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;p=xscreensaver diff --git a/hacks/glx/sphere.c b/hacks/glx/sphere.c index 182d0084..dee4541c 100644 --- a/hacks/glx/sphere.c +++ b/hacks/glx/sphere.c @@ -1,5 +1,5 @@ /* sphere, Copyright (c) 2002 Paul Bourke , - * Copyright (c) 2010 Jamie Zawinski + * Copyright (c) 2010-2014 Jamie Zawinski * Utility function to create a unit sphere in GL. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -24,7 +24,10 @@ # include "config.h" #endif -#ifndef HAVE_COCOA +#ifdef HAVE_COCOA +#elif defined(HAVE_ANDROID) +# include +#else /* real X11 */ # include #endif @@ -36,8 +39,8 @@ typedef struct { GLfloat x, y, z; } XYZ; -int -unit_sphere (int stacks, int slices, int wire_p) +static int +unit_sphere_1 (int stacks, int slices, int wire_p, int half_p) { int polys = 0; int i,j; @@ -47,6 +50,7 @@ unit_sphere (int stacks, int slices, int wire_p) XYZ c = {0, 0, 0}; /* center */ double r = 1.0; /* radius */ int stacks2 = stacks * 2; + int end = (half_p ? stacks/2 : stacks); int mode = (wire_p ? GL_LINE_STRIP : GL_TRIANGLE_STRIP); @@ -70,7 +74,7 @@ unit_sphere (int stacks, int slices, int wire_p) goto END; } - for (j = 0; j < stacks; j++) + for (j = 0; j < end; j++) { theta1 = j * (M_PI+M_PI) / stacks2 - M_PI_2; theta2 = (j + 1) * (M_PI+M_PI) / stacks2 - M_PI_2; @@ -136,3 +140,16 @@ unit_sphere (int stacks, int slices, int wire_p) return polys; } + + +int +unit_sphere (int stacks, int slices, int wire_p) +{ + return unit_sphere_1 (stacks, slices, wire_p, 0); +} + +int +unit_dome (int stacks, int slices, int wire_p) +{ + return unit_sphere_1 (stacks, slices, wire_p, 1); +}