X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fshader.h;fp=source%2Fcore%2Fshader.h;h=bab11a7e9603e8bcc32652427b20ade4e7796267;hb=7aaec9a70b8d7733429bec043f8e33e02956f266;hp=0000000000000000000000000000000000000000;hpb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;p=libs%2Fgl.git diff --git a/source/core/shader.h b/source/core/shader.h new file mode 100644 index 00000000..bab11a7e --- /dev/null +++ b/source/core/shader.h @@ -0,0 +1,66 @@ +#ifndef MSP_GL_SHADER_H_ +#define MSP_GL_SHADER_H_ + +#include +#include "gl.h" + +namespace Msp { +namespace GL { + +/** +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; + +protected: + Shader(GLenum t); + Shader(GLenum t, const std::string &); +private: + void init(GLenum); +public: + virtual ~Shader(); + + void source(unsigned count, const char **str, const int *len); + void source(const std::string &str); + void source(const char *str, int len); + void compile(); + unsigned get_id() const { return id; } + bool is_compiled() const { return compiled; } + 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 + +#endif