diff --git a/modules/juce_core/juce_core.h b/modules/juce_core/juce_core.h index 228f4dc134..7ba5db677c 100644 --- a/modules/juce_core/juce_core.h +++ b/modules/juce_core/juce_core.h @@ -51,7 +51,11 @@ @see jassert, jassertfalse, Logger */ #ifndef JUCE_LOG_ASSERTIONS - #define JUCE_LOG_ASSERTIONS 0 + #if JUCE_ANDROID + #define JUCE_LOG_ASSERTIONS 1 + #else + #define JUCE_LOG_ASSERTIONS 0 + #endif #endif //============================================================================= diff --git a/modules/juce_graphics/native/juce_android_Fonts.cpp b/modules/juce_graphics/native/juce_android_Fonts.cpp index 058a39c051..a0fb42d8eb 100644 --- a/modules/juce_graphics/native/juce_android_Fonts.cpp +++ b/modules/juce_graphics/native/juce_android_Fonts.cpp @@ -109,7 +109,7 @@ public: descent = paint.callFloatMethod (Paint.descent) / standardSize; const float height = ascent + descent; - unitsToHeightScaleFactor = 1.0f / 256.0f;//(height * standardSize); + unitsToHeightScaleFactor = 1.0f / 256.0f; } float getAscent() const { return ascent; } diff --git a/modules/juce_opengl/juce_opengl.cpp b/modules/juce_opengl/juce_opengl.cpp index fad7b4c5e7..359b2fb304 100644 --- a/modules/juce_opengl/juce_opengl.cpp +++ b/modules/juce_opengl/juce_opengl.cpp @@ -156,7 +156,8 @@ void OpenGLExtensionFunctions::initialise() #define JUCE_HIGHP #endif -static const char* getGLErrorMessage (GLenum e) +#if JUCE_DEBUG && ! defined (JUCE_CHECK_OPENGL_ERROR) +static const char* getGLErrorMessage (const GLenum e) { switch (e) { @@ -166,7 +167,7 @@ static const char* getGLErrorMessage (GLenum e) #ifdef GL_STACK_OVERFLOW case GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW"; #endif - #ifdef GL_STACK_OVERFLOW + #ifdef GL_STACK_UNDERFLOW case GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW"; #endif case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; @@ -176,12 +177,11 @@ static const char* getGLErrorMessage (GLenum e) return "Unknown error"; } -#if JUCE_DEBUG && ! defined (JUCE_CHECK_OPENGL_ERROR) static void checkGLError (const char* file, const int line) { for (;;) { - GLenum e = glGetError(); + const GLenum e = glGetError(); if (e == GL_NO_ERROR) break; diff --git a/modules/juce_opengl/native/juce_android_OpenGLComponent.cpp b/modules/juce_opengl/native/juce_android_OpenGLComponent.cpp index c0dfdd9761..d4692c9df2 100644 --- a/modules/juce_opengl/native/juce_android_OpenGLComponent.cpp +++ b/modules/juce_opengl/native/juce_android_OpenGLComponent.cpp @@ -223,20 +223,18 @@ JUCE_JNI_CALLBACK (JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024OpenG if (context != nullptr) { context->contextCreatedCallback(); + JUCE_CHECK_OPENGL_ERROR return; } Thread::sleep (20); } - DBG ("*** GL start failure!"); jassertfalse; } JUCE_JNI_CALLBACK (JUCE_JOIN_MACRO (JUCE_ANDROID_ACTIVITY_CLASSNAME, _00024OpenGLView), render, void, (JNIEnv* env, jobject view)) { - JUCE_CHECK_OPENGL_ERROR - AndroidGLContext* const context = AndroidGLContext::findContextFor (env, view); if (context != nullptr) diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 04c0d88430..91befdc97d 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -49,9 +49,11 @@ public: context.extensions.glGenFramebuffers (1, &frameBufferHandle); context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle); + JUCE_CHECK_OPENGL_ERROR glGenTextures (1, &textureID); glBindTexture (GL_TEXTURE_2D, textureID); + JUCE_CHECK_OPENGL_ERROR glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -59,6 +61,7 @@ public: glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + JUCE_CHECK_OPENGL_ERROR context.extensions.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0); @@ -101,10 +104,21 @@ public: if (frameBufferHandle != 0) context.extensions.glDeleteFramebuffers (1, &frameBufferHandle); + + JUCE_CHECK_OPENGL_ERROR } - void bind() { context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle); } - void unbind() { context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, 0); } + void bind() + { + context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle); + JUCE_CHECK_OPENGL_ERROR + } + + void unbind() + { + context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, 0); + JUCE_CHECK_OPENGL_ERROR + } OpenGLContext& context; const int width, height; @@ -202,6 +216,7 @@ bool OpenGLFrameBuffer::initialise (OpenGLFrameBuffer& other) glBindTexture (GL_TEXTURE_2D, p->textureID); pimpl->context.copyTexture (area, area); glBindTexture (GL_TEXTURE_2D, 0); + JUCE_CHECK_OPENGL_ERROR pimpl->unbind(); return true; @@ -298,7 +313,7 @@ bool OpenGLFrameBuffer::readPixels (PixelARGB* target, const Rectangle& are JUCE_RGBA_FORMAT, GL_UNSIGNED_BYTE, target); pimpl->context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, 0); glPixelStorei (GL_PACK_ALIGNMENT, 0); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR return true; } @@ -309,7 +324,7 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle glDisable (GL_DEPTH_TEST); glDisable (GL_BLEND); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR OpenGLTexture tex; tex.loadARGBFlipped (data, area.getWidth(), area.getHeight()); diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 9ee0a81b90..637b7ca3bd 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -1698,7 +1698,7 @@ public: JUCE_CHECK_OPENGL_ERROR activeTextures.disableTextures (shaderQuadQueue); blendMode.setPremultipliedBlendingMode (shaderQuadQueue); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR if (maskArea != nullptr) { diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index 0e4163318a..77e641b646 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -259,7 +259,7 @@ OpenGLTextureFromImage::OpenGLTextureFromImage (const Image& image) : imageWidth (image.getWidth()), imageHeight (image.getHeight()) { - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR OpenGLFrameBuffer* const fb = OpenGLImageType::getFrameBufferFrom (image); if (fb != nullptr) @@ -278,7 +278,7 @@ OpenGLTextureFromImage::OpenGLTextureFromImage (const Image& image) fullHeightProportion = imageHeight / (float) texture->getHeight(); } - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR } OpenGLTextureFromImage::~OpenGLTextureFromImage() {} diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp index 0811b3f2df..52ef3ccfe1 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp @@ -76,7 +76,7 @@ bool OpenGLShaderProgram::addShader (const char* const code, GLenum type) context.extensions.glAttachShader (programID, shaderID); context.extensions.glDeleteShader (shaderID); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR return true; } @@ -100,7 +100,7 @@ bool OpenGLShaderProgram::link() noexcept #endif } - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR return status != GL_FALSE; } diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp index ad8f6ad139..8d638998b6 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp @@ -51,14 +51,14 @@ void OpenGLTexture::create (const int w, const int h, const void* pixels, GLenum if (textureID == 0) { - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR glGenTextures (1, &textureID); glBindTexture (GL_TEXTURE_2D, textureID); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR } else { @@ -67,10 +67,10 @@ void OpenGLTexture::create (const int w, const int h, const void* pixels, GLenum } glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR glTexImage2D (GL_TEXTURE_2D, 0, type == GL_ALPHA ? GL_ALPHA : GL_RGBA, w, h, 0, type, GL_UNSIGNED_BYTE, pixels); - JUCE_CHECK_OPENGL_ERROR; + JUCE_CHECK_OPENGL_ERROR } template