1 Star 0 Fork 0

pengrui/opengl-animation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
OpenglUtil.cpp 2.51 KB
一键复制 编辑 原始数据 按行查看 历史
pengrui 提交于 2024-05-16 09:43 . 1
#include"OpenglUtil.h"
#include<glad/glad.h>
#include<iostream>
#include<cstdlib>
namespace{
auto err = []()->std::ostream&{ return std::cerr;};
}
void OpenglUtil::clearError(){
int count = 0;
while(GL_NO_ERROR != glGetError()) count++;
if(count)err()<<"clear error count:" << count;
}
void OpenglUtil::checkError(const Path& file,Line line){
// Get the last error
const GLenum errorCode = glGetError();
if (errorCode != GL_NO_ERROR)
{
std::string error = "Unknown error";
std::string description = "No description";
// Decode the error code
switch (errorCode)
{
case GL_INVALID_ENUM:
{
error = "GL_INVALID_ENUM";
description = "An unacceptable value has been specified for an enumerated argument.";
break;
}
case GL_INVALID_VALUE:
{
error = "GL_INVALID_VALUE";
description = "A numeric argument is out of range.";
break;
}
case GL_INVALID_OPERATION:
{
error = "GL_INVALID_OPERATION";
description = "The specified operation is not allowed in the current state.";
break;
}
case GL_STACK_OVERFLOW:
{
error = "GL_STACK_OVERFLOW";
description = "This command would cause a stack overflow.";
break;
}
case GL_STACK_UNDERFLOW:
{
error = "GL_STACK_UNDERFLOW";
description = "This command would cause a stack underflow.";
break;
}
case GL_OUT_OF_MEMORY:
{
error = "GL_OUT_OF_MEMORY";
description = "There is not enough memory left to execute the command.";
break;
}
case GL_INVALID_FRAMEBUFFER_OPERATION:
{
error = "GL_INVALID_FRAMEBUFFER_OPERATION";
description = "The object bound to FRAMEBUFFER_BINDING is not \"framebuffer complete\".";
break;
}
}
err() << "An internal OpenGL call failed in " << file << "(" << line << ")."
<< "\nExpression:\n "
<< "\nError description:\n " << error << "\n " << description << '\n'
<< std::endl;
if(exitOnError)
std::exit(2);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pengrui1993/opengl-animation.git
git@gitee.com:pengrui1993/opengl-animation.git
pengrui1993
opengl-animation
opengl-animation
master

搜索帮助