PolyShader.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * PolyShader.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 9/20/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package Materials
  10. #pragma once
  11. #include "PolyGlobals.h"
  12. #include "PolyResource.h"
  13. #include "PolyTexture.h"
  14. #include "PolyCubemap.h"
  15. namespace Polycode {
  16. class ShaderBinding;
  17. class _PolyExport Shader : public Resource {
  18. public:
  19. Shader(int type);
  20. virtual ~Shader();
  21. int getType();
  22. void setName(string name);
  23. string getName();
  24. virtual ShaderBinding *createBinding() = 0;
  25. static const int FIXED_SHADER = 0;
  26. static const int MODULE_SHADER = 1;
  27. protected:
  28. string name;
  29. int type;
  30. };
  31. class _PolyExport ShaderRenderTarget {
  32. public:
  33. string id;
  34. float width;
  35. float height;
  36. int sizeMode;
  37. bool hasSize;
  38. Texture *texture;
  39. static const int SIZE_MODE_PIXELS = 0;
  40. static const int SIZE_MODE_NORMALIZED = 1;
  41. };
  42. typedef struct {
  43. string name;
  44. void *data;
  45. } LocalShaderParam;
  46. typedef struct {
  47. string id;
  48. string name;
  49. int mode;
  50. Texture *texture;
  51. float width;
  52. float height;
  53. static const int MODE_IN= 0;
  54. static const int MODE_OUT = 1;
  55. } RenderTargetBinding;
  56. class _PolyExport ShaderBinding {
  57. public:
  58. ShaderBinding(Shader *shader);
  59. virtual ~ShaderBinding();
  60. virtual void clearTexture(string name){};
  61. virtual void addTexture(string name, Texture *texture) {};
  62. virtual void addParam(string type, string name, string value) {};
  63. virtual void addCubemap(string name, Cubemap *cubemap) {};
  64. unsigned int getNumLocalParams();
  65. LocalShaderParam *getLocalParam(unsigned int index);
  66. LocalShaderParam *getLocalParamByName(string name);
  67. void addRenderTargetBinding(RenderTargetBinding *binding);
  68. unsigned int getNumRenderTargetBindings();
  69. RenderTargetBinding *getRenderTargetBinding(unsigned int index);
  70. unsigned int getNumInTargetBindings();
  71. RenderTargetBinding *getInTargetBinding(unsigned int index);
  72. unsigned int getNumOutTargetBindings();
  73. RenderTargetBinding *getOutTargetBinding(unsigned int index);
  74. Shader* shader;
  75. vector<LocalShaderParam*> localParams;
  76. vector<RenderTargetBinding*> renderTargetBindings;
  77. vector<RenderTargetBinding*> inTargetBindings;
  78. vector<RenderTargetBinding*> outTargetBindings;
  79. };
  80. }