Blender V5.3
GHOST_ContextWGL.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "GHOST_Context.hh"
12
13#include <epoxy/wgl.h>
14
15#include <list>
16
17#ifndef GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY
18# define GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY 0
19#endif
20
22 /* XR code needs low level graphics data to send to OpenXR. */
24
25 public:
29 GHOST_ContextWGL(const GHOST_ContextParams &context_params,
30 bool alphaBackground,
31 HWND hWnd,
32 HDC hDC,
33 int contextProfileMask,
34 int contextMajorVersion,
35 int contextMinorVersion,
36 int contextFlags,
37 int contextResetNotificationStrategy);
38
42 ~GHOST_ContextWGL() override;
43
46 {
47 return GHOST_kSuccess;
48 }
49
55
61
67
73
80
86 GHOST_TSuccess setSwapInterval(int interval) override;
87
93 GHOST_TSuccess getSwapInterval(int &interval_out) override;
94
95 private:
96 int choose_pixel_format_arb(bool stereoVisual, bool needAlpha);
97 int _choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha);
98
99 HWND h_wnd_;
100 HDC h_DC_;
101
102 const int context_profile_mask_;
103 const int context_major_version_;
104 const int context_minor_version_;
105 const int context_flags_;
106 const bool alpha_background_;
107 const int context_reset_notification_strategy_;
108
109 HGLRC h_GLRC_;
110
111#ifndef NDEBUG
112 const char *dummy_vendor_;
113 const char *dummy_renderer_;
114 const char *dummy_version_;
115#endif
116
117 static HGLRC s_sharedHGLRC;
118 static int s_sharedCount;
119
120 /* Offscreen window handles are cached to ensure they are created and freed on the
121 * main thread, as required by the Windows API. */
122 struct OffscreenWindowHandle {
123 OffscreenWindowHandle();
124 ~OffscreenWindowHandle();
125
126 HWND h_wnd = nullptr;
127 HDC h_DC = nullptr;
128 bool used = false;
129 };
130
131 static std::list<OffscreenWindowHandle> s_sharedOffscreenWindowHandles;
132 OffscreenWindowHandle *offscreen_window_handle_;
133};
GHOST_TSuccess
@ GHOST_kSuccess
friend class GHOST_XrGraphicsBindingOpenGL
GHOST_ContextWGL(const GHOST_ContextParams &context_params, bool alphaBackground, HWND hWnd, HDC hDC, int contextProfileMask, int contextMajorVersion, int contextMinorVersion, int contextFlags, int contextResetNotificationStrategy)
GHOST_TSuccess releaseNativeHandles() override
GHOST_TSuccess releaseDrawingContext() override
GHOST_TSuccess initializeDrawingContext() override
GHOST_TSuccess setSwapInterval(int interval) override
GHOST_TSuccess activateDrawingContext() override
GHOST_TSuccess getSwapInterval(int &interval_out) override
GHOST_TSuccess swapBufferAcquire() override
GHOST_TSuccess swapBufferRelease() override
GHOST_Context(const GHOST_ContextParams &context_params)