diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-08-01 13:40:00 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2014-09-25 19:47:07 +0200 |
commit | 41e5902e7799808fc71504d4222ee6363fec1aef (patch) | |
tree | 6bd63b04e2071bb7cee8156aaca9cd8b7eabea26 /src/core/gl_surface_qt.cpp | |
parent | f3500da1ff1c7d383386c0197848262d7bedf90e (diff) |
Add Desktop OpenGL backend for Windows
Enabling rendering into a WGL backbuffer, in addition to the EGL/angle
one.
Change-Id: I8f2e3f5ecf52b6db22712b1129059f462725a256
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/core/gl_surface_qt.cpp')
-rw-r--r-- | src/core/gl_surface_qt.cpp | 84 |
1 files changed, 82 insertions, 2 deletions
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 72758cbff..cc2809af1 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -64,6 +64,11 @@ extern "C" { } #endif +#if defined(OS_WIN) +#include "ui/gl/gl_surface_wgl.h" +#include "ui/gl/gl_context_wgl.h" +#endif + using ui::GetLastEGLErrorString; namespace gfx { @@ -239,7 +244,75 @@ void* GLSurfaceQtGLX::GetHandle() return reinterpret_cast<void*>(m_surfaceBuffer); } -#endif // defined(USE_X11) +#elif defined(OS_WIN) + +class GLSurfaceQtWGL: public GLSurfaceQt { +public: + explicit GLSurfaceQtWGL(const gfx::Size& size); + + static bool InitializeOneOff(); + + virtual bool Initialize() Q_DECL_OVERRIDE; + virtual void Destroy() Q_DECL_OVERRIDE; + virtual void* GetHandle() Q_DECL_OVERRIDE; + virtual void* GetDisplay() Q_DECL_OVERRIDE; + virtual void* GetConfig() Q_DECL_OVERRIDE; + +protected: + ~GLSurfaceQtWGL(); + +private: + PbufferGLSurfaceWGL *m_surfaceBuffer; + DISALLOW_COPY_AND_ASSIGN(GLSurfaceQtWGL); +}; + +GLSurfaceQtWGL::GLSurfaceQtWGL(const gfx::Size& size) + : GLSurfaceQt(size), + m_surfaceBuffer(0) +{ +} + +GLSurfaceQtWGL::~GLSurfaceQtWGL() +{ + Destroy(); +} + +bool GLSurfaceQtWGL::InitializeOneOff() +{ + return GLSurfaceWGL::InitializeOneOff(); +} + +bool GLSurfaceQtWGL::Initialize() +{ + m_surfaceBuffer = new PbufferGLSurfaceWGL(m_size); + + return m_surfaceBuffer->Initialize(); +} + +void GLSurfaceQtWGL::Destroy() +{ + if (m_surfaceBuffer) { + delete m_surfaceBuffer; + m_surfaceBuffer = 0; + } +} + +void *GLSurfaceQtWGL::GetHandle() +{ + return m_surfaceBuffer->GetHandle(); +} + +void *GLSurfaceQtWGL::GetDisplay() +{ + return m_surfaceBuffer->GetDisplay(); +} + +void *GLSurfaceQtWGL::GetConfig() +{ + return m_surfaceBuffer->GetConfig(); +} + +#endif // defined(OS_WIN) GLSurfaceQt::GLSurfaceQt() { @@ -287,9 +360,11 @@ bool GLSurface::InitializeOneOffInternal() if (GetGLImplementation() == kGLImplementationEGLGLES2) return GLSurfaceQtEGL::InitializeOneOff(); -#if defined(USE_X11) if (GetGLImplementation() == kGLImplementationDesktopGL) +#if defined(USE_X11) return GLSurfaceQtGLX::InitializeOneOff(); +#elif defined(OS_WIN) + return GLSurfaceQtWGL::InitializeOneOff(); #endif return false; @@ -456,6 +531,11 @@ GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) if (!surface->Initialize()) return NULL; return surface; +#elif defined(OS_WIN) + scoped_refptr<GLSurface> surface = new GLSurfaceQtWGL(size); + if (!surface->Initialize()) + return NULL; + return surface; #else LOG(ERROR) << "Desktop GL is not supported on this platform."; Q_UNREACHABLE(); |