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