1// qgl.sip generated by MetaSIP
2//
3// This file is part of the QtOpenGL Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
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
22
23%If (PyQt_OpenGL)
24
25namespace QGL
26{
27%TypeHeaderCode
28#include <qgl.h>
29%End
30
31    enum FormatOption
32    {
33        DoubleBuffer,
34        DepthBuffer,
35        Rgba,
36        AlphaChannel,
37        AccumBuffer,
38        StencilBuffer,
39        StereoBuffers,
40        DirectRendering,
41        HasOverlay,
42        SampleBuffers,
43        SingleBuffer,
44        NoDepthBuffer,
45        ColorIndex,
46        NoAlphaChannel,
47        NoAccumBuffer,
48        NoStencilBuffer,
49        NoStereoBuffers,
50        IndirectRendering,
51        NoOverlay,
52        NoSampleBuffers,
53        DeprecatedFunctions,
54        NoDeprecatedFunctions,
55    };
56
57    typedef QFlags<QGL::FormatOption> FormatOptions;
58};
59
60%End
61%If (PyQt_OpenGL)
62QFlags<QGL::FormatOption> operator|(QGL::FormatOption f1, QFlags<QGL::FormatOption> f2);
63%End
64%If (PyQt_OpenGL)
65
66class QGLFormat
67{
68%TypeHeaderCode
69#include <qgl.h>
70%End
71
72public:
73    enum OpenGLVersionFlag
74    {
75        OpenGL_Version_None,
76        OpenGL_Version_1_1,
77        OpenGL_Version_1_2,
78        OpenGL_Version_1_3,
79        OpenGL_Version_1_4,
80        OpenGL_Version_1_5,
81        OpenGL_Version_2_0,
82        OpenGL_Version_2_1,
83        OpenGL_Version_3_0,
84        OpenGL_Version_3_1,
85        OpenGL_Version_3_2,
86        OpenGL_Version_3_3,
87        OpenGL_Version_4_0,
88        OpenGL_Version_4_1,
89        OpenGL_Version_4_2,
90        OpenGL_Version_4_3,
91        OpenGL_ES_Common_Version_1_0,
92        OpenGL_ES_CommonLite_Version_1_0,
93        OpenGL_ES_Common_Version_1_1,
94        OpenGL_ES_CommonLite_Version_1_1,
95        OpenGL_ES_Version_2_0,
96    };
97
98    typedef QFlags<QGLFormat::OpenGLVersionFlag> OpenGLVersionFlags;
99    QGLFormat();
100    QGLFormat(QGL::FormatOptions options, int plane = 0);
101    QGLFormat(const QGLFormat &other);
102    ~QGLFormat();
103    void setDepthBufferSize(int size);
104    int depthBufferSize() const;
105    void setAccumBufferSize(int size);
106    int accumBufferSize() const;
107    void setAlphaBufferSize(int size);
108    int alphaBufferSize() const;
109    void setStencilBufferSize(int size);
110    int stencilBufferSize() const;
111    void setSampleBuffers(bool enable);
112    void setSamples(int numSamples);
113    int samples() const;
114    void setDoubleBuffer(bool enable);
115    void setDepth(bool enable);
116    void setRgba(bool enable);
117    void setAlpha(bool enable);
118    void setAccum(bool enable);
119    void setStencil(bool enable);
120    void setStereo(bool enable);
121    void setDirectRendering(bool enable);
122    void setOverlay(bool enable);
123    int plane() const;
124    void setPlane(int plane);
125    void setOption(QGL::FormatOptions opt);
126    bool testOption(QGL::FormatOptions opt) const;
127    static QGLFormat defaultFormat();
128    static void setDefaultFormat(const QGLFormat &f);
129    static QGLFormat defaultOverlayFormat();
130    static void setDefaultOverlayFormat(const QGLFormat &f);
131    static bool hasOpenGL();
132    static bool hasOpenGLOverlays();
133    bool doubleBuffer() const;
134    bool depth() const;
135    bool rgba() const;
136    bool alpha() const;
137    bool accum() const;
138    bool stencil() const;
139    bool stereo() const;
140    bool directRendering() const;
141    bool hasOverlay() const;
142    bool sampleBuffers() const;
143    void setRedBufferSize(int size);
144    int redBufferSize() const;
145    void setGreenBufferSize(int size);
146    int greenBufferSize() const;
147    void setBlueBufferSize(int size);
148    int blueBufferSize() const;
149    void setSwapInterval(int interval);
150    int swapInterval() const;
151    static QGLFormat::OpenGLVersionFlags openGLVersionFlags();
152    void setVersion(int major, int minor);
153    int majorVersion() const;
154    int minorVersion() const;
155
156    enum OpenGLContextProfile
157    {
158        NoProfile,
159        CoreProfile,
160        CompatibilityProfile,
161    };
162
163    void setProfile(QGLFormat::OpenGLContextProfile profile);
164    QGLFormat::OpenGLContextProfile profile() const;
165};
166
167%End
168%If (PyQt_OpenGL)
169bool operator==(const QGLFormat &, const QGLFormat &);
170%End
171%If (PyQt_OpenGL)
172bool operator!=(const QGLFormat &, const QGLFormat &);
173%End
174%If (PyQt_OpenGL)
175
176class QGLContext /Supertype=sip.wrapper/
177{
178%TypeHeaderCode
179#include <qgl.h>
180%End
181
182public:
183    QGLContext(const QGLFormat &format);
184    virtual ~QGLContext();
185    virtual bool create(const QGLContext *shareContext = 0);
186    bool isValid() const;
187    bool isSharing() const;
188    void reset();
189    QGLFormat format() const;
190    QGLFormat requestedFormat() const;
191    void setFormat(const QGLFormat &format);
192    virtual void makeCurrent();
193    virtual void doneCurrent();
194    virtual void swapBuffers() const;
195    GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA);
196    GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA);
197    void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
198    void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
199    GLuint bindTexture(const QString &fileName);
200    void deleteTexture(GLuint tx_id);
201    static void setTextureCacheLimit(int size);
202    static int textureCacheLimit();
203    QFunctionPointer getProcAddress(const QString &proc) const;
204    QPaintDevice *device() const;
205    QColor overlayTransparentColor() const;
206    static const QGLContext *currentContext();
207
208protected:
209    virtual bool chooseContext(const QGLContext *shareContext = 0);
210    bool deviceIsPixmap() const;
211    bool windowCreated() const;
212    void setWindowCreated(bool on);
213    bool initialized() const;
214    void setInitialized(bool on);
215
216public:
217    static bool areSharing(const QGLContext *context1, const QGLContext *context2);
218
219    enum BindOption
220    {
221        NoBindOption,
222        InvertedYBindOption,
223        MipmapBindOption,
224        PremultipliedAlphaBindOption,
225        LinearFilteringBindOption,
226        DefaultBindOption,
227    };
228
229    typedef QFlags<QGLContext::BindOption> BindOptions;
230    GLuint bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options);
231    GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options);
232    void moveToThread(QThread *thread);
233
234private:
235    QGLContext(const QGLContext &);
236};
237
238%End
239%If (PyQt_OpenGL)
240
241class QGLWidget : QWidget
242{
243%TypeHeaderCode
244#include <qgl.h>
245%End
246
247%ConvertToSubClassCode
248    static struct class_graph {
249        const char *name;
250        sipTypeDef **type;
251        int yes, no;
252    } graph[] = {
253        {sipName_QGLWidget, &sipType_QGLWidget, -1, -1},
254    };
255
256    int i = 0;
257
258    sipType = NULL;
259
260    do
261    {
262        struct class_graph *cg = &graph[i];
263
264        if (cg->name != NULL && sipCpp->inherits(cg->name))
265        {
266            sipType = *cg->type;
267            i = cg->yes;
268        }
269        else
270            i = cg->no;
271    }
272    while (i >= 0);
273%End
274
275public:
276    QGLWidget(QWidget *parent /TransferThis/ = 0, const QGLWidget *shareWidget = 0, Qt::WindowFlags flags = Qt::WindowFlags());
277    QGLWidget(QGLContext *context /Transfer/, QWidget *parent /TransferThis/ = 0, const QGLWidget *shareWidget = 0, Qt::WindowFlags flags = Qt::WindowFlags());
278    QGLWidget(const QGLFormat &format, QWidget *parent /TransferThis/ = 0, const QGLWidget *shareWidget = 0, Qt::WindowFlags flags = Qt::WindowFlags());
279    virtual ~QGLWidget();
280    void qglColor(const QColor &c) const;
281    void qglClearColor(const QColor &c) const;
282    bool isValid() const;
283    bool isSharing() const;
284    void makeCurrent();
285    void doneCurrent();
286    bool doubleBuffer() const;
287    void swapBuffers();
288    QGLFormat format() const;
289    QGLContext *context() const;
290    void setContext(QGLContext *context /Transfer/, const QGLContext *shareContext = 0, bool deleteOldContext = true);
291    QPixmap renderPixmap(int width = 0, int height = 0, bool useContext = false);
292    QImage grabFrameBuffer(bool withAlpha = false);
293    void makeOverlayCurrent();
294    const QGLContext *overlayContext() const;
295    static QImage convertToGLFormat(const QImage &img);
296    void renderText(int x, int y, const QString &str, const QFont &font = QFont());
297    void renderText(double x, double y, double z, const QString &str, const QFont &font = QFont());
298    virtual QPaintEngine *paintEngine() const;
299    GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA);
300    GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA);
301    GLuint bindTexture(const QString &fileName);
302    void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
303    void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D);
304    void deleteTexture(GLuint tx_id);
305
306public slots:
307    virtual void updateGL();
308    virtual void updateOverlayGL();
309
310protected:
311    virtual bool event(QEvent *);
312    virtual void initializeGL();
313    virtual void resizeGL(int w, int h);
314    virtual void paintGL();
315    virtual void initializeOverlayGL();
316    virtual void resizeOverlayGL(int w, int h);
317    virtual void paintOverlayGL();
318    void setAutoBufferSwap(bool on);
319    bool autoBufferSwap() const;
320    virtual void paintEvent(QPaintEvent *);
321    virtual void resizeEvent(QResizeEvent *);
322    virtual void glInit();
323    virtual void glDraw();
324
325public:
326    GLuint bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options);
327    GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options);
328};
329
330%End
331%If (PyQt_OpenGL)
332QFlags<QGLFormat::OpenGLVersionFlag> operator|(QGLFormat::OpenGLVersionFlag f1, QFlags<QGLFormat::OpenGLVersionFlag> f2);
333%End
334%If (PyQt_OpenGL)
335QFlags<QGLContext::BindOption> operator|(QGLContext::BindOption f1, QFlags<QGLContext::BindOption> f2);
336%End
337