1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtCanvas3D 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 | // |
41 | // W A R N I N G |
42 | // ------------- |
43 | // |
44 | // This file is not part of the QtCanvas3D API. It exists purely as an |
45 | // implementation detail. This header file may change from version to |
46 | // version without notice, or even be removed. |
47 | // |
48 | // We mean it. |
49 | |
50 | #ifndef GLSTATESTORE_P_H |
51 | #define GLSTATESTORE_P_H |
52 | |
53 | #include "glcommandqueue_p.h" |
54 | #include <QtGui/QOpenGLFunctions> |
55 | |
56 | QT_BEGIN_NAMESPACE |
57 | QT_CANVAS3D_BEGIN_NAMESPACE |
58 | |
59 | class GLStateStore : public QObject, protected QOpenGLFunctions |
60 | { |
61 | Q_OBJECT |
62 | public: |
63 | explicit GLStateStore(QOpenGLContext *context, GLint maxAttribs, |
64 | CanvasGlCommandQueue &commandQueue, QObject *parent = 0); |
65 | ~GLStateStore(); |
66 | |
67 | void initGLDefaultState(); |
68 | void storeStateCommand(const GlCommand &command); |
69 | void restoreStoredState(); |
70 | |
71 | private: |
72 | void enableDisable(bool enable, GLenum flag); |
73 | |
74 | CanvasGlCommandQueue &m_commandQueue; |
75 | |
76 | GLenum m_activeTexture; |
77 | GLuint m_boundArrayBuffer; |
78 | GLuint m_boundElementArrayBuffer; |
79 | GLuint m_boundRenderbuffer; |
80 | GLuint m_boundTexture2D; |
81 | GLuint m_boundTextureCubeMap; |
82 | GLclampf m_blendColor[4]; |
83 | GLenum m_blendEquationRGB; |
84 | GLenum m_blendEquationAlpha; |
85 | GLenum m_blendFuncSrcRGB; |
86 | GLenum m_blendFuncSrcAlpha; |
87 | GLenum m_blendFuncDestRGB; |
88 | GLenum m_blendFuncDestAlpha; |
89 | GLclampf m_clearColor[4]; |
90 | GLclampf m_clearDepth; |
91 | GLint m_clearStencil; |
92 | GLboolean m_colorMask[4]; |
93 | GLenum m_cullFace; |
94 | GLenum m_depthFunc; |
95 | GLboolean m_depthMask; |
96 | GLclampf m_depthRange[2]; |
97 | |
98 | // enable/disable flags |
99 | GLboolean m_blendEnabled; |
100 | GLboolean m_cullFaceEnabled; |
101 | GLboolean m_depthTestEnabled; |
102 | GLboolean m_ditherEnabled; |
103 | GLboolean m_polygonOffsetFillEnabled; |
104 | GLboolean m_sampleAlphaToCoverageEnabled; |
105 | GLboolean m_sampleCoverageEnabled; |
106 | GLboolean m_scissorTestEnabled; |
107 | GLboolean m_stencilTestEnabled; |
108 | |
109 | GLenum m_frontFace; |
110 | GLenum m_hintMode; |
111 | GLint m_lineWidth; |
112 | GLint m_packAlignment; |
113 | GLint m_unpackAlignment; |
114 | GLfloat m_polygonOffsetFactor; |
115 | GLfloat m_polygonOffsetUnits; |
116 | GLclampf m_sampleCoverageValue; |
117 | GLboolean m_sampleCoverageInvert; |
118 | GLint m_scissorBox[4]; |
119 | |
120 | GLenum m_stencilFuncFront; |
121 | GLint m_stencilFuncRefFront; |
122 | GLuint m_stencilFuncMaskFront; |
123 | GLenum m_stencilFuncBack; |
124 | GLint m_stencilFuncRefBack; |
125 | GLuint m_stencilFuncMaskBack; |
126 | GLuint m_stencilMaskFront; |
127 | GLuint m_stencilMaskBack; |
128 | GLenum m_stancilOpSFailFront; |
129 | GLenum m_stancilOpDpFailFront; |
130 | GLenum m_stancilOpDpPassFront; |
131 | GLenum m_stancilOpSFailBack; |
132 | GLenum m_stancilOpDpFailBack; |
133 | GLenum m_stancilOpDpPassBack; |
134 | |
135 | GLuint m_boundProgram; |
136 | |
137 | GLint m_maxVertexAttribs; |
138 | GLint m_highestUsedAttrib; |
139 | bool *m_vertexAttribArrayEnabledStates; |
140 | GLint *m_vertexAttribArrayBoundBuffers; |
141 | GLint *m_vertexAttribArraySizes; |
142 | GLenum *m_vertexAttribArrayTypes; |
143 | GLboolean *m_vertexAttribArrayNormalized; |
144 | GLint *m_vertexAttribArrayStrides; |
145 | GLint *m_vertexAttribArrayOffsets; |
146 | }; |
147 | |
148 | QT_CANVAS3D_END_NAMESPACE |
149 | QT_END_NAMESPACE |
150 | |
151 | #endif // GLSTATESTORE_P_H |
152 | |