Fix building WITH_GHOST_WAYLAND, WITH_OPENXR (without X11)
The pre-processor blocks contained un-balanced braces, causing a syntax error when building with WAYLAND but not X11. Use the same number of opening & closing braces in each pre-processor block so changes aren't as likely to break other platforms. Also assert when unexpected states are reached.
This commit is contained in:
parent
ebcf004ecf
commit
b3e9ef1924
@ -123,27 +123,44 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
|
||||
void initFromGhostContext(GHOST_Context &ghost_ctx) override
|
||||
{
|
||||
#if defined(WITH_GHOST_X11) || defined(WITH_GHOST_WAYLAND)
|
||||
if (dynamic_cast<GHOST_ContextEGL *>(&ghost_ctx)) {
|
||||
/* WAYLAND/X11 may be dynamically selected at load time but both may also be
|
||||
* supported at compile time individually.
|
||||
* Without `is_ctx_egl` & `is_wayland` preprocessor checks become an unmanageable soup. */
|
||||
const bool is_ctx_egl = dynamic_cast<GHOST_ContextEGL *>(&ghost_ctx) != nullptr;
|
||||
if (is_ctx_egl) {
|
||||
GHOST_ContextEGL &ctx_egl = static_cast<GHOST_ContextEGL &>(ghost_ctx);
|
||||
|
||||
const bool is_wayland = (
|
||||
# if defined(WITH_GHOST_WAYLAND)
|
||||
if (dynamic_cast<const GHOST_SystemWayland *const>(ctx_egl.m_system)) {
|
||||
dynamic_cast<const GHOST_SystemWayland *const>(ctx_egl.m_system) != nullptr
|
||||
# else
|
||||
false
|
||||
# endif
|
||||
);
|
||||
|
||||
if (is_wayland) {
|
||||
# if defined(WITH_GHOST_WAYLAND)
|
||||
/* #GHOST_SystemWayland */
|
||||
oxr_binding.wl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR;
|
||||
oxr_binding.wl.display = (struct wl_display *)ctx_egl.m_nativeDisplay;
|
||||
# else
|
||||
GHOST_ASSERT(false, "Unexpected State: logical error, unreachable!");
|
||||
# endif /* !WITH_GHOST_WAYLAND */
|
||||
}
|
||||
else
|
||||
# endif
|
||||
else { /* `!is_wayland` */
|
||||
# if defined(WITH_GHOST_X11)
|
||||
{
|
||||
/* SystemX11. */
|
||||
/* #GHOST_SystemX11. */
|
||||
oxr_binding.egl.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX;
|
||||
oxr_binding.egl.getProcAddress = eglGetProcAddress;
|
||||
oxr_binding.egl.display = ctx_egl.getDisplay();
|
||||
oxr_binding.egl.config = ctx_egl.getConfig();
|
||||
oxr_binding.egl.context = ctx_egl.getContext();
|
||||
# else
|
||||
GHOST_ASSERT(false, "Unexpected State: built with only WAYLAND and no System found!");
|
||||
# endif /* !WITH_GHOST_X11 */
|
||||
}
|
||||
}
|
||||
else {
|
||||
else { /* `!is_ctx_egl` */
|
||||
# if defined(WITH_GHOST_X11)
|
||||
GHOST_ContextGLX &ctx_glx = static_cast<GHOST_ContextGLX &>(ghost_ctx);
|
||||
XVisualInfo *visual_info = glXGetVisualFromFBConfig(ctx_glx.m_display, ctx_glx.m_fbconfig);
|
||||
|
||||
@ -155,7 +172,9 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
|
||||
oxr_binding.glx.visualid = visual_info->visualid;
|
||||
|
||||
XFree(visual_info);
|
||||
# endif
|
||||
# else
|
||||
GHOST_ASSERT(false, "Unexpected State: built without X11 and no EGL context is available!");
|
||||
# endif /* !WITH_GHOST_X11 */
|
||||
}
|
||||
#elif defined(WIN32)
|
||||
GHOST_ContextWGL &ctx_wgl = static_cast<GHOST_ContextWGL &>(ghost_ctx);
|
||||
@ -163,7 +182,7 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding {
|
||||
oxr_binding.wgl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR;
|
||||
oxr_binding.wgl.hDC = ctx_wgl.m_hDC;
|
||||
oxr_binding.wgl.hGLRC = ctx_wgl.m_hGLRC;
|
||||
#endif
|
||||
#endif /* WIN32 */
|
||||
|
||||
/* Generate a frame-buffer to use for blitting into the texture. */
|
||||
glGenFramebuffers(1, &m_fbo);
|
||||
|
Loading…
x
Reference in New Issue
Block a user