I am trying to get Irrlicht to be using a window I created using SDL2 under X11, but it fails within Irrlicht at GLXCreateWindow
.
On my box the following MCVE reproduces the issue:
#include <irrlicht/irrlicht.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
int main()
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("Hello",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
800, 600,
SDL_WINDOW_OPENGL);
if (!window)
{
return false;
}
SDL_SysWMinfo wm_info;
SDL_VERSION(&wm_info.version);
if (!SDL_GetWindowWMInfo(window, &wm_info))
{
return false;
}
irr::SIrrlichtCreationParameters params;
params.DeviceType = irr::EIDT_BEST;
params.DriverType = irr::video::EDT_OPENGL;
params.WindowSize = { 800, 600 };
params.WindowId = reinterpret_cast<void*>(wm_info.info.x11.window);
irr::createDeviceEx(params);
}
This results in the following error:
Irrlicht Engine version 1.9.0
Linux 4.16.16-1-ck #1 SMP PREEMPT Tue Jun 19 20:30:54 CEST 2018 x86_64
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 152 (GLX)
Minor opcode of failed request: 31 (X_GLXCreateWindow)
Serial number of failed request: 364
Current serial number in output stream: 365
If you comment out the WindowId
set Irrlicht will create its own window, which succeeds.
Irrlicht Engine version 1.9.0
Linux 4.16.16-1-ck #1 SMP PREEMPT Tue Jun 19 20:30:54 CEST 2018 x86_64
Using renderer: OpenGL 4.4
Radeon RX 580 Series (POLARIS10, DRM 3.23.0, 4.16.16-1-ck, LLVM 7.0.0): X.Org
OpenGL driver version is 1.2 or better.
GLSL version: 4.4
I tried to troubleshoot the issue but unfortunately I have no idea how to debug X11 errors like those. However, as per the docs, "BadMatch is generated if win was not created with a visual that corresponds to config, or if config
does not support rendering to windows (i.e., GLX_DRAWABLE_TYPE
does not contain GLX_WINDOW_BIT
)."
Some of my attempts included, to no avail:
- Setting
params.Bits
to16
,24
and32
. - Using Irrlicht 1.7 and 1.9.0 SVN (built as of today).
- Setting the Irrlicht render backend to software rendering works, as it doesn't try to create a GLX context.
- Setting
params.LoggingLevel = ELL_DEBUG;
as it would hopefully print useful info on the problem, but doesn't. - Setting
params.IgnoreInput = true;
. - Toggling the
SDL_WINDOW_OPENGL
flag inSDL_CreateWindow
. - Using
apitrace
to try to figure out details on errors, or at least obviously invalid parameters, but I couldn't find it out, especially as it doesn't seem to simply track X11 calls, only GLX and OpenGL calls.
GLXWindow
on top of presented window with different visual id than initial window that SDL have created. I honestly have no idea why it even attempts to create said window (except when maybe window wasn't created with GL capabilities), creating context is enough (and even that probably should be delegated to SDL), and I see no possible fix without modifying irrlicht source. As a proof of concept, you can get visual id it tries to use in debugger or printf, andexport SDL_VIDEO_X11_VISUALID
to that value. – VeronUseGLXWindow
inCIrrDeviceLinux::createWindow()
to force it to create context instead of creating window. Not sure if it is rarely tested part or actually intended thing. – Veron