VertexShader.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "GPUObject.h"
  25. #include "Resource.h"
  26. class Deserializer;
  27. /// Vertex shader resource
  28. class VertexShader : public Resource, public GPUObject
  29. {
  30. OBJECT(VertexShader);
  31. friend unsigned GetVSRegister(VSParameter param);
  32. public:
  33. /// Construct
  34. VertexShader(Context* context);
  35. /// Destruct
  36. virtual ~VertexShader();
  37. /// Register object factory
  38. static void RegisterObject(Context* context);
  39. /// Load resource. Return true if successful
  40. virtual bool Load(Deserializer& source);
  41. /// Release shader
  42. virtual void Release();
  43. /// Return whether uses a specific shader parameter
  44. bool HasParameter(VSParameter parameter) const { return useParameter_[parameter]; }
  45. /// Return whether is Shader Model 3 format
  46. bool IsSM3() const { return isSM3_; }
  47. /// Check whether a shader parameter needs update
  48. bool NeedParameterUpdate(VSParameter parameter, const void* source);
  49. private:
  50. /// Load parameters from an XML file
  51. void LoadParameters();
  52. /// Clear parameter use flags
  53. void ClearParameters();
  54. /// Parameter use flags
  55. bool useParameter_[MAX_VS_PARAMETERS];
  56. /// Shader Model 3 flag
  57. bool isSM3_;
  58. };