summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor <egor.yusov@gmail.com>2018-02-03 20:21:27 +0000
committerEgor <egor.yusov@gmail.com>2018-02-03 20:21:27 +0000
commite5d695a20e555cb50435c8c82adcb809d6a2c0cf (patch)
treefef38c349f361395edb84058bff4e52fab76992f /Graphics/GraphicsEngineOpenGL
parentFixed Linux build (diff)
downloadDiligentCore-e5d695a20e555cb50435c8c82adcb809d6a2c0cf.tar.gz
DiligentCore-e5d695a20e555cb50435c8c82adcb809d6a2c0cf.zip
Fixed Android and MacOS builds
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h14
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLContextMacOS.h14
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp17
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp18
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp12
9 files changed, 32 insertions, 53 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h b/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h
index 8e64b2cd..622b60ba 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h
@@ -28,18 +28,12 @@
namespace Diligent
{
- struct ContextInitInfo
- {
- SwapChainDesc SwapChainAttribs;
- void *pNativeWndHandle = nullptr;
- };
-
class GLContext
{
public:
typedef EGLContext NativeGLContextType;
- GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps );
+ GLContext( const struct EngineGLAttribs &InitAttribs, DeviceCaps &DeviceCaps );
~GLContext();
bool Init( ANativeWindow* window );
@@ -51,9 +45,9 @@ namespace Diligent
void Suspend();
EGLint Resume( ANativeWindow* window );
- const SwapChainDesc& GetSwapChainDesc()const{ return SwapChainAttribs_; }
-
NativeGLContextType GetCurrentNativeGLContext();
+ int32_t GetScreenWidth()const{return screen_width_;}
+ int32_t GetScreenHeight()const{return screen_height_;}
private:
//EGL configurations
@@ -68,6 +62,8 @@ namespace Diligent
int32_t depth_size_ = 0;
int32_t major_version_ = 0;
int32_t minor_version_ = 0;
+ int32_t screen_width_ = 0;
+ int32_t screen_height_ = 0;
//Flags
bool gles_initialized_ = false;
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h b/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h
index 40dcf92d..49c5d99a 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h
@@ -30,7 +30,7 @@ namespace Diligent
public:
typedef GLXContext NativeGLContextType;
- GLContext(const struct EngineGLAttribs &Attribs, struct DeviceCaps &DeviceCaps);
+ GLContext(const struct EngineGLAttribs &InitAttribs, struct DeviceCaps &DeviceCaps);
~GLContext();
void SwapBuffers();
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextMacOS.h b/Graphics/GraphicsEngineOpenGL/include/GLContextMacOS.h
index 3e5b77bb..df6d3b23 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLContextMacOS.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLContextMacOS.h
@@ -25,25 +25,13 @@
namespace Diligent
{
- struct ContextInitInfo
- {
- SwapChainDesc SwapChainAttribs;
- void *pNativeWndHandle = nullptr;
- };
-
class GLContext
{
public:
typedef void* NativeGLContextType; // NSOpenGLContext*
- GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps);
- void SwapBuffers();
-
- const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; }
+ GLContext(const struct EngineGLAttribs &InitAttribs, struct DeviceCaps &DeviceCaps);
NativeGLContextType GetCurrentNativeGLContext();
-
- private:
- SwapChainDesc m_SwapChainAttribs;
};
}
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h b/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h
index 9b128518..de0e14d6 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h
@@ -32,7 +32,7 @@ template<class CreateReleaseHelperType>
class GLObjWrapper
{
public:
- explicit GLObjWrapper(bool CreateObject, CreateReleaseHelperType CreateReleaseHelper = CreateReleaseHelperType()) :
+ GLObjWrapper(bool CreateObject, CreateReleaseHelperType CreateReleaseHelper = CreateReleaseHelperType()) :
m_uiHandle(0),
m_CreateReleaseHelper(CreateReleaseHelper)
{
diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h
index cb542177..973e31b9 100644
--- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h
@@ -31,7 +31,7 @@ namespace Diligent
class RenderDeviceGLESImpl : public RenderDeviceGLImpl
{
public:
- RenderDeviceGLESImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const ContextInitInfo &InitInfo );
+ RenderDeviceGLESImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineGLAttribs &InitAttribs );
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface );
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
index 1abda109..685e82cb 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
@@ -24,6 +24,7 @@
#include "pch.h"
#include "GLContextAndroid.h"
+#include "EngineGLAttribs.h"
#ifndef EGL_CONTEXT_MINOR_VERSION_KHR
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
@@ -114,11 +115,8 @@ namespace Diligent
LOG_ERROR_AND_THROW( "Failed to create EGLSurface" );
}
- int32_t screen_width = 0, screen_height = 0;
- eglQuerySurface( display_, surface_, EGL_WIDTH, &screen_width );
- eglQuerySurface( display_, surface_, EGL_HEIGHT, &screen_height );
- SwapChainAttribs_.Width = screen_width;
- SwapChainAttribs_.Height = screen_height;
+ eglQuerySurface( display_, surface_, EGL_WIDTH, &screen_width_ );
+ eglQuerySurface( display_, surface_, EGL_HEIGHT, &screen_height_ );
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
@@ -230,17 +228,16 @@ namespace Diligent
return true;
}
- GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) :
+ GLContext::GLContext( const EngineGLAttribs &InitAttribs, DeviceCaps &DeviceCaps ) :
display_( EGL_NO_DISPLAY ),
surface_( EGL_NO_SURFACE ),
context_( EGL_NO_CONTEXT ),
egl_context_initialized_( false ),
gles_initialized_( false ),
major_version_(0),
- minor_version_(0),
- SwapChainAttribs_(Info.SwapChainAttribs)
+ minor_version_(0)
{
- auto *NativeWindow = reinterpret_cast<ANativeWindow*>(Info.pNativeWndHandle);
+ auto *NativeWindow = reinterpret_cast<ANativeWindow*>(InitAttribs.pNativeWndHandle);
Init( NativeWindow );
FillDeviceCaps(DeviceCaps);
@@ -351,7 +348,7 @@ namespace Diligent
eglQuerySurface( display_, surface_, EGL_WIDTH, &new_screen_width );
eglQuerySurface( display_, surface_, EGL_HEIGHT, &new_screen_height );
- if( new_screen_width != SwapChainAttribs_.Width || new_screen_height != SwapChainAttribs_.Height )
+ if( new_screen_width != screen_width_ || new_screen_height != screen_height_ )
{
//Screen resized
LOG_INFO_MESSAGE( "Screen resized\n" );
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp
index 81e0efdd..65cca525 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.cpp
@@ -28,12 +28,11 @@
#include "GLContextMacOS.h"
#include "DeviceCaps.h"
#include "GLTypeConversions.h"
+#include "EngineGLAttribs.h"
namespace Diligent
{
-
- GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) :
- m_SwapChainAttribs(Info.SwapChainAttribs)
+ GLContext::GLContext( struct EngineGLAttribs &InitAttribs, DeviceCaps &DeviceCaps )
{
if (GetCurrentNativeGLContext() == nullptr)
{
@@ -46,12 +45,6 @@ namespace Diligent
if( GLEW_OK != err )
LOG_ERROR_AND_THROW( "Failed to initialize GLEW" );
- //Set dummy width and height until resize is called by the app
- if(m_SwapChainAttribs.Width == 0)
- m_SwapChainAttribs.Width = 1024;
- if(m_SwapChainAttribs.Height)
- m_SwapChainAttribs.Height = 768;
-
//Checking GL version
const GLubyte *GLVersionString = glGetString( GL_VERSION );
const GLubyte *GLRenderer = glGetString(GL_RENDERER);
@@ -60,7 +53,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
@@ -93,11 +86,6 @@ namespace Diligent
DeviceCaps.bMultithreadedResourceCreationSupported = False;
}
- void GLContext::SwapBuffers()
- {
- LOG_ERROR("Swap buffers operation must be performed by the app on MacOS");
- }
-
GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext()
{
NSOpenGLContext* CurrentCtx = [NSOpenGLContext currentContext];
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp
index 041b4fcd..0446a157 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp
@@ -27,8 +27,8 @@
namespace Diligent
{
- RenderDeviceGLESImpl::RenderDeviceGLESImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const ContextInitInfo &InitInfo ) :
- RenderDeviceGLImpl( pRefCounters, RawMemAllocator, InitInfo )
+ RenderDeviceGLESImpl::RenderDeviceGLESImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineGLAttribs &InitAttribs ) :
+ RenderDeviceGLImpl( pRefCounters, RawMemAllocator, InitAttribs )
{
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
index ed47747e..4754b93d 100644
--- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
@@ -50,6 +50,14 @@ SwapChainGLImpl::SwapChainGLImpl(IReferenceCounters *pRefCounters,
m_SwapChainDesc.Width = XWndAttribs.width;
m_SwapChainDesc.Height = XWndAttribs.height;
+#elif defined(PLATFORM_ANDROID)
+ auto &GLContext = pRenderDeviceGL->m_GLContext;
+ m_SwapChainDesc.Width = GLContext.GetScreenWidth();
+ m_SwapChainDesc.Height = GLContext.GetScreenHeight();
+#elif defined(PLATFORM_MACOS)
+ //Set dummy width and height until resize is called by the app
+ m_SwapChainAttribs.Width = 1024;
+ m_SwapChainAttribs.Height = 768;
#else
# error Unsupported platform
#endif
@@ -65,8 +73,10 @@ void SwapChainGLImpl::Present()
{
auto *pDeviceGL = ValidatedCast<RenderDeviceGLImpl>(m_pRenderDevice.RawPtr());
auto &GLContext = pDeviceGL->m_GLContext;
-#if defined(PLATFORM_WIN32) || defined(PLATFORM_LINUX)
+#if defined(PLATFORM_WIN32) || defined(PLATFORM_LINUX) ||defined(PLATFORM_ANDROID)
GLContext.SwapBuffers();
+#elif defined(PLATFORM_MACOS)
+ LOG_ERROR("Swap buffers operation must be performed by the app on MacOS");
#else
# error Unsupported platform
#endif