X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.h;h=1e41e84423f8680ba787a83d8ecea5c45d1bc7c7;hb=8ac93980ef87834fd431c97104baa441561a7ce0;hp=a77a70d708102fcf9345e33b80ab273bd97bda9e;hpb=85facfb688035b5bbc9a3a87d080582fbf34930b;p=libs%2Fgl.git diff --git a/source/program.h b/source/program.h index a77a70d7..1e41e844 100644 --- a/source/program.h +++ b/source/program.h @@ -10,36 +10,84 @@ Distributed under the LGPL #include #include -#include -#include "shader.h" -#include "types.h" +#include +#include "bindable.h" +#include "gl.h" namespace Msp { namespace GL { class Shader; -class Program +class Program: public Bindable { +public: + class Loader: public DataFile::ObjectLoader + { + public: + Loader(Program &); + + private: + virtual void finish(); + + void attribute(unsigned, const std::string &); + void fragment_shader(const std::string &); + void standard(); + void vertex_shader(const std::string &); + }; + + struct StandardFeatures + { + class Loader: public DataFile::ObjectLoader + { + public: + Loader(StandardFeatures &); + }; + + bool texture; + bool material; + bool lighting; + bool specular; + bool normalmap; + bool shadow; + + StandardFeatures(); + + std::string create_flags() const; + }; + +private: + unsigned id; + std::list shaders; + bool del_shaders; + bool linked; + public: Program(); + Program(const StandardFeatures &); + Program(const std::string &, const std::string &); +private: + void init(); +public: virtual ~Program(); void attach_shader(Shader &shader); void detach_shader(Shader &shader); - void bind_attribute(int, const std::string &); - bool link(); + void add_standard_shaders(const StandardFeatures &); +private: + static std::string process_standard_source(const char **, const std::string &); +public: + const std::list &get_shaders() const { return shaders; } + void set_del_shaders(bool); + void bind_attribute(unsigned, const std::string &); + void link(); int get_param(GLenum param) const; + bool get_linked() const { return linked; } std::string get_info_log() const; - void bind(); + void bind() const; + int get_uniform_location(const std::string &) const; static void unbind(); -private: - uint id; - std::list shaders; - bool linked; - - static Program *cur_prog; }; } // namespace GL