]> git.tdb.fi Git - libs/gl.git/commitdiff
Add basic support for geometry shaders
authorMikko Rasa <tdb@tdb.fi>
Sun, 16 Oct 2016 08:16:38 +0000 (11:16 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 16 Oct 2016 11:25:47 +0000 (14:25 +0300)
extensions/ext_geometry_shader4.glext [new file with mode: 0644]
source/program.cpp
source/program.h
source/shader.cpp
source/shader.h

diff --git a/extensions/ext_geometry_shader4.glext b/extensions/ext_geometry_shader4.glext
new file mode 100644 (file)
index 0000000..0bc0f85
--- /dev/null
@@ -0,0 +1 @@
+extension EXT_geometry_shader4
index 30c73f33631373c7043a66f20509b7cc09369ea6..021b23483dcdce1c074388916a38721a72aee567 100644 (file)
@@ -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;
index 53daaa76caad73669d09aaab4ba21453e9a3b107..53f060d2d99fdf4fd92e55b3fefd4a956c54da2e 100644 (file)
@@ -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 &);
        };
index 1b3455f1aa91270c810d0494ac80c3e80b7fe051..17bf3fad3196ad08b735669bda32f72bf2212a92 100644 (file)
@@ -1,6 +1,7 @@
 #include <msp/gl/extensions/arb_fragment_shader.h>
 #include <msp/gl/extensions/arb_shader_objects.h>
 #include <msp/gl/extensions/arb_vertex_shader.h>
+#include <msp/gl/extensions/ext_geometry_shader4.h>
 #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
index 961cb6944fb5f553ad3abbdb5af90675ac897230..bab11a7e9603e8bcc32652427b20ade4e7796267 100644 (file)
@@ -52,6 +52,14 @@ public:
        FragmentShader(const std::string &);
 };
 
+
+class GeometryShader: public Shader
+{
+public:
+       GeometryShader();
+       GeometryShader(const std::string &);
+};
+
 } // namespace GL
 } // namespace Msp