summaryrefslogtreecommitdiffstats
path: root/tests/manual/examples/opengl/contextinfo/renderwindow.h
diff options
context:
space:
mode:
authorLaszlo Agocs <[email protected]>2023-11-15 16:50:11 +0100
committerLaszlo Agocs <[email protected]>2023-11-17 22:27:01 +0100
commit9f3d6e325f48ad41766f16b33ac2543e09b800fe (patch)
treed65bc0fc5adb520a87c8c20a96a57f132d57c60f /tests/manual/examples/opengl/contextinfo/renderwindow.h
parent2198fc6a4ab3ba565802a9012e693a8ba16080bd (diff)
Make contextinfo example a manual test
Change-Id: I9023016d50e82bba1fa73632cc1409b3d016f352 Reviewed-by: Kristoffer Skau <[email protected]> Reviewed-by: Christian Strømme <[email protected]>
Diffstat (limited to 'tests/manual/examples/opengl/contextinfo/renderwindow.h')
-rw-r--r--tests/manual/examples/opengl/contextinfo/renderwindow.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/manual/examples/opengl/contextinfo/renderwindow.h b/tests/manual/examples/opengl/contextinfo/renderwindow.h
new file mode 100644
index 00000000000..964dd601a6e
--- /dev/null
+++ b/tests/manual/examples/opengl/contextinfo/renderwindow.h
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef RENDERWINDOW_H
+#define RENDERWINDOW_H
+
+#include <QWindow>
+#include <QOpenGLVertexArrayObject>
+#include <QOpenGLBuffer>
+
+QT_FORWARD_DECLARE_CLASS(QOpenGLContext)
+QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
+
+class RenderWindow : public QWindow
+{
+ Q_OBJECT
+
+public:
+ RenderWindow(const QSurfaceFormat &format);
+ QOpenGLContext *context() { return m_context; }
+ void exposeEvent(QExposeEvent *) override;
+ void setForceGLSL110(bool enable) { m_forceGLSL110 = enable; }
+
+signals:
+ void ready();
+ void error(const QString &msg);
+
+protected:
+ bool event(QEvent *ev) override;
+
+private slots:
+ void render();
+
+private:
+ void init();
+ void setupVertexAttribs();
+
+ QOpenGLContext *m_context;
+ bool m_initialized;
+ bool m_forceGLSL110;
+ QOpenGLShaderProgram *m_program;
+ int m_posAttr, m_colAttr, m_matrixUniform;
+ QOpenGLVertexArrayObject m_vao;
+ QOpenGLBuffer m_vbo;
+ float m_angle;
+};
+
+#endif // RENDERWINDOW_H