File: GLContext.h

package info (click to toggle)
dolphin-emu 2503%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 111,624 kB
  • sloc: cpp: 787,747; ansic: 217,914; xml: 31,400; python: 4,226; yacc: 3,985; javascript: 2,430; makefile: 777; asm: 726; sh: 281; pascal: 257; perl: 97; objc: 75
file content (66 lines) | stat: -rw-r--r-- 1,862 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include <memory>
#include <string>
#include <utility>

#include "Common/CommonTypes.h"
#include "Common/WindowSystemInfo.h"

class GLContext
{
public:
  enum class Mode
  {
    Detect,
    OpenGL,
    OpenGLES
  };

  virtual ~GLContext();

  Mode GetMode() const { return m_opengl_mode; }
  bool IsGLES() const { return m_opengl_mode == Mode::OpenGLES; }

  u32 GetBackBufferWidth() const { return m_backbuffer_width; }
  u32 GetBackBufferHeight() const { return m_backbuffer_height; }

  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);

  // Creates an instance of GLContext specific to the platform we are running on.
  // If successful, the context is made current on the calling thread.
  static std::unique_ptr<GLContext> Create(const WindowSystemInfo& wsi, bool stereo = false,
                                           bool core = true, bool prefer_egl = false,
                                           bool prefer_gles = false);

protected:
  virtual bool Initialize(const WindowSystemInfo& wsi, bool stereo, bool core);

  Mode m_opengl_mode = Mode::Detect;

  // Window dimensions.
  u32 m_backbuffer_width = 0;
  u32 m_backbuffer_height = 0;
  bool m_is_shared = false;

  // 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;
};