PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/error.cpp

https://github.com/sonyomega/ogl-samples
C++ | 72 lines | 68 code | 4 blank | 0 comment | 4 complexity | 4d205a9bcc5b29397b9ac9097ab13287 MD5 | raw file
 1#include "error.hpp"
 2#include <string>
 3#include <cstdio>
 4#include <cassert>
 5
 6bool checkError(const char* Title)
 7{
 8	int Error;
 9	if((Error = glGetError()) != GL_NO_ERROR)
10	{
11		std::string ErrorString;
12		switch(Error)
13		{
14		case GL_INVALID_ENUM:
15			ErrorString = "GL_INVALID_ENUM";
16			break;
17		case GL_INVALID_VALUE:
18			ErrorString = "GL_INVALID_VALUE";
19			break;
20		case GL_INVALID_OPERATION:
21			ErrorString = "GL_INVALID_OPERATION";
22			break;
23		case GL_INVALID_FRAMEBUFFER_OPERATION:
24			ErrorString = "GL_INVALID_FRAMEBUFFER_OPERATION";
25			break;
26		case GL_OUT_OF_MEMORY:
27			ErrorString = "GL_OUT_OF_MEMORY";
28			break;
29		default:
30			ErrorString = "UNKNOWN";
31			break;
32		}
33		fprintf(stdout, "OpenGL Error(%s): %s\n", ErrorString.c_str(), Title);
34		assert(0);
35	}
36	return Error == GL_NO_ERROR;
37}
38
39inline bool checkFramebuffer(GLuint FramebufferName)
40{
41	GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
42	switch(Status)
43	{
44	case GL_FRAMEBUFFER_UNDEFINED:
45		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_UNDEFINED");
46		break;
47	case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
48		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
49		break;
50	case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
51		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
52		break;
53	case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
54		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER");
55		break;
56	case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
57		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER");
58		break;
59	case GL_FRAMEBUFFER_UNSUPPORTED:
60		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_UNSUPPORTED");
61		break;
62	case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
63		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE");
64		break;
65	case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
66		fprintf(stdout, "OpenGL Error(%s)\n", "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS");
67		break;
68	}
69
70	return Status != GL_FRAMEBUFFER_COMPLETE;
71}
72