X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fshader.h;h=bab11a7e9603e8bcc32652427b20ade4e7796267;hp=c1fd6b2294a47c57c38b62ce9aa41241c19bc9c6;hb=b38a4cba9d2a9963a0937757eff9e955f18ddf2a;hpb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8 diff --git a/source/shader.h b/source/shader.h index c1fd6b22..bab11a7e 100644 --- a/source/shader.h +++ b/source/shader.h @@ -7,25 +7,25 @@ namespace Msp { namespace GL { -enum ShaderType -{ - FRAGMENT_SHADER = GL_FRAGMENT_SHADER_ARB, - VERTEX_SHADER = GL_VERTEX_SHADER_ARB -}; +/** +A single shader stage. Shaders must be attached to a Program to be used. +This class can't be instantiated directly. Use one of the VertexShader and +FragmentShader classes to create Shaders. +*/ class Shader { private: unsigned id; bool compiled; -public: - Shader(ShaderType t); - Shader(ShaderType t, const std::string &); +protected: + Shader(GLenum t); + Shader(GLenum t, const std::string &); private: - void init(ShaderType); + void init(GLenum); public: - ~Shader(); + virtual ~Shader(); void source(unsigned count, const char **str, const int *len); void source(const std::string &str); @@ -36,6 +36,30 @@ public: std::string get_info_log() const; }; + +class VertexShader: public Shader +{ +public: + VertexShader(); + VertexShader(const std::string &); +}; + + +class FragmentShader: public Shader +{ +public: + FragmentShader(); + FragmentShader(const std::string &); +}; + + +class GeometryShader: public Shader +{ +public: + GeometryShader(); + GeometryShader(const std::string &); +}; + } // namespace GL } // namespace Msp