gallium: add target-helpers/wrap_screen.c to C_SOURCES
[mesa/mesa-lb.git] / src / glut / beos / glut_util.c
blob29e79513a3f35993fd41c458816d3e76076b61d4
2 /* Copyright (c) Mark J. Kilgard, 1994. */
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. */
8 #include <stdlib.h>
9 #include <stdarg.h>
10 #include <string.h>
11 #include <stdio.h>
13 #include "glutint.h"
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). */
19 char *
20 __glutStrdup(const char *string)
22 char *copy;
24 copy = (char*) malloc(strlen(string) + 1);
25 if (copy == NULL)
26 return NULL;
27 strcpy(copy, string);
28 return copy;
31 void
32 __glutWarning(char *format,...)
34 va_list args;
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);
44 /* CENTRY */
45 void APIENTRY
46 glutReportErrors(void)
48 GLenum error;
50 while ((error = glGetError()) != GL_NO_ERROR)
51 __glutWarning("GL error: %s", gluErrorString(error));
53 /* ENDCENTRY */
55 void
56 __glutFatalError(char *format,...)
58 va_list args;
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);
69 void
70 __glutFatalUsage(char *format,...)
72 va_list args;
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();