Debian Codegraph @

Source/Core/Common/GL/GLContext.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <array>
7 #include <memory>
8 #include <string>
9 #include <utility>
10
11 #include "Common/CommonTypes.h"
12 #include "Common/WindowSystemInfo.h"
13
14 class GLContext
15 {
16 public:
17 enum class Mode
18 {
19 Detect,
20 OpenGL,
21 OpenGLES
22 };
23
24 virtual ~GLContext();
25
26 Mode GetMode() const { return m_opengl_mode; }
27 bool IsGLES() const { return m_opengl_mode == Mode::OpenGLES; }
28
29 u32 GetBackBufferWidth() const { return m_backbuffer_width; }
30 u32 GetBackBufferHeight() const { return m_backbuffer_height; }
31
32 virtual bool IsHeadless() const;
33
34 virtual std::unique_ptr<GLContext> CreateSharedContext();
35
36 virtual bool MakeCurrent();
37 virtual bool ClearCurrent();
38
39 virtual void Update();
40 virtual void UpdateSurface(void* window_handle);
41
42 virtual void Swap();
43 virtual void SwapInterval(int interval);
44
45 virtual void* GetFuncAddress(const std::string& name);
46
47 // Creates an instance of GLContext specific to the platform we are running on.
48 // If successful, the context is made current on the calling thread.
49 static std::unique_ptr<GLContext> Create(const WindowSystemInfo& wsi, bool stereo = false,
50 bool core = true, bool prefer_gles = false);
51
52 protected:
53 virtual bool Initialize(const WindowSystemInfo& wsi, bool stereo, bool core);
54
55 Mode m_opengl_mode = Mode::Detect;
56
57 // Window dimensions.
58 u32 m_backbuffer_width = 0;
59 u32 m_backbuffer_height = 0;
60 bool m_is_shared = false;
61
62 // A list of desktop OpenGL versions to attempt to create a context for.
63 // (4.6-3.2, geometry shaders is a minimum requirement since we're using core profile).
64 static const std::array<std::pair<int, int>, 9> s_desktop_opengl_versions;
65 };