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

Last change on this file since 3589 was 3559, checked in by gah, 11 years ago
  • Clean up unused variable warnings.
  • Remove use of ffmpeg libraries from nanovis. This should make it easier to maintain (don't have to keep up with all the backward incompatible changes to the ffmpeg library).
  • Property svn:eol-style set to native
File size: 3.1 KB
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[3452]2/*
3 * Copyright (C) 2004-2013  HUBzero Foundation, LLC
4 *
5 * Author: George A. Howlett <gah@purdue.edu>
6 */
[848]7#include <stdio.h>
[911]8#include <stdarg.h>
[2831]9#include <syslog.h>
[3492]10#include <string.h>
[848]11
[1196]12#include <GL/glew.h>
[2822]13
[2831]14#include "nanovis.h"
15#include "Trace.h"
[1196]16
[3452]17#define MSG_LEN 2047
[2374]18
[1200]19void
[3452]20LogMessage(int priority, const char *funcname,
21           const char *path, int lineNum, const char* fmt, ...)
[848]22{
[1991]23    char message[MSG_LEN+1];
24    const char *s;
25    int length;
[911]26    va_list lst;
[1984]27
[1991]28    va_start(lst, fmt);
29    s = strrchr(path, '/');
30    if (s == NULL) {
31        s = path;
32    } else {
33        s++;
[1520]34    }
[3452]35    if (priority & LOG_DEBUG) {
36        length = snprintf(message, MSG_LEN, "%s:%d(%s): ", s, lineNum, funcname);
37    } else {
38        length = snprintf(message, MSG_LEN, "%s:%d: ", s, lineNum);
39    }
[1991]40    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
41    message[MSG_LEN] = '\0';
[3452]42
43    syslog(priority, "%s", message);
[848]44}
45
[1199]46bool
[1200]47CheckFBO(GLenum *statusPtr)
[1196]48{
[1200]49    *statusPtr = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
[1199]50    return (*statusPtr == GL_FRAMEBUFFER_COMPLETE_EXT);
51}
52
53void
[1200]54PrintFBOStatus(GLenum status, const char *prefix)
[1199]55{
[3559]56#ifdef WANT_TRACE
[1200]57    const char *mesg;
[3559]58
[1200]59    switch(status) {
[1196]60    case GL_FRAMEBUFFER_COMPLETE_EXT:
[1200]61        mesg = "<<<< OK >>>>";                                          break;
[1196]62    case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
[1200]63        mesg = "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT";              break;
[1196]64    case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
[1200]65        mesg = "GL_FRAMEBUFFER_UNSUPPORTED_EXT";                        break;
[1196]66    case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
[1200]67        mesg = "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT";      break;
[1196]68    case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
[1200]69        mesg = "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT";              break;
[1196]70    case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
[1200]71        mesg = "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT";                 break;
[1196]72    case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
[1200]73        mesg = "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT";             break;
[1196]74    case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
[1200]75        mesg = "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT";             break;
[1196]76    default:
[3452]77        TRACE("FB Status: %s: UNKNOWN framebuffer status %u",
[1984]78               prefix, (unsigned int)status);
[1200]79        return;
80    }
[3452]81    TRACE("FB Status: %s: %s", prefix, mesg);
[3559]82#endif  /*WANT_TRACE*/
[1196]83}
84
85bool
[1200]86CheckGL(const char *prefix)
[1196]87{
[1200]88    GLenum status = (GLenum)glGetError();
[3559]89    if (status == GL_NO_ERROR) {
90        return true;
91    }
92#ifdef WANT_TRACE
93    const char *mesg;                   
94
[1200]95    switch(status) {
[1196]96    case GL_INVALID_ENUM:
[1200]97        mesg = "GL_INVALID_ENUM";                       break;
[1196]98    case GL_INVALID_VALUE:
[1200]99        mesg = "GL_INVALID_VALUE";                      break;
[1196]100    case GL_INVALID_OPERATION:
[1200]101        mesg = "GL_INVALID_OPERATION";                  break;
[1196]102    case GL_STACK_OVERFLOW:
[1200]103        mesg = "GL_STACK_OVERFLOW";                     break;
[1196]104    case GL_STACK_UNDERFLOW:
[1200]105        mesg = "GL_STACK_UNDERFLOW";                    break;
[1196]106    case GL_OUT_OF_MEMORY:
[1200]107        mesg = "GL_OUT_OF_MEMORY";                      break;
[1196]108    case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
[1200]109        mesg = "GL_INVALID_FRAMEBUFFER_OPERATION_EXT";  break;
[1196]110    default:
[3452]111        TRACE("GL Status: %s: Unknown status %d", prefix, status);
[1200]112        return false;
113    }
[3452]114    TRACE("GL Status: %s: %s", prefix, mesg);
[3559]115#endif
[1200]116    return false;
[1196]117}
118
119
Note: See TracBrowser for help on using the repository browser.