~ubuntu-branches/ubuntu/gutsy/rss-glx/gutsy

« back to all changes in this revision

Viewing changes to other_src/busyspheres.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-11-30 18:21:27 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051130182127-5iww7elbiyzej1lk
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <math.h>
22
22
#include <stdio.h>
23
23
#include <stdlib.h>
24
 
#include <time.h>
25
24
#include <GL/gl.h>
26
25
#include <GL/glu.h>
27
 
#include <sys/time.h>
28
26
 
29
27
#include "driver.h"
30
28
#include "rsDefines.h"
41
39
#define EFFECT_LONGITUDE        4
42
40
 
43
41
int OldMode = 0, NewMode;
44
 
float ConvertTime;
 
42
float ConvertTime = 0;
45
43
float Points[NRPOINTS][3];
46
44
 
47
45
void hack_reshape (xstuff_t * XStuff)
64
62
        int i, j;
65
63
        float x, y, r, d;
66
64
        unsigned char texbuf[64][64];
67
 
        struct timeval now;
68
 
 
69
 
        gettimeofday (&now, NULL);
70
 
 
71
 
        ConvertTime = (now.tv_sec * 1000000 + now.tv_usec) * 0.000001;
72
65
 
73
66
        for (i = 0; i < NRPOINTS; i++) {
74
 
                Points[i][0] = myRandf (PIx2);
75
 
                Points[i][1] = myRandf (PI) - 0.5 * PI;
 
67
                Points[i][0] = rsRandf (PIx2);
 
68
                Points[i][1] = rsRandf (PI) - 0.5 * PI;
76
69
                Points[i][2] = Points[i][0];
77
70
                Points[i][3] = Points[i][1];
78
71
        }
110
103
{
111
104
}
112
105
 
113
 
void CalcPoints ()
 
