PolyGlobals.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. // Polycode CORE LIBRARY CONFIGURATION SECTION
  21. // Compile support for lua bindings.
  22. //#define _COMPILE_LUA
  23. #define POLYCODE_VERSION_STRING "0.8.5_dev"
  24. #define USE_POSIX_MUTEX 1
  25. #define COMPILE_GL_RENDERER
  26. typedef float PolyRendererVertexType;
  27. typedef unsigned int PolyRendererIndexType;
  28. #ifdef _WINDOWS
  29. #define WIN32_LEAN_AND_MEAN
  30. #pragma warning(disable:4251)
  31. #pragma warning(disable:4305)
  32. #pragma warning(disable:4244)
  33. #pragma warning(disable:4018)
  34. #pragma warning(disable:4996)
  35. #pragma warning(disable:4309)
  36. #ifndef NULL
  37. #define NULL 0
  38. #endif
  39. // Prevent windows.h includes from generating min/max macros that
  40. // clash with the templates in <algorithm>
  41. #ifndef NOMINMAX
  42. #define NOMINMAX
  43. #endif
  44. #endif
  45. #include <stdint.h>
  46. #ifndef NULL
  47. #define NULL 0
  48. #endif
  49. #define PI 3.14159265
  50. #define RADIANS 57.2957795
  51. #define TODEGREES 57.2957795
  52. #define TORADIANS 0.0174532925
  53. #define PLATFORM_WINDOWS 1
  54. #define PLATFORM_MAC 2
  55. #define PLATFORM_UNIX 3
  56. #define PLATFORM_IOS 4
  57. #define PLATFORM_ANDROID 5
  58. #if defined(_WINDOWS) || defined(WINAPI_FAMILY) || defined(WIN32)
  59. #define PLATFORM PLATFORM_WINDOWS
  60. #elif __APPLE__ && __MACH__
  61. #ifndef CLDOC
  62. #include <TargetConditionals.h>
  63. #endif
  64. #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
  65. #define PLATFORM PLATFORM_IOS
  66. #define STRICT_OPENGLES2 1
  67. #define POLYCODE_NUMBER_IS_SINGLE 1
  68. #else
  69. #define PLATFORM PLATFORM_MAC
  70. #endif
  71. #elif defined(__ANDROID__)
  72. #define PLATFORM PLATFORM_ANDROID
  73. #define POLYCODE_NUMBER_IS_SINGLE 1
  74. #else
  75. #include <cstddef>
  76. #define PLATFORM PLATFORM_UNIX
  77. #endif
  78. #if (defined(_WINDOWS) || defined(WINAPI_FAMILY)) && defined(POLYCODE_EXPORTS)
  79. #define _PolyExport __declspec(dllexport)
  80. #else
  81. #define _PolyExport
  82. #endif
  83. #ifdef POLYCODE_NUMBER_IS_SINGLE
  84. typedef float Number;
  85. #else
  86. typedef double Number;
  87. #endif
  88. #ifdef _MSC_VER
  89. #if _MSC_VER<=1700
  90. #include <cmath> //cmath for "round / floor"
  91. inline int round(Number x) {
  92. return floor(x + 0.5);
  93. }
  94. #endif
  95. #endif
  96. #define RANDOM_NUMBER ((Number)rand()/(Number)RAND_MAX)
  97. inline Number clampf(Number x, Number a, Number b)
  98. {
  99. return x < a ? a : (x > b ? b : x);
  100. }
  101. #ifndef MIN
  102. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  103. #endif
  104. #ifndef MAX
  105. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  106. #endif
  107. #if PLATFORM == PLATFORM_IOS
  108. // #define BGRA_TEXTURE_FORMAT
  109. #endif
  110. // Special flag read by create_lua_library parser, suppresses Lua bindings for item.
  111. #define POLYIGNORE
  112. class _PolyExport PolyBase {};