~ubuntu-branches/ubuntu/dapper/xscreensaver/dapper-updates

« back to all changes in this revision

Viewing changes to hacks/glx/cage.c

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Hildebrandt
  • Date: 2005-04-09 00:06:43 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050409000643-z0abtifbt9s20pcc
Tags: 4.21-3
Patch by Joachim Breitner to check more frequently if DPMS kicked in (closes: #303374, #286664).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C; tab-width: 4 -*- */
2
2
/* cage --- the Impossible Cage, an Escher like scene. */
3
3
 
4
 
#if !defined( lint ) && !defined( SABER )
5
 
static const char sccsid[] = "@(#)cage.c        4.07 98/01/04 xlockmore";
6
 
 
 
4
#if 0
 
5
static const char sccsid[] = "@(#)cage.c        5.01 2001/03/01 xlockmore";
7
6
#endif
8
7
 
9
 
#undef DEBUG_LISTS
10
 
 
11
8
/*-
12
9
 * Permission to use, copy, modify, and distribute this software and its
13
10
 * documentation for any purpose and without fee is hereby granted,
22
19
 * other special, indirect and consequential damages.
23
20
 *
24
21
 * The RotateAroundU() routine was adapted from the book
25
 
 *    "Computer Graphics Principles and Practice 
 
22
 *    "Computer Graphics Principles and Practice
26
23
 *     Foley - vanDam - Feiner - Hughes
27
24
 *     Second Edition" Pag. 227, exercise 5.15.
28
 
 * 
 
25
 *
29
26
 * This mode shows some interesting scenes that are impossible OR very
30
27
 * wierd to build in the real universe. Much of the scenes are inspirated
31
28
 * on Mauritz Cornelis Escher's works which derivated the mode's name.
32
29
 * M.C. Escher (1898-1972) was a dutch artist and many people prefer to
33
30
 * say he was a mathematician.
34
31
 *
35
 
 * Thanks goes to Brian Paul for making it possible and inexpensive to use 
 
32
 * Thanks goes to Brian Paul for making it possible and inexpensive to use
36
33
 * OpenGL at home.
37
34
 *
38
35
 * Since I'm not a native English speaker, my apologies for any grammatical
39
 
 * mistake.
 
36
 * mistakes.
40
37
 *
41
38
 * My e-mail address is
42
 
 * m-vianna@usa.net
 
39
 * mfvianna@centroin.com.br
43
40
 *
44
41
 * Marcelo F. Vianna (Jun-01-1997)
45
42
 *
46
43
 * Revision History:
47
 
 * 01-Jan-98: Mode separated from escher and renamed
48
 
 * 08-Jun-97: New scene implemented: "Impossible Cage" based in a M.C. Escher's
49
 
 *            painting with the same name (quite similar). The first GL mode
50
 
 *            to use texture mapping.
51
 
 *            The "Impossible Cage" scene doesn't use DEPTH BUFFER, the 
52
 
 *            wood planks are drawn consistently using GL_CULL_FACE, and
53
 
 *            the painter's algorithm is used to sort the planks.
54
 
 *            Marcelo F. Vianna.
55
 
 * 07-Jun-97: Speed ups in Moebius Strip using GL_CULL_FACE.
56
 
 *            Marcelo F. Vianna.
57
 
 * 03-Jun-97: Initial Release (Only one scene: "Moebius Strip")
58
 
 *            The Moebius Strip scene was inspirated in a M.C. Escher's
59
 
 *            painting named Moebius Strip II in wich ants walk across a
60
 
 *            Moebius Strip path, sometimes meeting each other and sometimes
61
 
 *            being in "opposite faces" (note that the moebius strip has
62
 
 *            only one face and one edge).
63
 
 *            Marcelo F. Vianna.
64
 
 *
 
44
 * 05-Apr-2002: Removed all gllist uses (fix some bug with nvidia driver)
 
45
 * 01-Mar-2001: Added FPS stuff E.Lassauge <lassauge@mail.dotcom.fr>
 
46
 * 01-Nov-2000: Allocation checks
 
47
 * 01-Jan-1998: Mode separated from escher and renamed
 
48
 * 08-Jun-1997: New scene implemented: "Impossible Cage" based in a M.C.
 
49
 *              Escher's painting with the same name (quite similar). The
 
50
 *              first GL mode to use texture mapping.
 
51
 *              The "Impossible Cage" scene doesn't use DEPTH BUFFER, the
 
52
 *              wood planks are drawn consistently using GL_CULL_FACE, and
 
53
 *              the painter's algorithm is used to sort the planks.
 
54
 *              Marcelo F. Vianna.
 
55
 * 07-Jun-1997: Speed ups in Moebius Strip using GL_CULL_FACE.
 
56
 *              Marcelo F. Vianna.
 
57
 * 03-Jun-1997: Initial Release (Only one scene: "Moebius Strip")
 
58
 *              The Moebius Strip scene was inspirated in a M.C. Escher's
 
59
 *              painting named Moebius Strip II in wich ants walk across a
 
60
 *              Moebius Strip path, sometimes meeting each other and sometimes
 
61
 *              being in "opposite faces" (note that the moebius strip has
 
62
 *              only one face and one edge).
 
63
 *              Marcelo F. Vianna.
65
64
 */
66
65
 
67
66
/*-
76
75
 * In real OpenGL, PseudoColor DO NOT support texture map (as far as I know).
77
76
 */
78
77
 
79
 
#include <X11/Intrinsic.h>
80
 
 
81
78
#ifdef STANDALONE
 
79
# define MODE_cage
82
80
# define PROGCLASS                      "Cage"
83
81
# define HACK_INIT                      init_cage
84
82
# define HACK_DRAW                      draw_cage
85
 
# define HACK_RESHAPE                   reshape_cage
 
83
# define HACK_RESHAPE           reshape
86
84
# define cage_opts                      xlockmore_opts
87
 
# define DEFAULTS                       "*cycles:               1       \n"                     \
88
 
                                                        "*delay:                25000   \n"                     \
 
85
# define DEFAULTS                       "*delay:                25000   \n"                     \
89
86
                                                        "*showFPS:      False   \n"                     \
90
87
                                                        "*wireframe:    False   \n"
91
88
# include "xlockmore.h"         /* from the xscreensaver distribution */
94
91
 
95
92
#endif /* !STANDALONE */
96
93
 
97
 
#ifdef USE_GL
 
94
#ifdef MODE_cage
98
95
 
99
96
 
100
97
#include <GL/glu.h>
101
98
#include "e_textures.h"
102
99
 
103
100
ModeSpecOpt cage_opts =
104
 
{0, NULL, 0, NULL, NULL};
 
101
{0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL};
105
102
 
106
103
#ifdef USE_MODULES
107
104
ModStruct   cage_description =
108
105
{"cage", "init_cage", "draw_cage", "release_cage",
109
 
 "draw_cage", "change_cage", NULL, &cage_opts,
110
 
 1000, 1, 1, 1, 1.0, 4, "",
 
106
 "draw_cage", "change_cage", (char *) NULL, &cage_opts,
 
107
 25000, 1, 1, 1, 1.0, 4, "",
111
108
 "Shows the Impossible Cage, an Escher-like GL scene", 0, NULL};
112
109
 
113
110
#endif
121
118
#define Pi                         M_PI
122
119
#endif
123
120
 
 
121
#define ObjWoodPlank    0
 
122
#define MaxObj          1
 
123
 
124
124
/*************************************************************************/
125
125
 
126
126
typedef struct {
127
127
        GLint       WindH, WindW;
128
128
        GLfloat     step;
129
 
        int         AreObjectsDefined[1];
130
129
        GLXContext *glx_context;
131
130
} cagestruct;
132
131
 
150
149
static float MaterialWhite[] =
151
150
{0.7, 0.7, 0.7, 1.0};
152
151
 
153
 
static cagestruct *cage = NULL;
154
 
static GLuint objects;
155
 
 
156
 
#define ObjWoodPlank    0
 
152
static cagestruct *cage = (cagestruct *) NULL;
157
153
 
158
154
#define PlankWidth      3.0
159
155
#define PlankHeight     0.35
160
156
#define PlankThickness  0.15
161
157
 
162
 
static void
 
158
static Bool 
163
159
draw_woodplank(cagestruct * cp)
164
160
{
165
 
        if (!cp->AreObjectsDefined[ObjWoodPlank]) {
166
 
                glNewList(objects + ObjWoodPlank, GL_COMPILE_AND_EXECUTE);
167
 
                glBegin(GL_QUADS);
168
 
                glNormal3f(0, 0, 1);
169
 
                glTexCoord2f(0, 0);
170
 
                glVertex3f(-PlankWidth, -PlankHeight, PlankThickness);
171
 
                glTexCoord2f(1, 0);
172
 
                glVertex3f(PlankWidth, -PlankHeight, PlankThickness);
173
 
                glTexCoord2f(1, 1);
174
 
                glVertex3f(PlankWidth, PlankHeight, PlankThickness);
175
 
                glTexCoord2f(0, 1);
176
 
                glVertex3f(-PlankWidth, PlankHeight, PlankThickness);
177
 
                glNormal3f(0, 0, -1);
178
 
                glTexCoord2f(0, 0);
179
 
                glVertex3f(-PlankWidth, PlankHeight, -PlankThickness);
180
 
                glTexCoord2f(1, 0);
181
 
                glVertex3f(PlankWidth, PlankHeight, -PlankThickness);
182
 
                glTexCoord2f(1, 1);
183
 
                glVertex3f(PlankWidth, -PlankHeight, -PlankThickness);
184
 
                glTexCoord2f(0, 1);
185
 
                glVertex3f(-PlankWidth, -PlankHeight, -PlankThickness);
186
 
                glNormal3f(0, 1, 0);
187
 
                glTexCoord2f(0, 0);
188
 
                glVertex3f(-PlankWidth, PlankHeight, PlankThickness);
189
 
                glTexCoord2f(1, 0);
190
 
                glVertex3f(PlankWidth, PlankHeight, PlankThickness);
191
 
                glTexCoord2f(1, 1);
192
 
                glVertex3f(PlankWidth, PlankHeight, -PlankThickness);
193
 
                glTexCoord2f(0, 1);
194
 
                glVertex3f(-PlankWidth, PlankHeight, -PlankThickness);
195
 
                glNormal3f(0, -1, 0);
196
 
                glTexCoord2f(0, 0);
197
 
                glVertex3f(-PlankWidth, -PlankHeight, -PlankThickness);
198
 
                glTexCoord2f(1, 0);
199
 
                glVertex3f(PlankWidth, -PlankHeight, -PlankThickness);
200
 
                glTexCoord2f(1, 1);
201
 
                glVertex3f(PlankWidth, -PlankHeight, PlankThickness);
202
 
                glTexCoord2f(0, 1);
203
 
                glVertex3f(-PlankWidth, -PlankHeight, PlankThickness);
204
 
                glNormal3f(1, 0, 0);
205
 
                glTexCoord2f(0, 0);
206
 
                glVertex3f(PlankWidth, -PlankHeight, PlankThickness);
207
 
                glTexCoord2f(1, 0);
208
 
                glVertex3f(PlankWidth, -PlankHeight, -PlankThickness);
209
 
                glTexCoord2f(1, 1);
210
 
                glVertex3f(PlankWidth, PlankHeight, -PlankThickness);
211
 
                glTexCoord2f(0, 1);
212
 
                glVertex3f(PlankWidth, PlankHeight, PlankThickness);
213
 
                glNormal3f(-1, 0, 0);
214
 
                glTexCoord2f(0, 0);
215
 
                glVertex3f(-PlankWidth, PlankHeight, PlankThickness);
216
 
                glTexCoord2f(1, 0);
217
 
                glVertex3f(-PlankWidth, PlankHeight, -PlankThickness);
218
 
                glTexCoord2f(1, 1);
219
 
                glVertex3f(-PlankWidth, -PlankHeight, -PlankThickness);
220
 
                glTexCoord2f(0, 1);
221
 
                glVertex3f(-PlankWidth, -PlankHeight, PlankThickness);
222
 
                glEnd();
223
 
                glEndList();
224
 
                cp->AreObjectsDefined[ObjWoodPlank] = 1;
225
 
#ifdef DEBUG_LISTS
226
 
                (void) printf("WoodPlank drawn SLOWLY\n");
227
 
#endif
228
 
        } else {
229
 
                glCallList(objects + ObjWoodPlank);
230
 
#ifdef DEBUG_LISTS
231
 
                (void) printf("WoodPlank drawn quickly\n");
232
 
#endif
233
 
        }
 
161
        glBegin(GL_QUADS);
 
162
        glNormal3f(0, 0, 1);
 
163
        glTexCoord2f(0, 0);
 
164
        glVertex3f(-PlankWidth, -PlankHeight, PlankThickness);
 
165
        glTexCoord2f(1, 0);
 
166
        glVertex3f(PlankWidth, -PlankHeight, PlankThickness);
 
167
        glTexCoord2f(1, 1);
 
168
        glVertex3f(PlankWidth, PlankHeight, PlankThickness);
 
169
        glTexCoord2f(0, 1);
 
170
        glVertex3f(-PlankWidth, PlankHeight, PlankThickness);
 
171
        glNormal3f(0, 0, -1);
 
172
        glTexCoord2f(0, 0);
 
173
        glVertex3f(-PlankWidth, PlankHeight, -PlankThickness);
 
174
        glTexCoord2f(1, 0);
 
175
        glVertex3f(PlankWidth, PlankHeight, -PlankThickness);
 
176
        glTexCoord2f(1, 1);
 
177
        glVertex3f(PlankWidth, -PlankHeight, -PlankThickness);
 
178
        glTexCoord2f(0, 1);
 
179
        glVertex3f(-PlankWidth, -PlankHeight, -PlankThickness);
 
180
        glNormal3f(0, 1, 0);
 
181
        glTexCoord2f(0, 0);
 
182
        glVertex3f(-PlankWidth, PlankHeight, PlankThickness);
 
183
        glTexCoord2f(1, 0);
 
184
        glVertex3f(PlankWidth, PlankHeight, PlankThickness);
 
185
        glTexCoord2f(1, 1);
 
186
        glVertex3f(PlankWidth, PlankHeight, -PlankThickness);
 
187
        glTexCoord2f(0, 1);
 
188
        glVertex3f(-PlankWidth, PlankHeight, -PlankThickness);
 
189
        glNormal3f(0, -1, 0);
 
190
        glTexCoord2f(0, 0);
 
191
        glVertex3f(-PlankWidth, -PlankHeight, -PlankThickness);
 
192
        glTexCoord2f(1, 0);
 
193
        glVertex3f(PlankWidth, -PlankHeight, -PlankThickness);
 
194
        glTexCoord2f(1, 1);
 
195
        glVertex3f(PlankWidth, -PlankHeight, PlankThickness);
 
196
        glTexCoord2f(0, 1);
 
197
        glVertex3f(-PlankWidth, -PlankHeight, PlankThickness);
 
198
        glNormal3f(1, 0, 0);
 
199
        glTexCoord2f(0, 0);
 
200
        glVertex3f(PlankWidth, -PlankHeight, PlankThickness);
 
201
        glTexCoord2f(1, 0);
 
202
        glVertex3f(PlankWidth, -PlankHeight, -PlankThickness);
 
203
        glTexCoord2f(1, 1);
 
204
        glVertex3f(PlankWidth, PlankHeight, -PlankThickness);
 
205
        glTexCoord2f(0, 1);
 
206
        glVertex3f(PlankWidth, PlankHeight, PlankThickness);
 
207
        glNormal3f(-1, 0, 0);
 
208
        glTexCoord2f(0, 0);
 
209
        glVertex3f(-PlankWidth, PlankHeight, PlankThickness);
 
210
        glTexCoord2f(1, 0);
 
211
        glVertex3f(-PlankWidth, PlankHeight, -PlankThickness);
 
212
        glTexCoord2f(1, 1);
 
213
        glVertex3f(-PlankWidth, -PlankHeight, -PlankThickness);
 
214
        glTexCoord2f(0, 1);
 
215
        glVertex3f(-PlankWidth, -PlankHeight, PlankThickness);
 
216
        glEnd();
 
217
 
 
218
        return True;
234
219
}
235
220
 
236
 
static void
 
221
static Bool
237
222
draw_impossiblecage(cagestruct * cp)
238
223
{
239
224
        glPushMatrix();
240
225
        glRotatef(90, 0, 1, 0);
241
226
        glTranslatef(0.0, PlankHeight - PlankWidth, -PlankThickness - PlankWidth);
242
 
        draw_woodplank(cp);
 
227
        if (!draw_woodplank(cp))
 
228
                return False;
243
229
        glPopMatrix();
244
230
        glPushMatrix();
245
231
        glRotatef(90, 0, 0, 1);
246
232
        glTranslatef(0.0, PlankHeight - PlankWidth, PlankWidth - PlankThickness);
247
 
        draw_woodplank(cp);
 
233
        if (!draw_woodplank(cp))
 
234
                return False;
248
235
        glPopMatrix();
249
236
        glPushMatrix();
250
237
        glRotatef(90, 0, 1, 0);
251
238
        glTranslatef(0.0, PlankWidth - PlankHeight, -PlankThickness - PlankWidth);
252
 
        draw_woodplank(cp);
 
239
        if (!draw_woodplank(cp))
 
240
                return False;
253
241
        glPopMatrix();
254
242
        glPushMatrix();
255
243
        glTranslatef(0.0, PlankWidth - PlankHeight, 3 * PlankThickness - PlankWidth);
256
 
        draw_woodplank(cp);
 
244
        if (!draw_woodplank(cp))
 
245
                return False;
257
246
        glPopMatrix();
258
247
        glPushMatrix();
259
248
        glRotatef(90, 0, 0, 1);
260
249
        glTranslatef(0.0, PlankWidth - PlankHeight, PlankWidth - PlankThickness);
261
 
        draw_woodplank(cp);
 
250
        if (!draw_woodplank(cp))
 
251
                return False;
262
252
        glPopMatrix();
263
253
        glPushMatrix();
264
254
        glTranslatef(0.0, PlankWidth - PlankHeight, PlankWidth - 3 * PlankThickness);
265
 
        draw_woodplank(cp);
 
255
        if (!draw_woodplank(cp))
 
256
                return False;
266
257
        glPopMatrix();
267
258
        glPushMatrix();
268
259
        glTranslatef(0.0, PlankHeight - PlankWidth, 3 * PlankThickness - PlankWidth);
269
 
        draw_woodplank(cp);
 
260
        if (!draw_woodplank(cp))
 
261
                return False;
270
262
        glPopMatrix();
271
263
        glPushMatrix();
272
264
        glRotatef(90, 0, 0, 1);
273
265
        glTranslatef(0.0, PlankHeight - PlankWidth, PlankThickness - PlankWidth);
274
 
        draw_woodplank(cp);
 
266
        if (!draw_woodplank(cp))
 
267
                return False;
275
268
        glPopMatrix();
276
269
        glPushMatrix();
277
270
        glTranslatef(0.0, PlankHeight - PlankWidth, PlankWidth - 3 * PlankThickness);
278
 
        draw_woodplank(cp);
 
271
        if (!draw_woodplank(cp))
 
272
                return False;
279
273
        glPopMatrix();
280
274
        glPushMatrix();
281
275
        glRotatef(90, 0, 1, 0);
282
276
        glTranslatef(0.0, PlankHeight - PlankWidth, PlankWidth + PlankThickness);
283
 
        draw_woodplank(cp);
 
277
        if (!draw_woodplank(cp))
 
278
                return False;
284
279
        glPopMatrix();
285
280
        glPushMatrix();
286
281
        glRotatef(90, 0, 0, 1);
287
282
        glTranslatef(0.0, PlankWidth - PlankHeight, PlankThickness - PlankWidth);
288
 
        draw_woodplank(cp);
 
283
        if (!draw_woodplank(cp))
 
284
                return False;
289
285
        glPopMatrix();
290
286
        glPushMatrix();
291
287
        glRotatef(90, 0, 1, 0);
292
288
        glTranslatef(0.0, PlankWidth - PlankHeight, PlankWidth + PlankThickness);
293
 
        draw_woodplank(cp);
 
289
        if (!draw_woodplank(cp))
 
290
                return False;
294
291
        glPopMatrix();
 
292
        return True;
295
293
}
296
294
 
297
295
void
298
 
reshape_cage(ModeInfo * mi, int width, int height)
 
296
reshape(ModeInfo * mi, int width, int height)
299
297
{
300
298
        cagestruct *cp = &cage[MI_SCREEN(mi)];
 
299
        int i;
301
300
 
302
301
        glViewport(0, 0, cp->WindW = (GLint) width, cp->WindH = (GLint) height);
303
302
        glMatrixMode(GL_PROJECTION);
304
303
        glLoadIdentity();
305
304
        glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 15.0);
306
305
        glMatrixMode(GL_MODELVIEW);
307
 
        if (width >= 1024) {
308
 
                glLineWidth(3);
309
 
                glPointSize(3);
310
 
        } else if (width >= 512) {
311
 
                glLineWidth(2);
312
 
                glPointSize(2);
313
 
        } else {
314
 
                glLineWidth(1);
315
 
                glPointSize(1);
316
 
        }
317
 
        cp->AreObjectsDefined[ObjWoodPlank] = 0;
 
306
        i = width / 512 + 1;
 
307
        glLineWidth(i);
 
308
        glPointSize(i);
318
309
}
319
310
 
