You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

198 lines
4.3 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 isnan() is present even on systems that don't define it, or
  80. * when -ffast-math is being used. */
  81. #include <cmath>
  82. #if defined __FAST_MATH__
  83. # undef isnan
  84. #endif
  85. #if !defined isnan && !defined LOL_FEATURE_CXX11_ISNAN
  86. # define isnan isnan
  87. # include <stdint.h>
  88. static inline int isnan(float f)
  89. {
  90. union { float f; uint32_t x; } u = { f };
  91. return (u.x << 1) > 0xff000000u;
  92. }
  93. #endif
  94. /* XXX: workaround for a compilation bug in NaCl headers */
  95. #if defined __native_client__
  96. # define typeid(x) (*(type_info*)nullptr)
  97. #endif
  98. /* XXX: workaround for X11 headers that try to #define these */
  99. #undef Always
  100. #define Always Always
  101. #undef None
  102. #define None None
  103. /* External declaration for LolFx files. */
  104. #define LOLFX_RESOURCE_DECLARE(name) \
  105. extern "C" char const *LOLFX_RESOURCE_NAME(name)
  106. #define LOLFX_RESOURCE_NAME(name) lolfx_resource_##name
  107. /* If using NaCl or Android, override main() with our version */
  108. #if defined __native_client__
  109. # define main lol_nacl_main
  110. #elif defined __ANDROID__
  111. # define main lol_android_main
  112. #endif
  113. /* If using SDL on Windows or OS X, let it override main() */
  114. #if defined USE_SDL && (defined _WIN32 || defined __APPLE__)
  115. # include <SDL_main.h>
  116. #endif
  117. // Base types
  118. #include <lol/base/all.h>
  119. #include <lol/math/all.h>
  120. #include <lol/sys/all.h>
  121. #include <lol/gpu/all.h>
  122. #include <lol/image/all.h>
  123. #include <lol/debug/all.h>
  124. #include "utils.h"
  125. #include "numeric.h"
  126. // Static classes
  127. #include "platform.h"
  128. #include "video.h"
  129. #include "audio.h"
  130. #include "scene.h"
  131. #include "profiler.h"
  132. #include "messageservice.h"
  133. // Input
  134. #include "input/input.h"
  135. #include "input/controller.h"
  136. // Entities
  137. #include "entity.h"
  138. #include "worldentity.h"
  139. #include "camera.h"
  140. #include "light.h"
  141. #include "emitter.h"
  142. #include "font.h"
  143. #include "gradient.h"
  144. #include "sample.h"
  145. #include "sprite.h"
  146. #include "text.h"
  147. #include "tileset.h"
  148. #include "world.h"
  149. // Other objects
  150. #include "dict.h"
  151. #include "map.h"
  152. #include "layer.h"
  153. #include "mesh/mesh.h"
  154. #include "application/application.h"
  155. #include "easymesh/csgbsp.h"
  156. #include "easymesh/easymesh.h"
  157. // Managers
  158. #include "ticker.h"
  159. #include "forge.h"
  160. #include "tiler.h"
  161. #include "sampler.h"
  162. #endif // __LOL_CORE_H__