Browse Source

Minor android and GL clean-ups.

tags/2021-05-28
jules 13 years ago
parent
commit
ed9a2a1575
9 changed files with 39 additions and 22 deletions
  1. +5
    -1
      modules/juce_core/juce_core.h
  2. +1
    -1
      modules/juce_graphics/native/juce_android_Fonts.cpp
  3. +4
    -4
      modules/juce_opengl/juce_opengl.cpp
  4. +1
    -3
      modules/juce_opengl/native/juce_android_OpenGLComponent.cpp
  5. +19
    -4
      modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
  6. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp
  7. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp
  8. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp
  9. +4
    -4
      modules/juce_opengl/opengl/juce_OpenGLTexture.cpp

+ 5
- 1
modules/juce_core/juce_core.h View File

@@ -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
//=============================================================================


+ 1
- 1
modules/juce_graphics/native/juce_android_Fonts.cpp View File

@@ -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; }


+ 4
- 4
modules/juce_opengl/juce_opengl.cpp View File

@@ -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;


+ 1
- 3
modules/juce_opengl/native/juce_android_OpenGLComponent.cpp View File

@@ -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)


+ 19
- 4
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp View File

@@ -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);
JUCE_CHECK_OPENGL_ERROR
}
void bind() { context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, frameBufferHandle); }
void unbind() { context.extensions.glBindFramebuffer (GL_FRAMEBUFFER, 0); }
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<int>& 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<int>
glDisable (GL_DEPTH_TEST);
glDisable (GL_BLEND);
JUCE_CHECK_OPENGL_ERROR;
JUCE_CHECK_OPENGL_ERROR
OpenGLTexture tex;
tex.loadARGBFlipped (data, area.getWidth(), area.getHeight());


+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp View File

@@ -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)
{


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp View File

@@ -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() {}

+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp View File

@@ -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;
}


+ 4
- 4
modules/juce_opengl/opengl/juce_OpenGLTexture.cpp View File

@@ -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 <class PixelType>


Loading…
Cancel
Save