BsSamplerState.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "BsSamplerState.h"
  2. #include "BsSamplerStateRTTI.h"
  3. #include "BsRenderStateManager.h"
  4. #include "BsRenderSystem.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. SamplerState::SamplerState(const SAMPLER_STATE_DESC& desc)
  38. :mProperties(desc)
  39. {
  40. }
  41. SPtr<SamplerStateCore> SamplerState::getCore() const
  42. {
  43. return std::static_pointer_cast<SamplerStateCore>(mCoreSpecific);
  44. }
  45. SPtr<CoreObjectCore> SamplerState::createCore() const
  46. {
  47. return RenderStateCoreManager::instance().createSamplerStateInternal(mProperties.mData);
  48. }
  49. HSamplerState SamplerState::create(const SAMPLER_STATE_DESC& desc)
  50. {
  51. SamplerStatePtr samplerPtr = RenderStateManager::instance().createSamplerState(desc);
  52. return static_resource_cast<SamplerState>(gResources()._createResourceHandle(samplerPtr));
  53. }
  54. const SamplerStatePtr& SamplerState::getDefault()
  55. {
  56. return RenderStateManager::instance().getDefaultSamplerState();
  57. }
  58. const SamplerProperties& SamplerState::getProperties() const
  59. {
  60. return mProperties;
  61. }
  62. /************************************************************************/
  63. /* RTTI */
  64. /************************************************************************/
  65. RTTITypeBase* SamplerState::getRTTIStatic()
  66. {
  67. return SamplerStateRTTI::instance();
  68. }
  69. RTTITypeBase* SamplerState::getRTTI() const
  70. {
  71. return SamplerState::getRTTIStatic();
  72. }
  73. }