From d5c26754f23b20e06d1f0c312558c2cbfe43c5be Mon Sep 17 00:00:00 2001 From: Hugh Sanderson Date: Fri, 20 Sep 2024 16:23:07 +0800 Subject: [PATCH] Avoid glGetError on emscripten. Clear vertex attrib bindings on start --- project/ToolkitBuild.xml | 3 ++- project/src/common/ExternalInterface.cpp | 1 - project/src/opengl/OGLTexture.cpp | 4 ++++ project/src/opengl/OpenGLContext.cpp | 19 ++++++++++++++++--- project/src/sdl2/SDL2Stage.cpp | 3 +++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/project/ToolkitBuild.xml b/project/ToolkitBuild.xml index 6cf0e21d2..8d1389fcb 100644 --- a/project/ToolkitBuild.xml +++ b/project/ToolkitBuild.xml @@ -289,7 +289,8 @@ - + + diff --git a/project/src/common/ExternalInterface.cpp b/project/src/common/ExternalInterface.cpp index 5ff5fa9cb..ad8d1afff 100644 --- a/project/src/common/ExternalInterface.cpp +++ b/project/src/common/ExternalInterface.cpp @@ -16,7 +16,6 @@ #define NME_NO_LZMA #endif - #ifdef ANDROID #include #endif diff --git a/project/src/opengl/OGLTexture.cpp b/project/src/opengl/OGLTexture.cpp index 3774e106c..c74e2d228 100644 --- a/project/src/opengl/OGLTexture.cpp +++ b/project/src/opengl/OGLTexture.cpp @@ -387,6 +387,7 @@ class OGLTexture : public Texture if (mMipmaps) { + #if (!defined(EMSCRIPTEN) || !defined(NME_NO_GETERROR)) glGetError(); glGenerateMipmap(GL_TEXTURE_2D); int err = glGetError(); @@ -395,6 +396,7 @@ class OGLTexture : public Texture ELOG("Error creating mipmaps @ %dx%d,%d/%d : %d\n", mTextureWidth, mTextureHeight, store_format,pixel_format, err); mMipmaps = false; } + #endif } mUploadedFormat = store_format; @@ -528,9 +530,11 @@ class OGLTexture : public Texture if (mMipmaps) glGenerateMipmap(GL_TEXTURE_2D); + #ifndef NME_NO_GETERROR int err = glGetError(); if (err != GL_NO_ERROR) ELOG("GL Error: %d %dx%d", err, mDirtyRect.w, mDirtyRect.h); + #endif mDirtyRect = Rect(); } } diff --git a/project/src/opengl/OpenGLContext.cpp b/project/src/opengl/OpenGLContext.cpp index bdfa94466..4b623e953 100644 --- a/project/src/opengl/OpenGLContext.cpp +++ b/project/src/opengl/OpenGLContext.cpp @@ -37,8 +37,6 @@ void ReloadExtentions(); // --- HardwareRenderer Interface --------------------------------------------------------- - - void ResetHardwareContext() { //__android_log_print(ANDROID_LOG_ERROR, "NME", "ResetHardwareContext"); @@ -108,8 +106,20 @@ class OGLContext : public HardwareRenderer for(int i=0;i