From e3561c5c4d0b2caf00a0e50ce85c11a9fb62aa72 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 16 Oct 2016 11:16:38 +0300 Subject: [PATCH] Add basic support for geometry shaders --- extensions/ext_geometry_shader4.glext | 1 + source/program.cpp | 6 ++++++ source/program.h | 1 + source/shader.cpp | 12 ++++++++++++ source/shader.h | 8 ++++++++ 5 files changed, 28 insertions(+) create mode 100644 extensions/ext_geometry_shader4.glext diff --git a/extensions/ext_geometry_shader4.glext b/extensions/ext_geometry_shader4.glext new file mode 100644 index 00000000..0bc0f85d --- /dev/null +++ b/extensions/ext_geometry_shader4.glext @@ -0,0 +1 @@ +extension EXT_geometry_shader4 diff --git a/source/program.cpp b/source/program.cpp index 30c73f33..021b2348 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -319,6 +319,7 @@ Program::Loader::Loader(Program &p): { add("attribute", &Loader::attribute); add("fragment_shader", &Loader::fragment_shader); + add("geometry_shader", &Loader::geometry_shader); add("standard", &Loader::standard); add("vertex_shader", &Loader::vertex_shader); } @@ -338,6 +339,11 @@ void Program::Loader::fragment_shader(const string &src) obj.attach_shader_owned(new FragmentShader(src)); } +void Program::Loader::geometry_shader(const string &src) +{ + obj.attach_shader_owned(new GeometryShader(src)); +} + void Program::Loader::standard() { ProgramBuilder::StandardFeatures feat; diff --git a/source/program.h b/source/program.h index 53daaa76..53f060d2 100644 --- a/source/program.h +++ b/source/program.h @@ -31,6 +31,7 @@ public: void attribute(unsigned, const std::string &); void fragment_shader(const std::string &); + void geometry_shader(const std::string &); void standard(); void vertex_shader(const std::string &); }; diff --git a/source/shader.cpp b/source/shader.cpp index 1b3455f1..17bf3fad 100644 --- a/source/shader.cpp +++ b/source/shader.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "error.h" #include "misc.h" #include "shader.h" @@ -31,6 +32,8 @@ void Shader::init(GLenum t) static Require _req(ARB_fragment_shader); else if(t==GL_VERTEX_SHADER) static Require _req(ARB_vertex_shader); + else if(t==GL_GEOMETRY_SHADER) + static Require _req(EXT_geometry_shader4); id = glCreateShader(t); } @@ -91,5 +94,14 @@ FragmentShader::FragmentShader(const string &src): Shader(GL_FRAGMENT_SHADER, src) { } + +GeometryShader::GeometryShader(): + Shader(GL_GEOMETRY_SHADER) +{ } + +GeometryShader::GeometryShader(const string &src): + Shader(GL_GEOMETRY_SHADER, src) +{ } + } // namespace GL } // namespace Msp diff --git a/source/shader.h b/source/shader.h index 961cb694..bab11a7e 100644 --- a/source/shader.h +++ b/source/shader.h @@ -52,6 +52,14 @@ public: FragmentShader(const std::string &); }; + +class GeometryShader: public Shader +{ +public: + GeometryShader(); + GeometryShader(const std::string &); +}; + } // namespace GL } // namespace Msp -- 2.45.2