1 /* 2 * Copyright 1994-1997 Mark Kilgard, All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Mark Kilgard 7 */ 8 9 10 #include <stdlib.h> 11 #include <stdarg.h> 12 #include <string.h> 13 #include <stdio.h> 14 15 #include "glutint.h" 16 17 18 /* strdup is actually not a standard ANSI C or POSIX routine 19 so implement a private one for GLUT. OpenVMS does not have a 20 strdup; Linux's standard libc doesn't declare strdup by default 21 (unless BSD or SVID interfaces are requested). */ 22 char * 23 __glutStrdup(const char *string) 24 { 25 char *copy; 26 27 copy = (char*) malloc(strlen(string) + 1); 28 if (copy == NULL) 29 return NULL; 30 strcpy(copy, string); 31 return copy; 32 } 33 34 void 35 __glutWarning(const char *format,...) 36 { 37 va_list args; 38 39 va_start(args, format); 40 fprintf(stderr, "GLUT: Warning in %s: ", 41 __glutProgramName ? __glutProgramName : "(unamed)"); 42 vfprintf(stderr, format, args); 43 va_end(args); 44 putc('\n', stderr); 45 } 46 47 /* CENTRY */ 48 void APIENTRY 49 glutReportErrors(void) 50 { 51 GLenum error; 52 53 while ((error = glGetError()) != GL_NO_ERROR) 54 __glutWarning("GL error: %s", gluErrorString(error)); 55 } 56 /* ENDCENTRY */ 57 58 void 59 __glutFatalError(const char *format,...) 60 { 61 va_list args; 62 63 va_start(args, format); 64 fprintf(stderr, "GLUT: Fatal Error in %s: ", 65 __glutProgramName ? __glutProgramName : "(unamed)"); 66 vfprintf(stderr, format, args); 67 va_end(args); 68 putc('\n', stderr); 69 exit(1); 70 } 71 72 void 73 __glutFatalUsage(const char *format,...) 74 { 75 va_list args; 76 77 va_start(args, format); 78 fprintf(stderr, "GLUT: Fatal API Usage in %s: ", 79 __glutProgramName ? __glutProgramName : "(unamed)"); 80 vfprintf(stderr, format, args); 81 va_end(args); 82 putc('\n', stderr); 83 abort(); 84 } 85