320
311
static void
321
 
pinit(void)
 
312
pinit(ModeInfo *mi)
322
313
{
 
314
        int status;
323
315
        glClearDepth(1.0);
324
316
        glClearColor(0.0, 0.0, 0.0, 1.0);
325
317
 
346
338
        glEnable(GL_CULL_FACE);
347
339
 
348
340
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
349
 
        gluBuild2DMipmaps(GL_TEXTURE_2D, 3, WoodTextureWidth, WoodTextureHeight,
350
 
                          GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
 
341
 
 
342
        clear_gl_error();
 
343
        if (MI_IS_MONO(mi))
 
344
      status = 0;
 
345
    else
 
346
      status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
 
347
                                 WoodTextureWidth, WoodTextureHeight,
 
348
                                 GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
 
349
        if (status)
 
350
          {
 
351
                const char *s = (char *) gluErrorString (status);
 
352
                fprintf (stderr, "%s: error mipmapping texture: %s\n",
 
353
                                 progname, (s ? s : "(unknown)"));
 
354
                exit (1);
 
355
          }
 
356
        check_gl_error("mipmapping");
 
357
 
351
358
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
352
359
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
353
360
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
359
366
}
360
367
 
361
368
void
 
369
release_cage(ModeInfo * mi)
 
370
{
 
371
        if (cage != NULL) {
 
372
                int screen;
 
373
 
 
374
                for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
 
375
                        cagestruct *cp = &cage[screen];
 
376
 
 
377
                        if (cp->glx_context) {
 
378
                                cp->glx_context = (GLXContext *) NULL;
 
379
                        }
 
380
                }
 
381
                (void) free((void *) cage);
 
382
                cage = (cagestruct *) NULL;
 
383
        }
 
384
        FreeAllGL(mi);
 
385
}
 
