X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.h;h=a1f454e9453272cf14b84a29ce60bc8c6a765b60;hb=9d2291e3f3c007b1aa7fe66d882a8c1fce8fdee6;hp=af506fe8c57b1128a5354e1515c20059bcccdb1e;hpb=ceae2a27dfc58310c5bab7e3aa3fedf0fa9a1f49;p=libs%2Fgl.git diff --git a/source/program.h b/source/program.h index af506fe8..a1f454e9 100644 --- a/source/program.h +++ b/source/program.h @@ -1,16 +1,10 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GL_PROGRAM_H_ #define MSP_GL_PROGRAM_H_ #include #include #include +#include "bindable.h" #include "gl.h" namespace Msp { @@ -18,16 +12,8 @@ namespace GL { class Shader; -class Program +class Program: public Bindable { -private: - unsigned id; - std::list shaders; - bool del_shaders; - bool linked; - - static const Program *cur_prog; - public: class Loader: public DataFile::ObjectLoader { @@ -35,13 +21,55 @@ public: Loader(Program &); private: - void vertex_shader(const std::string &); - void fragment_shader(const std::string &); - void attribute(unsigned, 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; + bool reflection; + bool transform; + + StandardFeatures(); + + std::string create_flags() const; }; + struct UniformInfo + { + std::string name; + int location; + int size; + GLenum type; + }; + +private: + unsigned id; + std::list shaders; + std::list owned_data; + bool linked; + std::map uniforms; + unsigned uniform_layout_hash; + +public: Program(); + Program(const StandardFeatures &); Program(const std::string &, const std::string &); private: void init(); @@ -49,21 +77,22 @@ public: virtual ~Program(); void attach_shader(Shader &shader); + void attach_shader_owned(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(unsigned, const std::string &); void link(); - int get_param(GLenum param) const; - bool get_linked() const { return linked; } + bool is_linked() const { return linked; } std::string get_info_log() const; void bind() const; + unsigned get_uniform_layout_hash() const { return uniform_layout_hash; } int get_uniform_location(const std::string &) const; static void unbind(); - -private: - void maybe_bind(); }; } // namespace GL