106
void CalcPoints (float currentTime)
114
107
{
115
108
        float x1, x2, y1, y2;
116
109
        int i;
117
 
        float time, dt;
118
 
        struct timeval now;
119
 
 
120
 
        gettimeofday (&now, NULL);
121
 
 
122
 
        time = (now.tv_sec * 1000000 + now.tv_usec) * 0.000001;
123
 
        dt = time - ConvertTime;
 
110
        float dt;
 
111
 
 
112
        dt = currentTime - ConvertTime;
124
113
 
125
114
        if (dt < 5) {
126
115
                for (i = 0; i < NRPOINTS; i++) {
137
126
                                break;
138
127
 
139
128
                        case EFFECT_CRESCENT:
140
 
                                x1 = (i * 0.2 * (1 + sin (0.3 * time))) / (PIx2);
 
129
                                x1 = (i * 0.2 * (1 + sin (0.3 * currentTime))) / (PIx2);
141
130
                                x1 = PIx2 * (x1 - (int)x1);
142
131
                                y1 = PI * ((float)i / NRPOINTS - 0.5);
143
132
 
145
134
 
146
135
                        case EFFECT_DOT:
147
136
                                x1 = Points[i][2];
148
 
                                y1 = ((Points[i][3] > 0) ? 0.5 : -0.5) * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
137
                                y1 = ((Points[i][3] > 0) ? 0.5 : -0.5) * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
149
138
 
150
139
                                break;
151
140
 
152
141
                        case EFFECT_RING:
153
142
                                x1 = Points[i][2];
154
 
                                y1 = Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
143
                                y1 = Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
155
144
 
156
145
                                break;
157
146
 
169
158
                                break;
170
159
 
171
160
                        case EFFECT_CRESCENT:
172
 
                                x2 = (i * 0.2 * (1 + sin (0.3 * time))) / (PIx2);
 
161
                                x2 = (i * 0.2 * (1 + sin (0.3 * currentTime))) / (PIx2);
173
162
                                x2 = PIx2 * (x2 - (int)x2);
174
163
                                y2 = PI * ((float)i / NRPOINTS - 0.5);
175
164
 
178
167
                        case EFFECT_DOT:
179
168
                                x2 = Points[i][2];
180
169
                                if (Points[i][3] > 0) {
181
 
                                        y2 = 0.5 * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
170
                                        y2 = 0.5 * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
182
171
                                } else {
183
 
                                        y2 = -0.5 * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
172
                                        y2 = -0.5 * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
184
173
                                }
185
174
 
186
175
                                break;
187
176
 
188
177
                        case EFFECT_RING:
189
178
                                x2 = Points[i][2];
190
 
                                y2 = Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
179
                                y2 = Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
191
180
 
192
181
                                break;
193
182
 
212
201
 
213
202
                case EFFECT_CRESCENT:
214
203
                        for (i = 0; i < NRPOINTS; i++) {
215
 
                                Points[i][0] = (i * 0.2 * (1 + sin (0.3 * time))) / (PIx2);
 
204
                                Points[i][0] = (i * 0.2 * (1 + sin (0.3 * currentTime))) / (PIx2);
216
205
                                Points[i][0] = PIx2 * (Points[i][0] - (int)Points[i][0]);
217
206
                                Points[i][1] = PI * ((float)i / NRPOINTS - 0.5);
218
207
                        }
222
211
                case EFFECT_DOT:
223
212
                        for (i = 0; i < NRPOINTS; i++) {
224
213
                                Points[i][0] = Points[i][2];
225
 
                                Points[i][1] = ((Points[i][3] > 0) ? 0.5 : -0.5) * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
214
                                Points[i][1] = ((Points[i][3] > 0) ? 0.5 : -0.5) * PI - Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
226
215
                        }
227
216
 
228
217
                        break;
230
219
                case EFFECT_RING:
231
220
                        for (i = 0; i < NRPOINTS; i++) {
232
221
                                Points[i][0] = Points[i][2];
233
 
                                Points[i][1] = Points[i][3] * 0.5 * (1 + sin (0.3 * time));
 
222
                                Points[i][1] = Points[i][3] * 0.5 * (1 + sin (0.3 * currentTime));
234
223
                        }
235
224
 
236
225
                        break;
245
234
        }
246
235
}
247
236
 
248
 
void hack_draw (xstuff_t * XStuff)
 
237
void hack_draw (xstuff_t * XStuff, double currentTime, float frameTime)
249
238
{
250
239
        float x, y, z, w, ws;
251
240
        int i, k;
252
 
        float st2, ct2, t, t2, time;
 
241
        float st2, ct2, t, t2;
253
242
        float fb_buffer[NRPOINTS * 37 * 4];
254
 
        struct timeval now;
255
 
 
256
 
        gettimeofday (&now, NULL);
257
 
 
258
 
        time = (now.tv_sec * 1000000 + now.tv_usec) * 0.000001;
259
 
        t = 5 * time + 0.35 * (cos (time * 0.41 + 0.123) + cos (time * 0.51 + 0.234) + cos (time * 0.61 + 0.623) + cos (time * 0.21 + 0.723));
260
 
        t2 = 0.3 * time;
261
 
 
262
 
        if ((time - ConvertTime) > 10) {
 
243
 
 
244
        currentTime = currentTime - (int)currentTime + (int)currentTime % 86400;
 
245
 
 
246
        t = 5 * currentTime + 0.35 * (cos (currentTime * 0.41 + 0.123) + cos (currentTime * 0.51 + 0.234) + cos (currentTime * 0.61 + 0.623) + cos (currentTime * 0.21 + 0.723));
 
247
        t2 = 0.3 * currentTime;
 
248
 
 
249
        if ((currentTime - ConvertTime) > 10) {
263
250
                OldMode = NewMode;
264
 
                NewMode = myRandi (5);
265
 
                ConvertTime = time;
 
251
                NewMode = rsRandi (5);
 
252
                ConvertTime = currentTime;
266
253
        }
267
254
 
268
 
        CalcPoints();
 
255
        CalcPoints(currentTime);
269
256
 
270
257
        glClear (GL_COLOR_BUFFER_BIT);
271
258