1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2018-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_qopengl_functions_h)
27 #define octave_qopengl_functions_h 1
28 
29 #include "oct-opengl.h"
30 
31 #if defined (HAVE_QOPENGLFUNCTIONS_1_1)
32 #  include <QOpenGLFunctions_1_1>
33 #endif
34 
35 namespace octave
36 {
37   // If we don't have QOPENGLFUNCTIONS_1_1, then we will default to
38   // calling OpenGL functions directly through the base
39   // opengl_functions class.
40 
41   class qopengl_functions : public opengl_functions
42   {
43   public:
44 
qopengl_functions(void)45     qopengl_functions (void)
46 #if defined (HAVE_QOPENGLFUNCTIONS_1_1)
47       : m_glfcns ()
48 #endif
49     { }
50 
51     qopengl_functions (const qopengl_functions&) = default;
52 
53     qopengl_functions& operator = (const qopengl_functions&) = default;
54 
55     ~qopengl_functions (void) = default;
56 
init(void)57     void init (void)
58     {
59 #if defined (HAVE_QOPENGLFUNCTIONS_1_1)
60       m_glfcns.initializeOpenGLFunctions ();
61 #endif
62     }
63 
64 #if defined (HAVE_QOPENGLFUNCTIONS_1_1)
65 
glAlphaFunc(GLenum func,GLclampf ref)66     void glAlphaFunc (GLenum func, GLclampf ref)
67     {
68       m_glfcns.glAlphaFunc (func, ref);
69     }
70 
glBegin(GLenum mode)71     void glBegin (GLenum mode)
72     {
73       m_glfcns.glBegin (mode);
74     }
75 
glBindTexture(GLenum target,GLuint texture)76     void glBindTexture (GLenum target, GLuint texture)
77     {
78       m_glfcns.glBindTexture (target, texture);
79     }
80 
glBitmap(GLsizei width,GLsizei height,GLfloat xorig,GLfloat yorig,GLfloat xmove,GLfloat ymove,const GLubyte * bitmap)81     void glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
82                    GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
83     {
84       m_glfcns.glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap);
85     }
86 
glBlendFunc(GLenum sfactor,GLenum dfactor)87     void glBlendFunc (GLenum sfactor, GLenum dfactor)
88     {
89       m_glfcns.glBlendFunc (sfactor, dfactor);
90     }
91 
glCallList(GLuint list)92     void glCallList (GLuint list)
93     {
94       m_glfcns.glCallList (list);
95     }
96 
glClearColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)97     void glClearColor (GLclampf red, GLclampf green, GLclampf blue,
98                        GLclampf alpha)
99     {
100       m_glfcns.glClearColor (red, green, blue, alpha);
101     }
102 
glClear(GLbitfield mask)103     void glClear (GLbitfield mask)
104     {
105       m_glfcns.glClear (mask);
106     }
107 
glClipPlane(GLenum plane,const GLdouble * equation)108     void glClipPlane (GLenum plane, const GLdouble *equation)
109     {
110       m_glfcns.glClipPlane (plane, equation);
111     }
112 
glColor3dv(const GLdouble * v)113     void glColor3dv (const GLdouble *v)
114     {
115       m_glfcns.glColor3dv (v);
116     }
117 
glColor3f(GLfloat red,GLfloat green,GLfloat blue)118     void glColor3f (GLfloat red, GLfloat green, GLfloat blue)
119     {
120       m_glfcns.glColor3f (red, green, blue);
121     }
122 
glColor3fv(const GLfloat * v)123     void glColor3fv (const GLfloat *v)
124     {
125       m_glfcns.glColor3fv (v);
126     }
127 
glColor4d(GLdouble red,GLdouble green,GLdouble blue,GLdouble alpha)128     void glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
129     {
130       m_glfcns.glColor4d (red, green, blue, alpha);
131     }
132 
glColor4f(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)133     void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
134     {
135       m_glfcns.glColor4f (red, green, blue, alpha);
136     }
137 
glColor4fv(const GLfloat * v)138     void glColor4fv (const GLfloat *v)
139     {
140       m_glfcns.glColor4fv (v);
141     }
142 
glDeleteLists(GLuint list,GLsizei range)143     void glDeleteLists (GLuint list, GLsizei range)
144     {
145       m_glfcns.glDeleteLists (list, range);
146     }
147 
glDeleteTextures(GLsizei n,const GLuint * textures)148     void glDeleteTextures (GLsizei n, const GLuint *textures)
149     {
150       m_glfcns.glDeleteTextures (n, textures);
151     }
152 
glDepthFunc(GLenum func)153     void glDepthFunc (GLenum func)
154     {
155       m_glfcns.glDepthFunc (func);
156     }
157 
glDisable(GLenum cap)158     void glDisable (GLenum cap)
159     {
160       m_glfcns.glDisable (cap);
161     }
162 
glDrawPixels(GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)163     void glDrawPixels (GLsizei width, GLsizei height, GLenum format,
164                        GLenum type, const GLvoid *pixels)
165     {
166       m_glfcns.glDrawPixels (width, height, format, type, pixels);
167     }
168 
glEdgeFlag(GLboolean flag)169     void glEdgeFlag (GLboolean flag)
170     {
171       m_glfcns.glEdgeFlag (flag);
172     }
173 
glEnable(GLenum cap)174     void glEnable (GLenum cap)
175     {
176       m_glfcns.glEnable (cap);
177     }
178 
glEndList(void)179     void glEndList (void)
180     {
181       m_glfcns.glEndList ();
182     }
183 
glEnd(void)184     void glEnd (void)
185     {
186       m_glfcns.glEnd ();
187     }
188 
glFinish(void)189     void glFinish (void)
190     {
191       m_glfcns.glFinish ();
192     }
193 
glGenLists(GLsizei range)194     GLuint glGenLists (GLsizei range)
195     {
196       return m_glfcns.glGenLists (range);
197     }
198 
glGenTextures(GLsizei n,GLuint * textures)199     void glGenTextures (GLsizei n, GLuint *textures)
200     {
201       m_glfcns.glGenTextures (n, textures);
202     }
203 
glGetBooleanv(GLenum pname,GLboolean * data)204     void glGetBooleanv (GLenum pname, GLboolean *data)
205     {
206       m_glfcns.glGetBooleanv (pname, data);
207     }
208 
glGetDoublev(GLenum pname,GLdouble * data)209     void glGetDoublev (GLenum pname, GLdouble *data)
210     {
211       m_glfcns.glGetDoublev (pname, data);
212     }
213 
glGetError(void)214     GLenum glGetError (void)
215     {
216       return m_glfcns.glGetError ();
217     }
218 
glGetFloatv(GLenum pname,GLfloat * data)219     void glGetFloatv (GLenum pname, GLfloat *data)
220     {
221       m_glfcns.glGetFloatv (pname, data);
222     }
223 
glGetIntegerv(GLenum pname,GLint * data)224     void glGetIntegerv (GLenum pname, GLint *data)
225     {
226       m_glfcns.glGetIntegerv (pname, data);
227     }
228 
glGetString(GLenum name)229     const GLubyte * glGetString (GLenum name)
230     {
231       return m_glfcns.glGetString (name);
232     }
233 
glHint(GLenum target,GLenum mode)234     void glHint (GLenum target, GLenum mode)
235     {
236       m_glfcns.glHint (target, mode);
237     }
238 
glInitNames(void)239     void glInitNames (void)
240     {
241       m_glfcns.glInitNames ();
242     }
243 
glIsEnabled(GLenum cap)244     GLboolean glIsEnabled (GLenum cap)
245     {
246       return m_glfcns.glIsEnabled (cap);
247     }
248 
glLightfv(GLenum light,GLenum pname,const GLfloat * params)249     void glLightfv (GLenum light, GLenum pname, const GLfloat *params)
250     {
251       m_glfcns.glLightfv (light, pname, params);
252     }
253 
glLineStipple(GLint factor,GLushort pattern)254     void glLineStipple (GLint factor, GLushort pattern)
255     {
256       m_glfcns.glLineStipple (factor, pattern);
257     }
258 
glLineWidth(GLfloat width)259     void glLineWidth (GLfloat width)
260     {
261       m_glfcns.glLineWidth (width);
262     }
263 
glLoadIdentity(void)264     void glLoadIdentity (void)
265     {
266       m_glfcns.glLoadIdentity ();
267     }
268 
glMaterialf(GLenum face,GLenum pname,GLfloat param)269     void glMaterialf (GLenum face, GLenum pname, GLfloat param)
270     {
271       m_glfcns.glMaterialf (face, pname, param);
272     }
273 
glMaterialfv(GLenum face,GLenum pname,const GLfloat * params)274     void glMaterialfv (GLenum face, GLenum pname, const GLfloat *params)
275     {
276       m_glfcns.glMaterialfv (face, pname, params);
277     }
278 
glMatrixMode(GLenum mode)279     void glMatrixMode (GLenum mode)
280     {
281       m_glfcns.glMatrixMode (mode);
282     }
283 
glMultMatrixd(const GLdouble * m)284     void glMultMatrixd (const GLdouble *m)
285     {
286       m_glfcns.glMultMatrixd (m);
287     }
288 
glNewList(GLuint list,GLenum mode)289     void glNewList (GLuint list, GLenum mode)
290     {
291       m_glfcns.glNewList (list, mode);
292     }
293 
glNormal3d(GLdouble nx,GLdouble ny,GLdouble nz)294     void glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz)
295     {
296       m_glfcns.glNormal3d (nx, ny, nz);
297     }
298 
glNormal3dv(const GLdouble * v)299     void glNormal3dv (const GLdouble *v)
300     {
301       m_glfcns.glNormal3dv (v);
302     }
303 
glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble near_val,GLdouble far_val)304     void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
305                   GLdouble near_val, GLdouble far_val)
306     {
307       m_glfcns.glOrtho (left, right, bottom, top, near_val, far_val);
308     }
309 
glPixelStorei(GLenum pname,GLint param)310     void glPixelStorei (GLenum pname, GLint param)
311     {
312       m_glfcns.glPixelStorei (pname, param);
313     }
314 
glPixelZoom(GLfloat xfactor,GLfloat yfactor)315     void glPixelZoom (GLfloat xfactor, GLfloat yfactor)
316     {
317       m_glfcns.glPixelZoom (xfactor, yfactor);
318     }
319 
glPolygonMode(GLenum face,GLenum mode)320     void glPolygonMode (GLenum face, GLenum mode)
321     {
322       m_glfcns.glPolygonMode (face, mode);
323     }
324 
glPolygonOffset(GLfloat factor,GLfloat units)325     void glPolygonOffset (GLfloat factor, GLfloat units)
326     {
327       m_glfcns.glPolygonOffset (factor, units);
328     }
329 
glPopAttrib(void)330     void glPopAttrib (void)
331     {
332       m_glfcns.glPopAttrib ();
333     }
334 
glPopMatrix(void)335     void glPopMatrix (void)
336     {
337       m_glfcns.glPopMatrix ();
338     }
339 
glPopName(void)340     void glPopName (void)
341     {
342       m_glfcns.glPopName ();
343     }
344 
glPushAttrib(GLbitfield mask)345     void glPushAttrib (GLbitfield mask)
346     {
347       m_glfcns.glPushAttrib (mask);
348     }
349 
glPushMatrix(void)350     void glPushMatrix (void)
351     {
352       m_glfcns.glPushMatrix ();
353     }
354 
glPushName(GLuint name)355     void glPushName (GLuint name)
356     {
357       m_glfcns.glPushName (name);
358     }
359 
glRasterPos3d(GLdouble x,GLdouble y,GLdouble z)360     void glRasterPos3d (GLdouble x, GLdouble y, GLdouble z)
361     {
362       m_glfcns.glRasterPos3d (x, y, z);
363     }
364 
glReadPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLvoid * pixels)365     void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height,
366                        GLenum format, GLenum type, GLvoid *pixels)
367     {
368       m_glfcns.glReadPixels (x, y, width, height, format, type, pixels);
369     }
370 
glRenderMode(GLenum mode)371     GLint glRenderMode (GLenum mode)
372     {
373       return m_glfcns.glRenderMode (mode);
374     }
375 
glRotated(GLdouble angle,GLdouble x,GLdouble y,GLdouble z)376     void glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
377     {
378       m_glfcns.glRotated (angle, x, y, z);
379     }
380 
glScaled(GLdouble x,GLdouble y,GLdouble z)381     void glScaled (GLdouble x, GLdouble y, GLdouble z)
382     {
383       m_glfcns.glScaled (x, y, z);
384     }
385 
glScalef(GLfloat x,GLfloat y,GLfloat z)386     void glScalef (GLfloat x, GLfloat y, GLfloat z)
387     {
388       m_glfcns.glScalef (x, y, z);
389     }
390 
glSelectBuffer(GLsizei size,GLuint * buffer)391     void glSelectBuffer (GLsizei size, GLuint *buffer)
392     {
393       m_glfcns.glSelectBuffer (size, buffer);
394     }
395 
glShadeModel(GLenum mode)396     void glShadeModel (GLenum mode)
397     {
398       m_glfcns.glShadeModel (mode);
399     }
400 
glTexCoord2d(GLdouble s,GLdouble t)401     void glTexCoord2d (GLdouble s, GLdouble t)
402     {
403       m_glfcns.glTexCoord2d (s, t);
404     }
405 
glTexImage2D(GLenum target,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)406     void glTexImage2D (GLenum target, GLint level, GLint internalFormat,
407                        GLsizei width, GLsizei height, GLint border,
408                        GLenum format, GLenum type, const GLvoid *pixels)
409     {
410       m_glfcns.glTexImage2D (target, level, internalFormat, width, height,
411                              border, format, type, pixels);
412     }
413 
glTexParameteri(GLenum target,GLenum pname,GLint param)414     void glTexParameteri (GLenum target, GLenum pname, GLint param)
415     {
416       m_glfcns.glTexParameteri (target, pname, param);
417     }
418 
glTranslated(GLdouble x,GLdouble y,GLdouble z)419     void glTranslated (GLdouble x, GLdouble y, GLdouble z)
420     {
421       m_glfcns.glTranslated (x, y, z);
422     }
423 
glTranslatef(GLfloat x,GLfloat y,GLfloat z)424     void glTranslatef (GLfloat x, GLfloat y, GLfloat z)
425     {
426       m_glfcns.glTranslatef (x, y, z);
427     }
428 
glVertex2d(GLdouble x,GLdouble y)429     void glVertex2d (GLdouble x, GLdouble y)
430     {
431       m_glfcns.glVertex2d (x, y);
432     }
433 
glVertex3d(GLdouble x,GLdouble y,GLdouble z)434     void glVertex3d (GLdouble x, GLdouble y, GLdouble z)
435     {
436       m_glfcns.glVertex3d (x, y, z);
437     }
438 
glVertex3dv(const GLdouble * v)439     void glVertex3dv (const GLdouble *v)
440     {
441       m_glfcns.glVertex3dv (v);
442     }
443 
glViewport(GLint x,GLint y,GLsizei width,GLsizei height)444     void glViewport (GLint x, GLint y, GLsizei width, GLsizei height)
445     {
446       m_glfcns.glViewport (x, y, width, height);
447     }
448 
449   private:
450 
451     QOpenGLFunctions_1_1 m_glfcns;
452 
453 #endif
454   };
455 }
456 
457 #endif
458