1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2016-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_oct_opengl_h)
27 #define octave_oct_opengl_h 1
28 
29 #include "octave-config.h"
30 
31 #if defined (HAVE_OPENGL)
32 
33 #  if defined (HAVE_GL_GL_H)
34 #    include <GL/gl.h>
35 #  elif defined (HAVE_OPENGL_GL_H) || defined (HAVE_FRAMEWORK_OPENGL)
36 #    include <OpenGL/gl.h>
37 #  endif
38 
39 #  if defined (HAVE_GL_GLU_H)
40 #    include <GL/glu.h>
41 #  elif defined (HAVE_OPENGL_GLU_H) || defined (HAVE_FRAMEWORK_OPENGL)
42 #    include <OpenGL/glu.h>
43 #  endif
44 
45 #  if defined (HAVE_GL_GLEXT_H)
46 #    include <GL/glext.h>
47 #  elif defined (HAVE_OPENGL_GLEXT_H) || defined (HAVE_FRAMEWORK_OPENGL)
48 #    include <OpenGL/glext.h>
49 #  endif
50 
51 #endif
52 
53 namespace octave
54 {
55   class opengl_functions
56   {
57   public:
58 
opengl_functions(void)59     opengl_functions (void) { }
60 
61     opengl_functions (const opengl_functions&) = default;
62 
63     opengl_functions& operator = (const opengl_functions&) = default;
64 
65     virtual ~opengl_functions (void) = default;
66 
67 #if defined (HAVE_OPENGL)
68 
69     // If OpenGL is not available, opengl_functions will be a dummy
70     // class that does nothing.  This makes the implementation of
71     // other things that rely on this class slightly simpler.
72 
glAlphaFunc(GLenum func,GLclampf ref)73     virtual void glAlphaFunc (GLenum func, GLclampf ref)
74     {
75       ::glAlphaFunc (func, ref);
76     }
77 
glBegin(GLenum mode)78     virtual void glBegin (GLenum mode)
79     {
80       ::glBegin (mode);
81     }
82 
glBindTexture(GLenum target,GLuint texture)83     virtual void glBindTexture (GLenum target, GLuint texture)
84     {
85       ::glBindTexture (target, texture);
86     }
87 
glBitmap(GLsizei width,GLsizei height,GLfloat xorig,GLfloat yorig,GLfloat xmove,GLfloat ymove,const GLubyte * bitmap)88     virtual void glBitmap (GLsizei width, GLsizei height, GLfloat xorig,
89                            GLfloat yorig, GLfloat xmove, GLfloat ymove,
90                            const GLubyte *bitmap)
91     {
92       ::glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap);
93     }
94 
glBlendFunc(GLenum sfactor,GLenum dfactor)95     virtual void glBlendFunc (GLenum sfactor, GLenum dfactor)
96     {
97       ::glBlendFunc (sfactor, dfactor);
98     }
99 
glCallList(GLuint list)100     virtual void glCallList (GLuint list)
101     {
102       ::glCallList (list);
103     }
104 
glClearColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)105     virtual void glClearColor (GLclampf red, GLclampf green, GLclampf blue,
106                                GLclampf alpha)
107     {
108       ::glClearColor (red, green, blue, alpha);
109     }
110 
glClear(GLbitfield mask)111     virtual void glClear (GLbitfield mask)
112     {
113       ::glClear (mask);
114     }
115 
glClipPlane(GLenum plane,const GLdouble * equation)116     virtual void glClipPlane (GLenum plane, const GLdouble *equation)
117     {
118       ::glClipPlane (plane, equation);
119     }
120 
glColor3dv(const GLdouble * v)121     virtual void glColor3dv (const GLdouble *v)
122     {
123       ::glColor3dv (v);
124     }
125 
glColor3f(GLfloat red,GLfloat green,GLfloat blue)126     virtual void glColor3f (GLfloat red, GLfloat green, GLfloat blue)
127     {
128       ::glColor3f (red, green, blue);
129     }
130 
glColor3fv(const GLfloat * v)131     virtual void glColor3fv (const GLfloat *v)
132     {
133       ::glColor3fv (v);
134     }
135 
glColor4d(GLdouble red,GLdouble green,GLdouble blue,GLdouble alpha)136     virtual void glColor4d (GLdouble red, GLdouble green, GLdouble blue,
137                             GLdouble alpha)
138     {
139       ::glColor4d (red, green, blue, alpha);
140     }
141 
glColor4f(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)142     virtual void glColor4f (GLfloat red, GLfloat green, GLfloat blue,
143                             GLfloat alpha)
144     {
145       ::glColor4f (red, green, blue, alpha);
146     }
147 
glColor4fv(const GLfloat * v)148     virtual void glColor4fv (const GLfloat *v)
149     {
150       ::glColor4fv (v);
151     }
152 
glDeleteLists(GLuint list,GLsizei range)153     virtual void glDeleteLists (GLuint list, GLsizei range)
154     {
155       ::glDeleteLists (list, range);
156     }
157 
glDeleteTextures(GLsizei n,const GLuint * textures)158     virtual void glDeleteTextures (GLsizei n, const GLuint *textures)
159     {
160       ::glDeleteTextures (n, textures);
161     }
162 
glDepthFunc(GLenum func)163     virtual void glDepthFunc (GLenum func)
164     {
165       ::glDepthFunc (func);
166     }
167 
glDisable(GLenum cap)168     virtual void glDisable (GLenum cap)
169     {
170       ::glDisable (cap);
171     }
172 
glDrawPixels(GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)173     virtual void glDrawPixels (GLsizei width, GLsizei height, GLenum format,
174                                GLenum type, const GLvoid *pixels)
175     {
176       ::glDrawPixels (width, height, format, type, pixels);
177     }
178 
glEdgeFlag(GLboolean flag)179     virtual void glEdgeFlag (GLboolean flag)
180     {
181       ::glEdgeFlag (flag);
182     }
183 
glEnable(GLenum cap)184     virtual void glEnable (GLenum cap)
185     {
186       ::glEnable (cap);
187     }
188 
glEndList(void)189     virtual void glEndList (void)
190     {
191       ::glEndList ();
192     }
193 
glEnd(void)194     virtual void glEnd (void)
195     {
196       ::glEnd ();
197     }
198 
glFinish(void)199     virtual void glFinish (void)
200     {
201       ::glFinish ();
202     }
203 
glGenLists(GLsizei range)204     virtual GLuint glGenLists (GLsizei range)
205     {
206       return ::glGenLists (range);
207     }
208 
glGenTextures(GLsizei n,GLuint * textures)209     virtual void glGenTextures (GLsizei n, GLuint *textures)
210     {
211       ::glGenTextures (n, textures);
212     }
213 
glGetBooleanv(GLenum pname,GLboolean * data)214     virtual void glGetBooleanv (GLenum pname, GLboolean *data)
215     {
216       ::glGetBooleanv (pname, data);
217     }
218 
glGetDoublev(GLenum pname,GLdouble * data)219     virtual void glGetDoublev (GLenum pname, GLdouble *data)
220     {
221       ::glGetDoublev (pname, data);
222     }
223 
glGetError(void)224     virtual GLenum glGetError (void)
225     {
226       return ::glGetError ();
227     }
228 
glGetFloatv(GLenum pname,GLfloat * data)229     virtual void glGetFloatv (GLenum pname, GLfloat *data)
230     {
231       ::glGetFloatv (pname, data);
232     }
233 
glGetIntegerv(GLenum pname,GLint * data)234     virtual void glGetIntegerv (GLenum pname, GLint *data)
235     {
236       ::glGetIntegerv (pname, data);
237     }
238 
glGetString(GLenum name)239     virtual const GLubyte * glGetString (GLenum name)
240     {
241       return ::glGetString (name);
242     }
243 
glHint(GLenum target,GLenum mode)244     virtual void glHint (GLenum target, GLenum mode)
245     {
246       ::glHint (target, mode);
247     }
248 
glInitNames(void)249     virtual void glInitNames (void)
250     {
251       ::glInitNames ();
252     }
253 
glIsEnabled(GLenum cap)254     virtual GLboolean glIsEnabled (GLenum cap)
255     {
256       return ::glIsEnabled (cap);
257     }
258 
glLightfv(GLenum light,GLenum pname,const GLfloat * params)259     virtual void glLightfv (GLenum light, GLenum pname, const GLfloat *params)
260     {
261       ::glLightfv (light, pname, params);
262     }
263 
glLineStipple(GLint factor,GLushort pattern)264     virtual void glLineStipple (GLint factor, GLushort pattern)
265     {
266       ::glLineStipple (factor, pattern);
267     }
268 
glLineWidth(GLfloat width)269     virtual void glLineWidth (GLfloat width)
270     {
271       ::glLineWidth (width);
272     }
273 
glLoadIdentity(void)274     virtual void glLoadIdentity (void)
275     {
276       ::glLoadIdentity ();
277     }
278 
glMaterialf(GLenum face,GLenum pname,GLfloat param)279     virtual void glMaterialf (GLenum face, GLenum pname, GLfloat param)
280     {
281       ::glMaterialf (face, pname, param);
282     }
283 
glMaterialfv(GLenum face,GLenum pname,const GLfloat * params)284     virtual void glMaterialfv (GLenum face, GLenum pname, const GLfloat *params)
285     {
286       ::glMaterialfv (face, pname, params);
287     }
288 
glMatrixMode(GLenum mode)289     virtual void glMatrixMode (GLenum mode)
290     {
291       ::glMatrixMode (mode);
292     }
293 
glMultMatrixd(const GLdouble * m)294     virtual void glMultMatrixd (const GLdouble *m)
295     {
296       ::glMultMatrixd (m);
297     }
298 
glNewList(GLuint list,GLenum mode)299     virtual void glNewList (GLuint list, GLenum mode)
300     {
301       ::glNewList (list, mode);
302     }
303 
glNormal3d(GLdouble nx,GLdouble ny,GLdouble nz)304     virtual void glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz)
305     {
306       ::glNormal3d (nx, ny, nz);
307     }
308 
glNormal3dv(const GLdouble * v)309     virtual void glNormal3dv (const GLdouble *v)
310     {
311       ::glNormal3dv (v);
312     }
313 
glOrtho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble near_val,GLdouble far_val)314     virtual void glOrtho (GLdouble left, GLdouble right, GLdouble bottom,
315                           GLdouble top, GLdouble near_val, GLdouble far_val)
316     {
317       ::glOrtho (left, right, bottom, top, near_val, far_val);
318     }
319 
glPixelStorei(GLenum pname,GLint param)320     virtual void glPixelStorei (GLenum pname, GLint param)
321     {
322       ::glPixelStorei (pname, param);
323     }
324 
glPixelZoom(GLfloat xfactor,GLfloat yfactor)325     virtual void glPixelZoom (GLfloat xfactor, GLfloat yfactor)
326     {
327       ::glPixelZoom (xfactor, yfactor);
328     }
329 
glPolygonMode(GLenum face,GLenum mode)330     virtual void glPolygonMode (GLenum face, GLenum mode)
331     {
332       ::glPolygonMode (face, mode);
333     }
334 
glPolygonOffset(GLfloat factor,GLfloat units)335     virtual void glPolygonOffset (GLfloat factor, GLfloat units)
336     {
337       ::glPolygonOffset (factor, units);
338     }
339 
glPopAttrib(void)340     virtual void glPopAttrib (void)
341     {
342       ::glPopAttrib ();
343     }
344 
glPopMatrix(void)345     virtual void glPopMatrix (void)
346     {
347       ::glPopMatrix ();
348     }
349 
glPopName(void)350     virtual void glPopName (void)
351     {
352       ::glPopName ();
353     }
354 
glPushAttrib(GLbitfield mask)355     virtual void glPushAttrib (GLbitfield mask)
356     {
357       ::glPushAttrib (mask);
358     }
359 
glPushMatrix(void)360     virtual void glPushMatrix (void)
361     {
362       ::glPushMatrix ();
363     }
364 
glPushName(GLuint name)365     virtual void glPushName (GLuint name)
366     {
367       ::glPushName (name);
368     }
369 
glRasterPos3d(GLdouble x,GLdouble y,GLdouble z)370     virtual void glRasterPos3d (GLdouble x, GLdouble y, GLdouble z)
371     {
372       ::glRasterPos3d (x, y, z);
373     }
374 
glReadPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLvoid * pixels)375     virtual void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height,
376                                GLenum format, GLenum type, GLvoid *pixels)
377     {
378       ::glReadPixels (x, y, width, height, format, type, pixels);
379     }
380 
glRenderMode(GLenum mode)381     virtual GLint glRenderMode (GLenum mode)
382     {
383       return ::glRenderMode (mode);
384     }
385 
glRotated(GLdouble angle,GLdouble x,GLdouble y,GLdouble z)386     virtual void glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
387     {
388       ::glRotated (angle, x, y, z);
389     }
390 
glScaled(GLdouble x,GLdouble y,GLdouble z)391     virtual void glScaled (GLdouble x, GLdouble y, GLdouble z)
392     {
393       ::glScaled (x, y, z);
394     }
395 
glScalef(GLfloat x,GLfloat y,GLfloat z)396     virtual void glScalef (GLfloat x, GLfloat y, GLfloat z)
397     {
398       ::glScalef (x, y, z);
399     }
400 
glSelectBuffer(GLsizei size,GLuint * buffer)401     virtual void glSelectBuffer (GLsizei size, GLuint *buffer)
402     {
403       ::glSelectBuffer (size, buffer);
404     }
405 
glShadeModel(GLenum mode)406     virtual void glShadeModel (GLenum mode)
407     {
408       ::glShadeModel (mode);
409     }
410 
glTexCoord2d(GLdouble s,GLdouble t)411     virtual void glTexCoord2d (GLdouble s, GLdouble t)
412     {
413       ::glTexCoord2d (s, t);
414     }
415 
glTexImage2D(GLenum target,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)416     virtual void glTexImage2D (GLenum target, GLint level, GLint internalFormat,
417                                GLsizei width, GLsizei height, GLint border,
418                                GLenum format, GLenum type, const GLvoid *pixels)
419     {
420       ::glTexImage2D (target, level, internalFormat, width, height, border,
421                       format, type, pixels);
422     }
423 
glTexParameteri(GLenum target,GLenum pname,GLint param)424     virtual void glTexParameteri (GLenum target, GLenum pname, GLint param)
425     {
426       ::glTexParameteri (target, pname, param);
427     }
428 
glTranslated(GLdouble x,GLdouble y,GLdouble z)429     virtual void glTranslated (GLdouble x, GLdouble y, GLdouble z)
430     {
431       ::glTranslated (x, y, z);
432     }
433 
glTranslatef(GLfloat x,GLfloat y,GLfloat z)434     virtual void glTranslatef (GLfloat x, GLfloat y, GLfloat z)
435     {
436       ::glTranslatef (x, y, z);
437     }
438 
glVertex2d(GLdouble x,GLdouble y)439     virtual void glVertex2d (GLdouble x, GLdouble y)
440     {
441       ::glVertex2d (x, y);
442     }
443 
glVertex3d(GLdouble x,GLdouble y,GLdouble z)444     virtual void glVertex3d (GLdouble x, GLdouble y, GLdouble z)
445     {
446       ::glVertex3d (x, y, z);
447     }
448 
glVertex3dv(const GLdouble * v)449     virtual void glVertex3dv (const GLdouble *v)
450     {
451       ::glVertex3dv (v);
452     }
453 
glViewport(GLint x,GLint y,GLsizei width,GLsizei height)454     virtual void glViewport (GLint x, GLint y, GLsizei width, GLsizei height)
455     {
456       ::glViewport (x, y, width, height);
457     }
458 
459 #endif
460   };
461 }
462 
463 
464 #endif
465