Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. QtQuick into an SDL2 window

QtQuick into an SDL2 window

Scheduled Pinned Locked Moved Unsolved Game Development
qtquicksdl2
4 Posts 2 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Illogica
    wrote on 17 Jun 2016, 14:46 last edited by
    #1

    Hello gentlemen

    Given an existing SDL_GLContext, what's the best approach to render QtQuick components into it?
    I see there's a QQuickRenderControl class which I can initialize with a QOpenGLContext, but I fail to see how to convert the SDL_GLContext into a QOpenGLContext.

    ? 1 Reply Last reply 17 Jun 2016, 14:55
    0
    • I Illogica
      17 Jun 2016, 14:46

      Hello gentlemen

      Given an existing SDL_GLContext, what's the best approach to render QtQuick components into it?
      I see there's a QQuickRenderControl class which I can initialize with a QOpenGLContext, but I fail to see how to convert the SDL_GLContext into a QOpenGLContext.

      ? Offline
      ? Offline
      A Former User
      wrote on 17 Jun 2016, 14:55 last edited by
      #2

      @Illogica Hi! There is this nice Scene Graph - OpenGL Under QML example; might be helpful.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Illogica
        wrote on 17 Jun 2016, 20:30 last edited by Illogica
        #3

        Thanks @Wieland for the response,
        all the examples I see show how to render into a Qt widget.
        What I want to do, is render QtQuick components inside the SDL window of my game engine.
        I found an example of this here but it's lacking a real implementation.
        It seems to me I need to use QOpenGLContext::setNativeHandle() passing it the GL context of my SDL window, but it would be extremely useful seeing a (cross platform) code example.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Illogica
          wrote on 19 Jun 2016, 16:59 last edited by Illogica
          #4

          According to the QWGLNativeContext documentation and some online examples, I set up this little function to try and initialize a QOpenGLContext from an existing and already initialized SDL2 context:

          void QtHooks::initQtOpenGlContext(SDL_Window *screen)
          {
              assert(screen);
              QOpenGLContext *context = new QOpenGLContext;
              SDL_SysWMinfo sysInfo;
              SDL_VERSION(&sysInfo.version);
              SDL_GetWindowWMInfo(screen, &sysInfo);
              HGLRC currentContext = wglGetCurrentContext();
              HWND currentWindow = sysInfo.info.win.window;
              assert(currentContext);
              assert(currentWindow);
          
              QWGLNativeContext nativeContext(currentContext, currentWindow);
              context->setNativeHandle(QVariant::fromValue(nativeContext));
          
              assert(qtContext->isValid());   // <<-- this line always fails 
              context->create();       // if i remove the previous assert, this line kills the application very badly
          }
          

          This little example always fails in the last two lines. Am I missing something?

          1 Reply Last reply
          0

          4/4

          19 Jun 2016, 16:59

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved