1 | #include <Trace.h> |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdarg.h> |
---|
4 | |
---|
5 | #include <GL/glew.h> |
---|
6 | #include <GL/glut.h> |
---|
7 | |
---|
8 | void |
---|
9 | Trace(const char* format, ...) |
---|
10 | { |
---|
11 | char buff[1024]; |
---|
12 | va_list lst; |
---|
13 | |
---|
14 | va_start(lst, format); |
---|
15 | vsnprintf(buff, 1023, format, lst); |
---|
16 | buff[1023] = '\0'; |
---|
17 | fprintf(stdout, "%s\n", buff); |
---|
18 | fflush(stdout); |
---|
19 | } |
---|
20 | |
---|
21 | bool |
---|
22 | CheckFBO(GLenum *statusPtr) |
---|
23 | { |
---|
24 | *statusPtr = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); |
---|
25 | return (*statusPtr == GL_FRAMEBUFFER_COMPLETE_EXT); |
---|
26 | } |
---|
27 | |
---|
28 | void |
---|
29 | PrintFBOStatus(GLenum status, const char *prefix) |
---|
30 | { |
---|
31 | const char *mesg; |
---|
32 | switch(status) { |
---|
33 | case GL_FRAMEBUFFER_COMPLETE_EXT: |
---|
34 | mesg = "<<<< OK >>>>"; break; |
---|
35 | case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: |
---|
36 | mesg = "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT"; break; |
---|
37 | case GL_FRAMEBUFFER_UNSUPPORTED_EXT: |
---|
38 | mesg = "GL_FRAMEBUFFER_UNSUPPORTED_EXT"; break; |
---|
39 | case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: |
---|
40 | mesg = "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT"; break; |
---|
41 | case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: |
---|
42 | mesg = "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT"; break; |
---|
43 | case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: |
---|
44 | mesg = "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT"; break; |
---|
45 | case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: |
---|
46 | mesg = "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT"; break; |
---|
47 | case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: |
---|
48 | mesg = "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT"; break; |
---|
49 | default: |
---|
50 | fprintf(stderr, "FB Status: %s: UNKNOWN framebuffer status %u\n", |
---|
51 | prefix, (unsigned int)status); |
---|
52 | return; |
---|
53 | } |
---|
54 | fprintf(stderr, "FB Status: %s: %s\n", prefix, mesg); |
---|
55 | } |
---|
56 | |
---|
57 | bool |
---|
58 | CheckGL(const char *prefix) |
---|
59 | { |
---|
60 | const char *mesg; |
---|
61 | GLenum status = (GLenum)glGetError(); |
---|
62 | switch(status) { |
---|
63 | case GL_NO_ERROR: |
---|
64 | return true; |
---|
65 | case GL_INVALID_ENUM: |
---|
66 | mesg = "GL_INVALID_ENUM"; break; |
---|
67 | case GL_INVALID_VALUE: |
---|
68 | mesg = "GL_INVALID_VALUE"; break; |
---|
69 | case GL_INVALID_OPERATION: |
---|
70 | mesg = "GL_INVALID_OPERATION"; break; |
---|
71 | case GL_STACK_OVERFLOW: |
---|
72 | mesg = "GL_STACK_OVERFLOW"; break; |
---|
73 | case GL_STACK_UNDERFLOW: |
---|
74 | mesg = "GL_STACK_UNDERFLOW"; break; |
---|
75 | case GL_OUT_OF_MEMORY: |
---|
76 | mesg = "GL_OUT_OF_MEMORY"; break; |
---|
77 | case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: |
---|
78 | mesg = "GL_INVALID_FRAMEBUFFER_OPERATION_EXT"; break; |
---|
79 | default: |
---|
80 | fprintf(stderr, "GL Status: %s: Unknown status %d\n", prefix, status); |
---|
81 | return false; |
---|
82 | } |
---|
83 | fprintf(stderr, "GL Status: %s: %s\n", prefix, mesg); |
---|
84 | return false; |
---|
85 | } |
---|
86 | |
---|
87 | |
---|