Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / libs / glut / glut_util.c
blob1461fa845bbb8de525db69f952a2a7642973b041
1 /*
2 * Copyright 1994-1997 Mark Kilgard, All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Mark Kilgard
7 */
10 #include <stdlib.h>
11 #include <stdarg.h>
12 #include <string.h>
13 #include <stdio.h>
15 #include "glutint.h"
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)
25 char *copy;
27 copy = (char*) malloc(strlen(string) + 1);
28 if (copy == NULL)
29 return NULL;
30 strcpy(copy, string);
31 return copy;
34 void
35 __glutWarning(const char *format,...)
37 va_list args;
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);
47 /* CENTRY */
48 void APIENTRY
49 glutReportErrors(void)
51 GLenum error;
53 while ((error = glGetError()) != GL_NO_ERROR)
54 __glutWarning("GL error: %s", gluErrorString(error));
56 /* ENDCENTRY */
58 void
59 __glutFatalError(const char *format,...)
61 va_list args;
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);
72 void
73 __glutFatalUsage(const char *format,...)
75 va_list args;
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();