Blender V4.5
GHOST_SystemHeadless.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#pragma once
11
12#include "../GHOST_Types.h"
13#include "GHOST_System.hh"
14#include "GHOST_WindowNULL.hh"
15
16#if defined(WITH_OPENGL_BACKEND) && defined(__linux__)
17# include "GHOST_ContextEGL.hh"
18#endif
19#ifdef WITH_VULKAN_BACKEND
20# include "GHOST_ContextVK.hh"
21#endif
22#include "GHOST_ContextNone.hh"
23
25
27 public:
29 { /* nop */
30 }
31 ~GHOST_SystemHeadless() override = default;
32
33 bool processEvents(bool /*waitForEvent*/) override
34 {
35 return false;
36 }
38 {
39 return false;
40 }
42 {
43 return GHOST_kSuccess;
44 }
45 GHOST_TSuccess getButtons(GHOST_Buttons & /*buttons*/) const override
46 {
47 return GHOST_kSuccess;
48 }
59 char *getClipboard(bool /*selection*/) const override
60 {
61 return nullptr;
62 }
63 void putClipboard(const char * /*buffer*/, bool /*selection*/) const override
64 { /* nop */
65 }
66 uint64_t getMilliSeconds() const override
67 {
68 return 0;
69 }
70 uint8_t getNumDisplays() const override
71 {
72 return uint8_t(1);
73 }
74 GHOST_TSuccess getCursorPosition(int32_t & /*x*/, int32_t & /*y*/) const override
75 {
76 return GHOST_kFailure;
77 }
79 {
80 return GHOST_kFailure;
81 }
82 void getMainDisplayDimensions(uint32_t & /*width*/, uint32_t & /*height*/) const override
83 { /* nop */
84 }
85 void getAllDisplayDimensions(uint32_t & /*width*/, uint32_t & /*height*/) const override
86 { /* nop */
87 }
89 {
90 switch (gpuSettings.context_type) {
91#ifdef WITH_VULKAN_BACKEND
92 case GHOST_kDrawingContextTypeVulkan: {
93 const bool debug_context = (gpuSettings.flags & GHOST_gpuDebugContext) != 0;
94# ifdef _WIN32
95 GHOST_Context *context = new GHOST_ContextVK(
96 false, (HWND)0, 1, 2, debug_context, gpuSettings.preferred_device);
97# elif defined(__APPLE__)
98 GHOST_Context *context = new GHOST_ContextVK(
99 false, nullptr, 1, 2, debug_context, gpuSettings.preferred_device);
100# else
101 GHOST_Context *context = new GHOST_ContextVK(false,
103 0,
104 0,
105 nullptr,
106 nullptr,
107 nullptr,
108 1,
109 2,
110 debug_context,
111 gpuSettings.preferred_device);
112# endif
113 if (context->initializeDrawingContext()) {
114 return context;
115 }
116
117 delete context;
118 return nullptr;
119 }
120#endif
121
122#if defined(WITH_OPENGL_BACKEND) && defined(__linux__)
123 case GHOST_kDrawingContextTypeOpenGL: {
124 GHOST_Context *context;
125 for (int minor = 6; minor >= 3; --minor) {
126 context = new GHOST_ContextEGL((GHOST_System *)this,
127 false,
128 EGLNativeWindowType(0),
129 EGLNativeDisplayType(EGL_DEFAULT_DISPLAY),
130 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
131 4,
132 minor,
135 EGL_OPENGL_API);
136
137 if (context->initializeDrawingContext()) {
138 return context;
139 }
140 delete context;
141 context = nullptr;
142 }
143
144 return context;
145 }
146#endif
147
148 default:
149 /* Unsupported backend. */
150 return nullptr;
151 }
152
153 return nullptr;
154 }
156 {
157 delete context;
158
159 return GHOST_kSuccess;
160 }
161
163 {
165
166 if (success) {
167 return GHOST_kSuccess;
168 }
169
170 return GHOST_kFailure;
171 }
172
173 GHOST_IWindow *createWindow(const char *title,
175 int32_t top,
176 uint32_t width,
177 uint32_t height,
179 GHOST_GPUSettings gpuSettings,
180 const bool /*exclusive*/,
181 const bool /*is_dialog*/,
182 const GHOST_IWindow *parentWindow) override
183 {
184 return new GHOST_WindowNULL(title,
185 left,
186 top,
187 width,
188 height,
189 state,
190 parentWindow,
191 gpuSettings.context_type,
192 ((gpuSettings.flags & GHOST_gpuStereoVisual) != 0));
193 }
194
196 {
197 return nullptr;
198 }
199};
#define GHOST_OPENGL_EGL_CONTEXT_FLAGS
#define GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY
@ GHOST_kVulkanPlatformHeadless
GHOST_TWindowState
GHOST_TCapabilityFlag
Definition GHOST_Types.h:89
@ GHOST_kCapabilityWindowPosition
Definition GHOST_Types.h:97
@ GHOST_kCapabilityKeyboardHyperKey
@ GHOST_kCapabilityCursorWarp
Definition GHOST_Types.h:93
@ GHOST_kCapabilityInputIME
@ GHOST_kCapabilityClipboardImages
@ GHOST_kCapabilityPrimaryClipboard
@ GHOST_kCapabilityWindowDecorationStyles
@ GHOST_kCapabilityDesktopSample
#define GHOST_CAPABILITY_FLAG_ALL
GHOST_TSuccess
Definition GHOST_Types.h:80
@ GHOST_kFailure
Definition GHOST_Types.h:80
@ GHOST_kSuccess
Definition GHOST_Types.h:80
@ GHOST_gpuStereoVisual
Definition GHOST_Types.h:69
@ GHOST_gpuDebugContext
Definition GHOST_Types.h:70
GHOST_TConsoleWindowState
unsigned long long int uint64_t
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &) const override
char * getClipboard(bool) const override
GHOST_TSuccess init() override
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpuSettings) override
bool processEvents(bool) override
uint64_t getMilliSeconds() const override
void getMainDisplayDimensions(uint32_t &, uint32_t &) const override
void getAllDisplayDimensions(uint32_t &, uint32_t &) const override
GHOST_TCapabilityFlag getCapabilities() const override
GHOST_IWindow * getWindowUnderCursor(int32_t, int32_t) override
uint8_t getNumDisplays() const override
GHOST_TSuccess setCursorPosition(int32_t, int32_t) override
~GHOST_SystemHeadless() override=default
GHOST_TSuccess getButtons(GHOST_Buttons &) const override
bool setConsoleWindowState(GHOST_TConsoleWindowState) override
GHOST_TSuccess disposeContext(GHOST_IContext *context) override
void putClipboard(const char *, bool) const override
GHOST_TSuccess getCursorPosition(int32_t &, int32_t &) const override
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpuSettings, const bool, const bool, const GHOST_IWindow *parentWindow) override
GHOST_TSuccess init() override
uint top
static ulong state[N]
static int left
GHOST_TDrawingContextType context_type
GHOST_GPUDevice preferred_device