2018-10-03 13:02:45 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-10-03 13:02:45 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-10-14 13:32:50 +00:00
|
|
|
#include <array>
|
2018-10-03 13:02:45 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2018-10-14 13:32:50 +00:00
|
|
|
#include <utility>
|
2018-10-03 13:02:45 +00:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2018-10-03 13:03:22 +00:00
|
|
|
#include "Common/WindowSystemInfo.h"
|
2018-10-03 13:02:45 +00:00
|
|
|
|
|
|
|
class GLContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class Mode
|
|
|
|
{
|
|
|
|
Detect,
|
|
|
|
OpenGL,
|
|
|
|
OpenGLES
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual ~GLContext();
|
|
|
|
|
2018-12-14 16:02:24 +00:00
|
|
|
Mode GetMode() const { return m_opengl_mode; }
|
2018-10-03 13:02:45 +00:00
|
|
|
bool IsGLES() const { return m_opengl_mode == Mode::OpenGLES; }
|
|
|
|
|
2018-12-14 16:02:24 +00:00
|
|
|
u32 GetBackBufferWidth() const { return m_backbuffer_width; }
|
|
|
|
u32 GetBackBufferHeight() const { return m_backbuffer_height; }
|
2018-10-03 13:02:45 +00:00
|
|
|
|
|
|
|
virtual bool IsHeadless() const;
|
|
|
|
|
|
|
|
virtual std::unique_ptr<GLContext> CreateSharedContext();
|
|
|
|
|
|
|
|
virtual bool MakeCurrent();
|
|
|
|
virtual bool ClearCurrent();
|
|
|
|
|
|
|
|
virtual void Update();
|
|
|
|
virtual void UpdateSurface(void* window_handle);
|
|
|
|
|
|
|
|
virtual void Swap();
|
|
|
|
virtual void SwapInterval(int interval);
|
|
|
|
|
|
|
|
virtual void* GetFuncAddress(const std::string& name);
|
|
|
|
|
2018-10-03 13:03:33 +00:00
|
|
|
// Creates an instance of GLContext specific to the platform we are running on.
|
|
|
|
// If successful, the context is made current on the calling thread.
|
2018-10-03 13:03:22 +00:00
|
|
|
static std::unique_ptr<GLContext> Create(const WindowSystemInfo& wsi, bool stereo = false,
|
2018-10-03 13:03:36 +00:00
|
|
|
bool core = true, bool prefer_egl = false,
|
|
|
|
bool prefer_gles = false);
|
2018-10-03 13:02:45 +00:00
|
|
|
|
|
|
|
protected:
|
2019-04-10 14:40:19 +00:00
|
|
|
virtual bool Initialize(const WindowSystemInfo& wsi, bool stereo, bool core);
|
2018-10-03 13:02:45 +00:00
|
|
|
|
|
|
|
Mode m_opengl_mode = Mode::Detect;
|
|
|
|
|
|
|
|
// Window dimensions.
|
|
|
|
u32 m_backbuffer_width = 0;
|
|
|
|
u32 m_backbuffer_height = 0;
|
|
|
|
bool m_is_shared = false;
|
2018-10-14 13:32:50 +00:00
|
|
|
|
|
|
|
// A list of desktop OpenGL versions to attempt to create a context for.
|
|
|
|
// (4.6-3.2, geometry shaders is a minimum requirement since we're using core profile).
|
|
|
|
static const std::array<std::pair<int, int>, 9> s_desktop_opengl_versions;
|
2018-10-03 13:02:45 +00:00
|
|
|
};
|