1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved.
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 |
|
---|
8 | #include "cr_error.h"
|
---|
9 | #include "cr_environment.h"
|
---|
10 | #include "cr_pack.h"
|
---|
11 | #include "packer.h"
|
---|
12 |
|
---|
13 |
|
---|
14 | /*
|
---|
15 | * Set the error handler callback
|
---|
16 | */
|
---|
17 | void crPackErrorFunction( CRPackContext *pc, CRPackErrorHandlerFunc function )
|
---|
18 | {
|
---|
19 | pc->Error = function;
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * This function is called by the packer functions when it detects and
|
---|
25 | * OpenGL error.
|
---|
26 | */
|
---|
27 | void __PackError( int line, const char *file, GLenum error, const char *info)
|
---|
28 | {
|
---|
29 | CR_GET_PACKER_CONTEXT(pc);
|
---|
30 |
|
---|
31 | if (pc->Error)
|
---|
32 | pc->Error( line, file, error, info );
|
---|
33 |
|
---|
34 | if (crGetenv("CR_DEBUG"))
|
---|
35 | {
|
---|
36 | char *glerr;
|
---|
37 |
|
---|
38 | switch (error) {
|
---|
39 | case GL_NO_ERROR:
|
---|
40 | glerr = "GL_NO_ERROR";
|
---|
41 | break;
|
---|
42 | case GL_INVALID_VALUE:
|
---|
43 | glerr = "GL_INVALID_VALUE";
|
---|
44 | break;
|
---|
45 | case GL_INVALID_ENUM:
|
---|
46 | glerr = "GL_INVALID_ENUM";
|
---|
47 | break;
|
---|
48 | case GL_INVALID_OPERATION:
|
---|
49 | glerr = "GL_INVALID_OPERATION";
|
---|
50 | break;
|
---|
51 | case GL_STACK_OVERFLOW:
|
---|
52 | glerr = "GL_STACK_OVERFLOW";
|
---|
53 | break;
|
---|
54 | case GL_STACK_UNDERFLOW:
|
---|
55 | glerr = "GL_STACK_UNDERFLOW";
|
---|
56 | break;
|
---|
57 | case GL_OUT_OF_MEMORY:
|
---|
58 | glerr = "GL_OUT_OF_MEMORY";
|
---|
59 | break;
|
---|
60 | case GL_TABLE_TOO_LARGE:
|
---|
61 | glerr = "GL_TABLE_TOO_LARGE";
|
---|
62 | break;
|
---|
63 | default:
|
---|
64 | glerr = "unknown";
|
---|
65 | break;
|
---|
66 | }
|
---|
67 |
|
---|
68 | crWarning( "GL error in packer: %s, line %d: %s: %s",
|
---|
69 | file, line, glerr, info );
|
---|
70 | }
|
---|
71 | }
|
---|