From 45ca3b1c4cfcf791c5884697f18ff96da77a2cdc Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 19 Dec 2017 21:41:39 -0800 Subject: Enabling linux build (in progress) --- Graphics/GraphicsEngineOpenGL/CMakeLists.txt | 4 ++ Graphics/GraphicsEngineOpenGL/include/GLContext.h | 14 +++--- .../include/GLContextAndroid.h | 2 +- .../GraphicsEngineOpenGL/include/GLContextLinux.h | 52 +++++++++++++++++++++ .../include/GLContextWindows.h | 2 +- Graphics/GraphicsEngineOpenGL/include/pch.h | 53 ++++++++++++++-------- .../interface/BaseInterfacesGL.h | 8 ++-- .../interface/RenderDeviceFactoryOpenGL.h | 2 +- .../src/RenderDeviceFactoryOpenGL.cpp | 4 +- .../src/Texture2DArray_OGL.cpp | 2 +- 10 files changed, 108 insertions(+), 35 deletions(-) create mode 100644 Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index 4ce567d0..bc4b423a 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -94,6 +94,8 @@ elseif(PLATFORM_ANDROID) set(APPEND INCLUDE include/RenderDeviceGLESImpl.h) set(APPEND INTERFACE interface/RenderDeviceGLES.h) +elseif(PLATFORM_LINUX) + set(APPEND INCLUDE include/GLContextLinux.h) else() message(FATAL_ERROR "Unknown platform") endif() @@ -151,6 +153,8 @@ elseif(PLATFORM_ANDROID) target_compile_definitions(GraphicsEngineOpenGL-static PRIVATE BUILDING_DLL USE_GL3_STUB=0) target_compile_definitions(GraphicsEngineOpenGL-shared PRIVATE BUILDING_DLL USE_GL3_STUB=0) set_target_properties(GraphicsEngineOpenGL-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) # -fvisibility=hidden +elseif(PLATFORM_LINUX) + set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} glew-static) else() message(FATAL_ERROR "Unknown platform") endif() diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContext.h b/Graphics/GraphicsEngineOpenGL/include/GLContext.h index 2db25f4c..d5ca746e 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContext.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLContext.h @@ -23,10 +23,12 @@ #pragma once -#ifdef PLATFORM_WIN32 -#include "GLContextWindows.h" -#endif - -#ifdef ANDROID -#include "GLContextAndroid.h" +#if defined(PLATFORM_WIN32) +# include "GLContextWindows.h" +#elif defined(PLATFORM_ANDROID) +# include "GLContextAndroid.h" +#elif defined(PLATFORM_LINUX) +# include "GLContextLinux.h" +#else +# error Unsupported platform #endif diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h b/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h index d2892c1e..68270a8f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h @@ -51,7 +51,7 @@ namespace Diligent void Suspend(); EGLint Resume( ANativeWindow* window ); - const SwapChainDesc& GetSwapChainDesc(){ return SwapChainAttribs_; } + const SwapChainDesc& GetSwapChainDesc()const{ return SwapChainAttribs_; } NativeGLContextType GetCurrentNativeGLContext(); diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h b/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h new file mode 100644 index 00000000..ff6796cb --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h @@ -0,0 +1,52 @@ +/* Copyright 2015-2017 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +namespace Diligent +{ + + struct ContextInitInfo + { + SwapChainDesc SwapChainAttribs; + void *pNativeWndHandle = nullptr; + }; + + class GLContext + { + public: + typedef void* NativeGLContextType; + + GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps) {} + ~GLContext() {} + void SwapBuffers() {} + + const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; } + + NativeGLContextType GetCurrentNativeGLContext() { return nullptr; } + + private: + void* m_Context; + SwapChainDesc m_SwapChainAttribs; + }; +} diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextWindows.h b/Graphics/GraphicsEngineOpenGL/include/GLContextWindows.h index adc2984a..38895afa 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContextWindows.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextWindows.h @@ -41,7 +41,7 @@ namespace Diligent ~GLContext(); void SwapBuffers(); - const SwapChainDesc& GetSwapChainDesc(){ return m_SwapChainAttribs; } + const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; } NativeGLContextType GetCurrentNativeGLContext(); diff --git a/Graphics/GraphicsEngineOpenGL/include/pch.h b/Graphics/GraphicsEngineOpenGL/include/pch.h index 9e6faac7..dd037ed6 100644 --- a/Graphics/GraphicsEngineOpenGL/include/pch.h +++ b/Graphics/GraphicsEngineOpenGL/include/pch.h @@ -35,35 +35,48 @@ #include #include -// Must be defined to use static version of glew -#ifdef PLATFORM_WIN32 +#if defined(PLATFORM_WIN32) + # ifndef GLEW_STATIC -# define GLEW_STATIC +# define GLEW_STATIC // Must be defined to use static version of glew # endif - #include "glew.h" +# include "glew.h" // Glew includes - #define NOMINMAX - #include "wglew.h" - #include -#endif +# define NOMINMAX +# include "wglew.h" +# include +#elif defined(PLATFORM_LINUX) -#ifdef ANDROID -#ifndef USE_GL3_STUB - #define USE_GL3_STUB 0 -#endif - #if USE_GL3_STUB - #include "gl3stub.h" - #include - #else - #include - #include - #endif +# ifndef GLEW_STATIC +# define GLEW_STATIC // Must be defined to use static version of glew +# endif +# ifndef GLEW_NO_GLU +# define GLEW_NO_GLU +# endif + +# include "glew.h" + +# elif defined(PLATFORM_ANDROID) + +# ifndef USE_GL3_STUB +# define USE_GL3_STUB 0 +# endif +# if USE_GL3_STUB +# include "gl3stub.h" +# include +# else +# include +# include +# endif + +#else +# error Unsupported platform #endif #include "Errors.h" -#ifdef ANDROID +#ifdef PLATFORM_ANDROID // GLStubs must be included after GLFeatures! #include "GLStubs.h" #endif diff --git a/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h b/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h index cad22936..45a281d7 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h +++ b/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h @@ -23,20 +23,20 @@ #pragma once -#ifdef ANDROID +#if defined(PLATFORM_ANDROID) #include "RenderDeviceGLES.h" namespace Diligent { using IGLDeviceBaseInterface = IRenderDeviceGLES; } -#endif - -#ifdef PLATFORM_WIN32 +#elif defined(PLATFORM_WIN32) || defined(PLATFORM_LINUX) #include "RenderDeviceGL.h" namespace Diligent { using IGLDeviceBaseInterface = IRenderDeviceGL; } +#else +# error Unsupported platform #endif #include "DeviceContextGL.h" diff --git a/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h b/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h index 8876b9ae..cbf67c8a 100644 --- a/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h +++ b/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h @@ -35,7 +35,7 @@ # define API_QUALIFIER -#elif defined(PLATFORM_ANDROID) +#elif defined(PLATFORM_ANDROID) || defined(PLATFORM_LINUX) # ifdef ENGINE_DLL # ifdef BUILDING_DLL diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp index a18ca767..aa19f8ee 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp @@ -39,10 +39,12 @@ namespace Diligent { -#if defined(PLATFORM_WIN32) || defined(PLATFORM_UNIVERSAL_WINDOWS) +#if defined(PLATFORM_WIN32) || defined(PLATFORM_UNIVERSAL_WINDOWS) || defined(PLATFORM_LINUX) typedef RenderDeviceGLImpl TRenderDeviceGLImpl; #elif defined(PLATFORM_ANDROID) typedef RenderDeviceGLESImpl TRenderDeviceGLImpl; +#else +# error Unsupported platform #endif /// Engine factory for OpenGL implementation diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp index b199439d..44507f58 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp @@ -48,7 +48,7 @@ Texture2DArray_OGL::Texture2DArray_OGL( IReferenceCounters *pRefCounters, if( m_Desc.SampleCount > 1 ) { // format width height depth - glTexStorage3DMultisample(m_BindTarget, m_Desc.SampleCount, m_GLTexFormat, m_Desc.Width, m_Desc.Height, m_Desc.ArraySize, TRUE); + glTexStorage3DMultisample(m_BindTarget, m_Desc.SampleCount, m_GLTexFormat, m_Desc.Width, m_Desc.Height, m_Desc.ArraySize, GL_TRUE); // The last parameter specifies whether the image will use identical sample locations and the same number of // samples for all texels in the image, and the sample locations will not depend on the internal format or size // of the image. -- cgit v1.2.3