# include "xlock.h"
#endif
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
# include "jwxyz.h"
#else
# include <X11/Xlib.h>
#ifdef USE_MODULES
ModStruct queens_description =
-{"queens", "init_queens", "draw_queens", "release_queens",
+{"queens", "init_queens", "draw_queens", NULL,
"draw_queens", "init_queens", NULL, &queens_opts,
1000, 1, 2, 1, 4, 1.0, "",
"Queens", 0, NULL};
{
Queenscreen *qs = &qss[MI_SCREEN(mi)];
- if (event->xany.type == ButtonPress &&
- event->xbutton.button == Button1)
+ if (gltrackball_event_handler (event, qs->trackball,
+ MI_WIDTH (mi), MI_HEIGHT (mi),
+ &qs->button_down_p))
+ return True;
+ else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
{
- qs->button_down_p = True;
- gltrackball_start (qs->trackball,
- event->xbutton.x, event->xbutton.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- return True;
- }
- else if (event->xany.type == ButtonRelease &&
- event->xbutton.button == Button1)
- {
- qs->button_down_p = False;
- return True;
- }
- else if (event->xany.type == ButtonPress &&
- (event->xbutton.button == Button4 ||
- event->xbutton.button == Button5 ||
- event->xbutton.button == Button6 ||
- event->xbutton.button == Button7))
- {
- gltrackball_mousewheel (qs->trackball, event->xbutton.button, 5,
- !event->xbutton.state);
- return True;
- }
- else if (event->xany.type == MotionNotify &&
- qs->button_down_p)
- {
- gltrackball_track (qs->trackball,
- event->xmotion.x, event->xmotion.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
+ qs->steps = 1024 - 1;
return True;
}
}
glEnd();
+
+ {
+ GLfloat off = 0.01;
+ GLfloat w = qs->BOARDSIZE;
+ GLfloat h = 0.1;
+
+ /* Give the board a slight lip. */
+ /* #### oops, normals are wrong here, but you can't tell */
+
+ glColor3f(0.3, 0.3, 0.3);
+ glBegin (GL_QUADS);
+ glVertex3f (0, 0, 0);
+ glVertex3f (0, -h, 0);
+ glVertex3f (0, -h, w);
+ glVertex3f (0, 0, w);
+
+ glVertex3f (0, 0, w);
+ glVertex3f (0, -h, w);
+ glVertex3f (w, -h, w);
+ glVertex3f (w, 0, w);
+
+ glVertex3f (w, 0, w);
+ glVertex3f (w, -h, w);
+ glVertex3f (w, -h, 0);
+ glVertex3f (w, 0, 0);
+
+ glVertex3f (w, 0, 0);
+ glVertex3f (w, -h, 0);
+ glVertex3f (0, -h, 0);
+ glVertex3f (0, 0, 0);
+
+ glVertex3f (0, -h, 0);
+ glVertex3f (w, -h, 0);
+ glVertex3f (w, -h, w);
+ glVertex3f (0, -h, w);
+ glEnd();
+ polys += 4;
+
+ /* Fill in the underside of the board with an invisible black box
+ to hide the reflections that are not on tiles. Probably there's
+ a way to do this with stencils instead.
+ */
+ w -= off*2;
+ h = 5;
+
+ glPushMatrix();
+ glTranslatef (off, 0, off);
+ glDisable(GL_LIGHTING);
+ glColor3f(0,0,0);
+ glBegin (GL_QUADS);
+ glVertex3f (0, 0, 0);
+ glVertex3f (0, -h, 0);
+ glVertex3f (0, -h, w);
+ glVertex3f (0, 0, w);
+
+ glVertex3f (0, 0, w);
+ glVertex3f (0, -h, w);
+ glVertex3f (w, -h, w);
+ glVertex3f (w, 0, w);
+
+ glVertex3f (w, 0, w);
+ glVertex3f (w, -h, w);
+ glVertex3f (w, -h, 0);
+ glVertex3f (w, 0, 0);
+
+ glVertex3f (w, 0, 0);
+ glVertex3f (w, -h, 0);
+ glVertex3f (0, -h, 0);
+ glVertex3f (0, 0, 0);
+
+ glVertex3f (0, -h, 0);
+ glVertex3f (w, -h, 0);
+ glVertex3f (w, -h, w);
+ glVertex3f (0, -h, w);
+ glEnd();
+ polys += 4;
+ glPopMatrix();
+ if (!wire)
+ glEnable(GL_LIGHTING);
+ }
+
return polys;
}
-static int display(Queenscreen *qs)
+static int display(ModeInfo *mi, Queenscreen *qs)
{
+ int max = 1024;
int polys = 0;
glClear(clearbits);
glRotatef(current_device_rotation(), 0, 0, 1);
/* setup light attenuation */
+ /* #### apparently this does nothing */
glEnable(GL_COLOR_MATERIAL);
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.8/(0.01+findAlpha(qs)));
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.06);
/** setup perspective */
glTranslatef(0.0, 0.0, -1.5*qs->BOARDSIZE);
glRotatef(30.0, 1.0, 0.0, 0.0);
- glRotatef(-current_device_rotation(), 0, 0, 1);
gltrackball_rotate (qs->trackball);
- glRotatef(current_device_rotation(), 0, 0, 1);
glRotatef(qs->theta*100, 0.0, 1.0, 0.0);
glTranslatef(-0.5*qs->BOARDSIZE, 0.0, -0.5*qs->BOARDSIZE);
glEnable(GL_LIGHT0);
}
+ /* Since the lighting attenuation trick up there doesn't seem to be working,
+ let's drop the old board down and drop the new board in. */
+ if (qs->steps < (max/8.0)) {
+ GLfloat y = qs->steps / (max/8.0);
+ y = sin (M_PI/2 * y);
+ glTranslatef (0, 10 - (y * 10), 0);
+ } else if (qs->steps > max-(max/8.0)) {
+ GLfloat y = (qs->steps - (max-(max/8.0))) / (GLfloat) (max/8.0);
+ y = 1 - sin (M_PI/2 * (1-y));
+ glTranslatef (0, -y * 15, 0);
+ }
+
/* draw reflections */
if(!wire) {
polys += draw_reflections(qs);
qs->theta += .002;
/* zero out board, find new solution of size MINBOARD <= i <= MAXBOARD */
- if(++qs->steps == 1024) {
+ if(++qs->steps == max) {
qs->steps = 0;
blank(qs);
qs->BOARDSIZE = MINBOARD + (random() % (MAXBOARD - MINBOARD + 1));
return polys;
}
-static const GLfloat spidermodel[][3] =
- {
- {0.48, 0.48, 0.22},
- {0.48, 0.34, 0.18},
- {0.34, 0.34, 0.10},
- {0.34, 0.18, 0.30},
- {0.18, 0.14, 0.38},
- {0.14, 0.29, 0.01},
- {0.29, 0.18, 0.18},
- {0.18, 0.18, 0.16},
- {0.18, 0.20, 0.26},
- {0.20, 0.27, 0.14},
- {0.27, 0.24, 0.08},
- {0.24, 0.17, 0.00},
- {0.17, 0.095, 0.08},
- {0.095, 0.07, 0.00},
- {0.07, 0.00, 0.12},
- };
-
-
#define EPSILON 0.001
#if 0
int poly_counts[PIECES];
wire = MI_IS_WIREFRAME(mi);
- if(!qss &&
- !(qss = (Queenscreen *) calloc(MI_NUM_SCREENS(mi), sizeof(Queenscreen))))
- return;
+# ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
+ wire = 0;
+# endif
+
+ MI_INIT (mi, qss, NULL);
qs = &qss[screen];
qs->window = MI_WINDOW(mi);
else
MI_CLEARWINDOW(mi);
- qs->trackball = gltrackball_init ();
+ qs->trackball = gltrackball_init (False);
qs->BOARDSIZE = 8; /* 8 cuz its classic */
- gen_model_lists(-1, poly_counts);
+ chessmodels_gen_lists(-1, poly_counts);
qs->queen_list = QUEEN;
qs->queen_polys = poly_counts[QUEEN];
else
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- mi->polygon_count = display(qs);
+ mi->polygon_count = display(mi, qs);
mi->recursion_depth = qs->BOARDSIZE;
if(mi->fps_p) do_fps(mi);