mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-20 22:03:12 +01:00
GL: Removed GLX context code.
This commit is contained in:
@@ -25,6 +25,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
typedef void (*EGLPROC)(void);
|
||||
|
||||
typedef EGLBoolean (EGLAPIENTRY* PGNEGLBINDAPIPROC)(EGLenum api);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config);
|
||||
typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list);
|
||||
typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEPBUFFERSURFACEPROC)(EGLDisplay display, EGLConfig config, EGLint const* attrib_list);
|
||||
@@ -42,9 +43,9 @@ namespace bgfx { namespace gl
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLTERMINATEPROC)(EGLDisplay dpy);
|
||||
typedef const char* (EGLAPIENTRY* PGNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PGNEGLBINDAPIPROC)(EGLenum api);
|
||||
|
||||
#define EGL_IMPORT \
|
||||
EGL_IMPORT_FUNC(PGNEGLBINDAPIPROC, eglBindAPI); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCREATEPBUFFERSURFACEPROC, eglCreatePbufferSurface); \
|
||||
@@ -62,7 +63,6 @@ namespace bgfx { namespace gl
|
||||
EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \
|
||||
EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate); \
|
||||
EGL_IMPORT_FUNC(PGNEGLQUERYSTRINGPROC, eglQueryString); \
|
||||
EGL_IMPORT_FUNC(PGNEGLBINDAPIPROC, eglBindAPI); \
|
||||
|
||||
#define EGL_IMPORT_FUNC(_proto, _func) _proto _func
|
||||
EGL_IMPORT
|
||||
@@ -73,9 +73,9 @@ EGL_IMPORT
|
||||
void* handle = bx::dlopen("libEGL." BX_DL_EXT);
|
||||
BGFX_FATAL(NULL != handle, Fatal::UnableToInitialize, "Failed to load libEGL dynamic library.");
|
||||
|
||||
#define EGL_IMPORT_FUNC(_proto, _func) \
|
||||
_func = (_proto)bx::dlsym(handle, #_func); \
|
||||
BX_TRACE("%p " #_func, _func); \
|
||||
#define EGL_IMPORT_FUNC(_proto, _func) \
|
||||
_func = (_proto)bx::dlsym(handle, #_func); \
|
||||
BX_TRACE("%p " #_func, _func); \
|
||||
BGFX_FATAL(NULL != _func, Fatal::UnableToInitialize, "Failed get " #_func ".")
|
||||
EGL_IMPORT
|
||||
#undef EGL_IMPORT_FUNC
|
||||
@@ -222,20 +222,22 @@ EGL_IMPORT
|
||||
BX_TRACE("Supported EGL extensions:");
|
||||
dumpExtensions(extensions);
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
// choose OpenGL API for EGL, by default it uses OpenGL ES
|
||||
EGLBoolean ok = eglBindAPI(EGL_OPENGL_API);
|
||||
BGFX_FATAL(ok, Fatal::UnableToInitialize, "Could not set API! error: %d", eglGetError());
|
||||
#endif //BGFX_CONFIG_RENDERER_OPENG
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
EGLBoolean ok = eglBindAPI(EGL_OPENGL_API);
|
||||
BGFX_FATAL(ok, Fatal::UnableToInitialize, "Could not set API! error: %d", eglGetError());
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_recordable.txt
|
||||
const bool hasEglAndroidRecordable = !bx::findIdentifierMatch(extensions, "EGL_ANDROID_recordable").isEmpty();
|
||||
|
||||
const uint32_t glVersion = BGFX_CONFIG_RENDERER_OPENGL ? BGFX_CONFIG_RENDERER_OPENGL : BGFX_CONFIG_RENDERER_OPENGLES;
|
||||
const uint32_t glVersion = !!BGFX_CONFIG_RENDERER_OPENGL
|
||||
? BGFX_CONFIG_RENDERER_OPENGL
|
||||
: BGFX_CONFIG_RENDERER_OPENGLES
|
||||
;
|
||||
|
||||
#if BX_PLATFORM_ANDROID
|
||||
uint32_t msaa = (_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
|
||||
uint32_t msaaSamples = msaa == 0 ? 0 : 1<<msaa;
|
||||
const uint32_t msaa = (_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
|
||||
const uint32_t msaaSamples = msaa == 0 ? 0 : 1<<msaa;
|
||||
m_msaaContext = true;
|
||||
#endif // BX_PLATFORM_ANDROID
|
||||
|
||||
@@ -243,17 +245,16 @@ EGL_IMPORT
|
||||
|
||||
EGLint attrs[] =
|
||||
{
|
||||
# if BGFX_CONFIG_RENDERER_OPENGL
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
# else
|
||||
EGL_RENDERABLE_TYPE, (glVersion >= 30) ? EGL_OPENGL_ES3_BIT_KHR : EGL_OPENGL_ES2_BIT,
|
||||
# endif
|
||||
EGL_RENDERABLE_TYPE, !!BGFX_CONFIG_RENDERER_OPENGL
|
||||
? EGL_OPENGL_BIT
|
||||
: (glVersion >= 30) ? EGL_OPENGL_ES3_BIT_KHR : EGL_OPENGL_ES2_BIT
|
||||
,
|
||||
|
||||
EGL_SURFACE_TYPE, headless ? EGL_PBUFFER_BIT : EGL_WINDOW_BIT,
|
||||
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
|
||||
# if BX_PLATFORM_ANDROID
|
||||
@@ -265,8 +266,8 @@ EGL_IMPORT
|
||||
EGL_STENCIL_SIZE, 8,
|
||||
|
||||
// Android Recordable surface
|
||||
hasEglAndroidRecordable ? 0x3142 : EGL_NONE,
|
||||
hasEglAndroidRecordable ? 1 : EGL_NONE,
|
||||
hasEglAndroidRecordable ? EGL_RECORDABLE_ANDROID : EGL_NONE,
|
||||
hasEglAndroidRecordable ? 1 : EGL_NONE,
|
||||
|
||||
EGL_NONE
|
||||
};
|
||||
@@ -341,15 +342,17 @@ EGL_IMPORT
|
||||
# else
|
||||
if (hasEglKhrCreateContext)
|
||||
{
|
||||
# if BGFX_CONFIG_RENDERER_OPENGL
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR), bx::ErrorAssert{} );
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR), bx::ErrorAssert{} );
|
||||
# endif
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR), bx::ErrorAssert{} );
|
||||
bx::write(&writer, EGLint(glVersion / 10), bx::ErrorAssert{} );
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR), bx::ErrorAssert{});
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR), bx::ErrorAssert{});
|
||||
}
|
||||
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR), bx::ErrorAssert{} );
|
||||
bx::write(&writer, EGLint(glVersion % 10), bx::ErrorAssert{} );
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR), bx::ErrorAssert{});
|
||||
bx::write(&writer, EGLint(glVersion / 10), bx::ErrorAssert{});
|
||||
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR), bx::ErrorAssert{});
|
||||
bx::write(&writer, EGLint(glVersion % 10), bx::ErrorAssert{});
|
||||
|
||||
flags |= BGFX_CONFIG_DEBUG && hasEglKhrNoError ? 0
|
||||
| EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
|
||||
@@ -451,10 +454,10 @@ EGL_IMPORT
|
||||
uint64_t GlContext::getCaps() const
|
||||
{
|
||||
return BX_ENABLED(0
|
||||
| BX_PLATFORM_LINUX
|
||||
| BX_PLATFORM_WINDOWS
|
||||
| BX_PLATFORM_ANDROID
|
||||
)
|
||||
| BX_PLATFORM_LINUX
|
||||
| BX_PLATFORM_WINDOWS
|
||||
| BX_PLATFORM_ANDROID
|
||||
)
|
||||
? BGFX_CAPS_SWAP_CHAIN
|
||||
: 0
|
||||
;
|
||||
@@ -521,13 +524,14 @@ EGL_IMPORT
|
||||
# define LIBRARY_NAME "libGLESv2.so.2"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
void* lib = bx::dlopen(LIBRARY_NAME);
|
||||
|
||||
# define GL_EXTENSION(_optional, _proto, _func, _import) \
|
||||
{ \
|
||||
if (NULL == _func) \
|
||||
{ \
|
||||
_func = bx::dlsym<_proto>(lib, #_import); \
|
||||
_func = bx::dlsym<_proto>(lib, #_import); \
|
||||
BX_TRACE("\t%p " #_func " (" #_import ")", _func); \
|
||||
BGFX_FATAL(_optional || NULL != _func \
|
||||
, Fatal::UnableToInitialize \
|
||||
|
||||
Reference in New Issue
Block a user