X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.h;h=ac8e24b54b6a8143510ac743d6676e963e3b78ae;hb=0646b330ffa9ea7fd77e2078257499b1d58ac0f7;hp=5b1ae29f3ed0681b9a4eb930d938a712fecfacdc;hpb=48420e9e3f950cfe1e3ced8f8ea92d89671ae8c4;p=libs%2Fgl.git diff --git a/source/program.h b/source/program.h index 5b1ae29f..ac8e24b5 100644 --- a/source/program.h +++ b/source/program.h @@ -1,44 +1,95 @@ -/* $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 "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; + 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; + public: Program(); + Program(const StandardFeatures &); + Program(const std::string &, const std::string &); +private: + void init(); +public: virtual ~Program(); void attach_shader(Shader &shader); + void attach_shader_owned(Shader *shader); void detach_shader(Shader &shader); - bool link(); - int get_param(GLenum param) const; + 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 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; static void unbind(); -private: - uint id; - std::list shaders; - bool linked; - - static Program *cur_prog; }; } // namespace GL