From 34052b51e00c939a35294d7085cadb5111484dd3 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 26 May 2018 13:20:47 +0200 Subject: Separate headers into compilation units --- src/shader/wrap/compute_shader.h | 45 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'src/shader/wrap/compute_shader.h') 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 + +#include 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; }; -- cgit v1.2.3