diff --git a/examples/common/entry/entry_x11.cpp b/examples/common/entry/entry_x11.cpp index 434e7c79..05080671 100644 --- a/examples/common/entry/entry_x11.cpp +++ b/examples/common/entry/entry_x11.cpp @@ -10,7 +10,8 @@ #define XK_MISCELLANY #define XK_LATIN1 #include -#include // will include X11 which #defines None... Don't mess with order of includes. +#include // will include X11 which #defines None... Don't mess with order of includes. +#include #undef None #include diff --git a/include/bgfxplatform.h b/include/bgfxplatform.h index 08b93844..1e073de8 100755 --- a/include/bgfxplatform.h +++ b/include/bgfxplatform.h @@ -51,12 +51,11 @@ namespace bgfx } // namespace bgfx #elif BX_PLATFORM_FREEBSD || BX_PLATFORM_LINUX || BX_PLATFORM_RPI -# include namespace bgfx { /// - void x11SetDisplayWindow(::Display* _display, ::Window _window); + void x11SetDisplayWindow(void* _display, uint32_t _window); } // namespace bgfx diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 21a98eab..d068b5aa 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -34,10 +34,10 @@ namespace bgfx g_bgfxEaglLayer = _layer; } #elif BX_PLATFORM_LINUX - ::Display* g_bgfxX11Display; - ::Window g_bgfxX11Window; + void* g_bgfxX11Display; + uint32_t g_bgfxX11Window; - void x11SetDisplayWindow(::Display* _display, ::Window _window) + void x11SetDisplayWindow(void* _display, uint32_t _window) { g_bgfxX11Display = _display; g_bgfxX11Window = _window; diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 4562aaaf..8589acb3 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -201,8 +201,8 @@ namespace bgfx #elif BX_PLATFORM_IOS extern void* g_bgfxEaglLayer; #elif BX_PLATFORM_LINUX - extern ::Display* g_bgfxX11Display; - extern ::Window g_bgfxX11Window; + extern void* g_bgfxX11Display; + extern uint32_t g_bgfxX11Window; #elif BX_PLATFORM_OSX extern void* g_bgfxNSWindow; #elif BX_PLATFORM_WINDOWS diff --git a/src/glcontext_egl.cpp b/src/glcontext_egl.cpp index 77abfa96..9ef95846 100644 --- a/src/glcontext_egl.cpp +++ b/src/glcontext_egl.cpp @@ -185,8 +185,8 @@ EGL_IMPORT ndt = GetDC(g_bgfxHwnd); nwh = g_bgfxHwnd; # elif BX_PLATFORM_LINUX - ndt = g_bgfxX11Display; - nwh = g_bgfxX11Window; + ndt = (EGLNativeDisplayType)g_bgfxX11Display; + nwh = (EGLNativeWindowType)g_bgfxX11Window; # endif // BX_PLATFORM_ m_display = eglGetDisplay(ndt); BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display %p", m_display); diff --git a/src/glcontext_glx.cpp b/src/glcontext_glx.cpp index fa738c25..1168672c 100644 --- a/src/glcontext_glx.cpp +++ b/src/glcontext_glx.cpp @@ -29,23 +29,23 @@ namespace bgfx SwapChainGL(::Window _window, XVisualInfo* _visualInfo, GLXContext _context) : m_window(_window) { - m_context = glXCreateContext(g_bgfxX11Display, _visualInfo, _context, GL_TRUE); + m_context = glXCreateContext( (::Display*)g_bgfxX11Display, _visualInfo, _context, GL_TRUE); } ~SwapChainGL() { - glXMakeCurrent(g_bgfxX11Display, 0, 0); - glXDestroyContext(g_bgfxX11Display, m_context); + glXMakeCurrent( (::Display*)g_bgfxX11Display, 0, 0); + glXDestroyContext( (::Display*)g_bgfxX11Display, m_context); } void makeCurrent() { - glXMakeCurrent(g_bgfxX11Display, m_window, m_context); + glXMakeCurrent( (::Display*)g_bgfxX11Display, m_window, m_context); } void swapBuffers() { - glXSwapBuffers(g_bgfxX11Display, m_window); + glXSwapBuffers( (::Display*)g_bgfxX11Display, m_window); } Window m_window; @@ -55,10 +55,10 @@ namespace bgfx void GlContext::create(uint32_t _width, uint32_t _height) { BX_UNUSED(_width, _height); - XLockDisplay(g_bgfxX11Display); + XLockDisplay( (::Display*)g_bgfxX11Display); int major, minor; - bool version = glXQueryVersion(g_bgfxX11Display, &major, &minor); + bool version = glXQueryVersion( (::Display*)g_bgfxX11Display, &major, &minor); BGFX_FATAL(version, Fatal::UnableToInitialize, "Failed to query GLX version"); BGFX_FATAL( (major == 1 && minor >= 2) || major > 1 , Fatal::UnableToInitialize @@ -67,9 +67,9 @@ namespace bgfx , minor ); - int32_t screen = DefaultScreen(g_bgfxX11Display); + int32_t screen = DefaultScreen( (::Display*)g_bgfxX11Display); - const char* extensions = glXQueryExtensionsString(g_bgfxX11Display, screen); + const char* extensions = glXQueryExtensionsString( (::Display*)g_bgfxX11Display, screen); BX_TRACE("GLX extensions:"); dumpExtensions(extensions); @@ -91,13 +91,13 @@ namespace bgfx GLXFBConfig bestConfig = NULL; int numConfigs; - GLXFBConfig* configs = glXChooseFBConfig(g_bgfxX11Display, screen, attrsGlx, &numConfigs); + GLXFBConfig* configs = glXChooseFBConfig( (::Display*)g_bgfxX11Display, screen, attrsGlx, &numConfigs); BX_TRACE("glX num configs %d", numConfigs); for (int ii = 0; ii < numConfigs; ++ii) { - m_visualInfo = glXGetVisualFromFBConfig(g_bgfxX11Display, configs[ii]); + m_visualInfo = glXGetVisualFromFBConfig( (::Display*)g_bgfxX11Display, configs[ii]); if (NULL != m_visualInfo) { BX_TRACE("---"); @@ -105,7 +105,7 @@ namespace bgfx for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2) { int value; - glXGetFBConfigAttrib(g_bgfxX11Display, configs[ii], attrsGlx[attr], &value); + glXGetFBConfigAttrib( (::Display*)g_bgfxX11Display, configs[ii], attrsGlx[attr], &value); BX_TRACE("glX %d/%d %2d: %4x, %8x (%8x%s)" , ii , numConfigs @@ -141,7 +141,7 @@ namespace bgfx BGFX_FATAL(m_visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration."); BX_TRACE("Create GL 2.1 context."); - m_context = glXCreateContext(g_bgfxX11Display, m_visualInfo, 0, GL_TRUE); + m_context = glXCreateContext( (::Display*)g_bgfxX11Display, m_visualInfo, 0, GL_TRUE); BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context."); #if BGFX_CONFIG_RENDERER_OPENGL >= 31 @@ -158,11 +158,11 @@ namespace bgfx 0, }; - GLXContext context = glXCreateContextAttribsARB(g_bgfxX11Display, bestConfig, 0, true, contextAttrs); + GLXContext context = glXCreateContextAttribsARB( (::Display*)g_bgfxX11Display, bestConfig, 0, true, contextAttrs); if (NULL != context) { - glXDestroyContext(g_bgfxX11Display, m_context); + glXDestroyContext( (::Display*)g_bgfxX11Display, m_context); m_context = context; } } @@ -170,17 +170,17 @@ namespace bgfx BX_UNUSED(bestConfig); #endif // BGFX_CONFIG_RENDERER_OPENGL >= 31 - XUnlockDisplay(g_bgfxX11Display); + XUnlockDisplay( (::Display*)g_bgfxX11Display); import(); - glXMakeCurrent(g_bgfxX11Display, g_bgfxX11Window, m_context); + glXMakeCurrent( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window, m_context); glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress( (const GLubyte*)"glXSwapIntervalEXT"); if (NULL != glXSwapIntervalEXT) { BX_TRACE("Using glXSwapIntervalEXT."); - glXSwapIntervalEXT(g_bgfxX11Display, g_bgfxX11Window, 0); + glXSwapIntervalEXT( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window, 0); } else { @@ -203,13 +203,13 @@ namespace bgfx glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); - glXSwapBuffers(g_bgfxX11Display, g_bgfxX11Window); + glXSwapBuffers( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window); } void GlContext::destroy() { - glXMakeCurrent(g_bgfxX11Display, 0, 0); - glXDestroyContext(g_bgfxX11Display, m_context); + glXMakeCurrent( (::Display*)g_bgfxX11Display, 0, 0); + glXDestroyContext( (::Display*)g_bgfxX11Display, m_context); XFree(m_visualInfo); } @@ -219,7 +219,7 @@ namespace bgfx if (NULL != glXSwapIntervalEXT) { - glXSwapIntervalEXT(g_bgfxX11Display, g_bgfxX11Window, interval); + glXSwapIntervalEXT( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window, interval); } else if (NULL != glXSwapIntervalMESA) { @@ -250,8 +250,8 @@ namespace bgfx { if (NULL == _swapChain) { - glXMakeCurrent(g_bgfxX11Display, g_bgfxX11Window, m_context); - glXSwapBuffers(g_bgfxX11Display, g_bgfxX11Window); + glXMakeCurrent( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window, m_context); + glXSwapBuffers( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window); } else { @@ -264,7 +264,7 @@ namespace bgfx { if (NULL == _swapChain) { - glXMakeCurrent(g_bgfxX11Display, g_bgfxX11Window, m_context); + glXMakeCurrent( (::Display*)g_bgfxX11Display, (::Window)g_bgfxX11Window, m_context); } else {