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_GRAPHICSHELPERINTERFACE_H
41#define QT3DRENDER_RENDER_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 <Qt3DRender/private/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;
67class RenderBuffer;
68
69class GraphicsHelperInterface
70{
71public:
72 enum Feature {
73 MRT = 0,
74 Tessellation,
75 UniformBufferObject,
76 BindableFragmentOutputs,
77 PrimitiveRestart,
78 RenderBufferDimensionRetrieval,
79 TextureDimensionRetrieval,
80 ShaderStorageObject,
81 Compute,
82 DrawBuffersBlend,
83 BlitFramebuffer,
84 IndirectDrawing,
85 MapBuffer,
86 Fences,
87 ShaderImage
88 };
89
90 enum FBOBindMode {
91 FBODraw,
92 FBORead,
93 FBOReadAndDraw
94 };
95
96 virtual ~GraphicsHelperInterface() {}
97 virtual void alphaTest(GLenum mode1, GLenum mode2) = 0;
98 virtual void bindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
99 virtual void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) = 0;
100 virtual bool frameBufferNeedsRenderBuffer(const Attachment &attachment) = 0;
101 virtual void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) = 0;
102 virtual void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) = 0;
103 virtual void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) = 0;
104 virtual void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) = 0;
105 virtual void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) = 0;
106 virtual void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
107 virtual void blendEquation(GLenum mode) = 0;
108 virtual void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) = 0;
109 virtual void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) = 0;
110 virtual void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = 0;
111 virtual GLuint boundFrameBufferObject() = 0;
112 virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0;
113 virtual bool checkFrameBufferComplete() = 0;
114 virtual void clearBufferf(GLint drawbuffer, const QVector4D &values) = 0;
115 virtual GLuint createFrameBufferObject() = 0;
116 virtual void depthRange(GLdouble nearValue, GLdouble farValue) = 0;
117 virtual void depthMask(GLenum mode) = 0;
118 virtual void depthTest(GLenum mode) = 0;
119 virtual void disableClipPlane(int clipPlane) = 0;
120 virtual void disablei(GLenum cap, GLuint index) = 0;
121 virtual void disablePrimitiveRestart() = 0;
122 virtual void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) = 0;
123 virtual char *mapBuffer(GLenum target, GLsizeiptr size) = 0;
124 virtual GLboolean unmapBuffer(GLenum target) = 0;
125 virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0;
126 virtual void drawArraysIndirect(GLenum mode,void *indirect) = 0;
127 virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
128 virtual void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseinstance) = 0;
129 virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
130 virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex) = 0;
131 virtual void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) = 0;
132 virtual void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex, GLint baseInstance) = 0;
133 virtual void enableClipPlane(int clipPlane) = 0;
134 virtual void enablei(GLenum cap, GLuint index) = 0;
135 virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;
136 virtual void enableVertexAttributeArray(int location) = 0;
137 virtual void frontFace(GLenum mode) = 0;
138 virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0;
139 virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0;
140 virtual void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) = 0;
141 virtual GLint maxClipPlaneCount() = 0;
142 virtual void memoryBarrier(QMemoryBarrier::Operations barriers) = 0;
143 virtual void pointSize(bool programmable, GLfloat value) = 0;
144 virtual QVector<ShaderAttribute> programAttributesAndLocations(GLuint programId) = 0;
145 virtual QVector<ShaderUniform> programUniformsAndLocations(GLuint programId) = 0;
146 virtual QVector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
147 virtual QVector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) = 0;
148 virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
149 virtual void setAlphaCoverageEnabled(bool enable) = 0;
150 virtual void setClipPlane(int clipPlane, const QVector3D &normal, float distance) = 0;
151 virtual void setMSAAEnabled(bool enable) = 0;
152 virtual void setSeamlessCubemap(bool enable) = 0;
153 virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
154 virtual bool supportsFeature(Feature feature) const = 0;
155 virtual uint uniformByteSize(const ShaderUniform &description) = 0;
156 virtual void useProgram(GLuint programId) = 0;
157 virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0;
158 virtual void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) = 0;
159 virtual void readBuffer(GLenum mode) = 0;
160 virtual void drawBuffer(GLenum mode) = 0;
161 virtual void rasterMode(GLenum faceMode, GLenum rasterMode) = 0;
162
163 virtual void *fenceSync() = 0;
164 virtual void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) = 0;
165 virtual void waitSync(void *sync) = 0;
166 virtual bool wasSyncSignaled(void *sync) = 0;
167 virtual void deleteSync(void *sync) = 0;
168
169 virtual void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) = 0;
170 virtual void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
171 virtual void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
172 virtual void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
173
174 virtual void glUniform1iv(GLint location, GLsizei count, const GLint *value) = 0;
175 virtual void glUniform2iv(GLint location, GLsizei count, const GLint *value) = 0;
176 virtual void glUniform3iv(GLint location, GLsizei count, const GLint *value) = 0;
177 virtual void glUniform4iv(GLint location, GLsizei count, const GLint *value) = 0;
178
179 virtual void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) = 0;
180 virtual void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) = 0;
181 virtual void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) = 0;
182 virtual void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) = 0;
183
184 virtual void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
185 virtual void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
186 virtual void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
187 virtual void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
188 virtual void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
189 virtual void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
190 virtual void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
191 virtual void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
192 virtual void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
193
194 virtual UniformType uniformTypeFromGLType(GLenum glType) = 0;
195};
196
197
198} // namespace Render
199} // namespace Qt3DRender
200
201QT_END_NAMESPACE
202
203#endif // QT3DRENDER_RENDER_GRAPHICSHELPERINTERFACE_H
204