~ubuntu-branches/ubuntu/lucid/xscreensaver/lucid

« back to all changes in this revision

Viewing changes to hacks/glx/stairs.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2007-12-06 09:53:12 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206095312-fkzcwe4vqm50z208
Tags: 5.04-1ubuntu1
* Merge from debian unstable, remaining changes:
  - split xscreensaver into xscreensaver, xscreensaver-data (hacks we ship),
    xscreensaver-data-extra (hacks in universe). split out gl hacks for
    universe to xscreensaver-gl-extra
  - use fridge for rss screensavers
  - create and install .desktop files for gnome-screensaver

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 * In real OpenGL, PseudoColor DO NOT support texture map (as far as I know).
58
58
 */
59
59
 
60
 
#include <X11/Intrinsic.h>
61
 
 
62
60
#ifdef STANDALONE
63
 
# define PROGCLASS                      "Stairs"
64
 
# define HACK_INIT                      init_stairs
65
 
# define HACK_DRAW                      draw_stairs
66
 
# define HACK_RESHAPE           reshape_stairs
67
 
# define stairs_opts            xlockmore_opts
68
61
# define DEFAULTS                       "*delay:                20000   \n" \
69
62
                                                        "*showFPS:      False   \n"
 
63
# define refresh_stairs 0
 
64
# define stairs_handle_event 0
70
65
# include "xlockmore.h"         /* from the xscreensaver distribution */
71
66
#else /* !STANDALONE */
72
67
# include "xlock.h"                     /* from the xlockmore distribution */
75
70
 
76
71
#ifdef USE_GL
77
72
 
78
 
#include <GL/glu.h>
79
73
#include "e_textures.h"
80
74
 
81
 
ModeSpecOpt stairs_opts =
 
75
ENTRYPOINT ModeSpecOpt stairs_opts =
82
76
{0, NULL, 0, NULL, NULL};
83
77
 
84
78
#ifdef USE_MODULES
109
103
        int         sphere_position;
110
104
        int         sphere_tick;
111
105
        GLXContext *glx_context;
 
106
    GLuint objects;
112
107
} stairsstruct;
113
108
 
114
 
static float front_shininess[] =
115
 
{60.0};
116
 
static float front_specular[] =
117
 
{0.7, 0.7, 0.7, 1.0};
118
 
static float ambient[] =
119
 
{0.0, 0.0, 0.0, 1.0};
120
 
static float diffuse[] =
121
 
{1.0, 1.0, 1.0, 1.0};
122
 
static float position0[] =
123
 
{1.0, 1.0, 1.0, 0.0};
124
 
static float position1[] =
125
 
{-1.0, -1.0, 1.0, 0.0};
126
 
static float lmodel_ambient[] =
127
 
{0.5, 0.5, 0.5, 1.0};
128
 
static float lmodel_twoside[] =
129
 
{GL_TRUE};
 
109
static const float front_shininess[] = {60.0};
 
110
static const float front_specular[] = {0.7, 0.7, 0.7, 1.0};
 
111
static const float ambient[] = {0.0, 0.0, 0.0, 1.0};
 
112
static const float diffuse[] = {1.0, 1.0, 1.0, 1.0};
 
113
static const float position0[] = {1.0, 1.0, 1.0, 0.0};
 
114
static const float position1[] = {-1.0, -1.0, 1.0, 0.0};
 
115
static const float lmodel_ambient[] = {0.5, 0.5, 0.5, 1.0};
 
116
static const float lmodel_twoside[] = {GL_TRUE};
130
117
 
131
118
#if 0
132
 
static float MaterialRed[] =
133
 
{0.7, 0.0, 0.0, 1.0};
134
 
static float MaterialGreen[] =
135
 
{0.1, 0.5, 0.2, 1.0};
136
 
static float MaterialBlue[] =
137
 
{0.0, 0.0, 0.7, 1.0};
138
 
static float MaterialCyan[] =
139
 
{0.2, 0.5, 0.7, 1.0};
140
 
static float MaterialMagenta[] =
141
 
{0.6, 0.2, 0.5, 1.0};
142
 
static float MaterialGray[] =
143
 
{0.2, 0.2, 0.2, 1.0};
144
 
static float MaterialGray5[] =
145
 
{0.5, 0.5, 0.5, 1.0};
146
 
static float MaterialGray6[] =
147
 
{0.6, 0.6, 0.6, 1.0};
148
 
static float MaterialGray8[] =
149
 
{0.8, 0.8, 0.8, 1.0};
 
119
static const float MaterialRed[] = {0.7, 0.0, 0.0, 1.0};
 
120
static const float MaterialGreen[] = {0.1, 0.5, 0.2, 1.0};
 
121
static const float MaterialBlue[] = {0.0, 0.0, 0.7, 1.0};
 
