From ce334547f0f0560386ca8b97f354d83da68019a5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 16 Dec 2018 22:09:17 +0100 Subject: 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. --- src/shader/wrap/graphic_shader.cc | 10 ++++++++++ src/shader/wrap/graphic_shader.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src/shader/wrap') 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(); -- cgit v1.2.3