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

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

Added #define's and local include<osg/Image> to fix Windows GL 1.1 build against

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
39static unsigned char *__gluNurbsErrors[] = {
40    (unsigned char*) " ",
41    (unsigned char*) "spline order un-supported",
42    (unsigned char*) "too few knots",
43    (unsigned char*) "valid knot range is empty",
44    (unsigned char*) "decreasing knot sequence knot",
45    (unsigned char*) "knot multiplicity greater than order of spline",
46    (unsigned char*) "gluEndCurve() must follow gluBeginCurve()",
47    (unsigned char*) "gluBeginCurve() must precede gluEndCurve()",
48    (unsigned char*) "missing or extra geometric data",
49    (unsigned char*) "can't draw piecewise linear trimming curves",
50    (unsigned char*) "missing or extra domain data",
51    (unsigned char*) "missing or extra domain data",
52    (unsigned char*) "gluEndTrim() must precede gluEndSurface()",
53    (unsigned char*) "gluBeginSurface() must precede gluEndSurface()",
54    (unsigned char*) "curve of improper type passed as trim curve",
55    (unsigned char*) "gluBeginSurface() must precede gluBeginTrim()",
56    (unsigned char*) "gluEndTrim() must follow gluBeginTrim()",
57    (unsigned char*) "gluBeginTrim() must precede gluEndTrim()",
58    (unsigned char*) "invalid or missing trim curve",
59    (unsigned char*) "gluBeginTrim() must precede gluPwlCurve()",
60    (unsigned char*) "piecewise linear trimming curve referenced twice",
61    (unsigned char*) "piecewise linear trimming curve and nurbs curve mixed",
62    (unsigned char*) "improper usage of trim data type",
63    (unsigned char*) "nurbs curve referenced twice",
64    (unsigned char*) "nurbs curve and piecewise linear trimming curve mixed",
65    (unsigned char*) "nurbs surface referenced twice",
66    (unsigned char*) "invalid property",
67    (unsigned char*) "gluEndSurface() must follow gluBeginSurface()",
68    (unsigned char*) "intersecting or misoriented trim curves",
69    (unsigned char*) "intersecting trim curves",
70    (unsigned char*) "UNUSED",
71    (unsigned char*) "unconnected trim curves",
72    (unsigned char*) "unknown knot error",
73    (unsigned char*) "negative vertex count encountered",
74    (unsigned char*) "negative byte-stride encounteed",
75    (unsigned char*) "unknown type descriptor",
76    (unsigned char*) "null control point reference",
77    (unsigned char*) "duplicate point on piecewise linear trimming curve",
78};
79
80const unsigned char *__gluNURBSErrorString( int errnum )
81{
82    return __gluNurbsErrors[errnum];
83}
84
85static unsigned char *__gluTessErrors[] = {
86    (unsigned char*) " ",
87    (unsigned char*) "gluTessBeginPolygon() must precede a gluTessEndPolygon()",
88    (unsigned char*) "gluTessBeginContour() must precede a gluTessEndContour()",
89    (unsigned char*) "gluTessEndPolygon() must follow a gluTessBeginPolygon()",
90    (unsigned char*) "gluTessEndContour() must follow a gluTessBeginContour()",
91    (unsigned char*) "a coordinate is too large",
92    (unsigned char*) "need combine callback",
93};
94
95const unsigned char *__gluTessErrorString( int errnum )
96{
97    return __gluTessErrors[errnum];
98} /* __glTessErrorString() */
99
100
101struct token_string
102{
103   GLuint Token;
104   const char *String;
105};
106
107static const struct token_string Errors[] = {
108   { GL_NO_ERROR, "no error" },
109   { GL_INVALID_ENUM, "invalid enumerant" },
110   { GL_INVALID_VALUE, "invalid value" },
111   { GL_INVALID_OPERATION, "invalid operation" },
112   { GL_STACK_OVERFLOW, "stack overflow" },
113   { GL_STACK_UNDERFLOW, "stack underflow" },
114   { GL_OUT_OF_MEMORY, "out of memory" },
115   { GL_TABLE_TOO_LARGE, "table too large" },
116#ifdef GL_EXT_framebuffer_object
117   { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
118#endif
119   /* GLU */
120   { GLU_INVALID_ENUM, "invalid enumerant" },
121   { GLU_INVALID_VALUE, "invalid value" },
122   { GLU_OUT_OF_MEMORY, "out of memory" },
123   { GLU_INCOMPATIBLE_GL_VERSION, "incompatible gl version" },
124   { GLU_INVALID_OPERATION, "invalid operation" },
125   { ~0, NULL } /* end of list indicator */
126};
127
128
129
130const GLubyte* gluErrorString(GLenum errorCode)
131{
132    int i;
133    for (i = 0; Errors[i].String; i++) {
134        if (Errors[i].Token == errorCode)
135            return (const GLubyte *) Errors[i].String;
136    }
137    if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR6)) {
138        return (const GLubyte *) __gluTessErrorString(errorCode - (GLU_TESS_ERROR1 - 1));
139    }
140    return (const GLubyte *) 0;
141}
Note: See TracBrowser for help on using the browser.