Propogate errors when creating an OpenGL context fails in X11

This commit is contained in:
clayjohn 2023-03-07 09:24:05 -08:00
parent 3695fe5a57
commit e7ea3ef531
3 changed files with 23 additions and 6 deletions

View file

@ -4873,7 +4873,9 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
#ifdef GLES3_ENABLED
if (gl_manager) {
visualInfo = gl_manager->get_vi(x11_display);
Error err;
visualInfo = gl_manager->get_vi(x11_display, err);
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't acquire visual info from display.");
vi_selected = true;
}
#endif

View file

@ -83,8 +83,13 @@ int GLManager_X11::_find_or_create_display(Display *p_x11_display) {
d.context = memnew(GLManager_X11_Private);
d.context->glx_context = nullptr;
//Error err = _create_context(d);
_create_context(d);
Error err = _create_context(d);
if (err != OK) {
_displays.remove_at(new_display_id);
return -1;
}
return new_display_id;
}
@ -191,8 +196,14 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) {
return OK;
}
XVisualInfo GLManager_X11::get_vi(Display *p_display) {
return _displays[_find_or_create_display(p_display)].x_vi;
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;
}
Error GLManager_X11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) {
@ -211,6 +222,10 @@ Error GLManager_X11::window_create(DisplayServer::WindowID p_window_id, ::Window
win.x11_window = p_window;
win.gldisplay_id = _find_or_create_display(p_display);
if (win.gldisplay_id == -1) {
return FAILED;
}
// the display could be invalid .. check NYI
GLDisplay &gl_display = _displays[win.gldisplay_id];
::Display *x11_display = gl_display.x11_display;

View file

@ -114,7 +114,7 @@ private:
Error _create_context(GLDisplay &gl_display);
public:
XVisualInfo get_vi(Display *p_display);
XVisualInfo get_vi(Display *p_display, Error &r_error);
Error window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height);
void window_destroy(DisplayServer::WindowID p_window_id);
void window_resize(DisplayServer::WindowID p_window_id, int p_width, int p_height);