Page MenuHomePhorge

ShaderProgram.h
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

ShaderProgram.h

#ifndef _ECHOSHADERPROGRAM_H_
#define _ECHOSHADERPROGRAM_H_
#include <echo/Types.h>
#include <echo/Graphics/VertexShader.h>
#include <echo/Graphics/FragmentShader.h>
#include <echo/Maths/Matrix4.h>
#include <map>
namespace Echo
{
//An internal structure for managing the shader resource
class ShaderProgramResource;
class ShaderProgramVariable;
class ShaderProgram
{
public:
//The constructor should allocate and/or assign the EShaderProgramResource
ShaderProgram();
~ShaderProgram();
ShaderProgramResource* GetShaderProgramResource() const { return mShaderProgramResource; }
void SetShaderResource(ShaderProgramResource* val) { mShaderProgramResource = val; }
// Adds a fragment shader
bool AddFragmentShader(shared_ptr<FragmentShader> shader);
//Adds vertex shader to be later linked
bool AddVertexShader(shared_ptr<VertexShader> shader);
//Links this program
bool Link();
//Setting active assigns all of the variables.
void SetActive();
void SetInactive();
//Setting an attribute stream passes a pointer to a stream of data that will be used for vertex attributes
//when the program is set to active. The streams must contain as much data as there are vertices.
bool SetFloatAttributeStream(const std::string& name, float* stream);
bool SetVector2AttributeStream(const std::string& name, Vector2* stream);
bool SetVector3AttributeStream(const std::string& name, Vector3* stream);
bool SetVector4AttributeStream(const std::string& name, Vector4* stream);
//These Get methods return a shared pointer that points to a value that can be changed so that when the program is
//set to active the value of the variables at that time will be the values of the uniform variables.
shared_ptr<float> GetFloat(const std::string& name);
shared_ptr<s32> GetInteger(const std::string& name);
shared_ptr<bool> GetBoolean(const std::string& name);
shared_ptr<Vector2> GetVector2(const std::string& name);
shared_ptr<Vector3> GetVector3(const std::string& name);
shared_ptr<Vector4> GetVector4(const std::string& name);
shared_ptr<Matrix3> GetMatrix3(const std::string& name);
shared_ptr<Matrix4> GetMatrix4(const std::string& name);
std::string GetErrors();
private:
std::string m_Source;
bool mLinked;
bool mActive;
ShaderProgramResource* mShaderProgramResource;
std::map < std::string, ShaderProgramVariable* > mUniformProgramVariables;
std::map < std::string, ShaderProgramVariable* > mAttributeProgramVariables;
};
}
#endif

File Metadata

Mime Type
text/x-c++
Expires
Thu, Dec 5, 1:58 AM (7 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
63264
Default Alt Text
ShaderProgram.h (2 KB)

Event Timeline