| GL Studio C++ Runtime API

gls_include.h
Go to the documentation of this file.
1/*! \file
2 \brief A file for all GL Studio files to include.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<br>
9 USA<br>
10 <br>
11 All rights reserved.<br>
12
13 This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38
39*/
40
41#ifndef INCLUDED_GLS_INCLUDE_H
42#define INCLUDED_GLS_INCLUDE_H
43
44/// Macro denoting which functions should be visible from the runtime library.
45#if defined( WIN32 ) && ( defined( GLS_DLL ) || defined( GLS_EXPORT_LIBRARY ) || defined( GLS_IMPORT_LIBRARY ) )
46# if defined( GLS_LIBRARY ) || defined( GLS_EXPORT_LIBRARY )
47# define GLS_EXPORT __declspec( dllexport )
48# else /* GLS_DLL || GLS_IMPORT_LIBRARY */
49# define GLS_EXPORT __declspec( dllimport )
50# endif /* GLS_LIBRARY */
51#else
52# define GLS_EXPORT
53#endif /* GLS_DLL && WIN32 */
54
55/// Macro denoting which functions should be visible from the editor.
56#if defined( WIN32 ) && ( defined( GLS_EXPORT_EDITOR ) || defined( GLS_IMPORT_EDITOR ) )
57# if defined( GLS_EXPORT_EDITOR )
58# define GLS_EDITOR __declspec( dllexport )
59# else
60# define GLS_EDITOR __declspec( dllimport )
61# endif /* GLS_EXPORT_EDITOR */
62#else
63# define GLS_EDITOR
64#endif
65
66/// Macro denoting which functions should be visible from packages.
67#if defined( WIN32 ) && ( defined( GLS_EXPORT_PACKAGES ) || defined( GLS_IMPORT_PACKAGES ) )
68# if defined( GLS_EXPORT_PACKAGES )
69# define GLS_EXPORT_PACKAGE __declspec( dllexport )
70# else
71# define GLS_EXPORT_PACKAGE __declspec( dllimport )
72# endif /* GLS_EXPORT_PACKAGES */
73#else
74# define GLS_EXPORT_PACKAGE
75#endif
76
77#if defined( GLS_EXPORT_EDITOR ) || defined( GLS_IMPORT_EDITOR )
78# define GLS_EDITOR_CODE
79#endif
80
81/// Macro to wrap code that should be present on Windows only.
82#ifdef WIN32
83# define IF_WIN32( win32 ) ( win32 )
84#else
85# define IF_WIN32( win32 )
86#endif
87
88/// Macro to wrap code specific to Windows, and an alternate implementation for other platforms.
89#ifdef WIN32
90# define IF_WIN32_ELSE( win32, notWin32 ) ( win32 )
91#else
92# define IF_WIN32_ELSE( win32, notWin32 ) ( notWin32 )
93#endif
94
95/// Macro to wrap code that should be present on all platforms except Windows.
96#ifdef WIN32
97# define IF_NOT_WIN32( notWin32 )
98#else
99# define IF_NOT_WIN32( notWin32 ) ( notWin32 )
100#endif
101
102/// Macro to wrap code that should be present on macOS only.
103#ifdef __APPLE__
104# define IF_APPLE( apple ) ( apple )
105#else
106# define IF_APPLE( apple )
107#endif
108
109/// Macro to wrap code specific to macOS, and an alternate implementation for other platforms.
110#ifdef __APPLE__
111# define IF_APPLE_ELSE( apple, notApple ) ( apple )
112#else
113# define IF_APPLE_ELSE( apple, notApple ) ( notApple )
114#endif
115
116/// Macro to wrap code that should be present on all platforms except macOS.
117#ifdef __APPLE__
118# define IF_NOT_APPLE( notApple )
119#else
120# define IF_NOT_APPLE( notApple ) ( notApple )
121#endif
122
123/// Macro to wrap code that should be present on Linux only.
124#ifdef LINUX
125# define IF_LINUX( linux ) ( linux )
126#else
127# define IF_LINUX( linux )
128#endif
129
130/// Macro to wrap code specific to Linux, and an alternate implementation for other platforms.
131#ifdef LINUX
132# define IF_LINUX_ELSE( linux, notLinux ) ( linux )
133#else
134# define IF_LINUX_ELSE( linux, notLinux ) ( notLinux )
135#endif
136
137/// Macro to wrap code that should be present on all platforms except Linux.
138#ifdef LINUX
139# define IF_NOT_LINUX( notLinux )
140#else
141# define IF_NOT_LINUX( notLinux ) ( notLinux )
142#endif
143
144/// Macro to wrap code that should only be present in ES.
145/// \code{.cpp}
146/// IF_GLES( SetShader() ); // Calls this function on OpenGL ES only.
147/// \endcode
148#ifdef GLES
149# define IF_GLES( esCode ) ( esCode )
150#else
151# define IF_GLES( esCode )
152#endif
153
154/// Macro to wrap code that should not be present in ES (Desktop).
155/// \code{.cpp}
156/// IF_NOT_GLES( DesktopFileChanged() ); // Calls this function on Desktop OpenGL only.
157/// \endcode
158#ifdef GLES
159# define IF_NOT_GLES( nonEsCode )
160#else
161# define IF_NOT_GLES( nonEsCode ) ( nonEsCode )
162#endif
163
164/// Macro to wrap code specific to ES, and an alternate implementation for Desktop.
165/// \code{.cpp}
166/// auto fov = IF_GLES_ELSE( esBufferFOV, desktopFOV ); // Selects an expression to be assigned to the variable fov.
167/// \endcode
168#ifdef GLES
169# define IF_GLES_ELSE( esCode, nonEsCode ) ( esCode )
170#else
171# define IF_GLES_ELSE( esCode, nonEsCode ) ( nonEsCode )
172#endif
173
174/// Macro to wrap a parameter type specific to ES, and an alternate type for Desktop.
175/// This is like IF_GLES_ELSE, but does not add parenthesis.
176/// \code{.cpp}
177/// void MyFunc( IF_GLES_ELSE_TYPE( float, double ) ); // Selects the function parameter's type.
178/// \endcode
179#ifdef GLES
180# define IF_GLES_ELSE_TYPE( esType, nonEsType ) esType
181#else
182# define IF_GLES_ELSE_TYPE( esType, nonEsType ) nonEsType
183#endif
184
185/// Macro to wrap code that should only be present in Debug builds.
186#ifdef NDEBUG
187# define IF_DEBUG( notRelease )
188#else
189# define IF_DEBUG( notRelease ) ( notRelease )
190#endif
191
192/// Macro to wrap code that should only be present in Release builds.
193#ifdef NDEBUG
194# define IF_RELEASE( release ) ( release )
195#else
196# define IF_RELEASE( release )
197#endif
198
199/// Macro to wrap code specific to Release builds, with alternative code for Debug.
200#ifdef NDEBUG
201# define IF_RELEASE_ELSE( release, notRelease ) ( release )
202#else
203# define IF_RELEASE_ELSE( release, notRelease ) ( notRelease )
204#endif
205
206/// Macro for checking bitness (safer macros borrowed from https://www.fluentcpp.com/2019/05/28/better-macros-better-flags/)
207#define DISTI_IS_BITNESS( X ) DISTI_IS_BITNESS_PRIVATE_DEFINITION_##X()
208
209/// Bitness checks borrowed from https://stackoverflow.com/a/12338526/201787
210#if _WIN64 || ( __GNUC__ && ( __x86_64__ || __aarch64__ ) )
211# define DISTI_IS_BITNESS_PRIVATE_DEFINITION_64() 1
212# define DISTI_IS_BITNESS_PRIVATE_DEFINITION_32() 0
213#elif _WIN32 || __GNUC__
214# define DISTI_IS_BITNESS_PRIVATE_DEFINITION_64() 0
215# define DISTI_IS_BITNESS_PRIVATE_DEFINITION_32() 1
216#else
217# error "Unknown bitness!"
218#endif
219#endif