-
Notifications
You must be signed in to change notification settings - Fork 5
/
error.h
78 lines (67 loc) · 3.24 KB
/
error.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
** error.h
**
** Copyright (c) 2008 Max Rupp ([email protected]) All rights reserved.
*/
#ifndef __ERROR_H__
#define __ERROR_H__
#ifdef DEBUG
#include <stdlib.h>
#include <assert.h>
#define GetError( )\
{\
for ( GLenum Error = glGetError( ); ( GL_NO_ERROR != Error ); Error = glGetError( ) )\
{\
switch ( Error )\
{\
case GL_INVALID_ENUM: printf( "\n%s\n\n", "GL_INVALID_ENUM" ); assert( 0 ); break;\
case GL_INVALID_VALUE: printf( "\n%s\n\n", "GL_INVALID_VALUE" ); assert( 0 ); break;\
case GL_INVALID_OPERATION: printf( "\n%s\n\n", "GL_INVALID_OPERATION" ); assert( 0 ); break;\
case GL_OUT_OF_MEMORY: printf( "\n%s\n\n", "GL_OUT_OF_MEMORY" ); assert( 0 ); break;\
default: break;\
}\
}\
}
#define CheckFramebufferStatus( )\
{\
switch ( glCheckFramebufferStatus( GL_FRAMEBUFFER ) )\
{\
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: printf( "\n%s\n\n", "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT" ); assert( 0 ); break;\
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: printf( "\n%s\n\n", "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT" ); assert( 0 ); break;\
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: printf( "\n%s\n\n", "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER" ); assert( 0 ); break;\
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: printf( "\n%s\n\n", "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER" ); assert( 0 ); break;\
case GL_FRAMEBUFFER_UNSUPPORTED: printf( "\n%s\n\n", "GL_FRAMEBUFFER_UNSUPPORTED" ); assert( 0 ); break;\
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: printf( "\n%s\n\n", "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE" ); assert( 0 ); break;\
case GL_FRAMEBUFFER_UNDEFINED: printf( "\n%s\n\n", "GL_FRAMEBUFFER_UNDEFINED" ); assert( 0 ); break;\
default: break;\
}\
}
#define GetShaderInfoLog( Shader, Source )\
{\
GLint Status, Count;\
GLchar *Error;\
\
glGetShaderiv( Shader, GL_COMPILE_STATUS, &Status );\
\
if ( !Status )\
{\
glGetShaderiv( Shader, GL_INFO_LOG_LENGTH, &Count );\
\
if ( Count > 0 )\
{\
glGetShaderInfoLog( Shader, Count, NULL, ( Error = calloc( 1, Count ) ) );\
\
printf( "%s\n\n%s\n", Source, Error );\
\
free( Error );\
\
assert( 0 );\
}\
}\
}
#else
#define GetError( )
#define CheckFramebufferStatus( )
#define GetShaderInfoLog( Shader, Source )
#endif /* DEBUG */
#endif /* __ERROR_H__ */