From 8ef1a9a0caaf6a644a9a20bde61c9c2b943744ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 11 Jun 2013 15:51:52 +0200 Subject: [PATCH] Added Renderer::error(). --- src/Renderer.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/Renderer.h b/src/Renderer.h index 0ff490450..407c2e323 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -871,6 +871,69 @@ class MAGNUM_EXPORT Renderer { */ static void finish() { glFinish(); } + /** + * @brief Error status + * + * @see error() + */ + enum class Error: GLenum { + /** No error has been recorded */ + NoError = GL_NO_ERROR, + + /** An unacceptable value specified for enumerated argument */ + InvalidEnum = GL_INVALID_ENUM, + + /** A numeric argument is out of range */ + InvalidValue = GL_INVALID_VALUE, + + /** The specified operation is not allowed in the current state */ + InvalidOperation = GL_INVALID_OPERATION, + + /** + * The framebuffer object is not complete. + * @see AbstractFramebuffer::checkStatus() + * @requires_gl30 %Extension @extension{EXT,framebuffer_object} + */ + InvalidFramebufferOperation = GL_INVALID_FRAMEBUFFER_OPERATION, + + /** There is not enough memory left to execute the command. */ + OutOfMemory = GL_OUT_OF_MEMORY, + + #ifndef MAGNUM_TARGET_GLES3 + /** + * Given operation would cause an internal stack to underflow. + * @requires_gl43 %Extension @extension{KHR,debug} + * @requires_es_extension %Extension @es_extension2{KHR,debug,debug} + */ + #ifndef MAGNUM_TARGET_GLES2 + StackUnderflow = GL_STACK_UNDERFLOW, + #else + StackUnderflow = GL_STACK_UNDERFLOW_KHR, + #endif + + /** + * Given operation would cause an internal stack to overflow. + * @requires_gl43 %Extension @extension{KHR,debug} + * @requires_es_extension %Extension @es_extension2{KHR,debug,debug} + */ + #ifndef MAGNUM_TARGET_GLES2 + StackOverflow = GL_STACK_OVERFLOW + #else + StackOverflow = GL_STACK_OVERFLOW_KHR + #endif + #endif + }; + + /** + * @brief Error status + * + * Returns error flag, if any set. If there aren't any more error + * flags, returns @ref Error "Error::NoError". Thus this function + * should be always called in a loop until it returns @ref Error "Error::NoError". + * @see @fn_gl{GetError} + */ + static Error error() { return static_cast(glGetError()); } + #ifndef MAGNUM_TARGET_GLES3 /** * @brief Graphics reset notification strategy