From 344c7d453063410301e5e07b44d796e8b9ff63f9 Mon Sep 17 00:00:00 2001 From: Mykhailo Parfeniuk Date: Tue, 13 Jul 2021 20:11:07 +0300 Subject: [PATCH] Fix GL_CHECK macro on Windows --- core/src/gl/framebuffer.cpp | 2 +- core/src/gl/glError.h | 2 ++ platforms/common/platform_gl.cpp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/gl/framebuffer.cpp b/core/src/gl/framebuffer.cpp index a8886e198d..8cc9c114b0 100644 --- a/core/src/gl/framebuffer.cpp +++ b/core/src/gl/framebuffer.cpp @@ -147,7 +147,7 @@ void FrameBuffer::init(RenderState& _rs) { } GLenum status = GL::checkFramebufferStatus(GL_FRAMEBUFFER); - GL_CHECK(); + GL_CHECK({}); if (status != GL_FRAMEBUFFER_COMPLETE) { LOGE("Framebuffer status is incomplete:"); diff --git a/core/src/gl/glError.h b/core/src/gl/glError.h index b3a0edb9c4..e098dae82e 100644 --- a/core/src/gl/glError.h +++ b/core/src/gl/glError.h @@ -25,6 +25,8 @@ class GLError { }; +// On Windows you should provide valid C++ statement for macro to compile +// using {} works good enough #ifdef DEBUG #define GL_CHECK(STMT) do { STMT; Tangram::GLError::error(#STMT, __FILE__, __LINE__); } while (0) #else diff --git a/platforms/common/platform_gl.cpp b/platforms/common/platform_gl.cpp index de50335bf0..93c4600409 100644 --- a/platforms/common/platform_gl.cpp +++ b/platforms/common/platform_gl.cpp @@ -11,7 +11,7 @@ GLenum GL::getError() { const GLubyte* GL::getString(GLenum name) { auto result = glGetString(name); - GL_CHECK(); + GL_CHECK({}); return result; } @@ -86,12 +86,12 @@ void GL::deleteShader(GLuint shader) { } GLuint GL::createShader(GLenum type) { auto result = glCreateShader(type); - GL_CHECK(); + GL_CHECK({}); return result; } GLuint GL::createProgram() { auto result = glCreateProgram(); - GL_CHECK(); + GL_CHECK({}); return result; } @@ -117,12 +117,12 @@ void GL::getProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLc } GLint GL::getUniformLocation(GLuint program, const GLchar *name) { auto result = glGetUniformLocation(program, name); - GL_CHECK(); + GL_CHECK({}); return result; } GLint GL::getAttribLocation(GLuint program, const GLchar *name) { auto result = glGetAttribLocation(program, name); - GL_CHECK(); + GL_CHECK({}); return result; } void GL::getProgramiv(GLuint program, GLenum pname, GLint *params) { @@ -263,12 +263,12 @@ void GL::uniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, co // mapbuffer void* GL::mapBuffer(GLenum target, GLenum access) { auto result = glMapBuffer(target, access); - GL_CHECK(); + GL_CHECK({}); return result; } GLboolean GL::unmapBuffer(GLenum target) { auto result = glUnmapBuffer(target); - GL_CHECK(); + GL_CHECK({}); return result; } @@ -329,7 +329,7 @@ void GL::deleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) { GLenum GL::checkFramebufferStatus(GLenum target) { GLenum status = glCheckFramebufferStatus(target); - GL_CHECK(); + GL_CHECK({}); return status; }