X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.h;h=4ff3f53a41c149a2e2d411d25cd52f4ae6873260;hb=953f041e904e97c4435e0229b8d88eabe31e5c3d;hp=f007fb3a5d3636b72820ffb9b6656e7860172977;hpb=3f285d3f4fd0a6790bf1efa780284dc7ba2287a2;p=libs%2Fgl.git diff --git a/source/program.h b/source/program.h index f007fb3a..4ff3f53a 100644 --- a/source/program.h +++ b/source/program.h @@ -10,66 +10,83 @@ Distributed under the LGPL #include #include -#include -#include -#include "types.h" +#include +#include "bindable.h" +#include "gl.h" namespace Msp { namespace GL { class Shader; -class Program +class Program: public Bindable { -private: - uint id; - std::list shaders; - bool del_shaders; - bool linked; - - static Program *cur_prog; - public: - class Loader: public DataFile::Loader + class Loader: public DataFile::ObjectLoader { - private: - Program &prog; - public: Loader(Program &); - ~Loader(); private: - void vertex_shader(const std::string &); + 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 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(int, const std::string &); - bool link(); - int get_param(GLenum param) const; - bool get_linked() const { return linked; } + void bind_attribute(unsigned, const std::string &); + void link(); + bool is_linked() const { return linked; } std::string get_info_log() const; - void bind(); + void bind() const; int get_uniform_location(const std::string &) const; - void uniform(int, int); - void uniform(int, float); - void uniform(int, float, float); - void uniform(int, float, float, float); - void uniform(int, float, float, float, float); - void uniform_matrix4(int, const float *); static void unbind(); - -private: - void maybe_bind(); }; } // namespace GL