Browse Source

OpenGL: Attempt to enable multisampling on Android

v6.1.6
reuk 3 years ago
parent
commit
abf493122f
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 33 additions and 25 deletions
  1. +33
    -25
      modules/juce_opengl/native/juce_OpenGL_android.h

+ 33
- 25
modules/juce_opengl/native/juce_OpenGL_android.h View File

@@ -78,9 +78,9 @@ class OpenGLContext::NativeContext : private SurfaceHolderCallback
{
public:
NativeContext (Component& comp,
const OpenGLPixelFormat& /*pixelFormat*/,
const OpenGLPixelFormat& pixelFormat,
void* /*contextToShareWith*/,
bool /*useMultisampling*/,
bool useMultisamplingIn,
OpenGLVersion)
: component (comp),
surface (EGL_NO_SURFACE), context (EGL_NO_CONTEXT)
@@ -92,7 +92,7 @@ public:
return;
// Initialise the EGL display
if (! initEGLDisplay())
if (! initEGLDisplay (pixelFormat, useMultisamplingIn))
return;
// create a native surface view
@@ -288,27 +288,34 @@ private:
juceContext->triggerRepaint();
}
bool tryChooseConfig (const std::vector<EGLint>& optionalAttribs)
{
std::vector<EGLint> allAttribs
{
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 16
};
allAttribs.insert (allAttribs.end(), optionalAttribs.begin(), optionalAttribs.end());
allAttribs.push_back (EGL_NONE);
EGLint numConfigs{};
return eglChooseConfig (display, allAttribs.data(), &config, 1, &numConfigs);
}
//==============================================================================
bool initEGLDisplay()
bool initEGLDisplay (const OpenGLPixelFormat& pixelFormat, bool multisample)
{
// already initialised?
if (display != EGL_NO_DISPLAY)
return true;
const EGLint attribs[] =
{
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_NONE
};
EGLint numConfigs;
if ((display = eglGetDisplay (EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
{
jassertfalse;
@@ -321,14 +328,15 @@ private:
return false;
}
if (! eglChooseConfig (display, attribs, &config, 1, &numConfigs))
{
eglTerminate (display);
jassertfalse;
return false;
}
if (tryChooseConfig ({ EGL_SAMPLE_BUFFERS, multisample ? 1 : 0, EGL_SAMPLES, pixelFormat.multisamplingLevel }))
return true;
return true;
if (tryChooseConfig ({}))
return true;
eglTerminate (display);
jassertfalse;
return false;
}
//==============================================================================


Loading…
Cancel
Save