From b6a776c7b8fc13b38bc8972f10fa4f7a5ceff3f2 Mon Sep 17 00:00:00 2001 From: Egor Date: Sat, 3 Feb 2018 10:48:23 -0800 Subject: Fixed Linux build --- .../GraphicsEngineOpenGL/include/GLContextLinux.h | 13 +------------ .../interface/EngineGLAttribs.h | 1 + .../GraphicsEngineOpenGL/src/GLContextLinux.cpp | 21 ++++++--------------- .../GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 11 ++++++++++- 4 files changed, 18 insertions(+), 28 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h b/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h index e4530fd7..40dcf92d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h @@ -25,31 +25,20 @@ namespace Diligent { - - struct ContextInitInfo - { - SwapChainDesc SwapChainAttribs; - void *pNativeWndHandle = nullptr; - void *pDisplay = nullptr; - }; - class GLContext { public: typedef GLXContext NativeGLContextType; - GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps); + GLContext(const struct EngineGLAttribs &Attribs, struct DeviceCaps &DeviceCaps); ~GLContext(); void SwapBuffers(); - const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; } - NativeGLContextType GetCurrentNativeGLContext(); private: void *m_pNativeWindow = nullptr; void *m_pDisplay = nullptr; NativeGLContextType m_Context; - SwapChainDesc m_SwapChainAttribs; }; } diff --git a/Graphics/GraphicsEngineOpenGL/interface/EngineGLAttribs.h b/Graphics/GraphicsEngineOpenGL/interface/EngineGLAttribs.h index 59dbad3d..bbb998bd 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/EngineGLAttribs.h +++ b/Graphics/GraphicsEngineOpenGL/interface/EngineGLAttribs.h @@ -38,6 +38,7 @@ namespace Diligent /// * On Win32 platform, this is a window handle (HWND) /// * On Android platform, this is a pointer to the native window (ANativeWindow*) + /// * On Linux, this is the native window (Window) void *pNativeWndHandle = nullptr; #if PLATFORM_LINUX diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp index c20b4b9f..ffa31068 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp @@ -26,6 +26,7 @@ #include "GLContextLinux.h" #include "DeviceCaps.h" #include "GLTypeConversions.h" +#include "EngineGLAttribs.h" namespace Diligent { @@ -83,11 +84,10 @@ namespace Diligent LOG_INFO_MESSAGE_ONCE( MessageSS.str().c_str() ); } - GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) : - m_SwapChainAttribs(Info.SwapChainAttribs), + GLContext::GLContext( const EngineGLAttribs &InitAttribs, DeviceCaps &DeviceCaps ) : m_Context(0), - m_pNativeWindow(Info.pNativeWndHandle), - m_pDisplay(Info.pDisplay) + m_pNativeWindow(InitAttribs.pNativeWndHandle), + m_pDisplay(InitAttribs.pDisplay) { auto CurrentCtx = glXGetCurrentContext(); if (CurrentCtx == 0) @@ -100,17 +100,8 @@ namespace Diligent if( GLEW_OK != err ) LOG_ERROR_AND_THROW( "Failed to initialize GLEW" ); - if(Info.pNativeWndHandle != nullptr && Info.pDisplay != nullptr) + if(InitAttribs.pNativeWndHandle != nullptr && InitAttribs.pDisplay != nullptr) { - auto wnd = static_cast(reinterpret_cast(Info.pNativeWndHandle)); - auto display = reinterpret_cast(Info.pDisplay); - - XWindowAttributes XWndAttribs; - XGetWindowAttributes(display, wnd, &XWndAttribs); - - m_SwapChainAttribs.Width = XWndAttribs.width; - m_SwapChainAttribs.Height = XWndAttribs.height; - //glXSwapIntervalEXT(0); if( glDebugMessageCallback ) @@ -135,7 +126,7 @@ namespace Diligent //Or better yet, use the GL3 way to get the version number glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion ); glGetIntegerv( GL_MINOR_VERSION, &MinorVersion ); - LOG_INFO_MESSAGE(Info.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); + LOG_INFO_MESSAGE(InitAttribs.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index bedc984a..ed47747e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -41,6 +41,15 @@ SwapChainGLImpl::SwapChainGLImpl(IReferenceCounters *pRefCounters, GetClientRect(hWnd, &rc); m_SwapChainDesc.Width = rc.right - rc.left; m_SwapChainDesc.Height = rc.bottom - rc.top; +#elif defined(PLATFORM_LINUX) + auto wnd = static_cast(reinterpret_cast(InitAttribs.pNativeWndHandle)); + auto display = reinterpret_cast(InitAttribs.pDisplay); + + XWindowAttributes XWndAttribs; + XGetWindowAttributes(display, wnd, &XWndAttribs); + + m_SwapChainDesc.Width = XWndAttribs.width; + m_SwapChainDesc.Height = XWndAttribs.height; #else # error Unsupported platform #endif @@ -56,7 +65,7 @@ void SwapChainGLImpl::Present() { auto *pDeviceGL = ValidatedCast(m_pRenderDevice.RawPtr()); auto &GLContext = pDeviceGL->m_GLContext; -#if defined(PLATFORM_WIN32) +#if defined(PLATFORM_WIN32) || defined(PLATFORM_LINUX) GLContext.SwapBuffers(); #else # error Unsupported platform -- cgit v1.2.3