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
|
|
|
|
2024-02-25 09:22:25 +00:00
|
|
|
#include "window_info.h"
|
2023-08-13 03:42:02 +00:00
|
|
|
|
|
|
|
#include "common/types.h"
|
|
|
|
|
2020-05-07 12:48:13 +00:00
|
|
|
#include <memory>
|
2024-01-20 13:21:35 +00:00
|
|
|
#include <span>
|
2021-02-13 14:52:34 +00:00
|
|
|
#include <vector>
|
2020-05-07 12:48:13 +00:00
|
|
|
|
2024-01-20 13:21:35 +00:00
|
|
|
class Error;
|
|
|
|
|
2024-02-25 09:22:25 +00:00
|
|
|
class OpenGLContext
|
2020-05-07 12:48:13 +00:00
|
|
|
{
|
|
|
|
public:
|
2024-02-25 09:22:25 +00:00
|
|
|
OpenGLContext(const WindowInfo& wi);
|
|
|
|
virtual ~OpenGLContext();
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
enum class Profile
|
|
|
|
{
|
|
|
|
NoProfile,
|
|
|
|
Core,
|
|
|
|
ES
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Version
|
|
|
|
{
|
|
|
|
Profile profile;
|
|
|
|
int major_version;
|
|
|
|
int minor_version;
|
|
|
|
};
|
|
|
|
|
2021-02-13 14:52:34 +00:00
|
|
|
struct FullscreenModeInfo
|
|
|
|
{
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
float refresh_rate;
|
|
|
|
};
|
|
|
|
|
2020-05-07 12:48:13 +00:00
|
|
|
ALWAYS_INLINE const WindowInfo& GetWindowInfo() const { return m_wi; }
|
|
|
|
ALWAYS_INLINE bool IsGLES() const { return (m_version.profile == Profile::ES); }
|
|
|
|
ALWAYS_INLINE u32 GetSurfaceWidth() const { return m_wi.surface_width; }
|
|
|
|
ALWAYS_INLINE u32 GetSurfaceHeight() const { return m_wi.surface_height; }
|
2023-08-13 03:42:02 +00:00
|
|
|
ALWAYS_INLINE GPUTexture::Format GetSurfaceFormat() const { return m_wi.surface_format; }
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
virtual void* GetProcAddress(const char* name) = 0;
|
|
|
|
virtual bool ChangeSurface(const WindowInfo& new_wi) = 0;
|
|
|
|
virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) = 0;
|
|
|
|
virtual bool SwapBuffers() = 0;
|
2022-12-08 03:17:20 +00:00
|
|
|
virtual bool IsCurrent() = 0;
|
2020-05-07 12:48:13 +00:00
|
|
|
virtual bool MakeCurrent() = 0;
|
|
|
|
virtual bool DoneCurrent() = 0;
|
|
|
|
virtual bool SetSwapInterval(s32 interval) = 0;
|
2024-02-25 09:22:25 +00:00
|
|
|
virtual std::unique_ptr<OpenGLContext> CreateSharedContext(const WindowInfo& wi, Error* error) = 0;
|
2020-05-07 12:48:13 +00:00
|
|
|
|
2021-02-13 14:52:34 +00:00
|
|
|
virtual std::vector<FullscreenModeInfo> EnumerateFullscreenModes();
|
|
|
|
|
2024-02-25 09:22:25 +00:00
|
|
|
static std::unique_ptr<OpenGLContext> Create(const WindowInfo& wi, Error* error);
|
2020-05-07 12:48:13 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
WindowInfo m_wi;
|
|
|
|
Version m_version = {};
|
|
|
|
};
|