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