1// Copyright (C) 2014 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 QT3DRENDER_RENDER_OPENGL_GRAPHICSHELPERINTERFACE_H
5#define QT3DRENDER_RENDER_OPENGL_GRAPHICSHELPERINTERFACE_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 for the convenience
12// of other Qt classes. 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 <QOpenGLFunctions>
19#include <QOpenGLTexture>
20#include <QOpenGLVersionFunctions>
21#include <shadervariables_p.h>
22#include <Qt3DRender/private/uniform_p.h>
23#include <Qt3DRender/qmemorybarrier.h>
24
25QT_BEGIN_NAMESPACE
26
27namespace Qt3DRender {
28namespace Render {
29
30struct Attachment;
31
32namespace OpenGL {
33
34class RenderBuffer;
35
36class GraphicsHelperInterface
37{
38public:
39 enum Feature {
40 MRT = 0,
41 Tessellation,
42 UniformBufferObject,
43 BindableFragmentOutputs,
44 PrimitiveRestart,
45 RenderBufferDimensionRetrieval,
46 TextureDimensionRetrieval,
47 ShaderStorageObject,
48 Compute,
49 DrawBuffersBlend,
50 BlitFramebuffer,
51 IndirectDrawing,
52 MapBuffer,
53 Fences,
54 ShaderImage
55 };
56
57 enum FBOBindMode {
58 FBODraw,
59 FBORead,
60 FBOReadAndDraw
61 };
62
63 virtual ~GraphicsHelperInterface() {}
64 virtual void alphaTest(GLenum mode1, GLenum mode2) = 0;
65 virtual void bindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
66 virtual void bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs) = 0;
67 virtual bool frameBufferNeedsRenderBuffer(const Attachment &attachment) = 0;
68 virtual void bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment) = 0;
69 virtual void bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment) = 0;
70 virtual void bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode) = 0;
71 virtual void bindImageTexture(GLuint imageUnit, GLuint texture, GLint mipLevel, GLboolean layered, GLint layer, GLenum access, GLenum format) = 0;
72 virtual void bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding) = 0;
73 virtual void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
74 virtual void blendEquation(GLenum mode) = 0;
75 virtual void blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) = 0;
76 virtual void blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha) = 0;
77 virtual void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = 0;
78 virtual GLuint boundFrameBufferObject() = 0;
79 virtual void buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer) = 0;
80 virtual bool checkFrameBufferComplete() = 0;
81 virtual void clearBufferf(GLint drawbuffer, const QVector4D &values) = 0;
82 virtual GLuint createFrameBufferObject() = 0;
83 virtual void depthRange(GLdouble nearValue, GLdouble farValue) = 0;
84 virtual void depthMask(GLenum mode) = 0;
85 virtual void depthTest(GLenum mode) = 0;
86 virtual void disableClipPlane(int clipPlane) = 0;
87 virtual void disablei(GLenum cap, GLuint index) = 0;
88 virtual void disablePrimitiveRestart() = 0;
89 virtual void dispatchCompute(GLuint wx, GLuint wy, GLuint wz) = 0;
90 virtual char *mapBuffer(GLenum target, GLsizeiptr size) = 0;
91 virtual GLboolean unmapBuffer(GLenum target) = 0;
92 virtual void drawArrays(GLenum primitiveType, GLint first, GLsizei count) = 0;
93 virtual void drawArraysIndirect(GLenum mode,void *indirect) = 0;
94 virtual void drawArraysInstanced(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances) = 0;
95 virtual void drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseinstance) = 0;
96 virtual void drawBuffers(GLsizei n, const int *bufs) = 0;
97 virtual void drawElements(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLint baseVertex) = 0;
98 virtual void drawElementsIndirect(GLenum mode, GLenum type, void *indirect) = 0;
99 virtual void drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType, GLsizei primitiveCount, GLint indexType, void * indices, GLsizei instances, GLint baseVertex, GLint baseInstance) = 0;
100 virtual void enableClipPlane(int clipPlane) = 0;
101 virtual void enablei(GLenum cap, GLuint index) = 0;
102 virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0;
103 virtual void enableVertexAttributeArray(int location) = 0;
104 virtual void frontFace(GLenum mode) = 0;
105 virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0;
106 virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0;
107 virtual void initializeHelper(QOpenGLContext *context, QAbstractOpenGLFunctions *functions) = 0;
108 virtual GLint maxClipPlaneCount() = 0;
109 virtual void memoryBarrier(QMemoryBarrier::Operations barriers) = 0;
110 virtual void pointSize(bool programmable, GLfloat value) = 0;
111 virtual std::vector<ShaderAttribute> programAttributesAndLocations(GLuint programId) = 0;
112 virtual std::vector<ShaderUniform> programUniformsAndLocations(GLuint programId) = 0;
113 virtual std::vector<ShaderUniformBlock> programUniformBlocks(GLuint programId) = 0;
114 virtual std::vector<ShaderStorageBlock> programShaderStorageBlocks(GLuint programId) = 0;
115 virtual void releaseFrameBufferObject(GLuint frameBufferId) = 0;
116 virtual void setAlphaCoverageEnabled(bool enable) = 0;
117 virtual void setClipPlane(int clipPlane, const QVector3D &normal, float distance) = 0;
118 virtual void setMSAAEnabled(bool enable) = 0;
119 virtual void setSeamlessCubemap(bool enable) = 0;
120 virtual void setVerticesPerPatch(GLint verticesPerPatch) = 0;
121 virtual bool supportsFeature(Feature feature) const = 0;
122 virtual uint uniformByteSize(const ShaderUniform &description) = 0;
123 virtual void useProgram(GLuint programId) = 0;
124 virtual void vertexAttribDivisor(GLuint index, GLuint divisor) = 0;
125 virtual void vertexAttributePointer(GLenum shaderDataType, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) = 0;
126 virtual void readBuffer(GLenum mode) = 0;
127 virtual void drawBuffer(GLenum mode) = 0;
128 virtual void rasterMode(GLenum faceMode, GLenum rasterMode) = 0;
129
130 virtual void *fenceSync() = 0;
131 virtual void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) = 0;
132 virtual void waitSync(void *sync) = 0;
133 virtual bool wasSyncSignaled(void *sync) = 0;
134 virtual void deleteSync(void *sync) = 0;
135
136 virtual void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) = 0;
137 virtual void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
138 virtual void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
139 virtual void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
140
141 virtual void glUniform1iv(GLint location, GLsizei count, const GLint *value) = 0;
142 virtual void glUniform2iv(GLint location, GLsizei count, const GLint *value) = 0;
143 virtual void glUniform3iv(GLint location, GLsizei count, const GLint *value) = 0;
144 virtual void glUniform4iv(GLint location, GLsizei count, const GLint *value) = 0;
145
146 virtual void glUniform1uiv(GLint location, GLsizei count, const GLuint *value) = 0;
147 virtual void glUniform2uiv(GLint location, GLsizei count, const GLuint *value) = 0;
148 virtual void glUniform3uiv(GLint location, GLsizei count, const GLuint *value) = 0;
149 virtual void glUniform4uiv(GLint location, GLsizei count, const GLuint *value) = 0;
150
151 virtual void glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
152 virtual void glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
153 virtual void glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
154 virtual void glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
155 virtual void glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
156 virtual void glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
157 virtual void glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
158 virtual void glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *value) = 0;
159 virtual void glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
160
161 virtual UniformType uniformTypeFromGLType(GLenum glType) = 0;
162};
163
164} // namespace OpenGL
165} // namespace Render
166} // namespace Qt3DRender
167
168QT_END_NAMESPACE
169
170#endif // QT3DRENDER_RENDER_OPENGL_GRAPHICSHELPERINTERFACE_H
171

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