1 | // Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QOPENGLQUERYHELPER_P_H |
5 | #define QOPENGLQUERYHELPER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtGui/private/qtguiglobal_p.h> |
19 | |
20 | #if !QT_CONFIG(opengles2) |
21 | |
22 | #include <QtGui/QOpenGLContext> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | // Helper class used by QOpenGLTimerQuery and later will be used by |
27 | // QOpenGLOcclusionQuery |
28 | class QOpenGLQueryHelper |
29 | { |
30 | public: |
31 | QOpenGLQueryHelper(QOpenGLContext *context) |
32 | : GetQueryObjectuiv(nullptr), |
33 | GetQueryObjectiv(nullptr), |
34 | GetQueryiv(nullptr), |
35 | EndQuery(nullptr), |
36 | BeginQuery(nullptr), |
37 | IsQuery(nullptr), |
38 | DeleteQueries(nullptr), |
39 | GenQueries(nullptr), |
40 | GetInteger64v(nullptr), |
41 | GetQueryObjectui64v(nullptr), |
42 | GetQueryObjecti64v(nullptr), |
43 | QueryCounter(nullptr) |
44 | { |
45 | Q_ASSERT(context); |
46 | |
47 | // Core in OpenGL >=1.5 |
48 | GetQueryObjectuiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint *)>(context->getProcAddress(procName: "glGetQueryObjectuiv" )); |
49 | GetQueryObjectiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint *)>(context->getProcAddress(procName: "glGetQueryObjectiv" )); |
50 | GetQueryiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint *)>(context->getProcAddress(procName: "glGetQueryiv" )); |
51 | EndQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum )>(context->getProcAddress(procName: "glEndQuery" )); |
52 | BeginQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLuint )>(context->getProcAddress(procName: "glBeginQuery" )); |
53 | IsQuery = reinterpret_cast<GLboolean (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(procName: "glIsQuery" )); |
54 | DeleteQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(procName: "glDeleteQueries" )); |
55 | GenQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(procName: "glGenQueries" )); |
56 | |
57 | // Core in OpenGL >=3.2 |
58 | GetInteger64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint64 *)>(context->getProcAddress(procName: "glGetInteger64v" )); |
59 | |
60 | // Core in OpenGL >=3.3 / ARB_timer_query |
61 | GetQueryObjectui64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint64 *)>(context->getProcAddress(procName: "glGetQueryObjectui64v" )); |
62 | GetQueryObjecti64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint64 *)>(context->getProcAddress(procName: "glGetQueryObjecti64v" )); |
63 | QueryCounter = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum )>(context->getProcAddress(procName: "glQueryCounter" )); |
64 | } |
65 | |
66 | inline void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) |
67 | { |
68 | GetQueryObjectuiv(id, pname, params); |
69 | } |
70 | |
71 | inline void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) |
72 | { |
73 | GetQueryObjectiv(id, pname, params); |
74 | } |
75 | |
76 | inline void glGetQueryiv(GLenum target, GLenum pname, GLint *params) |
77 | { |
78 | GetQueryiv(target, pname, params); |
79 | } |
80 | |
81 | inline void glEndQuery(GLenum target) |
82 | { |
83 | EndQuery(target); |
84 | } |
85 | |
86 | inline void glBeginQuery(GLenum target, GLuint id) |
87 | { |
88 | BeginQuery(target, id); |
89 | } |
90 | |
91 | inline GLboolean glIsQuery(GLuint id) |
92 | { |
93 | return IsQuery(id); |
94 | } |
95 | |
96 | inline void glDeleteQueries(GLsizei n, const GLuint *ids) |
97 | { |
98 | DeleteQueries(n, ids); |
99 | } |
100 | |
101 | inline void glGenQueries(GLsizei n, GLuint *ids) |
102 | { |
103 | GenQueries(n, ids); |
104 | } |
105 | |
106 | inline void glGetInteger64v(GLenum pname, GLint64 *params) |
107 | { |
108 | GetInteger64v(pname, params); |
109 | } |
110 | |
111 | inline void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) |
112 | { |
113 | GetQueryObjectui64v(id, pname, params); |
114 | } |
115 | |
116 | inline void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) |
117 | { |
118 | GetQueryObjecti64v(id, pname, params); |
119 | } |
120 | |
121 | inline void glQueryCounter(GLuint id, GLenum target) |
122 | { |
123 | QueryCounter(id, target); |
124 | } |
125 | |
126 | private: |
127 | // Core in OpenGL >=1.5 |
128 | void (QOPENGLF_APIENTRYP GetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params); |
129 | void (QOPENGLF_APIENTRYP GetQueryObjectiv)(GLuint id, GLenum pname, GLint *params); |
130 | void (QOPENGLF_APIENTRYP GetQueryiv)(GLenum target, GLenum pname, GLint *params); |
131 | void (QOPENGLF_APIENTRYP EndQuery)(GLenum target); |
132 | void (QOPENGLF_APIENTRYP BeginQuery)(GLenum target, GLuint id); |
133 | GLboolean (QOPENGLF_APIENTRYP IsQuery)(GLuint id); |
134 | void (QOPENGLF_APIENTRYP DeleteQueries)(GLsizei n, const GLuint *ids); |
135 | void (QOPENGLF_APIENTRYP GenQueries)(GLsizei n, GLuint *ids); |
136 | |
137 | // Core in OpenGL >=3.2 |
138 | void (QOPENGLF_APIENTRYP GetInteger64v)(GLenum pname, GLint64 *params); |
139 | |
140 | // Core in OpenGL >=3.3 and provided by ARB_timer_query |
141 | void (QOPENGLF_APIENTRYP GetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 *params); |
142 | void (QOPENGLF_APIENTRYP GetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 *params); |
143 | void (QOPENGLF_APIENTRYP QueryCounter)(GLuint id, GLenum target); |
144 | }; |
145 | |
146 | QT_END_NAMESPACE |
147 | |
148 | #endif |
149 | |
150 | #endif // QOPENGLQUERYHELPER_P_H |
151 | |