ComputeShader.hpp 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef PARTICLE_COMPUTE_SHADER
  2. #define PARTICLE_COMPUTE_SHADER
  3. #include <vector>
  4. #include <string>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <sstream>
  8. /* OpenGL */
  9. #include "glad/glad.h"
  10. #include <GLFW/glfw3.h>
  11. class ComputeShader
  12. {
  13. private:
  14. std::string m_shader_filename{};
  15. std::string m_shader_source{};
  16. GLuint m_program = 0;
  17. GLuint m_shader = 0;
  18. public:
  19. static void wait();
  20. ComputeShader() = default;
  21. ComputeShader(std::string &shader_filename);
  22. ~ComputeShader();
  23. GLuint get_program() const;
  24. bool load(std::string shader_filename);
  25. bool compile();
  26. void activate();
  27. void deactivate();
  28. void execute(size_t x, size_t group_size_x);
  29. void execute(size_t x, size_t y, size_t group_size_x, size_t group_size_y);
  30. bool release();
  31. bool set_uniform(char const * name, float value);
  32. bool set_uniform(char const * name, int value);
  33. bool set_uniform(char const * name, size_t value);
  34. };
  35. #endif // PARTICLE_COMPUTE_SHADER