mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
OpenGL: Attempt to enable multisampling on Android
This commit is contained in:
parent
75258a4ba6
commit
abf493122f
1 changed files with 33 additions and 25 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue