c++ - Trying to access QGLWidget from entire application -


What I'm trying to do basically is a QGLWidget QGLWidget < / Code> derived class) into a QMainWindow , and then access the rendering context of QGLWidget from anywhere in my QTCreator program anywhere on the naked open GL call Was able to.

I have tried:

1) Creating a subclass of OGLWidget and creating it in singleton, and Then the singletons are trying to subclass class "OGL widget" I thought it would give me access to the same rendering context which was using OGLVDT singleton but it does not work.

2) QGLWidget (QWidget * parent, QGLWidget * shared, QT :: WindowFlags) by using Constructor. For this, I tried to put a singleton object on a QGL widget and then pasting it into this creator said that when I was subclassing QGLWidget in another category named "Display". I tried to call each class on the merchandise before OpenGL call but only the original singletons would have to attract. I have also seen sharing and it has come true.

First of all, although the signal \ slots are a powerful and awful feature of Qt, I never use them Will present and order problems in my rendering routine due to additional overhead; In addition to the latter, besides this, it is not necessary to do this in the way you propose, in this way, your idea of ​​scattering the rendering routine on your project is a bad idea in my opinion what I do in my own project:

My derived QGLWidget is the owner of a renderer class which has been implemented as singleton. It contains all the OpenGL calls in some functions. I have created a system where all the drawables get from the same base class. When I want to render, I am creating a render queue which I applied with a custom sort function as a priority_queue . When it's time to provide a frame, I just keep poppins' and rendering until the queue is empty. By doing this with an event-driven render system, keeping the right render order will probably lead to you crazy.

For completeness, my (simplified) QGLWidget definition:

  #include & lt; QtOpenGL / QGLWidget & gt; #include "global.h" #include "renderer.h" / ** * derivation of QGLWidget. * / Class Engine: Public QGLWidget {Q_OBJECT Private: Renderer * Renderer; Private Slots: Zero Render Timeout (); // is based on my render-loop timer; Tap (QMouseEvent * qme); Zero performance (QMouseEvent * qme); Protected: zero initializeGL (); Zero resize GL (int wad, int h); / * For debugging, I use the couponer for overlay drawing, * hence I can not use PentGL * / zero paintage (Coupent Event * Event); Zero mousepress event (QMouseEvent * qme); Zero mouthwave event (QMouseEvent * qme); Public: engine (QWidget * guardian = 0); ~ Engine (); Signal: zero tacha orchard (CubicIevent * QM); Zero shrink (QMouseEvent * qme); };    

Comments