int motion_x = -1, motion_y = -1, motion_seq = -1 ;
int passivemotion_x = -1, passivemotion_y = -1, passivemotion_seq = -1 ;
+#define STRING_LENGTH 10
+
static void
bitmapPrintf (const char *fmt, ...)
{
glPushMatrix ();
glLoadIdentity ();
glColor3ub ( 0, 0, 0 );
- glRasterPos2i ( 10, glutGet ( GLUT_WINDOW_HEIGHT ) - 10 );
+ glRasterPos2i ( 10, glutGet ( GLUT_WINDOW_HEIGHT ) - 20 ); /* 10pt margin above 10pt letters */
if ( reshape_called )
{
glutSwapBuffers();
}
+static void
+Warning(const char *fmt, va_list ap)
+{
+ printf("%6d Warning callback:\n");
+
+ /* print warning message */
+ vprintf(fmt, ap);
+}
+
+static void
+Error(const char *fmt, va_list ap)
+{
+ char dummy_string[STRING_LENGTH];
+ printf("%6d Error callback:\n");
+
+ /* print warning message */
+ vprintf(fmt, ap);
+
+ /* terminate program, after pause for input so user can see */
+ printf ( "Please enter something to exit: " );
+ fgets ( dummy_string, STRING_LENGTH, stdin );
+
+ /* Call exit directly as freeglut is messed
+ * up internally when an error is called.
+ */
+ exit(1);
+}
+
static void
Reshape(int width, int height)
{
reshape_width = width ;
reshape_height = height ;
reshape_seq = sequence_number ;
+ glViewport(0,0,width,height);
glutPostRedisplay () ;
}
menudestroy_called = 1 ;
printf ( "%6d Window %d MenuDestroy Callback\n",
++sequence_number, window ) ;
- glutPostRedisplay () ;
+
+ if (window) /* When destroyed when shutting down, not always a window defined... */
+ glutPostRedisplay () ;
}
static void
int
main(int argc, char *argv[])
{
-#define STRING_LENGTH 10
int freeglut_window, aux_window ;
char dummy_string[STRING_LENGTH];
int menuID, subMenuA, subMenuB;
+ glutInitWarningFunc(Warning);
+ glutInitErrorFunc(Error);
glutInitWindowSize(500, 250);
glutInitWindowPosition ( 140, 140 );
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
glutInit(&argc, argv);
+ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_CONTINUE_EXECUTION);
freeglut_window = glutCreateWindow( "Callback Demo" );
printf ( "Creating window %d as 'Callback Demo'\n", freeglut_window ) ;