temp.defines.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. */
  5. #ifndef BGFX_DEFINES_H_HEADER_GUARD
  6. #define BGFX_DEFINES_H_HEADER_GUARD
  7. $version
  8. $cflags
  9. /// Blend function separate.
  10. #define BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) (UINT64_C(0) \
  11. | ( ( (uint64_t)(_srcRGB)|( (uint64_t)(_dstRGB)<<4) ) ) \
  12. | ( ( (uint64_t)(_srcA )|( (uint64_t)(_dstA )<<4) )<<8) \
  13. )
  14. /// Blend equation separate.
  15. #define BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA) ( (uint64_t)(_equationRGB)|( (uint64_t)(_equationA)<<3) )
  16. /// Blend function.
  17. #define BGFX_STATE_BLEND_FUNC(_src, _dst) BGFX_STATE_BLEND_FUNC_SEPARATE(_src, _dst, _src, _dst)
  18. /// Blend equation.
  19. #define BGFX_STATE_BLEND_EQUATION(_equation) BGFX_STATE_BLEND_EQUATION_SEPARATE(_equation, _equation)
  20. /// Utility predefined blend modes.
  21. /// Additive blending.
  22. #define BGFX_STATE_BLEND_ADD (0 \
  23. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE) \
  24. )
  25. /// Alpha blend.
  26. #define BGFX_STATE_BLEND_ALPHA (0 \
  27. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA) \
  28. )
  29. /// Selects darker color of blend.
  30. #define BGFX_STATE_BLEND_DARKEN (0 \
  31. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE) \
  32. | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_MIN) \
  33. )
  34. /// Selects lighter color of blend.
  35. #define BGFX_STATE_BLEND_LIGHTEN (0 \
  36. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE) \
  37. | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_MAX) \
  38. )
  39. /// Multiplies colors.
  40. #define BGFX_STATE_BLEND_MULTIPLY (0 \
  41. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_ZERO) \
  42. )
  43. /// Opaque pixels will cover the pixels directly below them without any math or algorithm applied to them.
  44. #define BGFX_STATE_BLEND_NORMAL (0 \
  45. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA) \
  46. )
  47. /// Multiplies the inverse of the blend and base colors.
  48. #define BGFX_STATE_BLEND_SCREEN (0 \
  49. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_COLOR) \
  50. )
  51. /// Decreases the brightness of the base color based on the value of the blend color.
  52. #define BGFX_STATE_BLEND_LINEAR_BURN (0 \
  53. | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_INV_DST_COLOR) \
  54. | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_SUB) \
  55. )
  56. ///
  57. #define BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) (0 \
  58. | ( (uint32_t)( (_src)>>BGFX_STATE_BLEND_SHIFT) \
  59. | ( (uint32_t)( (_dst)>>BGFX_STATE_BLEND_SHIFT)<<4) ) \
  60. )
  61. ///
  62. #define BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation) (0 \
  63. | BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) \
  64. | ( (uint32_t)( (_equation)>>BGFX_STATE_BLEND_EQUATION_SHIFT)<<8) \
  65. )
  66. #define BGFX_STATE_BLEND_FUNC_RT_1(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<< 0)
  67. #define BGFX_STATE_BLEND_FUNC_RT_2(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<<11)
  68. #define BGFX_STATE_BLEND_FUNC_RT_3(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<<22)
  69. #define BGFX_STATE_BLEND_FUNC_RT_1E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<< 0)
  70. #define BGFX_STATE_BLEND_FUNC_RT_2E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<<11)
  71. #define BGFX_STATE_BLEND_FUNC_RT_3E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<<22)
  72. #endif // BGFX_DEFINES_H_HEADER_GUARD