PixelEffect.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef LOVE_GRAPHICS_EFFECT_H
  2. #define LOVE_GRAPHICS_EFFECT_H
  3. #include <common/Object.h>
  4. #include <string>
  5. #include <map>
  6. #include "Image.h"
  7. #include "Canvas.h"
  8. namespace love
  9. {
  10. namespace graphics
  11. {
  12. namespace opengl
  13. {
  14. // A fragment shader
  15. class PixelEffect : public Object, public Volatile
  16. {
  17. public:
  18. PixelEffect(const std::string& code);
  19. virtual ~PixelEffect();
  20. std::string getWarnings() const;
  21. virtual bool loadVolatile();
  22. virtual void unloadVolatile();
  23. void attach();
  24. static void detach();
  25. static std::string getGLSLVersion();
  26. static bool isSupported();
  27. void sendFloat(const std::string& name, int size, const GLfloat* vec, int count);
  28. void sendMatrix(const std::string& name, int size, const GLfloat* m, int count);
  29. void sendImage(const std::string& name, const Image& image);
  30. void sendCanvas(const std::string& name, const Canvas& canvas);
  31. private:
  32. GLint getUniformLocation(const std::string& name);
  33. void checkSetUniformError();
  34. GLuint _program;
  35. std::string _code; // volatile and stuff
  36. // uniform location buffer
  37. std::map<std::string, GLint> _uniforms;
  38. // texture unit pool for setting images
  39. static std::map<std::string, GLint> _texture_unit_pool;
  40. static GLint _current_texture_unit;
  41. static GLint _max_texture_units;
  42. static GLint getTextureUnit(const std::string& name);
  43. };
  44. } // opengl
  45. } // graphics
  46. } // love
  47. #endif // LOVE_GRAPHICS_EFFECT_H