Common.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. //
  7. // Macros & functions
  8. //
  9. #if defined(__cplusplus)
  10. # define ANKI_BEGIN_NAMESPACE \
  11. namespace anki \
  12. {
  13. # define ANKI_END_NAMESPACE }
  14. # define ANKI_SHADER_FUNC_INLINE inline
  15. # define ANKI_SHADER_INOUT(type_) type&
  16. # define ANKI_SHADER_IN(type_) const type&
  17. # define ANKI_SHADER_OUT(type_) type&
  18. ANKI_BEGIN_NAMESPACE
  19. template<typename T>
  20. inline F32 dot(const T& a, const T& b)
  21. {
  22. return a.dot(b);
  23. }
  24. ANKI_END_NAMESPACE
  25. #else
  26. # define x() x
  27. # define y() y
  28. # define z() z
  29. # define w() w
  30. # define xyz() xyz
  31. # define ANKI_BEGIN_NAMESPACE
  32. # define ANKI_END_NAMESPACE
  33. # define ANKI_SHADER_FUNC_INLINE
  34. # define ANKI_SHADER_INOUT(type_) inout type
  35. # define ANKI_SHADER_IN(type_) in type
  36. # define ANKI_SHADER_OUT(type_) out type
  37. #endif
  38. //
  39. // Consts
  40. //
  41. ANKI_BEGIN_NAMESPACE
  42. const U32 SIZEOF_VEC4 = 4u * 4u;
  43. const U32 SIZEOF_MAT4 = 4u * SIZEOF_VEC4;
  44. ANKI_END_NAMESPACE