CmSamplerState.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "CmSamplerState.h"
  2. #include "CmSamplerStateRTTI.h"
  3. #include "CmRenderStateManager.h"
  4. #include "CmRenderSystem.h"
  5. #include "CmException.h"
  6. namespace CamelotEngine
  7. {
  8. void SamplerState::initialize(const SAMPLER_STATE_DESC& desc)
  9. {
  10. mData = desc;
  11. CoreGpuObject::initialize();
  12. }
  13. const SamplerStatePtr& SamplerState::getDefault()
  14. {
  15. static SamplerStatePtr samplerState = RenderStateManager::instance().createSamplerState(SAMPLER_STATE_DESC());
  16. return samplerState;
  17. }
  18. FilterOptions SamplerState::getTextureFiltering(FilterType ft) const
  19. {
  20. switch (ft)
  21. {
  22. case FT_MIN:
  23. return mData.minFilter;
  24. case FT_MAG:
  25. return mData.magFilter;
  26. case FT_MIP:
  27. return mData.mipFilter;
  28. }
  29. return mData.minFilter;
  30. }
  31. const Color& SamplerState::getBorderColor() const
  32. {
  33. return mData.borderColor;
  34. }
  35. SamplerStatePtr SamplerState::create(const SAMPLER_STATE_DESC& desc)
  36. {
  37. return RenderStateManager::instance().createSamplerState(desc);
  38. }
  39. /************************************************************************/
  40. /* RTTI */
  41. /************************************************************************/
  42. RTTITypeBase* SamplerState::getRTTIStatic()
  43. {
  44. return SamplerStateRTTI::instance();
  45. }
  46. RTTITypeBase* SamplerState::getRTTI() const
  47. {
  48. return SamplerState::getRTTIStatic();
  49. }
  50. }