2024-01-20 13:21:35 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2020-05-07 12:48:13 +00:00
|
|
|
#pragma once
|
2023-08-13 03:42:02 +00:00
|
|
|
|
2020-05-07 12:48:13 +00:00
|
|
|
#include "context.h"
|
2023-08-13 03:42:02 +00:00
|
|
|
|
2024-02-25 05:32:26 +00:00
|
|
|
#include "glad/egl.h"
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
namespace GL {
|
|
|
|
|
|
|
|
class ContextEGL : public Context
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContextEGL(const WindowInfo& wi);
|
|
|
|
~ContextEGL() override;
|
|
|
|
|
2024-01-20 13:21:35 +00:00
|
|
|
static std::unique_ptr<Context> Create(const WindowInfo& wi, std::span<const Version> versions_to_try, Error* error);
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
void* GetProcAddress(const char* name) override;
|
|
|
|
virtual bool ChangeSurface(const WindowInfo& new_wi) override;
|
|
|
|
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
|
|
|
|
bool SwapBuffers() override;
|
2022-12-08 03:17:20 +00:00
|
|
|
bool IsCurrent() override;
|
2020-05-07 12:48:13 +00:00
|
|
|
bool MakeCurrent() override;
|
|
|
|
bool DoneCurrent() override;
|
|
|
|
bool SetSwapInterval(s32 interval) override;
|
2024-02-25 05:32:26 +00:00
|
|
|
virtual std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
protected:
|
2024-02-18 08:16:46 +00:00
|
|
|
virtual EGLDisplay GetPlatformDisplay(const EGLAttrib* attribs, Error* error);
|
|
|
|
virtual EGLSurface CreatePlatformSurface(EGLConfig config, const EGLAttrib* attribs, Error* error);
|
|
|
|
|
|
|
|
EGLDisplay TryGetPlatformDisplay(EGLenum platform, const EGLAttrib* attribs);
|
|
|
|
EGLDisplay GetFallbackDisplay(Error* error);
|
|
|
|
EGLSurface CreateFallbackSurface(EGLConfig config, const EGLAttrib* attribs, void* window, Error* error);
|
2020-05-07 12:48:13 +00:00
|
|
|
|
2024-01-20 13:21:35 +00:00
|
|
|
bool Initialize(std::span<const Version> versions_to_try, Error* error);
|
2020-05-07 12:48:13 +00:00
|
|
|
bool CreateDisplay();
|
|
|
|
bool CreateContext(const Version& version, EGLContext share_context);
|
|
|
|
bool CreateContextAndSurface(const Version& version, EGLContext share_context, bool make_current);
|
|
|
|
bool CreateSurface();
|
2020-11-07 11:41:25 +00:00
|
|
|
bool CreatePBufferSurface();
|
2023-08-13 03:42:02 +00:00
|
|
|
bool CheckConfigSurfaceFormat(EGLConfig config, GPUTexture::Format format);
|
2023-10-31 15:52:28 +00:00
|
|
|
GPUTexture::Format GetSurfaceTextureFormat() const;
|
2021-01-31 15:27:14 +00:00
|
|
|
void DestroyContext();
|
|
|
|
void DestroySurface();
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
EGLDisplay m_display = EGL_NO_DISPLAY;
|
|
|
|
EGLSurface m_surface = EGL_NO_SURFACE;
|
|
|
|
EGLContext m_context = EGL_NO_CONTEXT;
|
|
|
|
|
|
|
|
EGLConfig m_config = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace GL
|