X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogram.h;h=fc60db46fcc2265af0b1ad9282eec1b5b19f6dcb;hp=53f060d2d99fdf4fd92e55b3fefd4a956c54da2e;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=e3561c5c4d0b2caf00a0e50ce85c11a9fb62aa72 diff --git a/source/program.h b/source/program.h index 53f060d2..fc60db46 100644 --- a/source/program.h +++ b/source/program.h @@ -1,12 +1,11 @@ #ifndef MSP_GL_PROGRAM_H_ #define MSP_GL_PROGRAM_H_ -#include #include +#include #include #include "bindable.h" #include "gl.h" -#include "programbuilder.h" #include "vertexformat.h" namespace Msp { @@ -32,7 +31,6 @@ public: void attribute(unsigned, const std::string &); void fragment_shader(const std::string &); void geometry_shader(const std::string &); - void standard(); void vertex_shader(const std::string &); }; @@ -59,9 +57,18 @@ public: LayoutHash layout_hash; }; - typedef std::list ShaderList; + struct AttributeInfo + { + std::string name; + unsigned location; + unsigned size; + GLenum type; + }; + + typedef std::vector ShaderList; typedef std::map UniformMap; typedef std::map UniformBlockMap; + typedef std::map AttributeMap; private: unsigned id; @@ -71,14 +78,14 @@ private: UniformBlockMap uniform_blocks; UniformMap uniforms; LayoutHash uniform_layout_hash; - bool legacy_vars; + AttributeMap attributes; public: /// Constructs an empty Program with no Shaders attached. Program(); - /// Constructs a Program with standard features. - Program(const ProgramBuilder::StandardFeatures &); + /// Constructs a Program from unified source code using ProgramCompiler. + Program(const std::string &); /// Constructs a Program from vertex and fragment shader source code. Program(const std::string &, const std::string &); @@ -99,6 +106,10 @@ public: void link(); private: + static void require_type(GLenum); + void query_uniforms(); + void query_uniform_blocks(const std::vector &); + void query_attributes(); static LayoutHash compute_layout_hash(const std::vector &); static bool uniform_location_compare(const UniformInfo *, const UniformInfo *); public: @@ -111,8 +122,9 @@ public: const UniformMap &get_uniforms() const { return uniforms; } const UniformInfo &get_uniform_info(const std::string &) const; int get_uniform_location(const std::string &) const; - - bool uses_legacy_variables() const { return legacy_vars; } + const AttributeMap &get_attributes() const { return attributes; } + const AttributeInfo &get_attribute_info(const std::string &) const; + int get_attribute_location(const std::string &) const; void bind() const; static void unbind();