Cleanup.
This commit is contained in:
parent
a6e372ead9
commit
54ab573055
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#if defined(WL_EGL_PLATFORM)
|
#if defined(WL_EGL_PLATFORM)
|
||||||
# include <wayland-egl.h>
|
# include <wayland-egl.h>
|
||||||
#endif
|
#endif // defined(WL_EGL_PLATFORM)
|
||||||
|
|
||||||
namespace bgfx { namespace gl
|
namespace bgfx { namespace gl
|
||||||
{
|
{
|
||||||
@ -128,38 +128,42 @@ EGL_IMPORT
|
|||||||
}
|
}
|
||||||
#endif // BGFX_USE_GL_DYNAMIC_LIB
|
#endif // BGFX_USE_GL_DYNAMIC_LIB
|
||||||
|
|
||||||
|
|
||||||
#if defined(WL_EGL_PLATFORM)
|
#if defined(WL_EGL_PLATFORM)
|
||||||
#define WL_EGL_IMPORT \
|
# define WL_EGL_IMPORT \
|
||||||
WL_EGL_FUNC(struct wl_egl_window *, wl_egl_window_create, (struct wl_surface *, int, int)) \
|
WL_EGL_FUNC(struct wl_egl_window *, wl_egl_window_create, (struct wl_surface *, int, int) ) \
|
||||||
WL_EGL_FUNC(void, wl_egl_window_destroy, (struct wl_egl_window *)) \
|
WL_EGL_FUNC(void, wl_egl_window_destroy, (struct wl_egl_window *)) \
|
||||||
WL_EGL_FUNC(void, wl_egl_window_resize, (struct wl_egl_window *, int, int, int, int)) \
|
WL_EGL_FUNC(void, wl_egl_window_resize, (struct wl_egl_window *, int, int, int, int)) \
|
||||||
WL_EGL_FUNC(void, wl_egl_window_get_attached_size, (struct wl_egl_window *, int *, int *)) \
|
WL_EGL_FUNC(void, wl_egl_window_get_attached_size, (struct wl_egl_window *, int *, int *) ) \
|
||||||
|
|
||||||
|
# define WL_EGL_FUNC(rt, fname, params) \
|
||||||
|
typedef rt(*PFNWLEGL_##fname) params; \
|
||||||
|
PFNWLEGL_##fname BGFX_WAYLAND_##fname;
|
||||||
|
|
||||||
#define WL_EGL_FUNC(rt, fname, params) \
|
|
||||||
typedef rt(*PFNWLEGL_##fname) params; \
|
|
||||||
PFNWLEGL_##fname BGFX_WAYLAND_##fname;
|
|
||||||
WL_EGL_IMPORT
|
WL_EGL_IMPORT
|
||||||
#undef WL_EGL_FUNC
|
|
||||||
|
|
||||||
void *waylandEglOpen() {
|
# undef WL_EGL_FUNC
|
||||||
void *so = bx::dlopen("libwayland-egl.so.1");
|
|
||||||
BGFX_FATAL(so != NULL, Fatal::UnableToInitialize, "Could not dlopen() libwayland-egl.so.1");
|
|
||||||
|
|
||||||
#define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = (PFNWLEGL_##fname) bx::dlsym(so, #fname);
|
void* waylandEglOpen()
|
||||||
|
{
|
||||||
|
void* handle = bx::dlopen("libwayland-egl.so.1");
|
||||||
|
BGFX_FATAL(handle != NULL, Fatal::UnableToInitialize, "Could not dlopen() libwayland-egl.so.1");
|
||||||
|
|
||||||
|
# define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = (PFNWLEGL_##fname) bx::dlsym(handle, #fname);
|
||||||
WL_EGL_IMPORT
|
WL_EGL_IMPORT
|
||||||
#undef WL_EGL_FUNC
|
# undef WL_EGL_FUNC
|
||||||
|
|
||||||
return so;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waylandEglClose(void *so) {
|
void waylandEglClose(void* _handle)
|
||||||
bx::dlclose(so);
|
{
|
||||||
#define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = NULL;
|
bx::dlclose(_handle);
|
||||||
|
|
||||||
|
# define WL_EGL_FUNC(rt, fname, params) BGFX_WAYLAND_##fname = NULL;
|
||||||
WL_EGL_IMPORT
|
WL_EGL_IMPORT
|
||||||
#undef WL_EGL_FUNC
|
# undef WL_EGL_FUNC
|
||||||
}
|
}
|
||||||
#endif
|
#endif // defined(WL_EGL_PLATFORM)
|
||||||
|
|
||||||
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
|
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func = NULL
|
||||||
# include "glimports.h"
|
# include "glimports.h"
|
||||||
@ -238,7 +242,7 @@ WL_EGL_IMPORT
|
|||||||
bcm_host_init();
|
bcm_host_init();
|
||||||
# endif // BX_PLATFORM_RPI
|
# endif // BX_PLATFORM_RPI
|
||||||
|
|
||||||
m_eglLibrary = eglOpen();
|
m_eglDll = eglOpen();
|
||||||
|
|
||||||
if (NULL == g_platformData.context)
|
if (NULL == g_platformData.context)
|
||||||
{
|
{
|
||||||
@ -257,7 +261,7 @@ WL_EGL_IMPORT
|
|||||||
}
|
}
|
||||||
# endif // BX_PLATFORM_WINDOWS
|
# endif // BX_PLATFORM_WINDOWS
|
||||||
|
|
||||||
m_display = eglGetDisplay(NULL == ndt ? EGL_DEFAULT_DISPLAY : ndt);
|
m_display = eglGetDisplay(NULL == ndt ? EGL_DEFAULT_DISPLAY : ndt);
|
||||||
BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display %p", m_display);
|
BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display %p", m_display);
|
||||||
|
|
||||||
EGLint major = 0;
|
EGLint major = 0;
|
||||||
@ -366,16 +370,18 @@ WL_EGL_IMPORT
|
|||||||
vc_dispmanx_update_submit_sync(dispmanUpdate);
|
vc_dispmanx_update_submit_sync(dispmanUpdate);
|
||||||
# endif // BX_PLATFORM_ANDROID
|
# endif // BX_PLATFORM_ANDROID
|
||||||
|
|
||||||
# if BX_PLATFORM_LINUX && defined(WL_EGL_PLATFORM)
|
# if defined(WL_EGL_PLATFORM)
|
||||||
if (g_platformData.type == NativeWindowHandleType::Wayland) {
|
if (g_platformData.type == NativeWindowHandleType::Wayland)
|
||||||
m_waylandEglLibrary = waylandEglOpen();
|
{
|
||||||
|
m_waylandEglDll = waylandEglOpen();
|
||||||
|
|
||||||
// A wl_surface needs to be first wrapped in a wl_egl_window
|
// A wl_surface needs to be first wrapped in a wl_egl_window
|
||||||
// before it can be used to create the EGLSurface.
|
// before it can be used to create the EGLSurface.
|
||||||
m_egl_window = BGFX_WAYLAND_wl_egl_window_create((wl_surface*)nwh, _width, _height);
|
m_eglWindow = BGFX_WAYLAND_wl_egl_window_create( (wl_surface*)nwh, _width, _height);
|
||||||
nwh = m_egl_window;
|
nwh = m_eglWindow;
|
||||||
}
|
}
|
||||||
# endif
|
# endif // defined(WL_EGL_PLATFORM)
|
||||||
|
|
||||||
if (headless)
|
if (headless)
|
||||||
{
|
{
|
||||||
EGLint pbAttribs[] =
|
EGLint pbAttribs[] =
|
||||||
@ -477,20 +483,23 @@ WL_EGL_IMPORT
|
|||||||
EGL_CHECK(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) );
|
EGL_CHECK(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) );
|
||||||
EGL_CHECK(eglDestroyContext(m_display, m_context) );
|
EGL_CHECK(eglDestroyContext(m_display, m_context) );
|
||||||
EGL_CHECK(eglDestroySurface(m_display, m_surface) );
|
EGL_CHECK(eglDestroySurface(m_display, m_surface) );
|
||||||
# if BX_PLATFORM_LINUX && defined(WL_EGL_PLATFORM)
|
|
||||||
if (m_egl_window) {
|
# if defined(WL_EGL_PLATFORM)
|
||||||
BGFX_WAYLAND_wl_egl_window_destroy(m_egl_window);
|
if (m_eglWindow)
|
||||||
waylandEglClose(m_waylandEglLibrary);
|
{
|
||||||
m_waylandEglLibrary = NULL;
|
BGFX_WAYLAND_wl_egl_window_destroy(m_eglWindow);
|
||||||
|
waylandEglClose(m_waylandEglDll);
|
||||||
|
m_waylandEglDll = NULL;
|
||||||
}
|
}
|
||||||
# endif
|
# endif // defined(WL_EGL_PLATFORM)
|
||||||
|
|
||||||
EGL_CHECK(eglTerminate(m_display) );
|
EGL_CHECK(eglTerminate(m_display) );
|
||||||
m_context = NULL;
|
m_context = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGL_CHECK(eglReleaseThread() );
|
EGL_CHECK(eglReleaseThread() );
|
||||||
eglClose(m_eglLibrary);
|
eglClose(m_eglDll);
|
||||||
m_eglLibrary = NULL;
|
m_eglDll = NULL;
|
||||||
|
|
||||||
# if BX_PLATFORM_RPI
|
# if BX_PLATFORM_RPI
|
||||||
bcm_host_deinit();
|
bcm_host_deinit();
|
||||||
@ -516,9 +525,10 @@ WL_EGL_IMPORT
|
|||||||
}
|
}
|
||||||
# elif BX_PLATFORM_EMSCRIPTEN
|
# elif BX_PLATFORM_EMSCRIPTEN
|
||||||
EMSCRIPTEN_CHECK(emscripten_set_canvas_element_size(HTML5_TARGET_CANVAS_SELECTOR, _width, _height) );
|
EMSCRIPTEN_CHECK(emscripten_set_canvas_element_size(HTML5_TARGET_CANVAS_SELECTOR, _width, _height) );
|
||||||
# elif BX_PLATFORM_LINUX && defined(WL_EGL_PLATFORM)
|
# elif defined(WL_EGL_PLATFORM)
|
||||||
if (NULL != m_egl_window) {
|
if (NULL != m_eglWindow)
|
||||||
BGFX_WAYLAND_wl_egl_window_resize(m_egl_window, _width, _height, 0, 0);
|
{
|
||||||
|
BGFX_WAYLAND_wl_egl_window_resize(m_eglWindow, _width, _height, 0, 0);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
BX_UNUSED(_width, _height);
|
BX_UNUSED(_width, _height);
|
||||||
|
@ -36,10 +36,10 @@ namespace bgfx { namespace gl
|
|||||||
, m_context(NULL)
|
, m_context(NULL)
|
||||||
, m_display(NULL)
|
, m_display(NULL)
|
||||||
, m_surface(NULL)
|
, m_surface(NULL)
|
||||||
#if BX_PLATFORM_LINUX && defined(WL_EGL_PLATFORM)
|
#if defined(WL_EGL_PLATFORM)
|
||||||
, m_waylandEglLibrary(NULL)
|
, m_waylandEglDll(NULL)
|
||||||
, m_egl_window(NULL)
|
, m_eglWindow(NULL)
|
||||||
#endif
|
#endif // defined(WL_EGL_PLATFORM)
|
||||||
, m_msaaContext(false)
|
, m_msaaContext(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -61,16 +61,18 @@ namespace bgfx { namespace gl
|
|||||||
return NULL != m_context;
|
return NULL != m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* m_eglLibrary;
|
void* m_eglDll;
|
||||||
SwapChainGL* m_current;
|
SwapChainGL* m_current;
|
||||||
EGLConfig m_config;
|
EGLConfig m_config;
|
||||||
EGLContext m_context;
|
EGLContext m_context;
|
||||||
EGLDisplay m_display;
|
EGLDisplay m_display;
|
||||||
EGLSurface m_surface;
|
EGLSurface m_surface;
|
||||||
#if BX_PLATFORM_LINUX && defined(WL_EGL_PLATFORM)
|
|
||||||
void *m_waylandEglLibrary;
|
#if defined(WL_EGL_PLATFORM)
|
||||||
struct wl_egl_window *m_egl_window;
|
void* m_waylandEglDll;
|
||||||
#endif
|
struct wl_egl_window *m_eglWindow;
|
||||||
|
#endif // defined(WL_EGL_PLATFORM)
|
||||||
|
|
||||||
// true when MSAA is handled by the context instead of using MSAA FBO
|
// true when MSAA is handled by the context instead of using MSAA FBO
|
||||||
bool m_msaaContext;
|
bool m_msaaContext;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user