Skip to content

Commit 12606a7

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 60bdade + 06a339f commit 12606a7

22 files changed

+180
-148
lines changed

Graphics/GraphicsEngineOpenGL/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ set(INTERFACE
3939
interface/BufferGL.h
4040
interface/BufferViewGL.h
4141
interface/DeviceContextGL.h
42+
interface/EngineGLAttribs.h
4243
interface/PipelineStateGL.h
4344
interface/RenderDeviceFactoryOpenGL.h
4445
interface/RenderDeviceGL.h

Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "DeviceContextBase.h"
2828
#include "BaseInterfacesGL.h"
2929
#include "GLContextState.h"
30+
#include "GLObjectWrapper.h"
3031

3132
namespace Diligent
3233
{
@@ -100,6 +101,7 @@ class DeviceContextGLImpl : public DeviceContextBase<IDeviceContextGL>
100101
std::vector<class BufferGLImpl*> m_BoundWritableBuffers;
101102

102103
bool m_bVAOIsUpToDate = false;
104+
GLObjectWrappers::GLFrameBufferObj m_DefaultFBO;
103105
};
104106

105107
}

Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@
2828

2929
namespace Diligent
3030
{
31-
struct ContextInitInfo
32-
{
33-
SwapChainDesc SwapChainAttribs;
34-
void *pNativeWndHandle = nullptr;
35-
};
36-
3731
class GLContext
3832
{
3933
public:
4034
typedef EGLContext NativeGLContextType;
4135

42-
GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps );
36+
GLContext( const struct EngineGLAttribs &InitAttribs, DeviceCaps &DeviceCaps );
4337
~GLContext();
4438

4539
bool Init( ANativeWindow* window );
@@ -51,9 +45,9 @@ namespace Diligent
5145
void Suspend();
5246
EGLint Resume( ANativeWindow* window );
5347

54-
const SwapChainDesc& GetSwapChainDesc()const{ return SwapChainAttribs_; }
55-
5648
NativeGLContextType GetCurrentNativeGLContext();
49+
int32_t GetScreenWidth()const{return screen_width_;}
50+
int32_t GetScreenHeight()const{return screen_height_;}
5751

5852
private:
5953
//EGL configurations
@@ -68,6 +62,8 @@ namespace Diligent
6862
int32_t depth_size_ = 0;
6963
int32_t major_version_ = 0;
7064
int32_t minor_version_ = 0;
65+
int32_t screen_width_ = 0;
66+
int32_t screen_height_ = 0;
7167

7268
//Flags
7369
bool gles_initialized_ = false;

Graphics/GraphicsEngineOpenGL/include/GLContextLinux.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,20 @@
2525

2626
namespace Diligent
2727
{
28-
29-
struct ContextInitInfo
30-
{
31-
SwapChainDesc SwapChainAttribs;
32-
void *pNativeWndHandle = nullptr;
33-
void *pDisplay = nullptr;
34-
};
35-
3628
class GLContext
3729
{
3830
public:
3931
typedef GLXContext NativeGLContextType;
4032

41-
GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps);
33+
GLContext(const struct EngineGLAttribs &InitAttribs, struct DeviceCaps &DeviceCaps);
4234
~GLContext();
4335
void SwapBuffers();
4436

45-
const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; }
46-
4737
NativeGLContextType GetCurrentNativeGLContext();
4838

4939
private:
5040
void *m_pNativeWindow = nullptr;
5141
void *m_pDisplay = nullptr;
5242
NativeGLContextType m_Context;
53-
SwapChainDesc m_SwapChainAttribs;
5443
};
5544
}

Graphics/GraphicsEngineOpenGL/include/GLContextMacOS.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,13 @@
2525

2626
namespace Diligent
2727
{
28-
struct ContextInitInfo
29-
{
30-
SwapChainDesc SwapChainAttribs;
31-
void *pNativeWndHandle = nullptr;
32-
};
33-
3428
class GLContext
3529
{
3630
public:
3731
typedef void* NativeGLContextType; // NSOpenGLContext*
3832

39-
GLContext(const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps);
40-
void SwapBuffers();
41-
42-
const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; }
33+
GLContext(const struct EngineGLAttribs &InitAttribs, struct DeviceCaps &DeviceCaps);
4334

4435
NativeGLContextType GetCurrentNativeGLContext();
45-
46-
private:
47-
SwapChainDesc m_SwapChainAttribs;
4836
};
4937
}

Graphics/GraphicsEngineOpenGL/include/GLContextWindows.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,19 @@
2525

