static void Cleanup(void)
{
+ /* do not handle this signal when cleaning up */
+ signal(SIGWINCH, SIG_IGN);
+
if(GameMode)
glutLeaveGameMode();
signal(SIGSEGV, CrashHandler);
signal(SIGINT, CrashHandler);
signal(SIGTERM, CrashHandler);
+ signal(SIGABRT, CrashHandler);
if(nomouse == 0)
InitializeMouse();
exit(0);
}
- /* Get the fixed screen info */
+ /* get the fixed screen info */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
static void ProcessTimers(void)
{
- if(GlutTimers && GlutTimers->time < glutGet(GLUT_ELAPSED_TIME)) {
+ while(GlutTimers && GlutTimers->time <= glutGet(GLUT_ELAPSED_TIME)) {
struct GlutTimer *timer = GlutTimers;
- timer->func(timer->value);
GlutTimers = timer->next;
+ timer->func(timer->value);
free(timer);
}
}
}
}
+static void ResizeVisual(void)
+{
+ if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
+ sprintf(exiterror, "Failure to Make Current\n");
+ exit(0);
+ }
+
+ InitializeMenus();
+
+ if(ReshapeFunc)
+ ReshapeFunc(VarInfo.xres, VarInfo.yres);
+ Redisplay = 1;
+}
+
+static void SignalWinch(int arg)
+{
+ /* we can't change bitdepth without destroying the visual */
+ int bits_per_pixel = VarInfo.bits_per_pixel;
+ struct fb_bitfield red = VarInfo.red, green = VarInfo.green,
+ blue = VarInfo.blue, transp = VarInfo.transp;
+
+ /* get the variable screen info */
+ if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &VarInfo)) {
+ sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ exit(0);
+ }
+
+ /* restore bitdepth and color masks only */
+ VarInfo.bits_per_pixel = bits_per_pixel;
+ VarInfo.red = red;
+ VarInfo.green = green;
+ VarInfo.blue = blue;
+ VarInfo.transp = transp;
+
+ SetVideoMode();
+ CreateBuffer();
+
+ ResizeVisual();
+}
+
int glutCreateWindow (const char *title)
{
if(Initialized == 0) {
glutSetWindowTitle(title);
+ signal(SIGWINCH, SignalWinch);
+
Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
if(!ParseFBModes(width, width, height, height, 0, MAX_VSYNC))
return;
+ signal(SIGWINCH, SIG_IGN);
+
SetVideoMode();
CreateBuffer();
-
- if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
- sprintf(exiterror, "Failure to Make Current\n");
- exit(0);
- }
- InitializeMenus();
-
- if(ReshapeFunc)
- ReshapeFunc(VarInfo.xres, VarInfo.yres);
- Redisplay = 1;
+ ResizeVisual();
+ signal(SIGWINCH, SignalWinch);
}
void glutFullScreen(void)
strerror(errno));
exit(0);
}
+
+ RestoreColorMap();
+
Redisplay = 1;
VisibleSwitch = 1;
Visible = 1;
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
+
raise(SIGSTOP);
}
vts and kill it without Alt-SysRq hack */
static void KeyboardHandler(int sig)
{
- int release, labelval;
unsigned char code;
- struct kbentry entry;
- static int lalt; /* only left alt does vt switch */
- if(read(ConsoleFD, &code, 1) != 1)
- return;
-
- release = code & 0x80;
-
- entry.kb_index = code & 0x7F;
- entry.kb_table = 0;
-
- if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
- sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
- exit(0);
- }
-
- labelval = entry.kb_value;
-
- switch(labelval) {
- case K_SHIFT:
- case K_SHIFTL:
- MODIFIER(GLUT_ACTIVE_SHIFT);
- return;
- case K_CTRL:
- MODIFIER(GLUT_ACTIVE_CTRL);
- return;
- case K_ALT:
- lalt = !release;
- case K_ALTGR:
- MODIFIER(GLUT_ACTIVE_ALT);
- return;
- }
+ while(read(ConsoleFD, &code, 1) == 1) {
- if(lalt && !release) {
- /* VT switch, we must do it */
- int vt = -1;
- struct vt_stat st;
- if(labelval >= K_F1 && labelval <= K_F12)
- vt = labelval - K_F1 + 1;
+ int release, labelval;
+ struct kbentry entry;
+ static int lalt; /* only left alt does vt switch */
- if(labelval == K_LEFT)
- if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
- vt = st.v_active - 1;
+ release = code & 0x80;
+
+ entry.kb_index = code & 0x7F;
+ entry.kb_table = 0;
+
+ if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
+ sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
+ exit(0);
+ }
- if(labelval == K_RIGHT)
- if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
- vt = st.v_active + 1;
+ labelval = entry.kb_value;
+
+ switch(labelval) {
+ case K_SHIFT:
+ case K_SHIFTL:
+ MODIFIER(GLUT_ACTIVE_SHIFT);
+ continue;
+ case K_CTRL:
+ MODIFIER(GLUT_ACTIVE_CTRL);
+ continue;
+ case K_ALT:
+ lalt = !release;
+ case K_ALTGR:
+ MODIFIER(GLUT_ACTIVE_ALT);
+ continue;
+ }
- if(vt != -1) {
- if(Swapping)
- VTSwitch = vt;
- else
- if(ioctl(ConsoleFD, VT_ACTIVATE, vt) < 0)
- sprintf(exiterror, "Error switching console\n");
- return;
+ if(lalt && !release) {
+ /* VT switch, we must do it */
+ int vt = -1;
+ struct vt_stat st;
+ if(labelval >= K_F1 && labelval <= K_F12)
+ vt = labelval - K_F1 + 1;
+
+ if(labelval == K_LEFT)
+ if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
+ vt = st.v_active - 1;
+
+ if(labelval == K_RIGHT)
+ if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
+ vt = st.v_active + 1;
+
+ if(vt != -1) {
+ if(Swapping)
+ VTSwitch = vt;
+ else
+ if(ioctl(ConsoleFD, VT_ACTIVATE, vt) < 0)
+ sprintf(exiterror, "Error switching console\n");
+ continue;
+ }
}
+ write(kbdpipe[1], &code, 1);
}
- write(kbdpipe[1], &code, 1);
}
static void LedModifier(int led, int release)
goto altset;
}
}
- stdkey:
+
if(specialkey) {
if(SpecialFunc)
SpecialFunc(specialkey, MouseX, MouseY);
|| (code == 95) || (code >= 123 && code <= 126))
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;
+ stdkey:
if(KeyboardFunc)
KeyboardFunc(code, MouseX, MouseY);
}
break;
case K_ENTER:
case K_ENTER - 1: /* keypad enter */
- labelval = '\n'; break;
+ labelval = '\r'; break;
}
/* dispatch callback */
close(fd);
}
+ /* if we close with the modifier set in glutIconifyWindow, we won't
+ get the signal when they are released, so set to zero here */
+ KeyboardModifiers = 0;
+
/* open the console tty */
sprintf(console, "/dev/tty%d", CurrentVT);
ConsoleFD = open(console, O_RDWR | O_NDELAY, 0);
if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");
- if (ioctl(ConsoleFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
+ if(ioctl(ConsoleFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
sprintf(exiterror, "ioctl KDSKBMODE failed!\n");
tcsetattr(0, TCSANOW, &OldTermios);
exit(0);
}
- if( ioctl(ConsoleFD, KDGKBLED, &KeyboardLedState) < 0) {
+ if(ioctl(ConsoleFD, KDGKBLED, &KeyboardLedState) < 0) {
sprintf(exiterror, "ioctl KDGKBLED failed!\n");
exit(0);
}
GpmMouse ||
#endif
ConsoleFD == 0)
- if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) {
- sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");
+ if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
goto skipioctl; /* no need to fail twice */
- }
if(ioctl(ConsoleFD, KDSETMODE, OldMode) < 0)
fprintf(stderr, "ioctl KDSETMODE failed!\n");
fprintf(stderr, "ioctl KDSKBMODE failed!\n");
close(ConsoleFD);
+
+ close(kbdpipe[0]);
+ close(kbdpipe[1]);
}
void InitializeMouse(void)
for (i = 5; i >= 0; i--) {
glBegin(type);
-/* glNormal3fv(&n[i][0]); */
+ glNormal3fv(&n[i][0]);
glVertex3fv(&v[faces[i][0]][0]);
glVertex3fv(&v[faces[i][1]][0]);
glVertex3fv(&v[faces[i][2]][0]);
sinPhi = sin(phi);
dist = R + r * cosPhi;
-/* glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); */
+ glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
-/* glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); */
+ glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
}
glEnd();
glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
-/* glPushAttrib(GL_POLYGON_BIT); */
-/* glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); */
+ glPushAttrib(GL_POLYGON_BIT);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
doughnut(innerRadius, outerRadius, nsides, rings);
-/* glPopAttrib(); */
+ glPopAttrib();
}
void APIENTRY
normalize(n0);
glBegin(shadeType);
-/* glNormal3fv(n0); */
+ glNormal3fv(n0);
glVertex3fv(&dodec[a][0]);
glVertex3fv(&dodec[b][0]);
glVertex3fv(&dodec[c][0]);
normalize(q1);
glBegin(shadeType);
-/* glNormal3fv(q1); */
+ glNormal3fv(q1);
glVertex3fv(n1);
glVertex3fv(n2);
glVertex3fv(n3);