2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* gl_manager_x11.cpp */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
#include "gl_manager_x11.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-06-08 14:51:32 +02:00
|
|
|
#if defined(X11_ENABLED) && defined(GLES3_ENABLED)
|
|
|
|
|
|
|
|
#include "thirdparty/glad/glad/glx.h"
|
2020-11-18 19:11:30 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
|
|
|
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
|
|
|
|
|
|
|
typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *);
|
|
|
|
|
2023-05-11 12:32:23 +02:00
|
|
|
// To prevent shadowing warnings
|
|
|
|
#undef glXCreateContextAttribsARB
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
struct GLManager_X11_Private {
|
2014-02-10 02:10:30 +01:00
|
|
|
::GLXContext glx_context;
|
|
|
|
};
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
GLManager_X11::GLDisplay::~GLDisplay() {
|
|
|
|
if (context) {
|
|
|
|
//release_current();
|
|
|
|
glXDestroyContext(x11_display, context->glx_context);
|
|
|
|
memdelete(context);
|
|
|
|
context = nullptr;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2015-10-25 15:15:56 +01:00
|
|
|
|
2016-11-23 00:51:56 +01:00
|
|
|
static bool ctxErrorOccurred = false;
|
|
|
|
static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
|
|
|
|
ctxErrorOccurred = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
int GLManager_X11::_find_or_create_display(Display *p_x11_display) {
|
|
|
|
for (unsigned int n = 0; n < _displays.size(); n++) {
|
|
|
|
const GLDisplay &d = _displays[n];
|
2022-01-27 17:34:33 +01:00
|
|
|
if (d.x11_display == p_x11_display) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return n;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2017-08-18 20:39:51 +02:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
|
|
|
|
// create
|
|
|
|
GLDisplay d_temp;
|
|
|
|
d_temp.x11_display = p_x11_display;
|
|
|
|
_displays.push_back(d_temp);
|
|
|
|
int new_display_id = _displays.size() - 1;
|
|
|
|
|
|
|
|
// create context
|
|
|
|
GLDisplay &d = _displays[new_display_id];
|
|
|
|
|
|
|
|
d.context = memnew(GLManager_X11_Private);
|
2022-01-27 17:34:33 +01:00
|
|
|
d.context->glx_context = nullptr;
|
2020-11-18 19:11:30 +01:00
|
|
|
|
2023-03-07 18:24:05 +01:00
|
|
|
Error err = _create_context(d);
|
|
|
|
|
|
|
|
if (err != OK) {
|
|
|
|
_displays.remove_at(new_display_id);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
return new_display_id;
|
2017-08-18 20:39:51 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
Error GLManager_X11::_create_context(GLDisplay &gl_display) {
|
|
|
|
// some aliases
|
|
|
|
::Display *x11_display = gl_display.x11_display;
|
|
|
|
|
2017-01-14 12:26:56 +01:00
|
|
|
//const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2017-08-21 21:15:36 +02:00
|
|
|
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte *)"glXCreateContextAttribsARB");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-09-09 17:46:44 +02:00
|
|
|
ERR_FAIL_NULL_V(glXCreateContextAttribsARB, ERR_UNCONFIGURED);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
static int visual_attribs[] = {
|
|
|
|
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
|
|
|
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
|
|
|
GLX_DOUBLEBUFFER, true,
|
|
|
|
GLX_RED_SIZE, 1,
|
|
|
|
GLX_GREEN_SIZE, 1,
|
|
|
|
GLX_BLUE_SIZE, 1,
|
2014-05-05 23:01:08 +02:00
|
|
|
GLX_DEPTH_SIZE, 24,
|
2016-03-09 00:00:52 +01:00
|
|
|
None
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-12-10 19:38:26 +01:00
|
|
|
static int visual_attribs_layered[] = {
|
|
|
|
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
|
|
|
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
|
|
|
GLX_DOUBLEBUFFER, true,
|
|
|
|
GLX_RED_SIZE, 8,
|
|
|
|
GLX_GREEN_SIZE, 8,
|
|
|
|
GLX_BLUE_SIZE, 8,
|
|
|
|
GLX_ALPHA_SIZE, 8,
|
|
|
|
GLX_DEPTH_SIZE, 24,
|
|
|
|
None
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
int fbcount;
|
2022-01-27 17:34:33 +01:00
|
|
|
GLXFBConfig fbconfig = nullptr;
|
2020-04-02 01:20:12 +02:00
|
|
|
XVisualInfo *vi = nullptr;
|
2017-12-10 19:38:26 +01:00
|
|
|
|
|
|
|
if (OS::get_singleton()->is_layered_allowed()) {
|
|
|
|
GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs_layered, &fbcount);
|
2023-09-09 17:46:44 +02:00
|
|
|
ERR_FAIL_NULL_V(fbc, ERR_UNCONFIGURED);
|
2017-12-10 19:38:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < fbcount; i++) {
|
|
|
|
vi = (XVisualInfo *)glXGetVisualFromFBConfig(x11_display, fbc[i]);
|
2022-01-27 17:34:33 +01:00
|
|
|
if (!vi) {
|
2017-12-10 19:38:26 +01:00
|
|
|
continue;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2017-12-10 19:38:26 +01:00
|
|
|
|
|
|
|
XRenderPictFormat *pict_format = XRenderFindVisualFormat(x11_display, vi->visual);
|
|
|
|
if (!pict_format) {
|
|
|
|
XFree(vi);
|
2020-04-02 01:20:12 +02:00
|
|
|
vi = nullptr;
|
2017-12-10 19:38:26 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fbconfig = fbc[i];
|
|
|
|
if (pict_format->direct.alphaMask > 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 16:23:54 +02:00
|
|
|
XFree(fbc);
|
2020-11-18 19:11:30 +01:00
|
|
|
|
2023-09-09 17:46:44 +02:00
|
|
|
ERR_FAIL_NULL_V(fbconfig, ERR_UNCONFIGURED);
|
2017-12-10 19:38:26 +01:00
|
|
|
} else {
|
|
|
|
GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs, &fbcount);
|
2023-09-09 17:46:44 +02:00
|
|
|
ERR_FAIL_NULL_V(fbc, ERR_UNCONFIGURED);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-12-10 19:38:26 +01:00
|
|
|
vi = glXGetVisualFromFBConfig(x11_display, fbc[0]);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-12-10 19:38:26 +01:00
|
|
|
fbconfig = fbc[0];
|
2019-07-02 16:23:54 +02:00
|
|
|
XFree(fbc);
|
2017-12-10 19:38:26 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-08-25 00:04:25 +02:00
|
|
|
int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&ctxErrorHandler);
|
2016-11-23 00:51:56 +01:00
|
|
|
|
2017-12-04 13:41:34 +01:00
|
|
|
switch (context_type) {
|
2021-09-27 01:07:10 +02:00
|
|
|
case GLES_3_0_COMPATIBLE: {
|
|
|
|
static int context_attribs[] = {
|
|
|
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
|
|
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
2021-10-26 17:18:39 +02:00
|
|
|
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
2021-09-27 01:07:10 +02:00
|
|
|
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*|GLX_CONTEXT_DEBUG_BIT_ARB*/,
|
|
|
|
None
|
|
|
|
};
|
|
|
|
|
|
|
|
gl_display.context->glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, nullptr, true, context_attribs);
|
|
|
|
ERR_FAIL_COND_V(ctxErrorOccurred || !gl_display.context->glx_context, ERR_UNCONFIGURED);
|
2017-12-04 13:41:34 +01:00
|
|
|
} break;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2016-11-23 00:51:56 +01:00
|
|
|
XSync(x11_display, False);
|
|
|
|
XSetErrorHandler(oldHandler);
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
// make our own copy of the vi data
|
|
|
|
// for later creating windows using this display
|
|
|
|
if (vi) {
|
|
|
|
gl_display.x_vi = *vi;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-10-25 15:15:56 +01:00
|
|
|
XFree(vi);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2023-03-07 18:24:05 +01:00
|
|
|
XVisualInfo GLManager_X11::get_vi(Display *p_display, Error &r_error) {
|
|
|
|
int display_id = _find_or_create_display(p_display);
|
|
|
|
if (display_id < 0) {
|
|
|
|
r_error = FAILED;
|
|
|
|
return XVisualInfo();
|
|
|
|
}
|
|
|
|
r_error = OK;
|
|
|
|
return _displays[display_id].x_vi;
|
2022-09-03 12:40:53 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
Error GLManager_X11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) {
|
|
|
|
// make sure vector is big enough...
|
|
|
|
// we can mirror the external vector, it is simpler
|
|
|
|
// to keep the IDs identical for fast lookup
|
|
|
|
if (p_window_id >= (int)_windows.size()) {
|
|
|
|
_windows.resize(p_window_id + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLWindow &win = _windows[p_window_id];
|
|
|
|
win.in_use = true;
|
|
|
|
win.window_id = p_window_id;
|
|
|
|
win.width = p_width;
|
|
|
|
win.height = p_height;
|
|
|
|
win.x11_window = p_window;
|
|
|
|
win.gldisplay_id = _find_or_create_display(p_display);
|
|
|
|
|
2023-03-07 18:24:05 +01:00
|
|
|
if (win.gldisplay_id == -1) {
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
// the display could be invalid .. check NYI
|
|
|
|
GLDisplay &gl_display = _displays[win.gldisplay_id];
|
|
|
|
::Display *x11_display = gl_display.x11_display;
|
|
|
|
::Window &x11_window = win.x11_window;
|
|
|
|
|
|
|
|
if (!glXMakeCurrent(x11_display, x11_window, gl_display.context->glx_context)) {
|
|
|
|
ERR_PRINT("glXMakeCurrent failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
_internal_set_current_window(&win);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLManager_X11::_internal_set_current_window(GLWindow *p_win) {
|
|
|
|
_current_window = p_win;
|
|
|
|
|
|
|
|
// quick access to x info
|
|
|
|
_x_windisp.x11_window = _current_window->x11_window;
|
|
|
|
const GLDisplay &disp = get_current_display();
|
|
|
|
_x_windisp.x11_display = disp.x11_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLManager_X11::window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height) {
|
|
|
|
get_window(p_window_id).width = p_width;
|
|
|
|
get_window(p_window_id).height = p_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLManager_X11::window_destroy(DisplayServer::WindowID p_window_id) {
|
|
|
|
GLWindow &win = get_window(p_window_id);
|
|
|
|
win.in_use = false;
|
|
|
|
|
|
|
|
if (_current_window == &win) {
|
|
|
|
_current_window = nullptr;
|
|
|
|
_x_windisp.x11_display = nullptr;
|
|
|
|
_x_windisp.x11_window = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLManager_X11::release_current() {
|
2022-01-27 17:34:33 +01:00
|
|
|
if (!_current_window) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2022-09-12 23:57:11 +02:00
|
|
|
|
|
|
|
if (!glXMakeCurrent(_x_windisp.x11_display, None, nullptr)) {
|
|
|
|
ERR_PRINT("glXMakeCurrent failed");
|
|
|
|
}
|
|
|
|
_current_window = nullptr;
|
2020-11-18 19:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLManager_X11::window_make_current(DisplayServer::WindowID p_window_id) {
|
2022-01-27 17:34:33 +01:00
|
|
|
if (p_window_id == -1) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
|
|
|
|
GLWindow &win = _windows[p_window_id];
|
2022-01-27 17:34:33 +01:00
|
|
|
if (!win.in_use) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
|
|
|
|
// noop
|
2022-01-27 17:34:33 +01:00
|
|
|
if (&win == _current_window) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
|
|
|
|
const GLDisplay &disp = get_display(win.gldisplay_id);
|
|
|
|
|
2022-09-12 23:57:11 +02:00
|
|
|
if (!glXMakeCurrent(disp.x11_display, win.x11_window, disp.context->glx_context)) {
|
|
|
|
ERR_PRINT("glXMakeCurrent failed");
|
|
|
|
}
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
_internal_set_current_window(&win);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2015-10-25 15:15:56 +01:00
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
void GLManager_X11::make_current() {
|
2022-01-27 17:34:33 +01:00
|
|
|
if (!_current_window) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
if (!_current_window->in_use) {
|
|
|
|
WARN_PRINT("current window not in use!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const GLDisplay &disp = get_current_display();
|
2022-09-12 23:57:11 +02:00
|
|
|
if (!glXMakeCurrent(_x_windisp.x11_display, _x_windisp.x11_window, disp.context->glx_context)) {
|
|
|
|
ERR_PRINT("glXMakeCurrent failed");
|
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
}
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
void GLManager_X11::swap_buffers() {
|
2022-01-27 17:34:33 +01:00
|
|
|
if (!_current_window) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
if (!_current_window->in_use) {
|
|
|
|
WARN_PRINT("current window not in use!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:23:36 +02:00
|
|
|
// On X11, when enabled, transparency is always active, so clear alpha manually.
|
2022-09-03 12:40:53 +02:00
|
|
|
if (OS::get_singleton()->is_layered_allowed()) {
|
|
|
|
if (!DisplayServer::get_singleton()->window_get_flag(DisplayServer::WINDOW_FLAG_TRANSPARENT, _current_window->window_id)) {
|
|
|
|
glColorMask(false, false, false, true);
|
|
|
|
glClearColor(0, 0, 0, 1);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
glColorMask(true, true, true, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
glXSwapBuffers(_x_windisp.x11_display, _x_windisp.x11_window);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2022-11-29 12:03:06 +01:00
|
|
|
Error GLManager_X11::initialize(Display *p_display) {
|
|
|
|
if (!gladLoaderLoadGLX(p_display, XScreenNumberOfScreen(XDefaultScreenOfDisplay(p_display)))) {
|
2022-11-12 21:46:16 +01:00
|
|
|
return ERR_CANT_CREATE;
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLManager_X11::set_use_vsync(bool p_use) {
|
|
|
|
// force vsync in the editor for now, as a safety measure
|
|
|
|
bool is_editor = Engine::get_singleton()->is_editor_hint();
|
|
|
|
if (is_editor) {
|
|
|
|
p_use = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we need an active window to get a display to set the vsync
|
2022-01-27 17:34:33 +01:00
|
|
|
if (!_current_window) {
|
2020-11-18 19:11:30 +01:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2020-11-18 19:11:30 +01:00
|
|
|
const GLDisplay &disp = get_current_display();
|
|
|
|
|
2016-06-07 00:19:01 +02:00
|
|
|
int val = p_use ? 1 : 0;
|
2022-11-12 21:46:16 +01:00
|
|
|
if (GLAD_GLX_MESA_swap_control) {
|
2016-06-07 00:19:01 +02:00
|
|
|
glXSwapIntervalMESA(val);
|
2022-11-12 21:46:16 +01:00
|
|
|
} else if (GLAD_GLX_SGI_swap_control) {
|
2016-06-07 00:19:01 +02:00
|
|
|
glXSwapIntervalSGI(val);
|
2022-11-12 21:46:16 +01:00
|
|
|
} else if (GLAD_GLX_EXT_swap_control) {
|
2016-06-07 00:19:01 +02:00
|
|
|
GLXDrawable drawable = glXGetCurrentDrawable();
|
2020-11-18 19:11:30 +01:00
|
|
|
glXSwapIntervalEXT(disp.x11_display, drawable, val);
|
2022-01-27 17:34:33 +01:00
|
|
|
} else {
|
2016-06-07 00:19:01 +02:00
|
|
|
return;
|
2022-01-27 17:34:33 +01:00
|
|
|
}
|
2016-06-07 00:19:01 +02:00
|
|
|
use_vsync = p_use;
|
2016-06-06 00:14:33 +02:00
|
|
|
}
|
2020-05-14 14:29:06 +02:00
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
bool GLManager_X11::is_using_vsync() const {
|
2016-06-07 00:19:01 +02:00
|
|
|
return use_vsync;
|
2016-06-06 00:14:33 +02:00
|
|
|
}
|
|
|
|
|
2022-10-23 03:29:15 +02:00
|
|
|
void *GLManager_X11::get_glx_context(DisplayServer::WindowID p_window_id) {
|
|
|
|
if (p_window_id == -1) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const GLWindow &win = _windows[p_window_id];
|
|
|
|
const GLDisplay &disp = get_display(win.gldisplay_id);
|
|
|
|
|
|
|
|
return (void *)disp.context->glx_context;
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
GLManager_X11::GLManager_X11(const Vector2i &p_size, ContextType p_context_type) {
|
2017-12-04 13:41:34 +01:00
|
|
|
context_type = p_context_type;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
double_buffer = false;
|
|
|
|
direct_render = false;
|
|
|
|
glx_minor = glx_major = 0;
|
2016-06-06 00:14:33 +02:00
|
|
|
use_vsync = false;
|
2020-11-18 19:11:30 +01:00
|
|
|
_current_window = nullptr;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2020-11-18 19:11:30 +01:00
|
|
|
GLManager_X11::~GLManager_X11() {
|
2015-10-25 15:15:56 +01:00
|
|
|
release_current();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2023-06-08 14:51:32 +02:00
|
|
|
#endif // X11_ENABLED && GLES3_ENABLED
|