root/OpenSceneGraph/trunk/src/osg/glu/libutil/error.cpp @ 11829

Revision 11829, 5.8 kB (checked in by robert, 4 years ago)

Introduced osg namespace to new local GLU functions

Line 
1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30
31#include <osg/GLU>
32
33// #include "gluos.h"
34
35#ifndef GL_TABLE_TOO_LARGE
36    #define GL_TABLE_TOO_LARGE  0x8031
37#endif
38
39namespace osg
40{
41
42static unsigned char *__gluNurbsErrors[] = {
43    (unsigned char*) " ",
44    (unsigned char*) "spline order un-supported",
45    (unsigned char*) "too few knots",
46    (unsigned char*) "valid knot range is empty",
47    (unsigned char*) "decreasing knot sequence knot",
48    (unsigned char*) "knot multiplicity greater than order of spline",
49    (unsigned char*) "gluEndCurve() must follow gluBeginCurve()",
50    (unsigned char*) "gluBeginCurve() must precede gluEndCurve()",
51    (unsigned char*) "missing or extra geometric data",
52    (unsigned char*) "can't draw piecewise linear trimming curves",
53    (unsigned char*) "missing or extra domain data",
54    (unsigned char*) "missing or extra domain data",
55    (unsigned char*) "gluEndTrim() must precede gluEndSurface()",
56    (unsigned char*) "gluBeginSurface() must precede gluEndSurface()",
57    (unsigned char*) "curve of improper type passed as trim curve",
58    (unsigned char*) "gluBeginSurface() must precede gluBeginTrim()",
59    (unsigned char*) "gluEndTrim() must follow gluBeginTrim()",
60    (unsigned char*) "gluBeginTrim() must precede gluEndTrim()",
61    (unsigned char*) "invalid or missing trim curve",
62    (unsigned char*) "gluBeginTrim() must precede gluPwlCurve()",
63    (unsigned char*) "piecewise linear trimming curve referenced twice",
64    (unsigned char*) "piecewise linear trimming curve and nurbs curve mixed",
65    (unsigned char*) "improper usage of trim data type",
66    (unsigned char*) "nurbs curve referenced twice",
67    (unsigned char*) "nurbs curve and piecewise linear trimming curve mixed",
68    (unsigned char*) "nurbs surface referenced twice",
69    (unsigned char*) "invalid property",
70    (unsigned char*) "gluEndSurface() must follow gluBeginSurface()",
71    (unsigned char*) "intersecting or misoriented trim curves",
72    (unsigned char*) "intersecting trim curves",
73    (unsigned char*) "UNUSED",
74    (unsigned char*) "unconnected trim curves",
75    (unsigned char*) "unknown knot error",
76    (unsigned char*) "negative vertex count encountered",
77    (unsigned char*) "negative byte-stride encounteed",
78    (unsigned char*) "unknown type descriptor",
79    (unsigned char*) "null control point reference",
80    (unsigned char*) "duplicate point on piecewise linear trimming curve",
81};
82
83const unsigned char *__gluNURBSErrorString( int errnum )
84{
85    return __gluNurbsErrors[errnum];
86}
87
88static unsigned char *__gluTessErrors[] = {
89    (unsigned char*) " ",
90    (unsigned char*) "gluTessBeginPolygon() must precede a gluTessEndPolygon()",
91    (unsigned char*) "gluTessBeginContour() must precede a gluTessEndContour()",
92    (unsigned char*) "gluTessEndPolygon() must follow a gluTessBeginPolygon()",
93    (unsigned char*) "gluTessEndContour() must follow a gluTessBeginContour()",
94    (unsigned char*) "a coordinate is too large",
95    (unsigned char*) "need combine callback",
96};
97
98const unsigned char *__gluTessErrorString( int errnum )
99{
100    return __gluTessErrors[errnum];
101} /* __glTessErrorString() */
102
103
104struct token_string
105{
106   GLuint Token;
107   const char *String;
108};
109
110static const struct token_string Errors[] = {
111   { GL_NO_ERROR, "no error" },
112   { GL_INVALID_ENUM, "invalid enumerant" },
113   { GL_INVALID_VALUE, "invalid value" },
114   { GL_INVALID_OPERATION, "invalid operation" },
115   { GL_STACK_OVERFLOW, "stack overflow" },
116   { GL_STACK_UNDERFLOW, "stack underflow" },
117   { GL_OUT_OF_MEMORY, "out of memory" },
118   { GL_TABLE_TOO_LARGE, "table too large" },
119#ifdef GL_EXT_framebuffer_object
120   { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
121#endif
122   /* GLU */
123   { GLU_INVALID_ENUM, "invalid enumerant" },
124   { GLU_INVALID_VALUE, "invalid value" },
125   { GLU_OUT_OF_MEMORY, "out of memory" },
126   { GLU_INCOMPATIBLE_GL_VERSION, "incompatible gl version" },
127   { GLU_INVALID_OPERATION, "invalid operation" },
128   { ~0, NULL } /* end of list indicator */
129};
130
131
132
133const GLubyte* gluErrorString(GLenum errorCode)
134{
135    int i;
136    for (i = 0; Errors[i].String; i++) {
137        if (Errors[i].Token == errorCode)
138            return (const GLubyte *) Errors[i].String;
139    }
140    if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR6)) {
141        return (const GLubyte *) __gluTessErrorString(errorCode - (GLU_TESS_ERROR1 - 1));
142    }
143    return (const GLubyte *) 0;
144}
145
146} // end of namespace osg
Note: See TracBrowser for help on using the browser.