CmSamplerState.cpp 1.5 KB

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