212 rader
4.6 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. //
  11. // The main header
  12. // ---------------
  13. //
  14. #if !defined __LOL_CORE_H__
  15. #define __LOL_CORE_H__
  16. /*
  17. * System and CPU features.
  18. */
  19. #undef LOL_FEATURE_THREADS
  20. #undef LOL_FEATURE_CHEAP_BRANCHES
  21. #undef LOL_FEATURE_VERY_CHEAP_BRANCHES
  22. #if !defined EMSCRIPTEN
  23. # define LOL_FEATURE_THREADS 1
  24. #endif
  25. #if !defined __CELLOS_LV2__
  26. # define LOL_FEATURE_CHEAP_BRANCHES 1
  27. #endif
  28. /*
  29. * Check for C++11 features.
  30. */
  31. #undef LOL_FEATURE_CXX11_CONSTEXPR
  32. #undef LOL_FEATURE_CXX11_ISNAN
  33. #if defined __GNUC__ /* GCC */
  34. # if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L
  35. # define LOL_FEATURE_CXX11_CONSTEXPR 1
  36. # define LOL_FEATURE_CXX11_ISNAN 1
  37. # endif
  38. #elif defined _MSC_VER /* Visual Studio */
  39. /* Even Visual Studio 2012 doesn't support constexpr. Idiots. */
  40. #elif defined __has_feature /* Clang */
  41. # if __has_feature(cxx_constexpr)
  42. # define LOL_FEATURE_CXX11_CONSTEXPR 1
  43. # endif
  44. #endif
  45. #if LOL_FEATURE_CXX11_CONSTEXPR
  46. # define LOL_CONSTEXPR constexpr
  47. #else
  48. # define LOL_CONSTEXPR /* Nothing */
  49. #endif
  50. // Optimisation helpers
  51. #if defined __GNUC__
  52. # define __likely(x) __builtin_expect(!!(x), 1)
  53. # define __unlikely(x) __builtin_expect(!!(x), 0)
  54. # define INLINEATTR __attribute__((always_inline))
  55. # if defined __CELLOS_LV2__ && !defined __SNC__
  56. # define FP_USE(x) __asm__("" : "+f" (x))
  57. # elif defined __x86_64__
  58. # define FP_USE(x) __asm__("" : "+x" (x))
  59. # elif defined __i386__ /* FIXME: this isn't good */
  60. # define FP_USE(x) __asm__("" : "+m" (x))
  61. # else
  62. # define FP_USE(x) (void)(x)
  63. # endif
  64. #else
  65. # define __likely(x) x
  66. # define __unlikely(x) x
  67. # define INLINEATTR
  68. # define FP_USE(x) (void)(x)
  69. #endif
  70. /* Ensure we have nullptr */
  71. #if defined nullptr
  72. /* do nothing */
  73. #elif defined __GNUC__
  74. # define nullptr __null
  75. #else
  76. # include <cstddef>
  77. # define nullptr NULL
  78. #endif
  79. /* Ensure we have ssize_t */
  80. #if defined ssize_t
  81. /* Do nothing, someone knows better than us it seems */
  82. #elif HAVE_SYS_TYPES_H
  83. # include <sys/types.h>
  84. #elif _MSC_VER /* Visual Studio compiler */
  85. # include <BaseTsd.h>
  86. # define _MSC_STDINT_H_
  87. typedef SSIZE_T ssize_t;
  88. #endif
  89. /* Ensure isnan() is present even on systems that don't define it, or
  90. * when -ffast-math is being used. */
  91. #include <cmath>
  92. #if defined __FAST_MATH__
  93. # undef isnan
  94. #endif
  95. #if !defined isnan && !defined LOL_FEATURE_CXX11_ISNAN
  96. # define isnan isnan
  97. # include <stdint.h>
  98. static inline int isnan(float f)
  99. {
  100. union { float f; uint32_t x; } u = { f };
  101. return (u.x << 1) > 0xff000000u;
  102. }
  103. #endif
  104. /* XXX: workaround for a compilation bug in NaCl headers */
  105. #if defined __native_client__
  106. # define typeid(x) (*(type_info*)nullptr)
  107. #endif
  108. /* XXX: workaround for X11 headers that try to #define these */
  109. #undef Always
  110. #define Always Always
  111. #undef None
  112. #define None None
  113. /* External declaration for LolFx files. */
  114. #define LOLFX_RESOURCE_DECLARE(name) \
  115. extern "C" char const *LOLFX_RESOURCE_NAME(name)
  116. #define LOLFX_RESOURCE_NAME(name) lolfx_resource_##name
  117. /* If using NaCl or Android, override main() with our version */
  118. #if defined __native_client__
  119. # define main lol_nacl_main
  120. #elif defined __ANDROID__
  121. # define main lol_android_main
  122. #endif
  123. /* If using SDL on Windows or OS X, let it override main() */
  124. #if defined USE_SDL && (defined _WIN32 || defined __APPLE__)
  125. # include <SDL_main.h>
  126. #endif
  127. // Base types
  128. #include <lol/base/all.h>
  129. #include <lol/math/all.h>
  130. #include <lol/algorithm/all.h>
  131. #include <lol/sys/all.h>
  132. #include <lol/gpu/all.h>
  133. #include <lol/image/all.h>
  134. #include <lol/debug/all.h>
  135. #include "utils.h"
  136. #include "numeric.h"
  137. // Static classes
  138. #include "platform.h"
  139. #include "video.h"
  140. #include "audio.h"
  141. #include "scene.h"
  142. #include "profiler.h"
  143. #include "messageservice.h"
  144. // Input
  145. #include "input/input.h"
  146. #include "input/controller.h"
  147. // Entities
  148. #include "entity.h"
  149. #include "worldentity.h"
  150. #include "camera.h"
  151. #include "light.h"
  152. #include "emitter.h"
  153. #include "font.h"
  154. #include "gradient.h"
  155. #include "sample.h"
  156. #include "sprite.h"
  157. #include "text.h"
  158. #include "tileset.h"
  159. #include "world.h"
  160. // Other objects
  161. #include "dict.h"
  162. #include "map.h"
  163. #include "layer.h"
  164. #include "mesh/mesh.h"
  165. #include "mesh/primitive.h"
  166. #include "application/application.h"
  167. #include "easymesh/csgbsp.h"
  168. #include "easymesh/easymesh.h"
  169. // Managers
  170. #include "ticker.h"
  171. #include "forge.h"
  172. #include "tiler.h"
  173. #include "sampler.h"
  174. #endif // __LOL_CORE_H__