Dusk Audio Framework
Loading...
Searching...
No Matches
OpenGL-include.hpp
1/*
2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef DGL_OPENGL_INCLUDE_HPP_INCLUDED
18#define DGL_OPENGL_INCLUDE_HPP_INCLUDED
19
20#include "../daf/src/DafDefines.h"
21
22// --------------------------------------------------------------------------------------------------------------------
23// Fix OpenGL includes for Windows, based on glfw code (part 1)
24
25#undef DGL_WINGDIAPI_DEFINED
26
27#ifdef DAF_OS_WINDOWS
28
29#ifndef WINAPI
30# define WINAPI __stdcall
31#endif
32
33#ifndef APIENTRY
34# define APIENTRY WINAPI
35#endif // APIENTRY
36
37/* We need WINGDIAPI defined */
38#ifndef WINGDIAPI
39# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
40# define WINGDIAPI __declspec(dllimport)
41# elif defined(__LCC__)
42# define WINGDIAPI __stdcall
43# else
44# define WINGDIAPI extern
45# endif
46# define DGL_WINGDIAPI_DEFINED
47#endif // WINGDIAPI
48
49#endif // DAF_OS_WINDOWS
50
51// --------------------------------------------------------------------------------------------------------------------
52// OpenGL includes
53
54#ifdef DAF_OS_MAC
55// There is no OpenGL ES on macOS: Apple ships no desktop GLES implementation and no <GLES2/gl2.h>, so there is
56// nothing to include here for a GLES build. This used to silently #undef DGL_USE_GLES/GLES2/GLES3 and fall
57// through to the desktop gl3.h path below, which meant a UI_TYPE=gles2 or gles3 build on macOS quietly produced
58// an ordinary desktop GL3 binary -- the build succeeded, the CI leg went green, and nothing GLES was ever
59// compiled or tested. Fail loudly instead, so the build says what it cannot do.
60# ifdef DGL_USE_GLES
61# error OpenGL ES is not supported on macOS, use UI_TYPE=opengl3 (desktop GL3 core profile) instead
62# endif
63# ifdef DGL_USE_OPENGL3
64# include <OpenGL/gl3.h>
65# include <OpenGL/gl3ext.h>
66# else
67# include <OpenGL/gl.h>
68# endif
69#else
70# ifndef DAF_OS_WINDOWS
71# define GL_GLEXT_PROTOTYPES
72# endif
73# ifndef __GLEW_H__
74# include <GL/gl.h>
75# include <GL/glext.h>
76# endif
77#endif
78
79// --------------------------------------------------------------------------------------------------------------------
80// Missing OpenGL defines
81
82#if defined(GL_BGR_EXT) && !defined(GL_BGR)
83# define GL_BGR GL_BGR_EXT
84#endif
85
86#if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
87# define GL_BGRA GL_BGRA_EXT
88#endif
89
90#ifndef GL_CLAMP_TO_BORDER
91# define GL_CLAMP_TO_BORDER 0x812D
92#endif
93
94// --------------------------------------------------------------------------------------------------------------------
95// Fix OpenGL includes for Windows, based on glfw code (part 2)
96
97#ifdef DGL_WINGDIAPI_DEFINED
98# undef WINGDIAPI
99# undef DGL_WINGDIAPI_DEFINED
100#endif
101
102// --------------------------------------------------------------------------------------------------------------------
103
104#endif