source: trunk/packages/vizservers/nanovis/Trace.cpp @ 1489

Last change on this file since 1489 was 1380, checked in by gah, 16 years ago
File size: 2.4 KB
Line 
1#include <Trace.h>
2#include <stdio.h>
3#include <stdarg.h>
4
5#include <GL/glew.h>
6#include <GL/glut.h>
7
8void
9Trace(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
21bool
22CheckFBO(GLenum *statusPtr)
23{
24    *statusPtr = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
25    return (*statusPtr == GL_FRAMEBUFFER_COMPLETE_EXT);
26}
27
28void
29PrintFBOStatus(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
57bool
58CheckGL(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
Note: See TracBrowser for help on using the repository browser.