24#ifdef GPUCA_BUILD_EVENT_DISPLAY_X11
27#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLFW
30#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
33#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
50#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
71 retVal = me->FrontendMain();
72 }
catch (
const std::exception& e) {
73 GPUError(
"Error in display frontend: %s", e.what());
76 if (
retVal && me->mDisplay->mInitResult == 0) {
77 me->InitDisplay(
true);
79 return ((
void*)(
size_t)
retVal);
85 const auto now = std::chrono::steady_clock::now();
91 const auto period = std::chrono::duration_cast<std::chrono::steady_clock::duration>(std::chrono::duration<double>(1. / cfg.fpsRate));
101 const GPUSettingsDisplayHeavy oldCfgH =
mDisplay->mCfgH;
102 const GPUSettingsDisplayLight oldCfgL =
mDisplay->mCfgL;
103 const GPUSettingsDisplayRenderer oldCfgR =
mDisplay->mCfgR;
104 bool changes = HandleExternalGUIKeys();
107 std::optional<GPUDisplayGUIChannel::Update> update;
110 update = std::exchange(
mGUIChannel->update, std::nullopt);
114 for (int32_t
key : update->keys) {
117 if (update->lineWidth) {
118 mDisplay->mCfgL.lineWidth = *update->lineWidth;
134 mGUIChannel->displayProcessingCurrentUpdate =
false;
145bool GPUDisplayFrontend::HandleExternalGUIKeys()
179#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
189#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
191 mGUIChannel = std::make_unique<GPUDisplayGUIChannel>();
194 if (!
mGUI->isRunning()) {
215#ifdef GPUCA_BUILD_EVENT_DISPLAY_QT
223#if !defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
224 if (strcmp(
type,
"glfw") == 0 || strcmp(
type,
"auto") == 0) {
229 if (strcmp(
type,
"windows") == 0 || strcmp(
type,
"auto") == 0) {
232#elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11)
233 if (strcmp(
type,
"x11") == 0 || strcmp(
type,
"auto") == 0) {
237#if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW)
238 if (strcmp(
type,
"glfw") == 0 || strcmp(
type,
"auto") == 0) {
242#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
243 if (strcmp(
type,
"wayland") == 0 || (strcmp(
type,
"auto") == 0 && getenv(
"XDG_SESSION_TYPE") && strcmp(getenv(
"XDG_SESSION_TYPE"),
"wayland") == 0)) {
247#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
248 if (strcmp(
type,
"glut") == 0 || strcmp(
type,
"auto") == 0) {
252 if (strcmp(
type,
"none") == 0) {
255 GPUError(
"Requested frontend not available");
267 mDisplay->mCfgR.fullScreen = fullScreen;
268 mDisplay->mCfgR.maximized = maximized;
273 std::fill(std::begin(
mKeys), std::end(
mKeys),
false);
302 GPUError(
"Coult not Create frontend Thread...");
307 if ((hThread = CreateThread(
nullptr,
nullptr, &OpenGLWrapper,
this,
nullptr,
nullptr)) ==
nullptr) {
308 GPUError(
"Coult not Create GL Thread...");
326 std::this_thread::sleep_for(std::chrono::microseconds(10000));
int32_t fpsLimitMode() const
std::unique_ptr< GPUDisplayGUIWrapper > mGUI
virtual void StopDisplayA()
void HandleExternalGUISignals()
int32_t & drawTextFontSize()
~GPUDisplayFrontend() override
std::mutex mExternalGUIKeyMutex
static void * FrontendThreadWrapper(void *)
bool HasExternalGUISignals() const
void HandleKey(uint8_t key)
std::unique_ptr< GPUDisplayGUIChannel > mGUIChannel
volatile int32_t mDisplayControl
virtual void ToggleMaximized(bool set)=0
std::mutex mExitStateMutex
volatile int32_t mNeedUpdate
static GPUDisplayFrontend * getFrontend(const char *type)
void ResizeScene(int32_t width, int32_t height)
static constexpr const char * DISPLAY_WINDOW_NAME
void StopDisplay() override
void setWindowState(bool fullScreen, bool maximized)
void sendExternalGUIKey(int32_t v) override
std::vector< int32_t > mExternalGUIKeys
GPUDisplayBackend * mBackend
int32_t InitDisplay(bool initFailure=false)
bool vsyncEnabled() const
GPUDisplayBackend * backend()
void applyInitialWindowState()
std::chrono::steady_clock::time_point mNextFrameTime
volatile bool mDisplayRunning
virtual void SwitchFullscreen(bool set)=0
void checkAndApplyConfigChanges(const GPUSettingsDisplayHeavy &oldCfgH, const GPUSettingsDisplayLight &oldCfgL, const GPUSettingsDisplayRenderer &oldCfgR)
const GPUSettingsDisplayRenderer & cfgR() const
int32_t & drawTextFontSize()
void HandleExternalGUIKey(int32_t key)
const GPUSettingsDisplay & cfg() const
void HandleKey(uint8_t key, bool doNotHandleConfigChanges=false)
int32_t InitDisplay(bool initFailure=false)
GPUDisplayBackend * backend() const
void ResizeScene(int32_t width, int32_t height, bool init=false)
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum GLenum type
GPUDisplayFrontend * createGPUDisplayFrontendWayland()