2626
namespace Diligent
2727
{
28-
29-
struct ContextInitInfo
30-
{
31-
SwapChainDesc SwapChainAttribs;
32-
void *pNativeWndHandle = nullptr;
33-
};
34-
3528
class GLContext
3629
{
3730
public:
3831
typedef HGLRC NativeGLContextType;
3932

40-
GLContext( const ContextInitInfo &Info, struct DeviceCaps &DeviceCaps );
33+
GLContext( const struct EngineGLAttribs &InitAttribs, struct DeviceCaps &DeviceCaps );
4134
~GLContext();
4235
void SwapBuffers();
4336

44-
const SwapChainDesc& GetSwapChainDesc()const{ return m_SwapChainAttribs; }
45-
4637
NativeGLContextType GetCurrentNativeGLContext();
4738

4839
private:
4940
HGLRC m_Context;
5041
HDC m_WindowHandleToDeviceContext;
51-
SwapChainDesc m_SwapChainAttribs;
5242
};
5343
}

Graphics/GraphicsEngineOpenGL/include/GLObjectWrapper.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,30 @@ typedef GLObjWrapper<GLSamplerCreateReleaseHelper> GLSamplerObj;
224224
class GLFBOCreateReleaseHelper
225225
{
226226
public:
227-
void Create(GLuint &FBO) { glGenFramebuffers(1, &FBO); }
228-
void Release(GLuint FBO) { glDeleteFramebuffers(1, &FBO); }
227+
explicit GLFBOCreateReleaseHelper(GLuint ExternalFBOHandle = 0) :
228+
m_ExternalFBOHandle(ExternalFBOHandle)
229+
{}
230+
231+
void Create(GLuint &FBO)
232+
{
233+
if (m_ExternalFBOHandle != 0)
234+
FBO = m_ExternalFBOHandle; // Attach to external FBO handle
235+
else
236+
glGenFramebuffers(1, &FBO);
237+
}
238+
239+
void Release(GLuint FBO)
240+
{
241+
if (m_ExternalFBOHandle != 0)
242+
m_ExternalFBOHandle = 0; // DO NOT delete the FBO
243+
else
244+
glDeleteFramebuffers(1, &FBO);
245+
}
246+
229247
static const char *Name;
248+
249+
private:
250+
GLuint m_ExternalFBOHandle;
230251
};
231252
typedef GLObjWrapper<GLFBOCreateReleaseHelper> GLFrameBufferObj;
232253

Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Diligent
3131
class RenderDeviceGLESImpl : public RenderDeviceGLImpl
3232
{
3333
public:
34-
RenderDeviceGLESImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const ContextInitInfo &InitInfo );
34+
RenderDeviceGLESImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineGLAttribs &InitAttribs );
3535

3636
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface );
3737

Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "BaseInterfacesGL.h"
3030
#include "FBOCache.h"
3131
#include "TexRegionRender.h"
32+
#include "EngineGLAttribs.h"
3233

3334
enum class GPU_VENDOR
3435
{
@@ -55,7 +56,7 @@ class RenderDeviceGLImpl : public RenderDeviceBase<IGLDeviceBaseInterface>
5556
public:
5657
typedef RenderDeviceBase<IGLDeviceBaseInterface> TRenderDeviceBase;
5758

58-
RenderDeviceGLImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const ContextInitInfo &InitInfo );
59+
RenderDeviceGLImpl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineGLAttribs &InitAttribs );
5960
~RenderDeviceGLImpl();
6061
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
6162

Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "SwapChainGL.h"
2727
#include "SwapChainBase.h"
28+
#include "GLObjectWrapper.h"
2829

2930
namespace Diligent
3031
{
@@ -37,16 +38,19 @@ class SwapChainGLImpl : public SwapChainBase<ISwapChainGL>
3738
typedef SwapChainBase<ISwapChainGL> TSwapChainBase;
3839

3940
SwapChainGLImpl(IReferenceCounters *pRefCounters,
41+
const EngineGLAttribs &InitAttribs,
4042
const SwapChainDesc& SwapChainDesc,
4143
class RenderDeviceGLImpl* pRenderDeviceGL,
4244
class DeviceContextGLImpl* pImmediateContextGL);
4345
~SwapChainGLImpl();
4446

45-
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface );
47+
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
4648

47-
virtual void Present();
49+
virtual void Present()override;
4850

49-
virtual void Resize( Uint32 NewWidth, Uint32 NewHeight );
51+
virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override;
52+
53+
virtual GLuint GetDefaultFBO()const override { return 0; }
5054
};
5155

5256
}

0 commit comments

Comments
 (0)