projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver]
/
hacks
/
glx
/
flurry.c
diff --git
a/hacks/glx/flurry.c
b/hacks/glx/flurry.c
index 3a40be48e5ab8b258aa50d9c053ed3fb2fe1c7c4..c9008a9471ed428f4500ee4c6da2c7e811e2569b 100644
(file)
--- a/
hacks/glx/flurry.c
+++ b/
hacks/glx/flurry.c
@@
-41,19
+41,14
@@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static const char sccsid[] = "@(#)flurry.c 4.07 97/11/24 xlockmore";
#endif
static const char sccsid[] = "@(#)flurry.c 4.07 97/11/24 xlockmore";
#endif
-#define DEF_PRESET "
classic
"
+#define DEF_PRESET "
random
"
#define DEF_BRIGHTNESS "8"
#define DEF_BRIGHTNESS "8"
-#include <X11/Intrinsic.h>
-
-# define PROGCLASS "Flurry"
-# define HACK_INIT init_flurry
-# define HACK_DRAW draw_flurry
-# define HACK_RESHAPE reshape_flurry
-# define flurry_opts xlockmore_opts
# define DEFAULTS "*delay: 10000 \n" \
"*showFPS: False \n"
# define DEFAULTS "*delay: 10000 \n" \
"*showFPS: False \n"
+# define release_flurry 0
+# define flurry_handle_event xlockmore_no_events
# include "xlockmore.h" /* from the xscreensaver distribution */
#ifdef USE_GL
# include "xlockmore.h" /* from the xscreensaver distribution */
#ifdef USE_GL
@@
-70,17
+65,17
@@
static argtype vars[] = {
#define countof(x) (sizeof((x))/sizeof((*x)))
#define countof(x) (sizeof((x))/sizeof((*x)))
-ModeSpecOpt flurry_opts = {countof(opts), opts, countof(vars), vars, NULL};
+
ENTRYPOINT
ModeSpecOpt flurry_opts = {countof(opts), opts, countof(vars), vars, NULL};
#ifdef USE_MODULES
ModStruct flurry_description = {
"flurry",
"init_flurry",
"draw_flurry",
#ifdef USE_MODULES
ModStruct flurry_description = {
"flurry",
"init_flurry",
"draw_flurry",
-
"release_flurry"
,
+
NULL
,
"draw_flurry",
"init_flurry",
"draw_flurry",
"init_flurry",
-
NULL
,
+
"free_flurry"
,
&flurry_opts,
1000, 1, 2, 1, 4, 1.0,
"",
&flurry_opts,
1000, 1, 2, 1, 4, 1.0,
"",
@@
-91,14
+86,11
@@
ModStruct flurry_description = {
#endif
#endif
-#include <sys/time.h>
-
#include "flurry.h"
global_info_t *flurry_info = NULL;
#include "flurry.h"
global_info_t *flurry_info = NULL;
-static double gTimeCounter = 0.0;
-
+static
double currentTime(void) {
struct timeval tv;
# ifdef GETTIMEOFDAY_TWO_ARGS
double currentTime(void) {
struct timeval tv;
# ifdef GETTIMEOFDAY_TWO_ARGS
@@
-111,14
+103,8
@@
double currentTime(void) {
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
}
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
}
-void OTSetup (void) {
- if (gTimeCounter == 0.0) {
- gTimeCounter = currentTime();
- }
-}
-
-double TimeInSecondsSinceStart (void) {
- return currentTime() - gTimeCounter;
+double TimeInSecondsSinceStart (const global_info_t *global) {
+ return currentTime() - global->gTimeCounter;
}
#if 0
}
#if 0
@@
-130,6
+116,8
@@
static int IsAltiVecAvailable(void)
#endif
#endif
#endif
#endif
+
+static
void delete_flurry_info(flurry_info_t *flurry)
{
int i;
void delete_flurry_info(flurry_info_t *flurry)
{
int i;
@@
-140,9
+128,10
@@
void delete_flurry_info(flurry_info_t *flurry)
{
free(flurry->spark[i]);
}
{
free(flurry->spark[i]);
}
- free(flurry);
+ /* free(flurry); */
}
}
+static
flurry_info_t *new_flurry_info(global_info_t *global, int streams, ColorModes colour, float thickness, float speed, double bf)
{
int i,k;
flurry_info_t *new_flurry_info(global_info_t *global, int streams, ColorModes colour, float thickness, float speed, double bf)
{
int i,k;
@@
-153,7
+142,8
@@
flurry_info_t *new_flurry_info(global_info_t *global, int streams, ColorModes co
flurry->flurryRandomSeed = RandFlt(0.0, 300.0);
flurry->fOldTime = 0;
flurry->flurryRandomSeed = RandFlt(0.0, 300.0);
flurry->fOldTime = 0;
- flurry->fTime = TimeInSecondsSinceStart() + flurry->flurryRandomSeed;
+ flurry->dframe = 0;
+ flurry->fTime = TimeInSecondsSinceStart(global) + flurry->flurryRandomSeed;
flurry->fDeltaTime = flurry->fTime - flurry->fOldTime;
flurry->numStreams = streams;
flurry->fDeltaTime = flurry->fTime - flurry->fOldTime;
flurry->numStreams = streams;
@@
-187,6
+177,7
@@
flurry_info_t *new_flurry_info(global_info_t *global, int streams, ColorModes co
return flurry;
}
return flurry;
}
+static
void GLSetupRC(global_info_t *global)
{
/* setup the defaults for OpenGL */
void GLSetupRC(global_info_t *global)
{
/* setup the defaults for OpenGL */
@@
-201,11
+192,10
@@
void GLSetupRC(global_info_t *global)
glViewport(0,0,(int) global->sys_glWidth,(int) global->sys_glHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,(int) global->sys_glWidth,(int) global->sys_glHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gl
uOrtho2D(0,global->sys_glWidth,0,global->sys_glHeight
);
+ gl
Ortho(0,global->sys_glWidth,0,global->sys_glHeight,-1,1
);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glClearColor(0.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glEnableClientState(GL_COLOR_ARRAY);
glClear(GL_COLOR_BUFFER_BIT);
glEnableClientState(GL_COLOR_ARRAY);
@@
-226,6
+216,7
@@
void GLSetupRC(global_info_t *global)
#endif /* 0 */
}
#endif /* 0 */
}
+static
void GLRenderScene(global_info_t *global, flurry_info_t *flurry, double b)
{
int i;
void GLRenderScene(global_info_t *global, flurry_info_t *flurry, double b)
{
int i;
@@
-233,7
+224,7
@@
void GLRenderScene(global_info_t *global, flurry_info_t *flurry, double b)
flurry->dframe++;
flurry->fOldTime = flurry->fTime;
flurry->dframe++;
flurry->fOldTime = flurry->fTime;
- flurry->fTime = TimeInSecondsSinceStart() + flurry->flurryRandomSeed;
+ flurry->fTime = TimeInSecondsSinceStart(
global
) + flurry->flurryRandomSeed;
flurry->fDeltaTime = flurry->fTime - flurry->fOldTime;
flurry->drag = (float) pow(0.9965,flurry->fDeltaTime*85.0);
flurry->fDeltaTime = flurry->fTime - flurry->fOldTime;
flurry->drag = (float) pow(0.9965,flurry->fDeltaTime*85.0);
@@
-310,6
+301,7
@@
void GLRenderScene(global_info_t *global, flurry_info_t *flurry, double b)
glDisable(GL_TEXTURE_2D);
}
glDisable(GL_TEXTURE_2D);
}
+static
void GLResize(global_info_t *global, float w, float h)
{
global->sys_glWidth = w;
void GLResize(global_info_t *global, float w, float h)
{
global->sys_glWidth = w;
@@
-317,7
+309,7
@@
void GLResize(global_info_t *global, float w, float h)
}
/* new window size or exposure */
}
/* new window size or exposure */
-void reshape_flurry(ModeInfo *mi, int width, int height)
+
ENTRYPOINT
void reshape_flurry(ModeInfo *mi, int width, int height)
{
global_info_t *global = flurry_info + MI_SCREEN(mi);
{
global_info_t *global = flurry_info + MI_SCREEN(mi);
@@
-326,18
+318,14
@@
void reshape_flurry(ModeInfo *mi, int width, int height)
glViewport(0.0, 0.0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0.0, 0.0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gl
uOrtho2D(0, width, 0, height
);
+ gl
Ortho(0, width, 0, height,-1,1
);
glMatrixMode(GL_MODELVIEW);
glMatrixMode(GL_MODELVIEW);
-
- glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
-
glFlush();
glFlush();
-
GLResize(global, (float)width, (float)height);
}
GLResize(global, (float)width, (float)height);
}
-void
+
ENTRYPOINT
void
init_flurry(ModeInfo * mi)
{
int screen = MI_SCREEN(mi);
init_flurry(ModeInfo * mi)
{
int screen = MI_SCREEN(mi);
@@
-354,15
+342,12
@@
init_flurry(ModeInfo * mi)
PRESET_MAX
} preset_num;
PRESET_MAX
} preset_num;
- if (flurry_info == NULL) {
- OTSetup();
- if ((flurry_info = (global_info_t *) calloc(MI_NUM_SCREENS(mi),
- sizeof (global_info_t))) == NULL)
- return;
- }
+ MI_INIT (mi, flurry_info);
global = &flurry_info[screen];
global = &flurry_info[screen];
+ global->gTimeCounter = currentTime();
+
global->window = MI_WINDOW(mi);
global->flurry = NULL;
global->window = MI_WINDOW(mi);
global->flurry = NULL;
@@
-403,7
+388,7
@@
init_flurry(ModeInfo * mi)
case PRESET_FIRE: {
flurry_info_t *flurry;
case PRESET_FIRE: {
flurry_info_t *flurry;
- flurry = new_flurry_info(global, 12, slowCyclicColorMode, 10000.0, 0.
0
, 1.0);
+ flurry = new_flurry_info(global, 12, slowCyclicColorMode, 10000.0, 0.
2
, 1.0);
flurry->next = global->flurry;
global->flurry = flurry;
break;
flurry->next = global->flurry;
global->flurry = flurry;
break;
@@
-473,13
+458,14
@@
init_flurry(ModeInfo * mi)
} else {
MI_CLEARWINDOW(mi);
}
} else {
MI_CLEARWINDOW(mi);
}
+
+ global->first = 1;
+ global->oldFrameTime = -1;
}
}
-void
+
ENTRYPOINT
void
draw_flurry(ModeInfo * mi)
{
draw_flurry(ModeInfo * mi)
{
- static int first = 1;
- static double oldFrameTime = -1;
double newFrameTime;
double deltaFrameTime = 0;
double brite;
double newFrameTime;
double deltaFrameTime = 0;
double brite;
@@
-491,7
+477,7
@@
draw_flurry(ModeInfo * mi)
Window window = MI_WINDOW(mi);
newFrameTime = currentTime();
Window window = MI_WINDOW(mi);
newFrameTime = currentTime();
- if (oldFrameTime == -1) {
+ if (
global->
oldFrameTime == -1) {
/* special case the first frame -- clear to black */
alpha = 1.0;
} else {
/* special case the first frame -- clear to black */
alpha = 1.0;
} else {
@@
-504,24
+490,24
@@
draw_flurry(ModeInfo * mi)
* than that and the blending causes the display to
* saturate, which looks really ugly.
*/
* than that and the blending causes the display to
* saturate, which looks really ugly.
*/
- if (newFrameTime - oldFrameTime < 1/60.0) {
- usleep(MAX_(1,(int)(20000 * (newFrameTime - oldFrameTime))));
+ if (newFrameTime -
global->
oldFrameTime < 1/60.0) {
+ usleep(MAX_(1,(int)(20000 * (newFrameTime -
global->
oldFrameTime))));
return;
}
return;
}
- deltaFrameTime = newFrameTime - oldFrameTime;
+ deltaFrameTime = newFrameTime -
global->
oldFrameTime;
alpha = 5.0 * deltaFrameTime;
}
alpha = 5.0 * deltaFrameTime;
}
- oldFrameTime = newFrameTime;
+
global->
oldFrameTime = newFrameTime;
if (alpha > 0.2) alpha = 0.2;
if (!global->glx_context)
return;
if (alpha > 0.2) alpha = 0.2;
if (!global->glx_context)
return;
- if (first) {
+ if (
global->
first) {
MakeTexture();
MakeTexture();
- first = 0;
+
global->
first = 0;
}
glDrawBuffer(GL_BACK);
glXMakeCurrent(display, window, *(global->glx_context));
}
glDrawBuffer(GL_BACK);
glXMakeCurrent(display, window, *(global->glx_context));
@@
-543,28
+529,21
@@
draw_flurry(ModeInfo * mi)
glXSwapBuffers(display, window);
}
glXSwapBuffers(display, window);
}
-void
-
releas
e_flurry(ModeInfo * mi)
+
ENTRYPOINT
void
+
fre
e_flurry(ModeInfo * mi)
{
{
- if (flurry_info != NULL) {
- int screen;
-
- for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
- global_info_t *global = &flurry_info[screen];
- flurry_info_t *flurry;
+ global_info_t *global = &flurry_info[MI_SCREEN(mi)];
+ flurry_info_t *flurry;
-
if (global->glx_context) {
-
glXMakeCurrent(MI_DISPLAY(mi), global->window, *(global->glx_context));
-
}
+ if (global->glx_context) {
+ glXMakeCurrent(MI_DISPLAY(mi), global->window, *(global->glx_context));
+ }
- for (flurry = global->flurry; flurry; flurry=flurry->next) {
- delete_flurry_info(flurry);
- }
- }
- (void) free((void *) flurry_info);
- flurry_info = NULL;
+ for (flurry = global->flurry; flurry; flurry=flurry->next) {
+ delete_flurry_info(flurry);
}
}
- FreeAllGL(mi);
}
}
+XSCREENSAVER_MODULE ("Flurry", flurry)
+
#endif
#endif