added the init error handler example program contributed by Chris Marshall
Not building it as part of the demos yet, since it was submitted quite late in the 3.0 release process git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1750 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
3f95e542fa
commit
c63102d06d
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -43,6 +43,7 @@ freeglut/freeglut/progs/demos/One/objects.ico -text
|
|||||||
freeglut/freeglut/progs/demos/One/one.c svn_keywords=Author+Date+Id+Revision
|
freeglut/freeglut/progs/demos/One/one.c svn_keywords=Author+Date+Id+Revision
|
||||||
freeglut/freeglut/progs/demos/One/one.rc -text
|
freeglut/freeglut/progs/demos/One/one.rc -text
|
||||||
freeglut/freeglut/progs/demos/Resizer/Resizer.cpp -text
|
freeglut/freeglut/progs/demos/Resizer/Resizer.cpp -text
|
||||||
|
freeglut/freeglut/progs/demos/init_error_func/init_error_func.c -text
|
||||||
freeglut/freeglut/progs/demos/multi-touch/multi-touch.c -text
|
freeglut/freeglut/progs/demos/multi-touch/multi-touch.c -text
|
||||||
freeglut/freeglut/progs/demos/shapes/glmatrix.c -text
|
freeglut/freeglut/progs/demos/shapes/glmatrix.c -text
|
||||||
freeglut/freeglut/progs/demos/shapes/glmatrix.h -text
|
freeglut/freeglut/progs/demos/shapes/glmatrix.h -text
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* ------------------------------------------
|
||||||
|
* user_error_handler.c
|
||||||
|
*
|
||||||
|
* This is a sample program showing a basic
|
||||||
|
* user defined error handlers with FreeGLUT
|
||||||
|
* ------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GL/freeglut.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ------------------------------------------
|
||||||
|
* Declare our own Error handler for FreeGLUT
|
||||||
|
* ------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This declares the vprintf() routine */
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* This declares the va_list type */
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
/* The new handler looks like a vprintf prototype */
|
||||||
|
void myError (const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "myError: Entering user defined error handler\n");
|
||||||
|
|
||||||
|
/* print warning message */
|
||||||
|
fprintf(stderr, "myError:");
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
/* deInitialize the freeglut state */
|
||||||
|
fprintf(stderr, "myError: Calling glutExit()\n");
|
||||||
|
glutExit();
|
||||||
|
|
||||||
|
/* terminate error handler appropriately */
|
||||||
|
fprintf(stderr, "myError: Exit-ing handler routine\n");
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ------------------------------------------
|
||||||
|
* Just enough code to create the error to
|
||||||
|
* demonstrate the user defined handler
|
||||||
|
* ------------------------------------------
|
||||||
|
*/
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
glutInitErrorFunc(&myError);
|
||||||
|
glutCreateWindow ("error test"); /* This is an error! */
|
||||||
|
glutInit(&argc, argv); /* Should be called
|
||||||
|
after glutInit() */
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user