summaryrefslogtreecommitdiffstats
path: root/examples/qwindow-compositor/surfacerenderer.h
blob: df60b9dcc6cf63bbdcd1528bb1d709ce0f90ff09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef SURFACERENDERER_H
#define SURFACERENDERER_H

#include <QOpenGLContext>
#include <QGLShaderProgram>
#include <QWindow>

class SurfaceRenderer
{
public:
    SurfaceRenderer(QOpenGLContext *context, QWindow *surface);

    void drawImage(const QImage &image, const QRect &geometry);
    void drawTexture(int textureId, const QRect &geometry, int depth = 0);
    GLuint textureFromImage(const QImage &image);

private:

    QOpenGLContext *m_context;
    QWindow *m_surface;
    QGLShaderProgram *m_shaderProgram;
    QMatrix4x4 m_transformMatrix;

    int m_matrixLocation;
    int m_vertexCoordEntry;
    int m_textureCoordEntry;
};

#endif // SURFACERENDERER_H