2014-08-09 14:31:27 +00:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-08-09 14:31:27 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2015-09-18 16:40:00 +00:00
|
|
|
#include "Common/GL/GLInterface/EGLX11.h"
|
2014-08-09 14:31:27 +00:00
|
|
|
|
2018-10-03 13:03:33 +00:00
|
|
|
GLContextEGLX11::~GLContextEGLX11()
|
|
|
|
{
|
|
|
|
// The context must be destroyed before the window.
|
|
|
|
DestroyWindowSurface();
|
|
|
|
DestroyContext();
|
|
|
|
m_render_window.reset();
|
|
|
|
}
|
2018-10-03 13:03:19 +00:00
|
|
|
|
|
|
|
void GLContextEGLX11::Update()
|
2014-08-09 14:31:27 +00:00
|
|
|
{
|
2018-10-03 13:03:19 +00:00
|
|
|
m_render_window->UpdateDimensions();
|
|
|
|
m_backbuffer_width = m_render_window->GetWidth();
|
|
|
|
m_backbuffer_height = m_render_window->GetHeight();
|
2014-08-09 14:31:27 +00:00
|
|
|
}
|
|
|
|
|
2018-10-03 13:02:45 +00:00
|
|
|
EGLDisplay GLContextEGLX11::OpenEGLDisplay()
|
|
|
|
{
|
2018-10-03 13:03:19 +00:00
|
|
|
return eglGetDisplay(static_cast<Display*>(m_host_display));
|
2018-10-03 13:02:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EGLNativeWindowType GLContextEGLX11::GetEGLNativeWindow(EGLConfig config)
|
2014-08-09 14:31:27 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
EGLint vid;
|
2018-10-03 13:02:45 +00:00
|
|
|
eglGetConfigAttrib(m_egl_display, config, EGL_NATIVE_VISUAL_ID, &vid);
|
2014-08-09 14:31:27 +00:00
|
|
|
|
2018-10-03 13:02:45 +00:00
|
|
|
XVisualInfo visTemplate = {};
|
2016-06-24 08:43:46 +00:00
|
|
|
visTemplate.visualid = vid;
|
2014-08-09 14:31:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
int nVisuals;
|
2018-10-03 13:03:19 +00:00
|
|
|
XVisualInfo* vi =
|
|
|
|
XGetVisualInfo(static_cast<Display*>(m_host_display), VisualIDMask, &visTemplate, &nVisuals);
|
2014-08-09 14:31:27 +00:00
|
|
|
|
2018-10-03 13:03:19 +00:00
|
|
|
if (m_render_window)
|
|
|
|
m_render_window.reset();
|
2014-10-23 12:54:05 +00:00
|
|
|
|
2018-10-03 13:03:19 +00:00
|
|
|
m_render_window = GLX11Window::Create(static_cast<Display*>(m_host_display),
|
|
|
|
reinterpret_cast<Window>(m_host_window), vi);
|
|
|
|
m_backbuffer_width = m_render_window->GetWidth();
|
|
|
|
m_backbuffer_height = m_render_window->GetHeight();
|
2014-10-23 12:54:05 +00:00
|
|
|
|
2018-10-03 13:02:45 +00:00
|
|
|
XFree(vi);
|
2014-08-09 14:31:27 +00:00
|
|
|
|
2018-10-03 13:03:19 +00:00
|
|
|
return reinterpret_cast<EGLNativeWindowType>(m_render_window->GetWindow());
|
2014-08-09 14:31:27 +00:00
|
|
|
}
|