| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | #include <osg/GLU> |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | #ifndef GL_TABLE_TOO_LARGE |
|---|
| 36 | #define GL_TABLE_TOO_LARGE 0x8031 |
|---|
| 37 | #endif |
|---|
| 38 | |
|---|
| 39 | namespace osg |
|---|
| 40 | { |
|---|
| 41 | |
|---|
| 42 | static 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 | |
|---|
| 83 | const unsigned char *__gluNURBSErrorString( int errnum ) |
|---|
| 84 | { |
|---|
| 85 | return __gluNurbsErrors[errnum]; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | static 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 | |
|---|
| 98 | const unsigned char *__gluTessErrorString( int errnum ) |
|---|
| 99 | { |
|---|
| 100 | return __gluTessErrors[errnum]; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | struct token_string |
|---|
| 105 | { |
|---|
| 106 | GLuint Token; |
|---|
| 107 | const char *String; |
|---|
| 108 | }; |
|---|
| 109 | |
|---|
| 110 | static 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 | |
|---|
| 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 } |
|---|
| 129 | }; |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | const 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 | } |
|---|