PolyModule.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * PolyModule.h
  3. * PolyCore
  4. *
  5. * Created by Ivan Safrin on 12/1/10.
  6. * Copyright 2010 Local Projects. All rights reserved.
  7. *
  8. */
  9. #pragma once
  10. #include "PolyGlobals.h"
  11. #include "tinyxml.h"
  12. #include "PolyShader.h"
  13. #include "PolyMaterial.h"
  14. namespace Polycode {
  15. class Renderer;
  16. class _PolyExport PolycodeModule {
  17. public:
  18. PolycodeModule();
  19. virtual ~PolycodeModule();
  20. int getType() { return type; }
  21. static const int TYPE_GENERIC = 0;
  22. static const int TYPE_SHADER = 0;
  23. protected:
  24. int type;
  25. };
  26. class _PolyExport PolycodeShaderModule : public PolycodeModule {
  27. public:
  28. PolycodeShaderModule();
  29. virtual ~PolycodeShaderModule();
  30. virtual bool acceptsExtension(string extension) = 0;
  31. virtual Resource* createProgramFromFile(string extension, string fullPath) = 0;
  32. virtual string getShaderType() = 0;
  33. virtual Shader *createShader(TiXmlNode *node) = 0;
  34. virtual bool applyShaderMaterial(Renderer *renderer, Material *material, ShaderBinding *localOptions, unsigned int shaderIndex) = 0;
  35. bool hasShader(Shader *shader) { for(int i=0; i < shaders.size(); i++) { if(shaders[i] == shader){ return true; } } return false; }
  36. virtual void clearShader() = 0;
  37. virtual void reloadPrograms() = 0;
  38. protected:
  39. vector<Shader*> shaders;
  40. };
  41. }