mirror of https://github.com/stenzek/duckstation
				
				
				
			GLContext: Rename to OpenGLContext
							parent
							
								
									c1381cfda6
								
							
						
					
					
						commit
						ab83247de3
					
				@ -1,44 +0,0 @@
 | 
			
		||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
 | 
			
		||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
 | 
			
		||||
 | 
			
		||||
#include "context_egl_x11.h"
 | 
			
		||||
 | 
			
		||||
#include "common/error.h"
 | 
			
		||||
 | 
			
		||||
namespace GL {
 | 
			
		||||
ContextEGLX11::ContextEGLX11(const WindowInfo& wi) : ContextEGL(wi)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
ContextEGLX11::~ContextEGLX11() = default;
 | 
			
		||||
 | 
			
		||||
std::unique_ptr<Context> ContextEGLX11::Create(const WindowInfo& wi, std::span<const Version> versions_to_try,
 | 
			
		||||
                                               Error* error)
 | 
			
		||||
{
 | 
			
		||||
  std::unique_ptr<ContextEGLX11> context = std::make_unique<ContextEGLX11>(wi);
 | 
			
		||||
  if (!context->Initialize(versions_to_try, error))
 | 
			
		||||
    return nullptr;
 | 
			
		||||
 | 
			
		||||
  return context;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::unique_ptr<Context> ContextEGLX11::CreateSharedContext(const WindowInfo& wi, Error* error)
 | 
			
		||||
{
 | 
			
		||||
  std::unique_ptr<ContextEGLX11> context = std::make_unique<ContextEGLX11>(wi);
 | 
			
		||||
  context->m_display = m_display;
 | 
			
		||||
 | 
			
		||||
  if (!context->CreateContextAndSurface(m_version, m_context, false))
 | 
			
		||||
    return nullptr;
 | 
			
		||||
 | 
			
		||||
  return context;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
EGLDisplay ContextEGLX11::GetPlatformDisplay(const EGLAttrib* attribs, Error* error)
 | 
			
		||||
{
 | 
			
		||||
  EGLDisplay dpy = TryGetPlatformDisplay(EGL_PLATFORM_X11_KHR, attribs);
 | 
			
		||||
  if (dpy == EGL_NO_DISPLAY)
 | 
			
		||||
    dpy = GetFallbackDisplay(error);
 | 
			
		||||
 | 
			
		||||
  return dpy;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace GL
 | 
			
		||||
@ -1,23 +0,0 @@
 | 
			
		||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
 | 
			
		||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "context_egl.h"
 | 
			
		||||
 | 
			
		||||
namespace GL {
 | 
			
		||||
 | 
			
		||||
class ContextEGLX11 final : public ContextEGL
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
  ContextEGLX11(const WindowInfo& wi);
 | 
			
		||||
  ~ContextEGLX11() override;
 | 
			
		||||
 | 
			
		||||
  static std::unique_ptr<Context> Create(const WindowInfo& wi, std::span<const Version> versions_to_try, Error* error);
 | 
			
		||||
 | 
			
		||||
  std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  EGLDisplay GetPlatformDisplay(const EGLAttrib* attribs, Error* error) override;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace GL
 | 
			
		||||
@ -0,0 +1,42 @@
 | 
			
		||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
 | 
			
		||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
 | 
			
		||||
 | 
			
		||||
#include "opengl_context_egl_x11.h"
 | 
			
		||||
 | 
			
		||||
#include "common/error.h"
 | 
			
		||||
 | 
			
		||||
OpenGLContextEGLX11::OpenGLContextEGLX11(const WindowInfo& wi) : OpenGLContextEGL(wi)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
OpenGLContextEGLX11::~OpenGLContextEGLX11() = default;
 | 
			
		||||
 | 
			
		||||
std::unique_ptr<OpenGLContext> OpenGLContextEGLX11::Create(const WindowInfo& wi,
 | 
			
		||||
                                                           std::span<const Version> versions_to_try, Error* error)
 | 
			
		||||
{
 | 
			
		||||
  std::unique_ptr<OpenGLContextEGLX11> context = std::make_unique<OpenGLContextEGLX11>(wi);
 | 
			
		||||
  if (!context->Initialize(versions_to_try, error))
 | 
			
		||||
    return nullptr;
 | 
			
		||||
 | 
			
		||||
  return context;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::unique_ptr<OpenGLContext> OpenGLContextEGLX11::CreateSharedContext(const WindowInfo& wi, Error* error)
 | 
			
		||||
{
 | 
			
		||||
  std::unique_ptr<OpenGLContextEGLX11> context = std::make_unique<OpenGLContextEGLX11>(wi);
 | 
			
		||||
  context->m_display = m_display;
 | 
			
		||||
 | 
			
		||||
  if (!context->CreateContextAndSurface(m_version, m_context, false))
 | 
			
		||||
    return nullptr;
 | 
			
		||||
 | 
			
		||||
  return context;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
EGLDisplay OpenGLContextEGLX11::GetPlatformDisplay(const EGLAttrib* attribs, Error* error)
 | 
			
		||||
{
 | 
			
		||||
  EGLDisplay dpy = TryGetPlatformDisplay(EGL_PLATFORM_X11_KHR, attribs);
 | 
			
		||||
  if (dpy == EGL_NO_DISPLAY)
 | 
			
		||||
    dpy = GetFallbackDisplay(error);
 | 
			
		||||
 | 
			
		||||
  return dpy;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,21 @@
 | 
			
		||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
 | 
			
		||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "opengl_context_egl.h"
 | 
			
		||||
 | 
			
		||||
class OpenGLContextEGLX11 final : public OpenGLContextEGL
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
  OpenGLContextEGLX11(const WindowInfo& wi);
 | 
			
		||||
  ~OpenGLContextEGLX11() override;
 | 
			
		||||
 | 
			
		||||
  static std::unique_ptr<OpenGLContext> Create(const WindowInfo& wi, std::span<const Version> versions_to_try,
 | 
			
		||||
                                               Error* error);
 | 
			
		||||
 | 
			
		||||
  std::unique_ptr<OpenGLContext> CreateSharedContext(const WindowInfo& wi, Error* error) override;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  EGLDisplay GetPlatformDisplay(const EGLAttrib* attribs, Error* error) override;
 | 
			
		||||
};
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue