c++断言调试宏

/* 
  MSVC调试有效

   __debugbreak(),调试中断
   __FILE__,文件路径

   __LINE__,行号

*/

#define ASSERT(x) if(!(x)) __debugbreak();
#define GLCall(x) GLClearError();\
       x;\
       ASSERT(GLLogCall(#x,__FILE__,__LINE__))


// 清除所有错误
static void GLClearError()
{
    while (glGetError() != GL_NO_ERROR);
}

static bool GLLogCall(const char* function, const char* file, int line)
{
    while (GLenum error = glGetError())
    {
        std::cout << "[OpenGL Error] (" << error << "): "
            << function << " "
            << file << ":"
            << line << std::endl;
        return false;
    }
    return true;
}


GLCall(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr));

 

posted @ 2022-03-29 15:26  冂冋冏囧  阅读(112)  评论(0编辑  收藏  举报