0032713: Visualization, OpenGl_GlFunctions - unify OpenGL and OpenGL ES function...
[occt.git] / src / OpenGl / OpenGl_GlNative.hxx
1 // Copyright (c) 2021 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef OpenGl_GlNative_HeaderFile
15 #define OpenGl_GlNative_HeaderFile
16
17 // required for correct APIENTRY definition
18 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
19   #define WIN32_LEAN_AND_MEAN
20   #include <windows.h>
21 #endif
22
23 #ifndef APIENTRY
24   #define APIENTRY
25 #endif
26 #ifndef APIENTRYP
27   #define APIENTRYP APIENTRY *
28 #endif
29 #ifndef GLAPI
30   #define GLAPI extern
31 #endif
32
33 #ifndef GL_APICALL
34   #define GL_APICALL GLAPI
35 #endif
36
37 // exclude modern definitions and system-provided glext.h, should be defined before gl.h inclusion
38 #ifndef GL_GLEXT_LEGACY
39   #define GL_GLEXT_LEGACY
40 #endif
41 #ifndef GLX_GLXEXT_LEGACY
42   #define GLX_GLXEXT_LEGACY
43 #endif
44
45 // include main OpenGL header provided with system
46 #if defined(__APPLE__)
47   #import <TargetConditionals.h>
48   // macOS 10.4 deprecated OpenGL framework - suppress useless warnings
49   #define GL_SILENCE_DEPRECATION
50   #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
51     #include <OpenGLES/ES3/gl.h>
52   #else
53     #include <OpenGL/gl.h>
54   #endif
55   #define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors
56 #elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
57   #if defined(_WIN32)
58     // Angle OpenGL ES headers do not define function prototypes even for core functions,
59     // however OCCT is expected to be linked against libGLESv2
60     #define GL_GLEXT_PROTOTYPES
61   #endif
62   #include <GLES3/gl3.h>
63 #else
64   #include <GL/gl.h>
65 #endif
66
67 #endif // OpenGl_GlNative_HeaderFile