qmlfrontend/gameview.h
author unc0rr
Sun, 07 Jan 2018 01:21:42 +0100
branchqmlfrontend
changeset 12883 adb1fccc706a
parent 12876 b544bbbd0696
child 12890 9c259fb4d405
permissions -rw-r--r--
- ResizeWindow function to pass engine new window size - Remove TabBar to leave more space at the bottom of the screen - ifdef GL_ES in shaders

#ifndef GAMEVIEW_H
#define GAMEVIEW_H

#include <QQuickItem>

#include <QtGui/QOpenGLFunctions>
#include <QtGui/QOpenGLShaderProgram>

class GameViewRenderer : public QObject, protected QOpenGLFunctions {
    Q_OBJECT
public:
    GameViewRenderer()
        : m_delta(0)
    {
    }
    ~GameViewRenderer();

    void tick(quint32 delta) { m_delta = delta; }
    void setViewportSize(const QSize& size);

public slots:
    void paint();

private:
    quint32 m_delta;
};

class GameView : public QQuickItem {
    Q_OBJECT

public:
    GameView();

    Q_INVOKABLE void tick(quint32 delta);

signals:
    void tChanged();

public slots:
    void sync();
    void cleanup();

private slots:
    void handleWindowChanged(QQuickWindow* win);

private:
    quint32 m_delta;
    GameViewRenderer* m_renderer;
    bool m_windowChanged;
};

#endif // GAMEVIEW_H