EGL: Initialize GLES2 when KHR_create_context is not available.

This commit is contained in:
Branimir Karadžić 2015-05-10 11:45:49 -07:00
parent 3afcd2c7c4
commit e70ee88dc7
2 changed files with 34 additions and 15 deletions

View file

@ -16,6 +16,10 @@
namespace bgfx { namespace gl
{
#ifndef EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
# define EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
#endif // EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
#if BGFX_USE_GL_DYNAMIC_LIB
typedef void (*EGLPROC)(void);
@ -245,30 +249,43 @@ EGL_IMPORT
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
const bool hasEglKhrCreateContext = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context");
const bool hasEglKhrNoError = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context_no_error");
for (uint32_t ii = 0; ii < 2; ++ii)
{
bx::StaticMemoryBlockWriter writer(s_contextAttrs, sizeof(s_contextAttrs) );
bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR) );
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES / 10) );
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR) );
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES % 10) );
EGLint flags = 0;
if (hasEglKhrCreateContext
&& 0 == ii)
if (hasEglKhrCreateContext)
{
flags = BGFX_CONFIG_DEBUG ? 0
| EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
// | EGL_OPENGL_ES3_BIT_KHR
bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR) );
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES / 10) );
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR) );
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES % 10) );
EGLint flags = 0;
flags |= BGFX_CONFIG_DEBUG && hasEglKhrNoError ? 0
| EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
: 0
;
bx::write(&writer, EGLint(EGL_CONTEXT_FLAGS_KHR) );
bx::write(&writer, flags);
if (0 == ii)
{
flags |= BGFX_CONFIG_DEBUG ? 0
| EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
// | EGL_OPENGL_ES3_BIT_KHR
: 0
;
bx::write(&writer, EGLint(EGL_CONTEXT_FLAGS_KHR) );
bx::write(&writer, flags);
}
}
else
{
bx::write(&writer, EGLint(EGL_CONTEXT_CLIENT_VERSION) );
bx::write(&writer, 2);
}
bx::write(&writer, EGLint(EGL_NONE) );

View file

@ -474,6 +474,7 @@ namespace bgfx { namespace gl
INTEL_fragment_shader_ordering,
KHR_debug,
KHR_no_error,
MOZ_WEBGL_compressed_texture_s3tc,
MOZ_WEBGL_depth_texture,
@ -667,6 +668,7 @@ namespace bgfx { namespace gl
{ "INTEL_fragment_shader_ordering", false, true },
{ "KHR_debug", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "KHR_no_error", false, true },
{ "MOZ_WEBGL_compressed_texture_s3tc", false, true },
{ "MOZ_WEBGL_depth_texture", false, true },