~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/glut/os2/glut_util.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

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