~ubuntu-branches/ubuntu/trusty/xscreensaver/trusty

« back to all changes in this revision

Viewing changes to hacks/glx/polytopes.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-11-30 13:33:13 UTC
  • mfrom: (1.1.8 upstream) (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091130133313-3b5nz2e7hvbb8h3l
Tags: 5.10-3ubuntu1
* Merge with Debian unstable, remaining changes: (LP: #489062)
  - debian/control: add Build-Depends on ubuntu-artwork
  - debian/rules: use /usr/share/backgrounds
  - debian/control: Move xli | xloadimage recommends to suggests
  - debian/split-hacks.config: Use different set of default hacks to Debian
  - debian/source_xscreensaver.py: Add apport hook
  - debian/patches/53_XScreenSaver.ad.in.patch: Use Ubuntu branding

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
static const char sccsid[] = "@(#)polytopes.c  1.2 05/09/28 xlockmore";
5
5
#endif
6
6
 
7
 
/* Copyright (c) 2003-2007 Carsten Steger <carsten@mirsanmir.org>. */
 
7
/* Copyright (c) 2003-2009 Carsten Steger <carsten@mirsanmir.org>. */
8
8
 
9
9
/*
10
10
 * Permission to use, copy, modify, and distribute this software and its
23
23
 * C. Steger - 03/08/10: Initial version
24
24
 * C. Steger - 05/09/28: Added trackball support
25
25
 * C. Steger - 07/01/23: Improved 4d trackball support
 
26
 * C. Steger - 09/08/23: Removed check-config.pl warnings
26
27
 */
27
28
 
28
29
/*
52
53
#define GOLDENINV22 0.27009075673772645360 /* (((sqrt(5)-1)/2)^2)/sqrt(2) */
53
54
 
54
55
#define DISP_WIREFRAME            0
55
 
#define DISP_WIREFRAME_STR       "0"
56
56
#define DISP_SURFACE              1
57
 
#define DISP_SURFACE_STR         "1"
58
57
#define DISP_TRANSPARENT          2
59
 
#define DISP_TRANSPARENT_STR     "2"
60
58
 
61
59
#define POLYTOPE_RANDOM          -1
62
 
#define POLYTOPE_RANDOM_STR      "-1"
63
60
#define POLYTOPE_5_CELL           0
64
 
#define POLYTOPE_5_CELL_STR      "0"
65
61
#define POLYTOPE_8_CELL           1
66
 
#define POLYTOPE_8_CELL_STR      "1"
67
62
#define POLYTOPE_16_CELL          2
68
 
#define POLYTOPE_16_CELL_STR     "2"
69
63
#define POLYTOPE_24_CELL          3
70
 
#define POLYTOPE_24_CELL_STR     "3"
71
64
#define POLYTOPE_120_CELL         4
72
 
#define POLYTOPE_120_CELL_STR    "4"
73
65
#define POLYTOPE_600_CELL         5
74
 
#define POLYTOPE_600_CELL_STR    "5"
75
66
#define POLYTOPE_LAST_CELL        POLYTOPE_600_CELL
76
67
 
77
68
#define COLORS_SINGLE             0
78
 
#define COLORS_SINGLE_STR        "0"
79
69
#define COLORS_DEPTH              1
80
 
#define COLORS_DEPTH_STR         "1"
81
70
 
82
71
#define DISP_3D_PERSPECTIVE       0
83
 
#define DISP_3D_PERSPECTIVE_STR  "0"
84
72
#define DISP_3D_ORTHOGRAPHIC      1
85
 
#define DISP_3D_ORTHOGRAPHIC_STR "1"
86
73
 
87
74
#define DISP_4D_PERSPECTIVE       0
88
75
#define DISP_4D_PERSPECTIVE_STR  "0"
89
76
#define DISP_4D_ORTHOGRAPHIC      1
90
77
#define DISP_4D_ORTHOGRAPHIC_STR "1"
91
78
 
92
 
#define DALPHA                    1.1
93
 
#define DALPHA_STR               "1.1"
94
 
#define DBETA                     1.3
95
 
#define DBETA_STR                "1.3"
96
 
#define DDELTA                    1.5
97
 
#define DDELTA_STR               "1.5"
98
 
#define DZETA                     1.7
99
 
#define DZETA_STR                "1.7"
100
 
#define DETA                      1.9
101
 
#define DETA_STR                 "1.9"
102
 
#define DTHETA                    2.1
103
 
#define DTHETA_STR               "2.1"
104
 
 
105
 
#define DEF_DISPLAY_MODE          DISP_TRANSPARENT_STR   
106
 
#define DEF_POLYTOPE              POLYTOPE_RANDOM_STR
107
 
#define DEF_COLORS                COLORS_DEPTH_STR
108
 
#define DEF_3D_PROJECTION         DISP_3D_PERSPECTIVE_STR
109
 
#define DEF_4D_PROJECTION         DISP_4D_PERSPECTIVE_STR
110
 
#define DEF_DALPHA                DALPHA_STR
111
 
#define DEF_DBETA                 DBETA_STR
112
 
#define DEF_DDELTA                DDELTA_STR
113
 
#define DEF_DZETA                 DZETA_STR
114
 
#define DEF_DETA                  DETA_STR
115
 
#define DEF_DTHETA                DTHETA_STR
 
79
#define DEF_DISPLAY_MODE          "transparent"
 
80
#define DEF_POLYTOPE              "random"
 
81
#define DEF_COLORS                "depth"
 
82
#define DEF_PROJECTION_3D         "perspective"
 
83
#define DEF_PROJECTION_4D         "perspective"
 
84
#define DEF_SPEEDWX               "1.1"
 
85
#define DEF_SPEEDWY               "1.3"
 
86
#define DEF_SPEEDWZ               "1.5"
 
87
#define DEF_SPEEDXY               "1.7"
 
88
#define DEF_SPEEDXZ               "1.9"
 
89
#define DEF_SPEEDYZ               "2.1"
116
90
 
117
91
#ifdef STANDALONE
118
92
# define DEFAULTS           "*delay:      25000 \n" \
140
114
#endif
141
115
 
142
116
 
 
117
static char *mode;
143
118
static int display_mode;
 
119
static char *poly_str;
144
120
static int polytope;
 
121
static char *color_str;
145
122
static int color_mode;
 
123
static char *proj_3d;
146
124
static int projection_3d;
 
125
static char *proj_4d;
147
126
static int projection_4d;
148
127
static float speed_wx;
149
128
static float speed_wy;
158
137
 
159
138
static XrmOptionDescRec opts[] =
160
139
{
161
 
  {"-mode",            ".polytopes.displayMode",  XrmoptionSepArg, 0 },
162
 
  {"-wireframe",       ".polytopes.displayMode",  XrmoptionNoArg,
163
 
                       DISP_WIREFRAME_STR },
164
 
  {"-surface",         ".polytopes.displayMode",  XrmoptionNoArg,
165
 
                       DISP_SURFACE_STR },
166
 
  {"-transparent",     ".polytopes.displayMode",  XrmoptionNoArg,
167
 
                       DISP_TRANSPARENT_STR },
168
 
  {"-random",          ".polytopes.polytope",     XrmoptionNoArg,
169
 
                       POLYTOPE_RANDOM_STR },
170
 
 
171
 
  {"-polytope",        ".polytopes.polytope",     XrmoptionSepArg, 0 },
172
 
  {"-5-cell",          ".polytopes.polytope",     XrmoptionNoArg,
173
 
                       POLYTOPE_5_CELL_STR },
174
 
  {"-8-cell",          ".polytopes.polytope",     XrmoptionNoArg,
175
 
                       POLYTOPE_8_CELL_STR },
176
 
  {"-16-cell",         ".polytopes.polytope",     XrmoptionNoArg,
177
 
                       POLYTOPE_16_CELL_STR },
178
 
  {"-24-cell",         ".polytopes.polytope",     XrmoptionNoArg,
179
 
                       POLYTOPE_24_CELL_STR },
180
 
  {"-120-cell",        ".polytopes.polytope",     XrmoptionNoArg,
181
 
                       POLYTOPE_120_CELL_STR },
182
 
  {"-600-cell",        ".polytopes.polytope",     XrmoptionNoArg,
183
 
                       POLYTOPE_600_CELL_STR },
184
 
  {"-single-color",    ".polytopes.colors",       XrmoptionNoArg,
185
 
                       COLORS_SINGLE_STR },
186
 
  {"-depth-colors",    ".polytopes.colors",       XrmoptionNoArg,
187
 
                       COLORS_DEPTH_STR },
188
 
  {"-perspective-3d",  ".polytopes.projection3d", XrmoptionNoArg,
189
 
                       DISP_3D_PERSPECTIVE_STR },
190
 
  {"-orthographic-3d", ".polytopes.projection3d", XrmoptionNoArg,
191
 
                       DISP_3D_ORTHOGRAPHIC_STR },
192
 
  {"-perspective-4d",  ".polytopes.projection4d", XrmoptionNoArg,
193
 
                       DISP_4D_PERSPECTIVE_STR },
194
 
  {"-orthographic-4d", ".polytopes.projection4d", XrmoptionNoArg,
195
 
                       DISP_4D_ORTHOGRAPHIC_STR },
196
 
  {"-speed-wx",        ".polytopes.speedwx",      XrmoptionSepArg, 0 },
197
 
  {"-speed-wy",        ".polytopes.speedwy",      XrmoptionSepArg, 0 },
198
 
  {"-speed-wz",        ".polytopes.speedwz",      XrmoptionSepArg, 0 },
199
 
  {"-speed-xy",        ".polytopes.speedxy",      XrmoptionSepArg, 0 },
200
 
  {"-speed-xz",        ".polytopes.speedxz",      XrmoptionSepArg, 0 },
201
 
  {"-speed-yz",        ".polytopes.speedyz",      XrmoptionSepArg, 0 }
 
140
  {"-mode",            ".displayMode",  XrmoptionSepArg, 0 },
 
141
  {"-wireframe",       ".displayMode",  XrmoptionNoArg,  "wireframe" },
 
142
  {"-surface",         ".displayMode",  XrmoptionNoArg,  "surface" },
 
143
  {"-transparent",     ".displayMode",  XrmoptionNoArg,  "transparent" },
 
144
  {"-polytope",        ".polytope",     XrmoptionSepArg, 0 },
 
145
  {"-random",          ".polytope",     XrmoptionNoArg,  "random" },
 
146
  {"-5-cell",          ".polytope",     XrmoptionNoArg,  "5-cell" },
 
147
  {"-8-cell",          ".polytope",     XrmoptionNoArg,  "8-cell" },
 
148
  {"-16-cell",         ".polytope",     XrmoptionNoArg,  "16-cell" },
 
149
  {"-24-cell",         ".polytope",     XrmoptionNoArg,  "24-cell" },
 
150
  {"-120-cell",        ".polytope",     XrmoptionNoArg,  "120-cell" },
 
151
  {"-600-cell",        ".polytope",     XrmoptionNoArg,  "600-cell" },
 
152
  {"-single-color",    ".colors",       XrmoptionNoArg,  "single" },
 
153
  {"-depth-colors",    ".colors",       XrmoptionNoArg,  "depth" },
 
154
  {"-perspective-3d",  ".projection3d", XrmoptionNoArg,  "perspective" },
 
155
  {"-orthographic-3d", ".projection3d", XrmoptionNoArg,  "orthographic" },
 
156
  {"-perspective-4d",  ".projection4d", XrmoptionNoArg,  "perspective" },
 
157
  {"-orthographic-4d", ".projection4d", XrmoptionNoArg,  "orthographic" },
 
158
  {"-speed-wx",        ".speedwx",      XrmoptionSepArg, 0 },
 
159
  {"-speed-wy",        ".speedwy",      XrmoptionSepArg, 0 },
 
160
  {"-speed-wz",        ".speedwz",      XrmoptionSepArg, 0 },
 
161
  {"-speed-xy",        ".speedxy",      XrmoptionSepArg, 0 },
 
162
  {"-speed-xz",        ".speedxz",      XrmoptionSepArg, 0 },
 
163
  {"-speed-yz",        ".speedyz",      XrmoptionSepArg, 0 }
202
164
};
203
165
 
204
166
static argtype vars[] =
205
167
{
206
 
  { &display_mode,  "displayMode",  "DisplayMode", DEF_DISPLAY_MODE,  t_Int },
207
 
  { &polytope,      "polytope",     "Polytope",    DEF_POLYTOPE,      t_Int },
208
 
  { &color_mode,    "colors",       "Colors",      DEF_COLORS,        t_Int },
209
 
  { &projection_3d, "projection3d", "Projection3d",DEF_3D_PROJECTION, t_Int },
210
 
  { &projection_4d, "projection4d", "Projection4d",DEF_4D_PROJECTION, t_Int },
211
 
  { &speed_wx,      "speedwx",      "Speedwx",     DEF_DALPHA,        t_Float},
212
 
  { &speed_wy,      "speedwy",      "Speedwy",     DEF_DBETA,         t_Float},
213
 
  { &speed_wz,      "speedwz",      "Speedwz",     DEF_DDELTA,        t_Float},
214
 
  { &speed_xy,      "speedxy",      "Speedxy",     DEF_DZETA,         t_Float},
215
 
  { &speed_xz,      "speedxz",      "Speedxz",     DEF_DETA,          t_Float},
216
 
  { &speed_yz,      "speedyz",      "Speedyz",     DEF_DTHETA,        t_Float}
 
168
  { &mode,      "displayMode",  "DisplayMode", DEF_DISPLAY_MODE,  t_String },
 
169
  { &poly_str,  "polytope",     "Polytope",    DEF_POLYTOPE,      t_String },
 
170
  { &color_str, "colors",       "Colors",      DEF_COLORS,        t_String },
 
171
  { &proj_3d,   "projection3d", "Projection3d",DEF_PROJECTION_3D, t_String },
 
172
  { &proj_4d,   "projection4d", "Projection4d",DEF_PROJECTION_4D, t_String },
 
173
  { &speed_wx,  "speedwx",      "Speedwx",     DEF_SPEEDWX,       t_Float},
 
174
  { &speed_wy,  "speedwy",      "Speedwy",     DEF_SPEEDWY,       t_Float},
 
175
  { &speed_wz,  "speedwz",      "Speedwz",     DEF_SPEEDWZ,       t_Float},
 
176
  { &speed_xy,  "speedxy",      "Speedxy",     DEF_SPEEDXY,       t_Float},
 
177
  { &speed_xz,  "speedxz",      "Speedxz",     DEF_SPEEDXZ,       t_Float},
 
178
  { &speed_yz,  "speedyz",      "Speedyz",     DEF_SPEEDYZ,       t_Float}
217
179
};
218
180
 
219
181
static OptionStruct desc[] =
3056
3018
  pp->current_trackball = 0;
3057
3019
  pp->button_pressed = False;
3058
3020
 
 
3021
  /* Set the display mode. */
 
3022
  if (!strcasecmp(mode,"wireframe") || !strcasecmp(mode,"0"))
 
3023
  {
 
3024
    display_mode = DISP_WIREFRAME;
 
3025
  }
 
3026
  else if (!strcasecmp(mode,"surface") || !strcasecmp(mode,"1"))
 
3027
  {
 
3028
    display_mode = DISP_SURFACE;
 
3029
  }
 
3030
  else if (!strcasecmp(mode,"transparent") || !strcasecmp(mode,"2"))
 
3031
  {
 
3032
    display_mode = DISP_TRANSPARENT;
 
3033
  }
 
3034
  else
 
3035
  {
 
3036
    display_mode = DISP_TRANSPARENT;
 
3037
  }
 
3038
 
 
3039
  /* Set the Klein bottle. */
 
3040
  if (!strcasecmp(poly_str,"random") || !strcasecmp(poly_str,"-1"))
 
3041
  {
 
3042
    polytope = POLYTOPE_RANDOM;
 
3043
  }
 
3044
  else if (!strcasecmp(poly_str,"5-cell") || !strcasecmp(poly_str,"0"))
 
3045
  {
 
3046
    polytope = POLYTOPE_5_CELL;
 
3047
  }
 
3048
  else if (!strcasecmp(poly_str,"8-cell") || !strcasecmp(poly_str,"1"))
 
3049
  {
 
3050
    polytope = POLYTOPE_8_CELL;
 
3051
  }
 
3052
  else if (!strcasecmp(poly_str,"16-cell") || !strcasecmp(poly_str,"2"))
 
3053
  {
 
3054
    polytope = POLYTOPE_16_CELL;
 
3055
  }
 
3056
  else if (!strcasecmp(poly_str,"24-cell") || !strcasecmp(poly_str,"3"))
 
3057
  {
 
3058
    polytope = POLYTOPE_24_CELL;
 
3059
  }
 
3060
  else if (!strcasecmp(poly_str,"120-cell") || !strcasecmp(poly_str,"4"))
 
3061
  {
 
3062
    polytope = POLYTOPE_120_CELL;
 
3063
  }
 
3064
  else if (!strcasecmp(poly_str,"600-cell") || !strcasecmp(poly_str,"5"))
 
3065
  {
 
3066
    polytope = POLYTOPE_600_CELL;
 
3067
  }
 
3068
  else
 
3069
  {
 
3070
    polytope = POLYTOPE_RANDOM;
 
3071
  }
 
3072
 
 
3073
  /* Set the color mode. */
 
3074
  if (!strcasecmp(color_str,"single") || !strcasecmp(color_str,"0"))
 
3075
  {
 
3076
    color_mode = COLORS_SINGLE;
 
3077
  }
 
3078
  else if (!strcasecmp(color_str,"depth") || !strcasecmp(color_str,"1"))
 
3079
  {
 
3080
    color_mode = COLORS_DEPTH;
 
3081
  }
 
3082
  else
 
3083
  {
 
3084
    color_mode = COLORS_DEPTH;
 
3085
  }
 
3086
 
 
3087
  /* Set the 3d projection mode. */
 
3088
  if (!strcasecmp(proj_3d,"perspective") || !strcasecmp(proj_3d,"0"))
 
3089
  {
 
3090
    projection_3d = DISP_3D_PERSPECTIVE;
 
3091
  }
 
3092
  else if (!strcasecmp(proj_3d,"orthographic") || !strcasecmp(proj_3d,"1"))
 
3093
  {
 
3094
    projection_3d = DISP_3D_ORTHOGRAPHIC;
 
3095
  }
 
3096
  else
 
3097
  {
 
3098
    projection_3d = DISP_3D_PERSPECTIVE;
 
3099
  }
 
3100
 
 
3101
  /* Set the 4d projection mode. */
 
3102
  if (!strcasecmp(proj_4d,"perspective") || !strcasecmp(proj_4d,"0"))
 
3103
  {
 
3104
    projection_4d = DISP_4D_PERSPECTIVE;
 
3105
  }
 
3106
  else if (!strcasecmp(proj_4d,"orthographic") || !strcasecmp(proj_4d,"1"))
 
3107
  {
 
3108
    projection_4d = DISP_4D_ORTHOGRAPHIC;
 
3109
  }
 
3110
  else
 
3111
  {
 
3112
    projection_4d = DISP_4D_PERSPECTIVE;
 
3113
  }
 
3114
 
3059
3115
  /* make multiple screens rotate at slightly different rates. */
3060
3116
  pp->speed_scale = 0.9 + frand(0.3);
3061
3117