From e9885141e4049a06b89000bf34959174fb2d4491 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 8 Jun 2018 14:15:59 +0200 Subject: Expose compute shader state --- src/shader/wrap/compute_shader.cc | 13 +++++++++++-- src/shader/wrap/compute_shader.h | 4 ++++ src/shader/wrap/graphic_shader.h | 2 -- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/shader/wrap') diff --git a/src/shader/wrap/compute_shader.cc b/src/shader/wrap/compute_shader.cc index 97ce52a..e91ba77 100644 --- a/src/shader/wrap/compute_shader.cc +++ b/src/shader/wrap/compute_shader.cc @@ -17,14 +17,23 @@ ComputeShader::Guard ComputeShader::use() const { ComputeShader::ComputeShader(const std::string& src): _id(glCreateProgram()) { - glAttachShader(_id, util::compileShader(src, GL_COMPUTE_SHADER)); - glLinkProgram(_id); + GLint shader = util::compileShader(src, GL_COMPUTE_SHADER); + + if ( shader != -1 ) { + glAttachShader(_id, shader); + glLinkProgram(_id); + _good = true; + } } ComputeShader::~ComputeShader() { glDeleteProgram(_id); } +bool ComputeShader::isGood() const { + return _good; +} + GLuint ComputeShader::setUniform(const std::string& name, float x, float y) const { GLuint id = util::getUniform(_id, name); glUniform2f(id, x, y); diff --git a/src/shader/wrap/compute_shader.h b/src/shader/wrap/compute_shader.h index e9e88ca..ffdde59 100644 --- a/src/shader/wrap/compute_shader.h +++ b/src/shader/wrap/compute_shader.h @@ -8,6 +8,8 @@ class ComputeShader { private: const GLuint _id; + bool _good; + public: struct Guard { const GLuint _id; @@ -21,6 +23,8 @@ public: ComputeShader(const std::string& src); ~ComputeShader(); + bool isGood() const; + GLuint setUniform(const std::string& name, float x, float y) const; void workOn(GLuint buffer) const; diff --git a/src/shader/wrap/graphic_shader.h b/src/shader/wrap/graphic_shader.h index 82f7e7a..25a5efb 100644 --- a/src/shader/wrap/graphic_shader.h +++ b/src/shader/wrap/graphic_shader.h @@ -6,8 +6,6 @@ #include #include -#include "shader/util.h" - class GraphicShader { private: const GLuint _id; -- cgit v1.2.3