source: trunk/src/opengl/glut/glut_util.c

Last change on this file was 3579, checked in by jeroen, 25 years ago

* empty log message *

File size: 2.5 KB
Line 
1/* $Id: glut_util.c,v 1.4 2000-05-20 13:48:23 jeroen Exp $ */
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#if defined(__WIN32OS2__)
16#include <misc.h>
17#endif
18
19/* strdup is actually not a standard ANSI C or POSIX routine
20 so implement a private one for GLUT. OpenVMS does not have a
21 strdup; Linux's standard libc doesn't declare strdup by default
22 (unless BSD or SVID interfaces are requested). */
23char *
24__glutStrdup(const char *string)
25{
26 char *copy;
27
28 copy = (char*) malloc(strlen(string) + 1);
29 if (copy == NULL)
30 return NULL;
31 strcpy(copy, string);
32 return copy;
33}
34
35void
36__glutWarning(char *format,...)
37{
38 va_list args;
39
40 va_start(args, format);
41
42#if defined(__WIN32OS2__)
43{
44 char errmsg[1024];
45
46 dprintf(("GLUT32: Warning %s: \n", __glutProgramName ? __glutProgramName : "(unnamed)"));
47 sprintf(errmsg, format, args);
48 dprintf(("GLUT32: %s\n",errmsg));
49}
50#endif
51 fprintf(stderr, "GLUT: Warning in %s: ",
52 __glutProgramName ? __glutProgramName : "(unamed)");
53 vfprintf(stderr, format, args);
54 va_end(args);
55 putc('\n', stderr);
56}
57
58/* CENTRY */
59void APIENTRY
60glutReportErrors(void)
61{
62 GLenum error;
63
64 while ((error = glGetError()) != GL_NO_ERROR)
65 __glutWarning("GL error: %s", gluErrorString(error));
66}
67/* ENDCENTRY */
68
69void
70__glutFatalError(char *format,...)
71{
72 va_list args;
73
74 va_start(args, format);
75#if defined(__WIN32OS2__)
76{
77 CHAR errmsg[1024];
78
79 dprintf(("GLUT32: Fatal Error in %s:\n",
80 __glutProgramName ? __glutProgramName : "(unamed)"));
81
82 sprintf(errmsg, format, args);
83
84 dprintf(("GLUT32: %s\n",errmsg));
85}
86#endif
87
88 fprintf(stderr, "GLUT: Fatal Error in %s: ",
89 __glutProgramName ? __glutProgramName : "(unamed)");
90 vfprintf(stderr, format, args);
91 va_end(args);
92 putc('\n', stderr);
93
94 exit(4);
95}
96
97void
98__glutFatalUsage(char *format,...)
99{
100 va_list args;
101
102 va_start(args, format);
103
104#if defined(__WIN32OS2__)
105{
106 char errmsg[1024];
107 dprintf(("GLUT: Fatal API Usage in %s:\n",
108 __glutProgramName ? __glutProgramName : "(unamed)"));
109 sprintf(errmsg, format, args);
110 dprintf(("GLUT32: %s",errmsg));
111 putc('\n', stderr);
112}
113#endif
114
115 fprintf(stderr, "GLUT: Fatal API Usage in %s: ",
116 __glutProgramName ? __glutProgramName : "(unamed)");
117 vfprintf(stderr, format, args);
118 va_end(args);
119 putc('\n', stderr);
120
121 exit(8);
122}
Note: See TracBrowser for help on using the repository browser.