home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src-glut / glut_util.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  1.7 KB  |  83 lines

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