From 9575e7d7ca31a241809fa156a53e2ae2e4a9609b Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sat, 1 Mar 2025 09:23:32 +0800 Subject: [PATCH] [Fix] (texture.cpp|loader.h): Fix the compilation when DEBUG is enabled. Signed-off-by: BZLZHH --- src/main/cpp/gl/texture.cpp | 10 ++++++---- src/main/cpp/gles/loader.h | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/cpp/gl/texture.cpp b/src/main/cpp/gl/texture.cpp index b136a87..6e431a6 100644 --- a/src/main/cpp/gl/texture.cpp +++ b/src/main/cpp/gl/texture.cpp @@ -80,8 +80,9 @@ void internal_convert(GLenum* internal_format, GLenum* type, GLenum* format) { case GL_DEPTH_COMPONENT: LOG_D("Find GL_DEPTH_COMPONENT: internalFormat: %s, format: %s, type: %s", glEnumToString(*internal_format), glEnumToString(*format), glEnumToString(*type)) - if(type) + if(type) { *type = GL_UNSIGNED_INT; + } break; case GL_DEPTH_STENCIL: @@ -567,7 +568,7 @@ void glRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, if (realInternalFormat != 0 && ERR == GL_NO_ERROR) internalFormat = (GLenum)realInternalFormat; else - internalFormat = GL_DEPTH_COMPONENT24; + internalFormat = GL_DEPTH_COMPONENT; CLEAR_GL_ERROR_NO_INIT @@ -594,7 +595,7 @@ void glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum int if (realInternalFormat != 0 && ERR == GL_NO_ERROR) internalFormat = (GLenum)realInternalFormat; else - internalFormat = GL_DEPTH_COMPONENT24; + internalFormat = GL_DEPTH_COMPONENT; LOG_D("glRenderbufferStorageMultisample, target: %d, samples: %d, internalFormat: %d, width: %d, height: %d", @@ -826,7 +827,8 @@ void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format x, y, width, height, format, type, pixels) static int count = 0; - + GLenum prevFormat = format; + if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) { format = GL_RGBA; type = GL_UNSIGNED_BYTE; diff --git a/src/main/cpp/gles/loader.h b/src/main/cpp/gles/loader.h index 87737d0..f5cc609 100644 --- a/src/main/cpp/gles/loader.h +++ b/src/main/cpp/gles/loader.h @@ -53,7 +53,7 @@ static name##_PTR egl_##name = NULL; \ } #define CLEAR_GL_ERROR \ - LOAD_GLES_FUNC(glGetError) \ + LOAD_GLES_FUNC(glGetError) \ GLenum ERR = gles_glGetError(); \ while (ERR != GL_NO_ERROR) \ ERR = gles_glGetError(); @@ -65,7 +65,7 @@ static name##_PTR egl_##name = NULL; \ #if GLOBAL_DEBUG #define CHECK_GL_ERROR \ - LOAD_GLES_FUNC(glGetError) \ + LOAD_GLES_FUNC(glGetError) \ GLenum ERR = gles_glGetError(); \ while (ERR != GL_NO_ERROR) { \ LOG_E("ERROR: %d @ %s:%d", ERR, __FILE__, __LINE__) \ @@ -73,14 +73,14 @@ static name##_PTR egl_##name = NULL; \ } #define INIT_CHECK_GL_ERROR \ - LOAD_GLES_FUNC(glGetError) \ + LOAD_GLES_FUNC(glGetError) \ GLenum ERR = GL_NO_ERROR; #define CHECK_GL_ERROR_NO_INIT \ - ERR = gles_glGetError(); \ - while (ERR != GL_NO_ERROR) { \ - LOG_E("ERROR: %d @ %s:%d", ERR, __FILE__, __LINE__) \ - ERR = gles_glGetError(); \ + ERR = gles_glGetError(); \ + while (ERR != GL_NO_ERROR) { \ + LOG_E("ERROR: %d @ %s:%d", ERR, __FILE__, __LINE__) \ + ERR = gles_glGetError(); \ } #else #define CHECK_GL_ERROR {} @@ -89,20 +89,20 @@ static name##_PTR egl_##name = NULL; \ #endif #define INIT_CHECK_GL_ERROR_FORCE \ - LOAD_GLES_FUNC(glGetError) \ + LOAD_GLES_FUNC(glGetError) \ GLenum ERR = GL_NO_ERROR; #define NATIVE_FUNCTION_HEAD(type,name,...) \ -GLAPI GLAPIENTRY type name##ARB(__VA_ARGS__) __attribute__((alias(#name))); \ -GLAPI GLAPIENTRY type name(__VA_ARGS__) { +extern "C" GLAPI GLAPIENTRY type name##ARB(__VA_ARGS__) __attribute__((alias(#name))); \ +extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) { #if GLOBAL_DEBUG #define NATIVE_FUNCTION_END(type,name,...) \ LOG_D("Use native function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \ - LOAD_RAW_GLES(name, type, __VA_ARGS__); \ + LOAD_GLES_FUNC(name); \ type ret = gles_##name(__VA_ARGS__); \ - LOAD_GLES_FUNC(glGetError) \ + LOAD_GLES_FUNC(glGetError) \ GLenum ERR = gles_glGetError(); \ if (ERR != GL_NO_ERROR) \ LOG_E("ERROR: %d", ERR) \ @@ -121,7 +121,7 @@ GLAPI GLAPIENTRY type name(__VA_ARGS__) { #if GLOBAL_DEBUG #define NATIVE_FUNCTION_END_NO_RETURN(type,name,...) \ LOG_D("Use native function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \ - LOAD_RAW_GLES(name, type, __VA_ARGS__); \ + LOAD_GLES_FUNC(name); \ gles_##name(__VA_ARGS__); \ CHECK_GL_ERROR \ } @@ -134,15 +134,15 @@ GLAPI GLAPIENTRY type name(__VA_ARGS__) { #endif #define STUB_FUNCTION_HEAD(type,name,...) \ -GLAPI GLAPIENTRY type name(__VA_ARGS__) { +extern "C" GLAPI GLAPIENTRY type name(__VA_ARGS__) { #define STUB_FUNCTION_END(type,name,...) \ - LOG_W("Stub function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \ + LOG_W("Stub function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \ return (type)0; \ } #define STUB_FUNCTION_END_NO_RETURN(type,name,...) \ - LOG_W("Stub function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \ + LOG_W("Stub function: %s @ %s(...)", RENDERERNAME, __FUNCTION__); \ } struct gles_caps_t {