CmSamplerState.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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() const
  36. {
  37. return mData.borderColor;
  38. }
  39. SamplerStatePtr SamplerState::create(const SAMPLER_STATE_DESC& desc)
  40. {
  41. return RenderStateManager::instance().createSamplerState(desc);
  42. }
  43. /************************************************************************/
  44. /* RTTI */
  45. /************************************************************************/
  46. RTTITypeBase* SamplerState::getRTTIStatic()
  47. {
  48. return SamplerStateRTTI::instance();
  49. }
  50. RTTITypeBase* SamplerState::getRTTI() const
  51. {
  52. return SamplerState::getRTTIStatic();
  53. }
  54. }