386
 
 
387
void
362
388
init_cage(ModeInfo * mi)
363
389
{
364
 
        int         screen = MI_SCREEN(mi);
365
390
        cagestruct *cp;
366
391
 
367
392
        if (cage == NULL) {
369
394
                                               sizeof (cagestruct))) == NULL)
370
395
                        return;
371
396
        }
372
 
        cp = &cage[screen];
 
397
        cp = &cage[MI_SCREEN(mi)];
 
398
 
373
399
        cp->step = NRAND(90);
374
 
 
375
400
        if ((cp->glx_context = init_GL(mi)) != NULL) {
376
401
 
377
 
                reshape_cage(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
 
402
                reshape(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
378
403
                glDrawBuffer(GL_BACK);
379
 
                if (!glIsList(objects))
380
 
                        objects = glGenLists(1);
381
 
                pinit();
 
404
                pinit(mi);
382
405
        } else {
383
406
                MI_CLEARWINDOW(mi);
384
407
        }
387
410
void
388
411
draw_cage(ModeInfo * mi)
389
412
{
390
 
        cagestruct *cp = &cage[MI_SCREEN(mi)];
391
 
 
392
413
        Display    *display = MI_DISPLAY(mi);
393
414
        Window      window = MI_WINDOW(mi);
 
415
        cagestruct *cp;
 
416
 
 
417
        if (cage == NULL)
 
418
                return;
 
419
        cp = &cage[MI_SCREEN(mi)];
394
420
 
395
421
        MI_IS_DRAWN(mi) = True;
396
 
 
397
422
        if (!cp->glx_context)
398
423
                return;
399
424
 
415
440
        glRotatef(cp->step * 100, 0, 0, 1);
416
441
        glRotatef(25 + cos(cp->step * 5) * 6, 1, 0, 0);
417
442
        glRotatef(204.5 - sin(cp->step * 5) * 8, 0, 1, 0);
418
 
        draw_impossiblecage(cp);
 
443
        if (!draw_impossiblecage(cp)) {
 
444
                release_cage(mi);
 
445
                return;
 
446
        }
419
447
 
420
448
        glPopMatrix();
421
 
 
422
 
    if (mi->fps_p) do_fps (mi);
 
449
        if (MI_IS_FPS(mi)) do_fps (mi);
423
450
        glFlush();
424
451
 
425
452
        glXSwapBuffers(display, window);
436
463
                return;
437
464
 
438
465
        glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(cp->glx_context));
439
 
        pinit();
440
 
}
441
 
 
442
 
void
443
 
release_cage(ModeInfo * mi)
444
 
{
445
 
        if (cage != NULL) {
446
 
                (void) free((void *) cage);
447
 
                cage = NULL;
448
 
        }
449
 
        if (glIsList(objects)) {
450
 
                glDeleteLists(objects, 1);
451
 
        }
452
 
        FreeAllGL(mi);
 
466
        pinit(mi);
453
467
}
454
468
 
455
469
#endif