aboutsummaryrefslogtreecommitdiff
path: root/src/shader/wrap
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-12-16 22:09:17 +0100
committerAdrian Kummerlaender2018-12-16 22:09:17 +0100
commitce334547f0f0560386ca8b97f354d83da68019a5 (patch)
tree2c4e148a7e8052779da70d9cf1767cea5c44926d /src/shader/wrap
parent52cbbff72bd5516b5f325d1c88e4fcd8ca67f989 (diff)
downloadcompustream-ce334547f0f0560386ca8b97f354d83da68019a5.tar
compustream-ce334547f0f0560386ca8b97f354d83da68019a5.tar.gz
compustream-ce334547f0f0560386ca8b97f354d83da68019a5.tar.bz2
compustream-ce334547f0f0560386ca8b97f354d83da68019a5.tar.lz
compustream-ce334547f0f0560386ca8b97f354d83da68019a5.tar.xz
compustream-ce334547f0f0560386ca8b97f354d83da68019a5.tar.zst
compustream-ce334547f0f0560386ca8b97f354d83da68019a5.zip
Generate fluid display using geometry shaders
This should provide much more flexibility. For our purpose it would be useful if the vertex shader was executed after the geometry shader (to apply the projection matrix) but alas this is not the case. Thus the MVP matrix is applied during geometry construction and the vertex shader only provides density extraction.
Diffstat (limited to 'src/shader/wrap')
-rw-r--r--src/shader/wrap/graphic_shader.cc10
-rw-r--r--src/shader/wrap/graphic_shader.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/shader/wrap/graphic_shader.cc b/src/shader/wrap/graphic_shader.cc
index 0ed37ff..c891730 100644
--- a/src/shader/wrap/graphic_shader.cc
+++ b/src/shader/wrap/graphic_shader.cc
@@ -15,6 +15,16 @@ GraphicShader::Guard GraphicShader::use() const {
return Guard(_id);
}
+GraphicShader::GraphicShader(const std::string& vertex,
+ const std::string& geometry,
+ const std::string fragment):
+ _id(glCreateProgram()) {
+ glAttachShader(_id, util::compileShader(vertex, GL_VERTEX_SHADER));
+ glAttachShader(_id, util::compileShader(geometry, GL_GEOMETRY_SHADER));
+ glAttachShader(_id, util::compileShader(fragment, GL_FRAGMENT_SHADER));
+ glLinkProgram(_id);
+}
+
GraphicShader::GraphicShader(const std::string& vertex, const std::string fragment):
_id(glCreateProgram()) {
glAttachShader(_id, util::compileShader(vertex, GL_VERTEX_SHADER));
diff --git a/src/shader/wrap/graphic_shader.h b/src/shader/wrap/graphic_shader.h
index 25a5efb..dcae6db 100644
--- a/src/shader/wrap/graphic_shader.h
+++ b/src/shader/wrap/graphic_shader.h
@@ -20,6 +20,7 @@ public:
Guard use() const;
+ GraphicShader(const std::string& vertex, const std::string& geometry, const std::string fragment);
GraphicShader(const std::string& vertex, const std::string fragment);
~GraphicShader();