#ifdef STANDALONE
# define DEFAULTS "*delay: 25000 \n" \
- "*showFPS: False \n"
+ "*showFPS: False \n" \
+ "*suppressRotationAnimation: True\n" \
# define refresh_polytopes 0
+# define release_polytopes 0
# include "xlockmore.h" /* from the xscreensaver distribution */
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
#ifdef USE_GL
-#include <X11/keysym.h>
+#ifndef HAVE_JWXYZ
+# include <X11/keysym.h>
+#endif
#include "gltrackball.h"
#ifdef USE_MODULES
ModStruct polytopes_description =
-{"polytopes", "init_polytopes", "draw_polytopes", "release_polytopes",
+{"polytopes", "init_polytopes", "draw_polytopes", NULL,
"draw_polytopes", "change_polytopes", NULL, &polytopes_opts,
25000, 1, 1, 1, 1.0, 4, "",
"Shows one of the six regular 4d polytopes rotating in 4d", 0, NULL};
static void init(ModeInfo *mi)
{
- static const GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
- static const GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
- static const GLfloat light_specular[] = { 0.0, 0.0, 0.0, 1.0 };
- static const GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 };
- static const GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
polytopesstruct *pp = &poly[MI_SCREEN(mi)];
set_colors(mi);
pp->tick = 0;
pp->poly = 0;
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- if (projection_3d == DISP_3D_PERSPECTIVE)
- gluPerspective(60.0,1.0,0.1,100.0);
- else
- glOrtho(-1.0,1.0,-1.0,1.0,0.1,100.0);;
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- if (display_mode == DISP_WIREFRAME)
- {
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glDisable(GL_LIGHT0);
- glDisable(GL_BLEND);
- }
- else if (display_mode == DISP_SURFACE)
- {
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
- glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
- glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
- glLightfv(GL_LIGHT0,GL_POSITION,light_position);
- glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_specular);
- glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,0.0);
- glDepthMask(GL_TRUE);
- glDisable(GL_BLEND);
- }
- else if (display_mode == DISP_TRANSPARENT)
- {
- glDisable(GL_DEPTH_TEST);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
- glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
- glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
- glLightfv(GL_LIGHT0,GL_POSITION,light_position);
- glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_specular);
- glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,0.0);
- glDepthMask(GL_FALSE);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- }
- else
- {
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glDisable(GL_LIGHT0);
- glDisable(GL_BLEND);
- }
}
{
gluPerspective(60.0,pp->aspect,0.1,100.0);
}
+
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
ENTRYPOINT Bool polytopes_handle_event(ModeInfo *mi, XEvent *event)
{
- Display *display = MI_DISPLAY(mi);
polytopesstruct *pp = &poly[MI_SCREEN(mi)];
- KeySym sym;
+ KeySym sym = 0;
+ char c = 0;
+
+ if (event->xany.type == KeyPress || event->xany.type == KeyRelease)
+ XLookupString (&event->xkey, &c, 1, &sym, 0);
if (event->xany.type == ButtonPress &&
event->xbutton.button == Button1)
}
else if (event->xany.type == KeyPress)
{
- sym = XKeycodeToKeysym(display,event->xkey.keycode,0);
if (sym == XK_Shift_L || sym == XK_Shift_R)
{
pp->current_trackball = 1;
}
else if (event->xany.type == KeyRelease)
{
- sym = XKeycodeToKeysym(display,event->xkey.keycode,0);
if (sym == XK_Shift_L || sym == XK_Shift_R)
{
pp->current_trackball = 0;
{
polytopesstruct *pp;
- if (poly == NULL)
- {
- poly = (polytopesstruct *)calloc(MI_NUM_SCREENS(mi),
- sizeof(polytopesstruct));
- if (poly == NULL)
- return;
- }
+ MI_INIT(mi, poly, NULL);
pp = &poly[MI_SCREEN(mi)];
- pp->trackballs[0] = gltrackball_init();
- pp->trackballs[1] = gltrackball_init();
+ pp->trackballs[0] = gltrackball_init(True);
+ pp->trackballs[1] = gltrackball_init(True);
pp->current_trackball = 0;
pp->button_pressed = False;
*/
ENTRYPOINT void draw_polytopes(ModeInfo *mi)
{
+ static const GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
+ static const GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
+ static const GLfloat light_specular[] = { 0.0, 0.0, 0.0, 1.0 };
+ static const GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 };
+ static const GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
+
Display *display = MI_DISPLAY(mi);
Window window = MI_WINDOW(mi);
polytopesstruct *hp;
glXMakeCurrent(display,window,*(hp->glx_context));
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ if (projection_3d == DISP_3D_PERSPECTIVE)
+ gluPerspective(60.0,1.0,0.1,100.0);
+ else
+ glOrtho(-1.0,1.0,-1.0,1.0,0.1,100.0);;
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ if (display_mode == DISP_WIREFRAME)
+ {
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_LIGHT0);
+ glDisable(GL_BLEND);
+ }
+ else if (display_mode == DISP_SURFACE)
+ {
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LESS);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
+ glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
+ glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
+ glLightfv(GL_LIGHT0,GL_POSITION,light_position);
+ glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_specular);
+ glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,0.0);
+ glDepthMask(GL_TRUE);
+ glDisable(GL_BLEND);
+ }
+ else if (display_mode == DISP_TRANSPARENT)
+ {
+ glDisable(GL_DEPTH_TEST);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
+ glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
+ glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
+ glLightfv(GL_LIGHT0,GL_POSITION,light_position);
+ glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_specular);
+ glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,0.0);
+ glDepthMask(GL_FALSE);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+ }
+ else
+ {
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_LIGHT0);
+ glDisable(GL_BLEND);
+ }
+
+
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}
-/*
- *-----------------------------------------------------------------------------
- * The display is being taken away from us. Free up malloc'ed
- * memory and X resources that we've alloc'ed. Only called
- * once, we must zap everything for every screen.
- *-----------------------------------------------------------------------------
- */
-
-ENTRYPOINT void release_polytopes(ModeInfo *mi)
-{
- if (poly != NULL)
- {
- int screen;
-
- for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++)
- {
- polytopesstruct *hp = &poly[screen];
-
- if (hp->glx_context)
- hp->glx_context = (GLXContext *)NULL;
- }
- (void) free((void *)poly);
- poly = (polytopesstruct *)NULL;
- }
- FreeAllGL(mi);
-}
-
#ifndef STANDALONE
ENTRYPOINT void change_polytopes(ModeInfo *mi)
{