122
static const float MaterialCyan[] = {0.2, 0.5, 0.7, 1.0};
 
123
static const float MaterialMagenta[] = {0.6, 0.2, 0.5, 1.0};
 
124
static const float MaterialGray[] = {0.2, 0.2, 0.2, 1.0};
 
125
static const float MaterialGray5[] = {0.5, 0.5, 0.5, 1.0};
 
126
static const float MaterialGray6[] = {0.6, 0.6, 0.6, 1.0};
 
127
static const float MaterialGray8[] = {0.8, 0.8, 0.8, 1.0};
150
128
 
151
129
#endif
152
 
static float MaterialYellow[] =
153
 
{0.7, 0.7, 0.0, 1.0};
154
 
static float MaterialWhite[] =
155
 
{0.7, 0.7, 0.7, 1.0};
 
130
static const float MaterialYellow[] = {0.7, 0.7, 0.0, 1.0};
 
131
static const float MaterialWhite[] = {0.7, 0.7, 0.7, 1.0};
156
132
 
157
 
static float positions[] =
 
133
static const float positions[] =
158
134
{
159
135
        -2.5, 4.0, 0.0,         /* First one is FUDGED :) */
160
136
        -3.0, 3.25, 1.0,
198
174
#define SPHERE_TICKS 8
199
175
 
200
176
static stairsstruct *stairs = NULL;
201
 
static GLuint objects;
202
177
 
203
178
#define ObjSphere    0
204
179
 
413
388
                sp->sphere_position = 0;
414
389
}
415
390
 
416
 
void
417
 
reshape_stairs(ModeInfo * mi, int width, int height)
 
391
ENTRYPOINT void
 
392
reshape_stairs (ModeInfo * mi, int width, int height)
418
393
{
419
394
        stairsstruct *sp = &stairs[MI_SCREEN(mi)];
420
395
 
489
464
        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
490
465
}
491
466
 
492
 
void
493
 
init_stairs(ModeInfo * mi)
 
467
ENTRYPOINT void
 
468
init_stairs (ModeInfo * mi)
494
469
{
495
470
        int         screen = MI_SCREEN(mi);
496
471
        stairsstruct *sp;
502
477
        }
503
478
        sp = &stairs[screen];
504
479
        sp->step = 0.0;
 
480
 
 
481
    /* make multiple screens rotate at slightly different rates. */
 
482
    sp->step -= frand(5.0);
 
483
 
505
484
        sp->direction = LRAND() & 1;
506
485
        sp->sphere_position = NRAND(NPOSITIONS / 3) * 3;
507
486
        sp->sphere_tick = 0;
510
489
 
511
490
                reshape_stairs(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
512
491
                glDrawBuffer(GL_BACK);
513
 
                if (!glIsList(objects))
514
 
                        objects = glGenLists(1);
 
492
                if (!glIsList(sp->objects))
 
493
                        sp->objects = glGenLists(1);
515
494
                pinit();
516
495
        } else {
517
496
                MI_CLEARWINDOW(mi);
518
497
        }
519
498
}
520
499
 
521
 
void
522
 
draw_stairs(ModeInfo * mi)
 
500
ENTRYPOINT void
 
501
draw_stairs (ModeInfo * mi)
523
502
{
524
503
        stairsstruct *sp = &stairs[MI_SCREEN(mi)];
525
504
 
562
541
        sp->step += 0.025;
563
542
}
564
543
 
565
 
void
566
 
change_stairs(ModeInfo * mi)
 
544
#ifndef STANDALONE
 
545
ENTRYPOINT void
 
546
change_stairs (ModeInfo * mi)
567
547
{
568
548
        stairsstruct *sp = &stairs[MI_SCREEN(mi)];
569
549
 
573
553
        glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sp->glx_context));
574
554
        pinit();
575
555
}
 
556
#endif /* !STANDALONE */
576
557
 
577
 
void
578
 
release_stairs(ModeInfo * mi)
 
558
ENTRYPOINT void
 
559
release_stairs (ModeInfo * mi)
579
560
{
580
561
        if (stairs != NULL) {
581
 
                (void) free((void *) stairs);
582
 
                stairs = NULL;
583
 
        }
584
 
        if (glIsList(objects)) {
585
 
                glDeleteLists(objects, 1);
 
562
      int i;
 
563
      for (i = 0; i < MI_NUM_SCREENS(mi); i++) {
 
564
        stairsstruct *sp = &stairs[i];
 
565
        if (glIsList(sp->objects)) {
 
566
          glDeleteLists(sp->objects, 1);
 
567
        }
 
568
      }
 
569
      free(stairs);
 
570
      stairs = NULL;
586
571
        }
587
572
        FreeAllGL(mi);
588
573
}
589
574
 
 
575
XSCREENSAVER_MODULE ("Stairs", stairs)
 
576
 
590
577
#endif