added shader
This commit is contained in:
parent
8f1ea5c7ff
commit
9daa5b5c2c
7 changed files with 173 additions and 8 deletions
31
src/Shader.hpp
Normal file
31
src/Shader.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class AbstractShader
|
||||
{
|
||||
friend class ShaderFactory;
|
||||
|
||||
public:
|
||||
AbstractShader(const std::string& vertexShader, const std::string& fragmentShader);
|
||||
AbstractShader(const AbstractShader& other) = delete;
|
||||
~AbstractShader();
|
||||
|
||||
inline bool Good() { return id != 0; }
|
||||
void Use();
|
||||
|
||||
private:
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<AbstractShader> Shader;
|
||||
|
||||
class ShaderFactory
|
||||
{
|
||||
public:
|
||||
inline static Shader Produce(const std::string& vertexShader, const std::string& fragmentShader)
|
||||
{
|
||||
return std::make_shared<AbstractShader>(vertexShader, fragmentShader);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue