Results 1 to 3 of 3

Thread: Rendering to 4 different windows

  1. #1

    Default Rendering to 4 different windows

    Hi everyone,
    I am working on an OpenGL project where I am rendering my scene from 4 different views (perspective, top, front and side). Right now, I am using 4 camera settings and render the scene once per frame with each camera , each camera drawing to a quarter of the viewport, i.e. it's a quadsplit.
    That is working perfectly but I was wondering whether it is possible to render each view into a different window (e.g. QWindow) so that I can resize and move them around completely independent of each other.
    Since I am loading and changing massive amounts of data during runtime, I don't want to create 4 running instances with equal data and different camera settings, but to keep one program which simply renders to 4 different windows using different camera settings.
    Does anyone know whether there is an easy way to set that up?

    I would really appreciate your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rendering to 4 different windows

    You can share the OpenGL context between different windows so that all data, including GL programs are available to all four windows. Then you just render what you want four times using different matrices (or other settings).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Default Re: Rendering to 4 different windows

    Thanks for the fast answer.
    I have been trying to get that to work. It seems like Qt5 has more options than qt 4.8. Unfortunately I have to use 4.8 for my program because it must interact with several 4.8 widgets.

    Is there any good example showing how to share contexts? I can't find any.

    I tried to set up a simple program but I cannot get it to work. I created a simple class (GLWidget) deriving from QGLWidget. It loads in shaders and only draws a single triangle. In my main.cpp, I was trying to create a new QGLWidget from my context which should also show the triangle.

    The code:

    -------------------------------------------------------------
    #include <QApplication>
    #include "glwidget.h"
    #include "QGLContext"
    #include <iostream>
    using namespace std;


    int main(int argc, char *argv[])
    {
    QApplication *a = new QApplication(argc, argv);
    GLWidget *myW = new GLWidget;
    myW->show();


    QGLContext *myContext = new QGLContext(myW->context()->format(), myW->context()->device());
    cout << "Create: " << myContext->create(myW->context()) << endl;

    QGLWidget *test = new QGLWidget(myContext, 0,0,0);

    cout << "Valid: " << myW->context()->isValid() << " " << test->context()->isValid() << endl;

    test->show();


    return a->exec();
    }
    -------------------------------------------------------------

    Unfortunately my test widget only shows a white screen and I get the following output:

    Create: 1
    QGLWidget::setContext: Context must refer to this widget
    Valid: 1 0


    Do you happen to know what I need to change in order to make it work?
    Thanks a lot

Similar Threads

  1. Replies: 0
    Last Post: 10th October 2013, 07:04
  2. Problems rendering small border-image in Windows
    By droneone in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2013, 16:05
  3. Replies: 8
    Last Post: 7th November 2012, 19:20
  4. Painting on top of real-time rendering windows
    By haji in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2011, 21:02
  5. PDF rendering
    By fober in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2011, 19:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.