X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fshader.h;h=bab11a7e9603e8bcc32652427b20ade4e7796267;hp=43d03ce109cd61343099db8c5b9a11df6c27d398;hb=99d25b5ef615a23ef63645fea87596b3384b5ede;hpb=3f285d3f4fd0a6790bf1efa780284dc7ba2287a2 diff --git a/source/shader.h b/source/shader.h index 43d03ce1..bab11a7e 100644 --- a/source/shader.h +++ b/source/shader.h @@ -1,44 +1,63 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GL_SHADER_H_ #define MSP_GL_SHADER_H_ #include -#include -#include "types.h" +#include "gl.h" namespace Msp { namespace GL { -enum ShaderType -{ - FRAGMENT_SHADER = GL_FRAGMENT_SHADER, - VERTEX_SHADER = GL_VERTEX_SHADER -}; +/** +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: - Shader(ShaderType t); - Shader(ShaderType t, const std::string &); - ~Shader(); + virtual ~Shader(); - void source(sizei count, const char **str, const int *len); + void source(unsigned count, const char **str, const int *len); void source(const std::string &str); void source(const char *str, int len); - bool compile(); - uint get_id() const { return id; } - bool get_compiled() const { return compiled; } - int get_param(GLenum param) const; + void compile(); + unsigned get_id() const { return id; } + bool is_compiled() const { return compiled; } std::string get_info_log() const; -private: - uint id; - bool compiled; +}; + + +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