2020-08-26 15:38:01 +08:00
|
|
|
#pragma once
|
2020-10-25 06:21:36 +08:00
|
|
|
#include <blah/containers/stackvector.h>
|
2020-12-24 19:01:05 +08:00
|
|
|
#include <blah/containers/str.h>
|
2020-08-26 15:38:01 +08:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace Blah
|
|
|
|
{
|
2020-12-24 19:01:05 +08:00
|
|
|
enum class UniformType
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Float,
|
|
|
|
Float2,
|
|
|
|
Float3,
|
|
|
|
Float4,
|
|
|
|
Mat3x2,
|
|
|
|
Mat4x4,
|
|
|
|
Texture
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UniformInfo
|
|
|
|
{
|
|
|
|
String name;
|
|
|
|
UniformType type;
|
|
|
|
int array_length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShaderData
|
|
|
|
{
|
|
|
|
const char* vertex;
|
|
|
|
const char* fragment;
|
|
|
|
};
|
2020-08-26 15:38:01 +08:00
|
|
|
|
2020-12-27 06:44:48 +08:00
|
|
|
class Shader;
|
|
|
|
typedef std::shared_ptr<Shader> ShaderRef;
|
|
|
|
|
2020-08-26 15:38:01 +08:00
|
|
|
class Shader
|
|
|
|
{
|
|
|
|
public:
|
2020-12-27 06:44:48 +08:00
|
|
|
|
|
|
|
// Creates a Shader with the given Shader Data.
|
|
|
|
// If the Shader creation fails, it will return an invalid ShaderRef.
|
|
|
|
static ShaderRef create(const ShaderData* data);
|
|
|
|
|
2020-08-26 15:38:01 +08:00
|
|
|
virtual ~Shader() = default;
|
|
|
|
|
|
|
|
// Gets a list of Shader Uniforms from Shader
|
2020-12-24 19:01:05 +08:00
|
|
|
virtual Vector<UniformInfo>& uniforms() = 0;
|
2020-08-26 15:38:01 +08:00
|
|
|
|
|
|
|
// Gets a list of Shader Uniforms from Shader
|
2020-12-24 19:01:05 +08:00
|
|
|
virtual const Vector<UniformInfo>& uniforms() const = 0;
|
2020-08-26 15:38:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|