Common.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # define ANKI_SHADER_STATIC_ASSERT(cond_) static_assert(cond_, "See file");
  19. ANKI_BEGIN_NAMESPACE
  20. template<typename T>
  21. inline F32 dot(const T& a, const T& b)
  22. {
  23. return a.dot(b);
  24. }
  25. ANKI_END_NAMESPACE
  26. #else
  27. # define x() x
  28. # define y() y
  29. # define z() z
  30. # define w() w
  31. # define xyz() xyz
  32. # define ANKI_BEGIN_NAMESPACE
  33. # define ANKI_END_NAMESPACE
  34. # define ANKI_SHADER_FUNC_INLINE
  35. # define ANKI_SHADER_INOUT(type_) inout type_
  36. # define ANKI_SHADER_IN(type_) in type_
  37. # define ANKI_SHADER_OUT(type_) out type_
  38. # define ANKI_SHADER_STATIC_ASSERT(cond_)
  39. #endif
  40. //
  41. // Consts
  42. //
  43. ANKI_BEGIN_NAMESPACE
  44. const U32 SIZEOF_VEC4 = 4u * 4u;
  45. const U32 SIZEOF_MAT4 = 4u * SIZEOF_VEC4;
  46. ANKI_END_NAMESPACE