Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, although signals\slots are a powerful and awesome feature of Qt I would never use them in my rendering routines because of the added overhead and render order problems; especially the latter. Besides, it's not necessary to do it the way you propose. Thus, your idea of scattering the rendering routines all over your project is a very bad idea in my opinion. What I do in my own project is the following:</p> <p>My derived <code>QGLWidget</code> owns a <code>Renderer</code> class that's implemented as a Singleton. It contains all of the OpenGl calls in a few functions. I've created a system where everything that's drawable derives from the same base class. When I want to render, I build a render queue which I implemented as a <code>priority_queue</code> with custom sort function. When It's time for rendering a frame I just keep poppin' and rendering until the queue is empty. Doing this with an event driven render system, while maintaining correct render order would probably drive you insane.</p> <p>For completeness, my (simplified) QGLWidget definition:</p> <pre><code>#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: void renderTimeout(); // my render-loop is timer based void onTap(QMouseEvent* qme); void onMove(QMouseEvent* qme); protected: void initializeGL(); void resizeGL(int w, int h); /* for debugging I use QPainter for drawing overlays, * so I can't use PaintGL */ void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent* qme); void mouseMoveEvent(QMouseEvent* qme); public: Engine( QWidget* parent = 0 ); ~Engine(); signals: void tapOccurred(QMouseEvent* qme); void moveOccurred(QMouseEvent* qme); }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload