mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2025-04-15 16:54:24 -04:00
EGL: Fixed use extension use.
This commit is contained in:
parent
ea375d5c03
commit
4e431c99db
1 changed files with 38 additions and 8 deletions
|
@ -176,6 +176,20 @@ EGL_IMPORT
|
|||
EGLBoolean success = eglInitialize(m_display, &major, &minor);
|
||||
BGFX_FATAL(success && major >= 1 && minor >= 3, Fatal::UnableToInitialize, "Failed to initialize %d.%d", major, minor);
|
||||
|
||||
BX_TRACE("EGL info:");
|
||||
const char* clientApis = eglQueryString(m_display, EGL_CLIENT_APIS);
|
||||
BX_TRACE(" APIs: %s", clientApis);
|
||||
|
||||
const char* vendor = eglQueryString(m_display, EGL_VENDOR);
|
||||
BX_TRACE(" Vendor: %s", vendor);
|
||||
|
||||
const char* version = eglQueryString(m_display, EGL_VERSION);
|
||||
BX_TRACE("Version: %s", version);
|
||||
|
||||
const char* extensions = eglQueryString(m_display, EGL_EXTENSIONS);
|
||||
BX_TRACE("Supported EGL extensions:");
|
||||
dumpExtensions(extensions);
|
||||
|
||||
EGLint attrs[] =
|
||||
{
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
|
@ -230,6 +244,9 @@ EGL_IMPORT
|
|||
m_surface = eglCreateWindowSurface(m_display, m_config, nwh, NULL);
|
||||
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
|
||||
|
||||
const bool hasEglKhrCreateContext = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context");
|
||||
|
||||
for (uint32_t ii = 0; ii < 2; ++ii)
|
||||
{
|
||||
bx::StaticMemoryBlockWriter writer(s_contextAttrs, sizeof(s_contextAttrs) );
|
||||
|
||||
|
@ -239,19 +256,32 @@ EGL_IMPORT
|
|||
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR) );
|
||||
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES % 10) );
|
||||
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_FLAGS_KHR) );
|
||||
EGLint flags = 0;
|
||||
|
||||
EGLint flags = BGFX_CONFIG_DEBUG ? 0
|
||||
| EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
|
||||
// | EGL_OPENGL_ES3_BIT_KHR
|
||||
: 0
|
||||
;
|
||||
bx::write(&writer, flags);
|
||||
if (hasEglKhrCreateContext
|
||||
&& 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);
|
||||
}
|
||||
|
||||
bx::write(&writer, EGLint(EGL_NONE) );
|
||||
|
||||
m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, s_contextAttrs);
|
||||
if (NULL != m_context)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
BX_TRACE("Failed to create EGL context with EGL_CONTEXT_FLAGS_KHR (%08x).", flags);
|
||||
}
|
||||
|
||||
m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, s_contextAttrs);
|
||||
BGFX_FATAL(m_context != EGL_NO_CONTEXT, Fatal::UnableToInitialize, "Failed to create context.");
|
||||
|
||||
success = eglMakeCurrent(m_display, m_surface, m_surface, m_context);
|
||||
|
|
Loading…
Add table
Reference in a new issue