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
/
antmaze.c
diff --git
a/hacks/glx/antmaze.c
b/hacks/glx/antmaze.c
index 3c9e1de3da3f1ce7aea10fb83065e6c3a0cc6940..79b7e0b997330579b9924846edfb47581902c226 100644
(file)
--- a/
hacks/glx/antmaze.c
+++ b/
hacks/glx/antmaze.c
@@
-15,7
+15,7
@@
* tennessy@cs.ubc.ca
*/
* tennessy@cs.ubc.ca
*/
-#if
!defined( lint ) && !defined( SABER )
+#if
0
static const char sccsid[] = "@(#)antmaze.c 5.01 2001/03/01 xlockmore";
#endif
static const char sccsid[] = "@(#)antmaze.c 5.01 2001/03/01 xlockmore";
#endif
@@
-25,13
+25,14
@@
static const char sccsid[] = "@(#)antmaze.c 5.01 2001/03/01 xlockmore";
"*showFPS: False \n" \
"*fpsSolid: True \n"
"*showFPS: False \n" \
"*fpsSolid: True \n"
-# define refresh_antmaze 0
+# define free_antmaze 0
+# define release_antmaze 0
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
#endif /* !STANDALONE */
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
#endif /* !STANDALONE */
-#ifdef HAVE_
COCOA
+#ifdef HAVE_
JWXYZ
# include "jwxyz.h"
#else
# include <X11/Xlib.h>
# include "jwxyz.h"
#else
# include <X11/Xlib.h>
@@
-81,7
+82,7
@@
ENTRYPOINT ModeSpecOpt antmaze_opts =
#ifdef USE_MODULES
ModStruct antmaze_description =
#ifdef USE_MODULES
ModStruct antmaze_description =
-{"antmaze", "init_antmaze", "draw_antmaze",
"release_antmaze"
,
+{"antmaze", "init_antmaze", "draw_antmaze",
NULL
,
"draw_antmaze", "change_antmaze", NULL, &antmaze_opts,
1000, 1, 1, 1, 4, 1.0, "",
"draws some ants", 0, NULL};
"draw_antmaze", "change_antmaze", NULL, &antmaze_opts,
1000, 1, 1, 1, 4, 1.0, "",
"draws some ants", 0, NULL};
@@
-1287,15
+1288,6
@@
static void pinit(antmazestruct *mp)
/* glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular); */
}
/* glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular); */
}
-ENTRYPOINT void release_antmaze(ModeInfo * mi)
-{
- if(antmaze) {
- free((void *) antmaze);
- antmaze = (antmazestruct *) NULL;
- }
- FreeAllGL(mi);
-}
-
#define MAX_MAGNIFICATION 10
#define max(a, b) a < b ? b : a
#define min(a, b) a < b ? a : b
#define MAX_MAGNIFICATION 10
#define max(a, b) a < b ? b : a
#define min(a, b) a < b ? a : b
@@
-1304,55
+1296,30
@@
ENTRYPOINT Bool antmaze_handle_event (ModeInfo *mi, XEvent *event)
{
antmazestruct *mp = &antmaze[MI_SCREEN(mi)];
{
antmazestruct *mp = &antmaze[MI_SCREEN(mi)];
- switch(event->xany.type) {
- case ButtonPress:
-
- switch(event->xbutton.button) {
+ if (gltrackball_event_handler (event, mp->trackball,
+ MI_WIDTH (mi), MI_HEIGHT (mi),
+ &mp->button_down_p))
+ return True;
- case Button1:
- mp->button_down_p = True;
- gltrackball_start(mp->trackball,
- event->xbutton.x, event->xbutton.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- break;
+ if (event->xany.type == ButtonPress)
+ {
+ switch(event->xbutton.button) {
- case Button3:
- mp->focus = (mp->focus + 1) % ANTCOUNT;
-
break
;
+
case Button3:
+
mp->focus = (mp->focus + 1) % ANTCOUNT;
+
return True
;
- case Button4:
- mp->mag = max(mp->mag-1, 1);
- break;
-
- case Button5:
- mp->mag = min(mp->mag+1, MAX_MAGNIFICATION);
- break;
- }
-
- break;
-
- case ButtonRelease:
+ case Button4:
+ mp->mag = max(mp->mag-1, 1);
+ return True;
- switch(event->xbutton.button) {
- case Button1:
-
mp->button_down_p = Fals
e;
- break;
+ case Button5:
+ mp->mag = min(mp->mag+1, MAX_MAGNIFICATION);
+
return Tru
e;
+ }
}
}
- break;
-
- case MotionNotify:
- if(mp->button_down_p)
- gltrackball_track(mp->trackball,
- event->xmotion.x, event->xmotion.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- break;
-
- default:
- return False;
- }
-
- return True;
+ return False;
}
ENTRYPOINT void init_antmaze(ModeInfo * mi)
}
ENTRYPOINT void init_antmaze(ModeInfo * mi)
@@
-1362,11
+1329,7
@@
ENTRYPOINT void init_antmaze(ModeInfo * mi)
antmazestruct *mp;
antmazestruct *mp;
- if (antmaze == NULL) {
- if ((antmaze = (antmazestruct *) calloc(MI_NUM_SCREENS(mi),
- sizeof (antmazestruct))) == NULL)
- return;
- }
+ MI_INIT(mi, antmaze);
mp = &antmaze[MI_SCREEN(mi)];
mp->step = NRAND(90);
mp->ant_position = NRAND(90);
mp = &antmaze[MI_SCREEN(mi)];
mp->step = NRAND(90);
mp->ant_position = NRAND(90);
@@
-1433,7
+1396,7
@@
ENTRYPOINT void init_antmaze(ModeInfo * mi)
mp->mag = 4.0;
mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
mp->mag = 4.0;
mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
- mp->trackball = gltrackball_init ();
+ mp->trackball = gltrackball_init (
False
);
if ((mp->glx_context = init_GL(mi)) != NULL) {
reshape_antmaze(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
if ((mp->glx_context = init_GL(mi)) != NULL) {
reshape_antmaze(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
@@
-1447,6
+1410,7
@@
ENTRYPOINT void init_antmaze(ModeInfo * mi)
static void
device_rotate(ModeInfo *mi)
{
static void
device_rotate(ModeInfo *mi)
{
+#if 0
GLfloat rot = current_device_rotation();
glRotatef(rot, 0, 0, 1);
if ((rot > 45 && rot < 135) ||
GLfloat rot = current_device_rotation();
glRotatef(rot, 0, 0, 1);
if ((rot > 45 && rot < 135) ||
@@
-1455,6
+1419,7
@@
device_rotate(ModeInfo *mi)
GLfloat s = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
glScalef (1/s, s, 1);
}
GLfloat s = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
glScalef (1/s, s, 1);
}
+#endif
}
}
@@
-1504,9
+1469,7
@@
ENTRYPOINT void draw_antmaze(ModeInfo * mi)
/* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0)), */
/* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0))); */
/* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0)), */
/* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0))); */
- glRotatef(-current_device_rotation(), 0, 0, 1);
gltrackball_rotate(mp->trackball);
gltrackball_rotate(mp->trackball);
- glRotatef(current_device_rotation(), 0, 0, 1);
glRotatef(mp->ant_step*0.6, 0.0, 1.0, 0.0);
glRotatef(mp->ant_step*0.6, 0.0, 1.0, 0.0);
@@
-1517,7
+1480,7
@@
ENTRYPOINT void draw_antmaze(ModeInfo * mi)
/* sync */
if(!draw_antmaze_strip(mi)) {
/* sync */
if(!draw_antmaze_strip(mi)) {
-
release_antmaze
(mi);
+
MI_ABORT
(mi);
return;
}
return;
}
@@
-1539,13
+1502,11
@@
ENTRYPOINT void draw_antmaze(ModeInfo * mi)
glTranslatef(0.0, 0.0, -16.0);
glRotatef(60.0, 1.0, 0.0, 0.0);
glRotatef(-15.0 + mp->ant_step/10.0, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -16.0);
glRotatef(60.0, 1.0, 0.0, 0.0);
glRotatef(-15.0 + mp->ant_step/10.0, 0.0, 1.0, 0.0);
- glRotatef(-current_device_rotation(), 0, 0, 1);
gltrackball_rotate(mp->trackball);
gltrackball_rotate(mp->trackball);
- glRotatef(current_device_rotation(), 0, 0, 1);
/* sync */
if(!draw_antmaze_strip(mi)) {
/* sync */
if(!draw_antmaze_strip(mi)) {
-
release_antmaze
(mi);
+
MI_ABORT
(mi);
return;
}
return;
}