BsSamplerState.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include "BsSamplerState.h"
  2. #include "BsSamplerStateRTTI.h"
  3. #include "BsRenderStateManager.h"
  4. #include "BsRenderAPI.h"
  5. #include "BsException.h"
  6. #include "BsResources.h"
  7. namespace BansheeEngine
  8. {
  9. SamplerProperties::SamplerProperties(const SAMPLER_STATE_DESC& desc)
  10. :mData(desc)
  11. { }
  12. FilterOptions SamplerProperties::getTextureFiltering(FilterType ft) const
  13. {
  14. switch (ft)
  15. {
  16. case FT_MIN:
  17. return mData.minFilter;
  18. case FT_MAG:
  19. return mData.magFilter;
  20. case FT_MIP:
  21. return mData.mipFilter;
  22. }
  23. return mData.minFilter;
  24. }
  25. const Color& SamplerProperties::getBorderColor() const
  26. {
  27. return mData.borderColor;
  28. }
  29. SamplerStateCore::SamplerStateCore(const SAMPLER_STATE_DESC& desc)
  30. :mProperties(desc)
  31. {
  32. }
  33. const SamplerProperties& SamplerStateCore::getProperties() const
  34. {
  35. return mProperties;
  36. }
  37. const SPtr<SamplerStateCore>& SamplerStateCore::getDefault()
  38. {
  39. return RenderStateCoreManager::instance().getDefaultSamplerState();
  40. }
  41. SamplerState::SamplerState(const SAMPLER_STATE_DESC& desc)
  42. :mProperties(desc)
  43. {
  44. }
  45. SPtr<SamplerStateCore> SamplerState::getCore() const
  46. {
  47. return std::static_pointer_cast<SamplerStateCore>(mCoreSpecific);
  48. }
  49. SPtr<CoreObjectCore> SamplerState::createCore() const
  50. {
  51. return RenderStateCoreManager::instance().createSamplerStateInternal(mProperties.mData);
  52. }
  53. SamplerStatePtr SamplerState::create(const SAMPLER_STATE_DESC& desc)
  54. {
  55. return RenderStateManager::instance().createSamplerState(desc);
  56. }
  57. const SamplerStatePtr& SamplerState::getDefault()
  58. {
  59. return RenderStateManager::instance().getDefaultSamplerState();
  60. }
  61. const SamplerProperties& SamplerState::getProperties() const
  62. {
  63. return mProperties;
  64. }
  65. /************************************************************************/
  66. /* RTTI */
  67. /************************************************************************/
  68. RTTITypeBase* SamplerState::getRTTIStatic()
  69. {
  70. return SamplerStateRTTI::instance();
  71. }
  72. RTTITypeBase* SamplerState::getRTTI() const
  73. {
  74. return SamplerState::getRTTIStatic();
  75. }
  76. }