2014-08-09 14:31:27 +00:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-08-09 14:31:27 +00:00
|
|
|
|
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()
|
|
|
|
{
|
2019-04-10 14:40:19 +00:00
|
|
|
return eglGetDisplay(static_cast<Display*>(m_wsi.display_connection));
|
2018-10-03 13:02:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EGLNativeWindowType GLContextEGLX11::GetEGLNativeWindow(EGLConfig config)
|
2014-08-09 14:31:27 +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 = {};
|
2014-08-09 14:31:27 +00:00
|
|
|
visTemplate.visualid = vid;
|
|
|
|
|
|
|
|
int nVisuals;
|
2019-04-10 14:40:19 +00:00
|
|
|
XVisualInfo* vi = XGetVisualInfo(static_cast<Display*>(m_wsi.display_connection), 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
|
|
|
|
2019-04-10 14:40:19 +00:00
|
|
|
m_render_window = GLX11Window::Create(static_cast<Display*>(m_wsi.display_connection),
|
|
|
|
reinterpret_cast<Window>(m_wsi.render_surface), vi);
|
2018-10-03 13:03:19 +00:00
|
|
|
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
|
|
|
}
|