qopenglshaderprogram.sip 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. // qopenglshaderprogram.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtOpenGL Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QOpenGLShader : public QObject
  22. {
  23. %TypeHeaderCode
  24. #include <qopenglshaderprogram.h>
  25. %End
  26. public:
  27. enum ShaderTypeBit /BaseType=Flag/
  28. {
  29. Vertex,
  30. Fragment,
  31. Geometry,
  32. TessellationControl,
  33. TessellationEvaluation,
  34. Compute,
  35. };
  36. typedef QFlags<QOpenGLShader::ShaderTypeBit> ShaderType;
  37. QOpenGLShader(QOpenGLShader::ShaderType type, QObject *parent /TransferThis/ = 0);
  38. virtual ~QOpenGLShader();
  39. QOpenGLShader::ShaderType shaderType() const;
  40. bool compileSourceCode(const QByteArray &source);
  41. bool compileSourceCode(const QString &source);
  42. bool compileSourceFile(const QString &fileName);
  43. QByteArray sourceCode() const;
  44. bool isCompiled() const;
  45. QString log() const;
  46. GLuint shaderId() const;
  47. static bool hasOpenGLShaders(QOpenGLShader::ShaderType type, QOpenGLContext *context = 0);
  48. };
  49. class QOpenGLShaderProgram : public QObject
  50. {
  51. %TypeHeaderCode
  52. #include <qopenglshaderprogram.h>
  53. %End
  54. public:
  55. explicit QOpenGLShaderProgram(QObject *parent /TransferThis/ = 0);
  56. virtual ~QOpenGLShaderProgram();
  57. bool addShader(QOpenGLShader *shader);
  58. void removeShader(QOpenGLShader *shader);
  59. QList<QOpenGLShader *> shaders() const;
  60. bool addShaderFromSourceCode(QOpenGLShader::ShaderType type, const QByteArray &source);
  61. bool addShaderFromSourceCode(QOpenGLShader::ShaderType type, const QString &source);
  62. bool addShaderFromSourceFile(QOpenGLShader::ShaderType type, const QString &fileName);
  63. void removeAllShaders();
  64. virtual bool link();
  65. bool isLinked() const;
  66. QString log() const;
  67. bool bind();
  68. void release();
  69. GLuint programId() const;
  70. void bindAttributeLocation(const QByteArray &name, int location);
  71. void bindAttributeLocation(const QString &name, int location);
  72. int attributeLocation(const QByteArray &name) const;
  73. int attributeLocation(const QString &name) const;
  74. void setAttributeValue(int location, GLfloat value);
  75. void setAttributeValue(int location, GLfloat x, GLfloat y);
  76. void setAttributeValue(int location, GLfloat x, GLfloat y, GLfloat z);
  77. void setAttributeValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  78. void setAttributeValue(int location, const QVector2D &value);
  79. void setAttributeValue(int location, const QVector3D &value);
  80. void setAttributeValue(int location, const QVector4D &value);
  81. void setAttributeValue(int location, const QColor &value);
  82. void setAttributeValue(const char *name, GLfloat value);
  83. void setAttributeValue(const char *name, GLfloat x, GLfloat y);
  84. void setAttributeValue(const char *name, GLfloat x, GLfloat y, GLfloat z);
  85. void setAttributeValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  86. void setAttributeValue(const char *name, const QVector2D &value);
  87. void setAttributeValue(const char *name, const QVector3D &value);
  88. void setAttributeValue(const char *name, const QVector4D &value);
  89. void setAttributeValue(const char *name, const QColor &value);
  90. void setAttributeArray(int location, SIP_PYOBJECT values /TypeHint="PYQT_SHADER_ATTRIBUTE_ARRAY"/);
  91. %MethodCode
  92. const GLfloat *values;
  93. int tsize;
  94. values = qpyopengl_attribute_array(a1, sipSelf, PyLong_FromLong(a0), &tsize,
  95. &sipError);
  96. if (values)
  97. sipCpp->setAttributeArray(a0, values, tsize);
  98. %End
  99. void setAttributeArray(const char *name, SIP_PYOBJECT values /TypeHint="PYQT_SHADER_ATTRIBUTE_ARRAY"/);
  100. %MethodCode
  101. const GLfloat *values;
  102. int tsize;
  103. values = qpyopengl_attribute_array(a1, sipSelf, PyBytes_FromString(a0),
  104. &tsize, &sipError);
  105. if (values)
  106. sipCpp->setAttributeArray(a0, values, tsize);
  107. %End
  108. void setAttributeBuffer(int location, GLenum type, int offset, int tupleSize, int stride = 0);
  109. void setAttributeBuffer(const char *name, GLenum type, int offset, int tupleSize, int stride = 0);
  110. void enableAttributeArray(int location);
  111. void enableAttributeArray(const char *name);
  112. void disableAttributeArray(int location);
  113. void disableAttributeArray(const char *name);
  114. int uniformLocation(const QByteArray &name) const;
  115. int uniformLocation(const QString &name) const;
  116. void setUniformValue(int location, GLint value /Constrained/);
  117. void setUniformValue(int location, GLfloat value /Constrained/);
  118. void setUniformValue(int location, GLfloat x, GLfloat y);
  119. void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z);
  120. void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  121. void setUniformValue(int location, const QVector2D &value);
  122. void setUniformValue(int location, const QVector3D &value);
  123. void setUniformValue(int location, const QVector4D &value);
  124. void setUniformValue(int location, const QColor &color);
  125. void setUniformValue(int location, const QPoint &point);
  126. void setUniformValue(int location, const QPointF &point);
  127. void setUniformValue(int location, const QSize &size);
  128. void setUniformValue(int location, const QSizeF &size);
  129. void setUniformValue(int location, const QMatrix2x2 &value);
  130. void setUniformValue(int location, const QMatrix2x3 &value);
  131. void setUniformValue(int location, const QMatrix2x4 &value);
  132. void setUniformValue(int location, const QMatrix3x2 &value);
  133. void setUniformValue(int location, const QMatrix3x3 &value);
  134. void setUniformValue(int location, const QMatrix3x4 &value);
  135. void setUniformValue(int location, const QMatrix4x2 &value);
  136. void setUniformValue(int location, const QMatrix4x3 &value);
  137. void setUniformValue(int location, const QMatrix4x4 &value);
  138. void setUniformValue(int location, const QTransform &value);
  139. void setUniformValue(const char *name, GLint value /Constrained/);
  140. void setUniformValue(const char *name, GLfloat value /Constrained/);
  141. void setUniformValue(const char *name, GLfloat x, GLfloat y);
  142. void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z);
  143. void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
  144. void setUniformValue(const char *name, const QVector2D &value);
  145. void setUniformValue(const char *name, const QVector3D &value);
  146. void setUniformValue(const char *name, const QVector4D &value);
  147. void setUniformValue(const char *name, const QColor &color);
  148. void setUniformValue(const char *name, const QPoint &point);
  149. void setUniformValue(const char *name, const QPointF &point);
  150. void setUniformValue(const char *name, const QSize &size);
  151. void setUniformValue(const char *name, const QSizeF &size);
  152. void setUniformValue(const char *name, const QMatrix2x2 &value);
  153. void setUniformValue(const char *name, const QMatrix2x3 &value);
  154. void setUniformValue(const char *name, const QMatrix2x4 &value);
  155. void setUniformValue(const char *name, const QMatrix3x2 &value);
  156. void setUniformValue(const char *name, const QMatrix3x3 &value);
  157. void setUniformValue(const char *name, const QMatrix3x4 &value);
  158. void setUniformValue(const char *name, const QMatrix4x2 &value);
  159. void setUniformValue(const char *name, const QMatrix4x3 &value);
  160. void setUniformValue(const char *name, const QMatrix4x4 &value);
  161. void setUniformValue(const char *name, const QTransform &value);
  162. void setUniformValueArray(int location, SIP_PYOBJECT values /TypeHint="PYQT_SHADER_UNIFORM_VALUE_ARRAY"/);
  163. %MethodCode
  164. const void *values;
  165. const sipTypeDef *array_type;
  166. int array_len, tsize;
  167. values = qpyopengl_uniform_value_array(a1, sipSelf, PyLong_FromLong(a0),
  168. &array_type, &array_len, &tsize, &sipError);
  169. if (values)
  170. {
  171. if (array_type == sipType_QVector2D)
  172. sipCpp->setUniformValueArray(a0,
  173. reinterpret_cast<const QVector2D *>(values), array_len);
  174. else if (array_type == sipType_QVector3D)
  175. sipCpp->setUniformValueArray(a0,
  176. reinterpret_cast<const QVector3D *>(values), array_len);
  177. else if (array_type == sipType_QVector4D)
  178. sipCpp->setUniformValueArray(a0,
  179. reinterpret_cast<const QVector4D *>(values), array_len);
  180. else if (array_type == sipType_QMatrix2x2)
  181. sipCpp->setUniformValueArray(a0,
  182. reinterpret_cast<const QMatrix2x2 *>(values), array_len);
  183. else if (array_type == sipType_QMatrix2x3)
  184. sipCpp->setUniformValueArray(a0,
  185. reinterpret_cast<const QMatrix2x3 *>(values), array_len);
  186. else if (array_type == sipType_QMatrix2x4)
  187. sipCpp->setUniformValueArray(a0,
  188. reinterpret_cast<const QMatrix2x4 *>(values), array_len);
  189. else if (array_type == sipType_QMatrix3x2)
  190. sipCpp->setUniformValueArray(a0,
  191. reinterpret_cast<const QMatrix3x2 *>(values), array_len);
  192. else if (array_type == sipType_QMatrix3x3)
  193. sipCpp->setUniformValueArray(a0,
  194. reinterpret_cast<const QMatrix3x3 *>(values), array_len);
  195. else if (array_type == sipType_QMatrix3x4)
  196. sipCpp->setUniformValueArray(a0,
  197. reinterpret_cast<const QMatrix3x4 *>(values), array_len);
  198. else if (array_type == sipType_QMatrix4x2)
  199. sipCpp->setUniformValueArray(a0,
  200. reinterpret_cast<const QMatrix4x2 *>(values), array_len);
  201. else if (array_type == sipType_QMatrix4x3)
  202. sipCpp->setUniformValueArray(a0,
  203. reinterpret_cast<const QMatrix4x3 *>(values), array_len);
  204. else if (array_type == sipType_QMatrix4x4)
  205. sipCpp->setUniformValueArray(a0,
  206. reinterpret_cast<const QMatrix4x4 *>(values), array_len);
  207. else
  208. sipCpp->setUniformValueArray(a0,
  209. reinterpret_cast<const GLfloat *>(values), array_len, tsize);
  210. }
  211. %End
  212. void setUniformValueArray(const char *name, SIP_PYOBJECT values /TypeHint="PYQT_SHADER_UNIFORM_VALUE_ARRAY"/);
  213. %MethodCode
  214. const void *values;
  215. const sipTypeDef *array_type;
  216. int array_len, tsize;
  217. values = qpyopengl_uniform_value_array(a1, sipSelf, PyBytes_FromString(a0),
  218. &array_type, &array_len, &tsize, &sipError);
  219. if (values)
  220. {
  221. if (array_type == sipType_QVector2D)
  222. sipCpp->setUniformValueArray(a0,
  223. reinterpret_cast<const QVector2D *>(values), array_len);
  224. else if (array_type == sipType_QVector3D)
  225. sipCpp->setUniformValueArray(a0,
  226. reinterpret_cast<const QVector3D *>(values), array_len);
  227. else if (array_type == sipType_QVector4D)
  228. sipCpp->setUniformValueArray(a0,
  229. reinterpret_cast<const QVector4D *>(values), array_len);
  230. else if (array_type == sipType_QMatrix2x2)
  231. sipCpp->setUniformValueArray(a0,
  232. reinterpret_cast<const QMatrix2x2 *>(values), array_len);
  233. else if (array_type == sipType_QMatrix2x3)
  234. sipCpp->setUniformValueArray(a0,
  235. reinterpret_cast<const QMatrix2x3 *>(values), array_len);
  236. else if (array_type == sipType_QMatrix2x4)
  237. sipCpp->setUniformValueArray(a0,
  238. reinterpret_cast<const QMatrix2x4 *>(values), array_len);
  239. else if (array_type == sipType_QMatrix3x2)
  240. sipCpp->setUniformValueArray(a0,
  241. reinterpret_cast<const QMatrix3x2 *>(values), array_len);
  242. else if (array_type == sipType_QMatrix3x3)
  243. sipCpp->setUniformValueArray(a0,
  244. reinterpret_cast<const QMatrix3x3 *>(values), array_len);
  245. else if (array_type == sipType_QMatrix3x4)
  246. sipCpp->setUniformValueArray(a0,
  247. reinterpret_cast<const QMatrix3x4 *>(values), array_len);
  248. else if (array_type == sipType_QMatrix4x2)
  249. sipCpp->setUniformValueArray(a0,
  250. reinterpret_cast<const QMatrix4x2 *>(values), array_len);
  251. else if (array_type == sipType_QMatrix4x3)
  252. sipCpp->setUniformValueArray(a0,
  253. reinterpret_cast<const QMatrix4x3 *>(values), array_len);
  254. else if (array_type == sipType_QMatrix4x4)
  255. sipCpp->setUniformValueArray(a0,
  256. reinterpret_cast<const QMatrix4x4 *>(values), array_len);
  257. else
  258. sipCpp->setUniformValueArray(a0,
  259. reinterpret_cast<const GLfloat *>(values), array_len, tsize);
  260. }
  261. %End
  262. static bool hasOpenGLShaderPrograms(QOpenGLContext *context = 0);
  263. int maxGeometryOutputVertices() const;
  264. void setPatchVertexCount(int count);
  265. int patchVertexCount() const;
  266. void setDefaultOuterTessellationLevels(const QList<float> &levels);
  267. QList<float> defaultOuterTessellationLevels() const;
  268. void setDefaultInnerTessellationLevels(const QList<float> &levels);
  269. QList<float> defaultInnerTessellationLevels() const;
  270. bool create();
  271. bool addCacheableShaderFromSourceCode(QOpenGLShader::ShaderType type, const QByteArray &source);
  272. bool addCacheableShaderFromSourceCode(QOpenGLShader::ShaderType type, const QString &source);
  273. bool addCacheableShaderFromSourceFile(QOpenGLShader::ShaderType type, const QString &fileName);
  274. };
  275. %ModuleHeaderCode
  276. #include "qpyopengl_api.h"
  277. %End
  278. %InitialisationCode
  279. qpyopengl_init();
  280. %End
  281. %TypeHintCode
  282. # Convenient aliases for complicated OpenGL types.
  283. PYQT_OPENGL_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float],
  284. PyQt6.sip.Buffer, None]
  285. PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int],
  286. typing.Sequence[float], PyQt6.sip.Buffer, int, None]
  287. PYQT_SHADER_ATTRIBUTE_ARRAY = typing.Union[typing.Sequence[QtGui.QVector2D],
  288. typing.Sequence[QtGui.QVector3D], typing.Sequence[QtGui.QVector4D],
  289. typing.Sequence[typing.Sequence[float]]]
  290. PYQT_SHADER_UNIFORM_VALUE_ARRAY = typing.Union[
  291. typing.Sequence[QtGui.QVector2D], typing.Sequence[QtGui.QVector3D],
  292. typing.Sequence[QtGui.QVector4D], typing.Sequence[QtGui.QMatrix2x2],
  293. typing.Sequence[QtGui.QMatrix2x3], typing.Sequence[QtGui.QMatrix2x4],
  294. typing.Sequence[QtGui.QMatrix3x2], typing.Sequence[QtGui.QMatrix3x3],
  295. typing.Sequence[QtGui.QMatrix3x4], typing.Sequence[QtGui.QMatrix4x2],
  296. typing.Sequence[QtGui.QMatrix4x3], typing.Sequence[QtGui.QMatrix4x4],
  297. typing.Sequence[typing.Sequence[float]]]
  298. %End