diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-02-03 20:50:41 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-02-03 20:50:41 +0000 |
| commit | 4214a267b8ce50d8edf5895165770cfb31123938 (patch) | |
| tree | 91df1615db6dbd7c4c7fcd819829e4eb996a71d3 /Graphics/GraphicsEngineOpenGL | |
| parent | Fixed c++/c flags on iOS (diff) | |
| download | DiligentCore-4214a267b8ce50d8edf5895165770cfb31123938.tar.gz DiligentCore-4214a267b8ce50d8edf5895165770cfb31123938.zip | |
Updated IOS implementation
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
7 files changed, 54 insertions, 31 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index fbd1b404..71d822d1 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -103,6 +103,8 @@ elseif(PLATFORM_IOS) list(APPEND SOURCE src/GLContextIOS.mm) list(APPEND INCLUDE include/GLContextIOS.h) list(APPEND INCLUDE include/GLStubsIOS.h) + list(APPEND SOURCE src/SwapChainGLIOS.mm) + list(APPEND INCLUDE include/SwapChainGLIOS.h) else() message(FATAL_ERROR "Unknown platform") endif() diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h b/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h index 3e5b77bb..5ff74d56 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLContextIOS.h @@ -23,6 +23,8 @@ #pragma once +#include "GLObjectWrapper.h" + namespace Diligent { struct ContextInitInfo @@ -34,7 +36,7 @@ namespace Diligent class GLContext { public: - typedef void* NativeGLContextType; // NSOpenGLContext* + typedef void* NativeGLContextType; // EAGLContext* GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps); void SwapBuffers(); @@ -45,5 +47,8 @@ namespace Diligent private: SwapChainDesc m_SwapChainAttribs; + GLObjectWrappers::GLRenderBufferObj m_ColorRenderBuffer; + GLObjectWrappers::GLRenderBufferObj m_DepthRenderBuffer; + GLObjectWrappers::GLFrameBufferObj m_FBO; }; } diff --git a/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h b/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h index 520e9965..43f77193 100644 --- a/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h +++ b/Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h @@ -230,4 +230,14 @@ public: }; typedef GLObjWrapper<GLFBOCreateReleaseHelper> GLFrameBufferObj; + +class GLRBOCreateReleaseHelper +{ +public: + void Create(GLuint &RBO) { glGenRenderbuffers(1, &RBO); } + void Release(GLuint RBO) { glDeleteRenderbuffers(1, &RBO); } + static const char *Name; +}; +typedef GLObjWrapper<GLRBOCreateReleaseHelper> GLRenderBufferObj; + } diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm index b93451e8..617dd1f8 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm @@ -23,7 +23,8 @@ #include "pch.h" -//#import <AppKit/AppKit.h> +#import <OpenGLES/EAGL.h> +#import <OpenGLES/EAGLDrawable.h> #include "GLContextIOS.h" #include "DeviceCaps.h" @@ -31,21 +32,17 @@ namespace Diligent { - GLContext::GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps ) : - m_SwapChainAttribs(Info.SwapChainAttribs) + m_SwapChainAttribs(Info.SwapChainAttribs), + m_ColorRenderBuffer(false), + m_DepthRenderBuffer(false), + m_FBO(false) { - /*if (GetCurrentNativeGLContext() == nullptr) + if (GetCurrentNativeGLContext() == nullptr) { LOG_ERROR_AND_THROW("No current GL context found!"); } - // Initialize GLEW - glewExperimental = true; // This is required on MacOS - GLenum err = glewInit(); - 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; @@ -66,35 +63,28 @@ namespace Diligent // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but // modern hardware is capable of interpolating across a cube face boundary. // GL_TEXTURE_CUBE_MAP_SEAMLESS is not defined in OpenGLES - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - if( glGetError() != GL_NO_ERROR ) - LOG_ERROR_MESSAGE("Failed to enable seamless cubemap filtering"); + //glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + //if( glGetError() != GL_NO_ERROR ) + // LOG_ERROR_MESSAGE("Failed to enable seamless cubemap filtering"); // When GL_FRAMEBUFFER_SRGB is enabled, and if the destination image is in the sRGB colorspace // then OpenGL will assume the shader's output is in the linear RGB colorspace. It will therefore // convert the output from linear RGB to sRGB. // Any writes to images that are not in the sRGB format should not be affected. // Thus this setting should be just set once and left that way - glEnable(GL_FRAMEBUFFER_SRGB); - if( glGetError() != GL_NO_ERROR ) - LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); + //glEnable(GL_FRAMEBUFFER_SRGB); + //if( glGetError() != GL_NO_ERROR ) + // LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); - DeviceCaps.DevType = DeviceType::OpenGL; + DeviceCaps.DevType = DeviceType::OpenGLES; DeviceCaps.MajorVersion = MajorVersion; DeviceCaps.MinorVersion = MinorVersion; - bool IsGL43OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 3); - bool IsGL42OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 2); - DeviceCaps.bComputeShadersSupported = IsGL42OrAbove; - auto &TexCaps = DeviceCaps.TexCaps; - TexCaps.bTexture2DMSSupported = IsGL43OrAbove; - TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; - TexCaps.bTextureViewSupported = IsGL43OrAbove; - TexCaps.bCubemapArraysSupported = IsGL43OrAbove; - DeviceCaps.bMultithreadedResourceCreationSupported = False;*/ + DeviceCaps.bMultithreadedResourceCreationSupported = False; DeviceCaps.bIndirectRenderingSupported = False; DeviceCaps.bGeometryShadersSupported = False; DeviceCaps.bTessellationSupported = False; DeviceCaps.bWireframeFillSupported = False; + DeviceCaps.bComputeShadersSupported = False; DeviceCaps.SamCaps.bLODBiasSupported = False; DeviceCaps.SamCaps.bBorderSamplingModeSupported = False; DeviceCaps.TexCaps.bTexture1DSupported = False; @@ -113,7 +103,7 @@ namespace Diligent GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext() { - //NSOpenGLContext* CurrentCtx = [NSOpenGLContext currentContext]; - return nullptr;//CurrentCtx; + EAGLContext* CurrentCtx = [EAGLContext currentContext]; + return (__bridge void*)CurrentCtx; } } diff --git a/Graphics/GraphicsEngineOpenGL/src/GLObjectWrapper.cpp b/Graphics/GraphicsEngineOpenGL/src/GLObjectWrapper.cpp index 5f183c9c..4454f15a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLObjectWrapper.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLObjectWrapper.cpp @@ -34,4 +34,5 @@ namespace GLObjectWrappers const char *GLTextureCreateReleaseHelper :: Name = "texture"; const char *GLSamplerCreateReleaseHelper :: Name = "sampler"; const char *GLFBOCreateReleaseHelper :: Name = "framebuffer"; + const char *GLRBOCreateReleaseHelper :: Name = "renderbuffer"; } diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index ec40f3a1..551e2751 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -643,6 +643,7 @@ void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) void RenderDeviceGLImpl :: QueryDeviceCaps() { + if(m_DeviceCaps.bWireframeFillSupported) { // Test glPolygonMode() function to check if it fails // (It does fail on NVidia Shield tablet, but works fine diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index 28ef9327..6bb33316 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -60,6 +60,7 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl #elif defined(PLATFORM_IOS) Settings.append( "#version 300 es\n" + "#extension GL_EXT_separate_shader_objects : enable\n" "#ifndef GL_ES\n" "# define GL_ES 1\n" "#endif\n" @@ -71,13 +72,26 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl "precision highp sampler2D;\n" "precision highp sampler3D;\n" "precision highp samplerCube;\n" - "precision highp samplerCubeArray;\n" "precision highp samplerCubeShadow;\n" - "precision highp samplerCubeArrayShadow;\n" "precision highp sampler2DShadow;\n" "precision highp sampler2DArray;\n" "precision highp sampler2DArrayShadow;\n" + + "precision highp isampler2D;\n" + "precision highp isampler3D;\n" + "precision highp isamplerCube;\n" + "precision highp isampler2DArray;\n" + + "precision highp usampler2D;\n" + "precision highp usampler3D;\n" + "precision highp usamplerCube;\n" + "precision highp usampler2DArray;\n" ); + + // Built-in variable 'gl_Position' must be redeclared before use, with separate shader objects. + if(m_Desc.ShaderType == SHADER_TYPE_VERTEX) + Settings.append("out vec4 gl_Position;\n"); + #elif defined(ANDROID) Settings.append( "#version 310 es\n" |
