Trying to render QML user interface into the SDL window.
There is an SDL 1.2 game that creates an OpenGL context via SDL_SetVideoMode
with SDL_OPENGLBLIT
flag.
The idea is to get the OpenGL context handle and pass it to the QQuickRenderControl that will draw the GUI over the scene.
Getting the native context (example for X11):
GLXContext currentContext;
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
if (SDL_GetWMInfo(&wmInfo))
{
Display *display = wmInfo.info.x11.gfxdisplay;
currentContext = glXGetCurrentContext();
assert(currentContext);
}
Adopting it in Qt:
QOpenGLContext *ctx = new QOpenGLContext;
ctx->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(
QGLXNativeContext(currentContext, wmInfo.info.x11.display, wmInfo.info.x11.window)
));
And creating the QQuickRenderControl:
QQuickRenderControl *renderControl = new QQuickRenderControl;
renderControl->initialize(ctx);
But QQuickRenderControl can't start without QWindow:
QQuickRenderControl::initialize called with no associated window
Also ctx->isValid()
and ctx->makeCurrent()
return false.
How to make it work?