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

« back to all changes in this revision

Viewing changes to hacks/glx/morph3d.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:
53
53
 
54
54
#ifdef STANDALONE
55
55
# define MODE_moebius
56
 
# define PROGCLASS              "Morph3d"
57
 
# define HACK_INIT              init_morph3d
58
 
# define HACK_DRAW              draw_morph3d
59
 
# define HACK_RESHAPE   reshape
60
 
# define morph3d_opts   xlockmore_opts
61
56
# define DEFAULTS               "*delay:                40000   \n"             \
62
57
                                                "*showFPS:      False   \n"             \
63
58
                                                "*count:                0               \n"
 
59
# define refresh_morph3d 0
 
60
# define morph3d_handle_event 0
64
61
# include "xlockmore.h"         /* from the xscreensaver distribution */
65
62
#else /* !STANDALONE */
66
63
# include "xlock.h"             /* from the xlockmore distribution */
68
65
 
69
66
#ifdef MODE_moebius
70
67
 
71
 
ModeSpecOpt morph3d_opts =
 
68
ENTRYPOINT ModeSpecOpt morph3d_opts =
72
69
{0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL};
73
70
 
74
71
#ifdef USE_MODULES
124
121
        int         VisibleSpikes;
125
122
        void        (*draw_object) (ModeInfo * mi);
126
123
        float       Magnitude;
127
 
        float      *MaterialColor[20];
 
124
        const float *MaterialColor[20];
128
125
        GLXContext *glx_context;
 
126
    int         arrayninit;
 
127
 
129
128
} morph3dstruct;
130
129
 
131
 
static float front_shininess[] =
132
 
{60.0};
133
 
static float front_specular[] =
134
 
{0.7, 0.7, 0.7, 1.0};
135
 
static float ambient[] =
136
 
{0.0, 0.0, 0.0, 1.0};
137
 
static float diffuse[] =
138
 
{1.0, 1.0, 1.0, 1.0};
139
 
static float position0[] =
140
 
{1.0, 1.0, 1.0, 0.0};
141
 
static float position1[] =
142
 
{-1.0, -1.0, 1.0, 0.0};
143
 
static float lmodel_ambient[] =
144
 
{0.5, 0.5, 0.5, 1.0};
145
 
static float lmodel_twoside[] =
146
 
{GL_TRUE};
 
130
static const GLfloat front_shininess[] = {60.0};
 
131
static const GLfloat front_specular[]  = {0.7, 0.7, 0.7, 1.0};
 
132
static const GLfloat ambient[]         = {0.0, 0.0, 0.0, 1.0};
 
133
static const GLfloat diffuse[]         = {1.0, 1.0, 1.0, 1.0};
 
134
static const GLfloat position0[]       = {1.0, 1.0, 1.0, 0.0};
 
135
static const GLfloat position1[]       = {-1.0, -1.0, 1.0, 0.0};
 
136
static const GLfloat lmodel_ambient[]  = {0.5, 0.5, 0.5, 1.0};
 
137
static const GLfloat lmodel_twoside[]  = {GL_TRUE};
147
138
 
148
 
static float MaterialRed[] =
149
 
{0.7, 0.0, 0.0, 1.0};
150
 
static float MaterialGreen[] =
151
 
{0.1, 0.5, 0.2, 1.0};
152
 
static float MaterialBlue[] =
153
 
{0.0, 0.0, 0.7, 1.0};
154
 
static float MaterialCyan[] =
155
 
{0.2, 0.5, 0.7, 1.0};
156
 
static float MaterialYellow[] =
157
 
{0.7, 0.7, 0.0, 1.0};
158
 
static float MaterialMagenta[] =
159
 
{0.6, 0.2, 0.5, 1.0};
160
 
static float MaterialWhite[] =
161
 
{0.7, 0.7, 0.7, 1.0};
162
 
static float MaterialGray[] =
163
 
{0.5, 0.5, 0.5, 1.0};
 
139
static const GLfloat MaterialRed[]     = {0.7, 0.0, 0.0, 1.0};
 
140
static const GLfloat MaterialGreen[]   = {0.1, 0.5, 0.2, 1.0};
 
141
static const GLfloat MaterialBlue[]    = {0.0, 0.0, 0.7, 1.0};
 
142
static const GLfloat MaterialCyan[]    = {0.2, 0.5, 0.7, 1.0};
 
143
static const GLfloat MaterialYellow[]  = {0.7, 0.7, 0.0, 1.0};
 
