-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.c
More file actions
43 lines (40 loc) · 909 Bytes
/
debug.c
File metadata and controls
43 lines (40 loc) · 909 Bytes
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
#include "debug.h"
#include <GL/gl.h>
#include <SDL2/SDL.h>
#include <GL/glu.h>
void render_check_gl_error( char * a )
{
#ifdef DEBUG
GLenum b = glGetError();
if( b == GL_NO_ERROR )
fprintf( stdout, "Finished %s\n", a );
else
fprintf( stderr, "Failed %s: %s\n", a, gluErrorString( b ) );
#endif
}
void render_check_glsl_error( char * a, GLuint shader )
{
#ifdef DEBUG
int b;
glGetShaderiv( shader, GL_COMPILE_STATUS, &b );
if( b == 1 )
fprintf( stdout, "Finished %s\n", a );
else
{
GLsizei length;
GLchar log[4096];
glGetShaderInfoLog( shader, 4096, &length, log );
debug_printf( "Fragment shader log: %s\n", log );
fprintf( stderr, "Failed %s:\n%s\n", a, log );
}
#endif
}
void render_check_sdl_error( char * a )
{
#ifdef DEBUG
if( strlen( SDL_GetError() ) == 0 )
fprintf( stdout, "Finished %s\n", a );
else
fprintf( stderr, "Failed %s: %s\n", a, SDL_GetError() );
#endif
}