diff options
author | Adrian Kummerlaender | 2018-05-26 13:20:47 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2018-05-26 13:21:40 +0200 |
commit | 34052b51e00c939a35294d7085cadb5111484dd3 (patch) | |
tree | 03a5b1e350e47e2aa8551393ef67b2124ad50ddb /src/shader/wrap/compute_shader.h | |
parent | f728e4c8d202de241673a13ce61570b6acb4bba7 (diff) | |
download | computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.gz computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.bz2 computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.lz computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.xz computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.zst computicle-34052b51e00c939a35294d7085cadb5111484dd3.zip |
Separate headers into compilation units
Diffstat (limited to 'src/shader/wrap/compute_shader.h')
-rw-r--r-- | src/shader/wrap/compute_shader.h | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/src/shader/wrap/compute_shader.h b/src/shader/wrap/compute_shader.h index 9f5c5cb..e9e88ca 100644 --- a/src/shader/wrap/compute_shader.h +++ b/src/shader/wrap/compute_shader.h @@ -1,6 +1,8 @@ #pragma once -#include "util.h" +#include <string> + +#include <GL/glew.h> class ComputeShader { private: @@ -10,38 +12,17 @@ public: struct Guard { const GLuint _id; - Guard(GLuint id): _id(id) { - glUseProgram(_id); - } - ~Guard() { - glUseProgram(0); - } + Guard(GLuint id); + ~Guard(); }; - Guard use() const { - return Guard(_id); - } + Guard use() const; - ComputeShader(const std::string& src): - _id(glCreateProgram()) { - glAttachShader(_id, util::compileShader(src, GL_COMPUTE_SHADER)); - glLinkProgram(_id); - }; - ~ComputeShader() { - glDeleteProgram(_id); - } - - GLuint setUniform(const std::string& name, float x, float y) const { - GLuint id = util::getUniform(_id, name); - glUniform2f(id, x, y); - return id; - } - - void workOn(GLuint buffer) const { - glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, buffer); - } - - void dispatch(std::size_t dimX) const { - glDispatchCompute(dimX, 1, 1); - } + ComputeShader(const std::string& src); + ~ComputeShader(); + + GLuint setUniform(const std::string& name, float x, float y) const; + + void workOn(GLuint buffer) const; + void dispatch(std::size_t dimX) const; }; |