Commits

Jason McKesson  committed 943eb86

glutil: Added functions for returning error codes as text.

  • Participants
  • Parent commits 56126fc

Comments (0)

Files changed (4)

File docs/glsdk.doxy

 
 Changes from 0.4.4:
 \li Modified how GL Load works, using a code generator from an external project.
+\li @ref module_glutil_debug "GL Util's debug system" now has functions to get string names and descriptions for OpenGL errors and framebuffer status codes.
+\li Added GL Load Gen to the distribution.
 
 Changes from 0.4.3:
 \li GL Load includes OpenGL 4.3 extensions and core functions.

File glutil/include/glutil/Debug.h

 #ifndef DEBUG_UTIL_H
 #define DEBUG_UTIL_H
 
+#include <string>
+#include <vector>
+
 /**
 \file
-\brief Includes a function for attaching to ARB_debug_output and printing error messages automatically.
+\brief Includes a function for attaching to ARB_debug_output and printing error messages automatically. This header must be included after an OpenGL header.
 **/
 
 namespace glutil
 	**/
 	bool RegisterDebugOutput(OutputLocation eLoc);
 
+	/**
+	\brief Generates the enumerator string for an OpenGL error code.
+
+	\returns The enumerator string for an error code. If \a errorCode is not an actual,
+	valid OpenGL error code, it will return an empty string.
+	**/
+	std::string ErrorCodeToEnumString(GLenum errorCode);
+
+	/**
+	\brief Generates a string description for an OpenGL error code.
+
+	This is a relatively short (sentence or two) length description of the meaning of an OpenGL error code.
+
+	\returns A short (sentence or two) description of an OpenGL error code. If \a errorCode is not an
+	actual, valid OpenGL error code, it will return an empty string.
+	**/
+	std::string ErrorCodeToDescription(GLenum errorCode);
+
+	/**
+	\brief Generates the enumerator string for an OpenGL framebuffer status code.
+
+	This will generate a string representing the OpenGL enumerator for the status returned
+	by <tt>glCheckFramebufferStatus</tt>.
+
+	\returns The enumerator string for the framebuffer status. If \a framebufferStatus is not
+	an actual, valid framebuffer status code, it will return an empty string.
+	**/
+	std::string FramebufferToEnumString(GLenum framebufferStatus);
+
+	/**
+	\brief Generates a description for an OpenGL framebuffer status code.
+	
+	This is a relatively short (sentence or two) length description of the meaning of an
+	OpenGL framebuffer status code.
+
+	\returns A short (sentence or two) description of a framebuffer status code. 
+	If \a errorCode is not an actual, valid framebuffer status code, it will return an empty string.
+	**/
+	std::string FramebufferToDescription(GLenum framebufferStatus);
 	///@}
 }
 

File glutil/include/glutil/glutil.h

 #include "MousePoles.h"
 #include "MatrixStack.h"
 #include "Font.h"
+#include "Error.h"
 
 
 /**

File glutil/source/Debug.cpp

 
 		return true;
 	}
+
+	std::string ErrorCodeToEnumString( GLenum errorCode )
+	{
+		switch(errorCode)
+		{
+		case gl::INVALID_ENUM:
+			return "GL_INVALID_ENUM";
+		case gl::INVALID_VALUE:
+			return "GL_INVALID_VALUE";
+		case gl::INVALID_OPERATION:
+			return "GL_INVALID_OPERATION";
+		case gl::OUT_OF_MEMORY:
+			return "GL_OUT_OF_MEMORY";
+		case gl::INVALID_FRAMEBUFFER_OPERATION:
+			return "GL_INVALID_FRAMEBUFFER_OPERATION";
+		case gl::STACK_OVERFLOW:
+			return "GL_STACK_OVERFLOW";
+		case gl::STACK_UNDERFLOW:
+			return "GL_STACK_UNDERFLOW";
+		case gl::TABLE_TOO_LARGE:
+			return "GL_TABLE_TOO_LARGE";
+		}
+
+		return std::string();
+	}
+
+	std::string ErrorCodeToDescription( GLenum errorCode )
+	{
+		switch(errorCode)
+		{
+		case gl::INVALID_ENUM:
+			return "An enumerator passed to a function is not an acceptable enumerator.";
+		case gl::INVALID_VALUE:
+			return "One of the integer or float values passed to a function is outside the accepted range.";
+		case gl::INVALID_OPERATION:
+			return "A combination of parameters to a function or the interaction with context state is not acceptable.";
+		case gl::OUT_OF_MEMORY:
+			return "OpenGL cannot allocate that much memory";
+		case gl::INVALID_FRAMEBUFFER_OPERATION:
+			return "The current draw or read framebuffer is not complete.";
+		case gl::STACK_OVERFLOW:
+			return "An operation attempted to push onto a stack that exceeded the stack's size.";
+		case gl::STACK_UNDERFLOW:
+			return "An operation attempted to pop from an empty stack.";
+		case gl::TABLE_TOO_LARGE:
+			return "The color lookup or histogram table is too large.";
+		}
+
+		return std::string();
+	}
+
+	std::string FramebufferToEnumString( GLenum framebufferStatus )
+	{
+		switch(framebufferStatus)
+		{
+		case gl::FRAMEBUFFER_UNDEFINED:
+			return "GL_FRAMEBUFFER_UNDEFINED";
+		case gl::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
+			return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
+		case gl::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
+			return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
+		case gl::FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
+			return "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER";
+		case gl::FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
+			return "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER";
+		case gl::FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
+			return "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE";
+		case gl::FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
+			return "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS";
+		case gl::FRAMEBUFFER_UNSUPPORTED:
+			return "GL_FRAMEBUFFER_UNSUPPORTED";
+		case gl::FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
+			return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT";
+		case gl::FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
+			return "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT";
+		}
+
+		return std::string();
+	}
+
+	std::string FramebufferToDescription( GLenum framebufferStatus )
+	{
+		switch(framebufferStatus)
+		{
+		case gl::FRAMEBUFFER_UNDEFINED:
+			return "The framebuffer is the default framebuffer, and the default framebuffer does not exist.";
+		case gl::FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
+			return "One of the framebuffer's attachments is incomplete.";
+		case gl::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
+			return "No image is attached, and no default width/height parameters are set.";
+		case gl::FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
+			return "One of the images specified in the draw buffers array does not have an image attached.";
+		case gl::FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
+			return "One of the images specified in the read buffers array does not have an image attached.";
+		case gl::FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
+			return "The attached images have an inconsistent number of samples.";
+		case gl::FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
+			return "The attached images have an inconsistent layering attachment. Some are layered and some are not.";
+		case gl::FRAMEBUFFER_UNSUPPORTED:
+			return "The combination of image formats is not supported in this implementation.";
+		case gl::FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
+			return "The attached images have inconsistent widths/heights.";
+		case gl::FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
+			return "The color attachments have inconsistent internal formats.";
+		}
+
+		return std::string();
+	}
 }