144
static const GLfloat MaterialMagenta[] = {0.6, 0.2, 0.5, 1.0};
 
145
static const GLfloat MaterialWhite[]   = {0.7, 0.7, 0.7, 1.0};
 
146
static const GLfloat MaterialGray[]    = {0.5, 0.5, 0.5, 1.0};
164
147
 
165
148
static morph3dstruct *morph3d = (morph3dstruct *) NULL;
166
149
 
273
256
  GLfloat   Zf=(Edge)*(Z);                                                                                       \
274
257
  GLfloat   AmpVr2=(Amp)/sqr((Edge)*cossec36_2);                                                                 \
275
258
                                                                                                                 \
276
 
  static    GLfloat x[6],y[6];                                                                                   \
277
 
  static    int arrayninit=1;                                                                                    \
 
259
  GLfloat x[6],y[6];                                                                                             \
278
260
                                                                                                                 \
279
 
  if (arrayninit) {                                                                                              \
280
 
    for(Fi=0;Fi<6;Fi++) {                                                                                        \
281
 
      x[Fi]=-cos( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge);                                             \
282
 
      y[Fi]=sin( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge);                                              \
283
 
    }                                                                                                            \
284
 
    arrayninit=0;                                                                                                \
 
261
  for(Fi=0;Fi<6;Fi++) {                                                                                          \
 
262
    x[Fi]=-cos( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge);                                               \
 
263
    y[Fi]=sin( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge);                                                \
285
264
  }                                                                                                              \
286
265
                                                                                                                 \
287
266
  for (Ri=1; Ri<=(Divisions); Ri++) {                                                                            \
291
270
        Xf=(float)(Ri-Ti)*x[Fi] + (float)Ti*x[Fi+1];                                                             \
292
271
        Yf=(float)(Ri-Ti)*y[Fi] + (float)Ti*y[Fi+1];                                                             \
293
272
        Xa=Xf+0.001; Yb=Yf+0.001;                                                                                \
294
 
        Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2);                                                         \
295
 
        Factor1=1-((sqr(Xa)+Yf2)*AmpVr2);                                                                        \
296
 
        Factor2=1-((Xf2+sqr(Yb))*AmpVr2);                                                                        \
 
273
        Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2);                                                             \
 
274
        Factor1=1-((sqr(Xa)+Yf2)*AmpVr2);                                                                            \
 
275
        Factor2=1-((Xf2+sqr(Yb))*AmpVr2);                                                                            \
297
276
        VertX=Factor*Xf;        VertY=Factor*Yf;        VertZ=Factor*Zf;                                         \
298
277
        NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ;                                  \
299
278
        NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ;                                  \
604
583
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
605
584
}
606
585
 
607
 
void
608
 
reshape(ModeInfo * mi, int width, int height)
 
586
ENTRYPOINT void
 
587
reshape_morph3d(ModeInfo * mi, int width, int height)
609
588
{
610
589
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
611
590
 
728
707
        }
729
708
}
730
709
 
731
 
void
 
710
ENTRYPOINT void
732
711
init_morph3d(ModeInfo * mi)
733
712
{
734
713
        morph3dstruct *mp;
744
723
 
745
724
        if ((mp->glx_context = init_GL(mi)) != NULL) {
746
725
 
747
 
                reshape(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
 
726
                reshape_morph3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
748
727
                glDrawBuffer(GL_BACK);
749
728
                mp->object = MI_COUNT(mi);
750
729
                if (mp->object <= 0 || mp->object > 5)
755
734
        }
756
735
}
757
736
 
758
 
void
 
737
ENTRYPOINT void
759
738
draw_morph3d(ModeInfo * mi)
760
739
{
761
740
        Display    *display = MI_DISPLAY(mi);
820
799
        mp->step += 0.05;
821
800
}
822
801
 
823
 
void
 
802
#ifndef STANDALONE
 
803
ENTRYPOINT void
824
804
change_morph3d(ModeInfo * mi)
825
805
{
826
806
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
831
811
        mp->object = (mp->object) % 5 + 1;
832
812
        pinit(mi);
833
813
}
 
814
#endif /* !STANDALONE */
834
815
 
835
 
void
 
816
ENTRYPOINT void
836
817
release_morph3d(ModeInfo * mi)
837
818
{
838
819
        if (morph3d != NULL) {
843
824
}
844
825
 
845
826
#endif
 
827
 
 
828
XSCREENSAVER_MODULE ("Morph3D", morph3d)