1/****************************************************************************
2**
3** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QT3DRENDER_RENDER_OPENGL_GRAPHICSHELPERINTERFACE_H
41#define QT3DRENDER_RENDER_OPENGL_GRAPHICSHELPERINTERFACE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists for the convenience
48// of other Qt classes. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QOpenGLFunctions>
55#include <QOpenGLTexture>
56#include <QVector>
57#include <shadervariables_p.h>
58#include <Qt3DRender/private/uniform_p.h>
59#include <Qt3DRender/qmemorybarrier.h>
60
61QT_BEGIN_NAMESPACE
62
63namespace Qt3DRender {
64namespace Render {
65
66struct Attachment;
67
68namespace OpenGL {
69
70class RenderBuffer;
71
72class GraphicsHelperInterface
73{
74public:
75 enum Feature {
76 MRT = 0,
77 Tessellation,
78 UniformBufferObject,
79 BindableFragmentOutputs,
80 PrimitiveRestart,
81 RenderBufferDimensionRetrieval,
82 TextureDimensionRetrieval,
83 ShaderStorageObject,
84 Compute,
85 DrawBuffersBlend,
86 BlitFramebuffer,
87 IndirectDrawing,
88 MapBuffer,
89 Fences,
90 ShaderImage
91 };
92
93 enum FBOBindMode {
94 FBODraw,
95 FBORead,
96 FBOReadAndDraw
97 };
98
99 virtual ~GraphicsHelperInterface() {}
100 virtual void alphaTest(GLenum mode1, GLenum mode2) = 0;
101 virtual void bindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
102 virtual void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) = 0;
103 virtual bool frameBufferNeedsRenderBuffer(const Attachment &attachment) = 0;
104 virtual void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) = 0;
105 virtual void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) = 0;
106 virtual void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) = 0;
107 virtual void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) = 0;
108 virtual void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) = 0;
109 virtual void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
110 virtual void blendEquation(GLenum mode) = 0;
111 virtual void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) = 0;
112 virtual void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) = 0;
113 virtual void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = 0;
114 virtual GLuint boundFrameBufferObject() = 0;
115 virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0;
116 virtual bool checkFrameBufferComplete() = 0;
117 virtual void clearBufferf(GLint drawbuffer, const QVector4D &values) = 0;
118 virtual GLuint createFrameBufferObject() = 0;
119 virtual void depthRange(GLdouble nearValue, GLdouble farValue) = 0;
120 virtual void depthMask(GLenum mode) = 0;
121 virtual void depthTest(GLenum mode) = 0;
122 virtual void disableClipPlane(int clipPlane) = 0;
123 virtual void disablei(GLenum cap, GLuint index) = 0;
124 virtual void disablePrimitiveRestart() = 0;
125 virtual void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) = 0;
126 virtual char *mapBuffer(GLenum target, GLsizeiptr size) = 0;
127 virtual GLboolean unmapBuffer(GLenum target) = 0;
128 virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0;
129 virtual void drawArraysIndirect(GLenum mode,void *indirect) = 0;
130 virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
131 virtual void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseinstance) = 0;
132 virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
133 virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex) = 0;
134 virtual void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) = 0;
135 virtual void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex, GLint baseInstance) = 0;
136 virtual void enableClipPlane(int clipPlane) = 0;
137 virtual void enablei(GLenum cap, GLuint index) = 0;
138 virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;
139 virtual void enableVertexAttributeArray(int location) = 0;
140 virtual void frontFace(GLenum mode) = 0;
141 virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0;
142 virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0;
143 virtual void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) = 0;
144 virtual GLint maxClipPlaneCount() = 0;
145 virtual void memoryBarrier(QMemoryBarrier::Operations barriers) = 0;
146 virtual void pointSize(bool programmable, GLfloat value) = 0;
147 virtual QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) = 0;
148 virtual QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) = 0;
149 virtual QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
150 virtual QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) = 0;
151 virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
152 virtual void setAlphaCoverageEnabled(bool enable) = 0;
153 virtual void setClipPlane(int clipPlane, const QVector3D &normal, float distance) = 0;
154 virtual void setMSAAEnabled(bool enable) = 0;
155 virtual void setSeamlessCubemap(bool enable) = 0;
156 virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
157 virtual bool supportsFeature(Feature feature) const = 0;
158 virtual uint uniformByteSize(const ShaderUniform &description) = 0;
159 virtual void useProgram(GLuint programId) = 0;
160 virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0;
161 virtual void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) = 0;
162 virtual void readBuffer(GLenum mode) = 0;
163 virtual void drawBuffer(GLenum mode) = 0;
164 virtual void rasterMode(GLenum faceMode, GLenum rasterMode) = 0;
165
166 virtual void *fenceSync() = 0;
167 virtual void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) = 0;
168 virtual void waitSync(void *sync) = 0;
169 virtual bool wasSyncSignaled(void *sync) = 0;
170 virtual void deleteSync(void *sync) = 0;
171
172 virtual void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) = 0;
173 virtual void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
174 virtual void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
175 virtual void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
176
177 virtual void glUniform1iv(GLint location, GLsizei count, const GLint *value) = 0;
178 virtual void glUniform2iv(GLint location, GLsizei count, const GLint *value) = 0;
179 virtual void glUniform3iv(GLint location, GLsizei count, const GLint *value) = 0;
180 virtual void glUniform4iv(GLint location, GLsizei count, const GLint *value) = 0;
181
182 virtual void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) = 0;
183 virtual void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) = 0;
184 virtual void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) = 0;
185 virtual void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) = 0;
186
187 virtual void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
188 virtual void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
189 virtual void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
190 virtual void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
191 virtual void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
192 virtual void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
193 virtual void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
194 virtual void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
195 virtual void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
196
197 virtual UniformType uniformTypeFromGLType(GLenum glType) = 0;
198};
199
200} // namespace OpenGL
201} // namespace Render
202} // namespace Qt3DRender
203
204QT_END_NAMESPACE
205
206#endif // QT3DRENDER_RENDER_OPENGL_GRAPHICSHELPERINTERFACE_H
207

source code of qt3d/src/plugins/renderers/opengl/graphicshelpers/graphicshelperinterface_p.h