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

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