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