mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
little bit more cleanup & naming fixes
This commit is contained in:
parent
6464db5a75
commit
52e362e1b2
|
@ -1294,12 +1294,12 @@ namespace Blah
|
||||||
|
|
||||||
// Blend Mode
|
// Blend Mode
|
||||||
{
|
{
|
||||||
GLenum colorOp = gl_get_blend_func(pass.blend.colorOp);
|
GLenum colorOp = gl_get_blend_func(pass.blend.color_op);
|
||||||
GLenum alphaOp = gl_get_blend_func(pass.blend.alphaOp);
|
GLenum alphaOp = gl_get_blend_func(pass.blend.alpha_op);
|
||||||
GLenum colorSrc = gl_get_blend_factor(pass.blend.colorSrc);
|
GLenum colorSrc = gl_get_blend_factor(pass.blend.color_src);
|
||||||
GLenum colorDst = gl_get_blend_factor(pass.blend.colorDst);
|
GLenum colorDst = gl_get_blend_factor(pass.blend.color_dst);
|
||||||
GLenum alphaSrc = gl_get_blend_factor(pass.blend.alphaSrc);
|
GLenum alphaSrc = gl_get_blend_factor(pass.blend.alpha_src);
|
||||||
GLenum alphaDst = gl_get_blend_factor(pass.blend.alphaDst);
|
GLenum alphaDst = gl_get_blend_factor(pass.blend.alpha_dst);
|
||||||
|
|
||||||
gl.Enable(GL_BLEND);
|
gl.Enable(GL_BLEND);
|
||||||
gl.BlendEquationSeparate(colorOp, alphaOp);
|
gl.BlendEquationSeparate(colorOp, alphaOp);
|
||||||
|
|
|
@ -48,12 +48,18 @@ namespace Blah
|
||||||
|
|
||||||
struct BlendMode
|
struct BlendMode
|
||||||
{
|
{
|
||||||
BlendOp colorOp;
|
// Normal, pre-multiplied, Blend Mode
|
||||||
BlendFactor colorSrc;
|
static const BlendMode Normal;
|
||||||
BlendFactor colorDst;
|
|
||||||
BlendOp alphaOp;
|
// Subtractive Blend Mode
|
||||||
BlendFactor alphaSrc;
|
static const BlendMode Subtract;
|
||||||
BlendFactor alphaDst;
|
|
||||||
|
BlendOp color_op;
|
||||||
|
BlendFactor color_src;
|
||||||
|
BlendFactor color_dst;
|
||||||
|
BlendOp alpha_op;
|
||||||
|
BlendFactor alpha_src;
|
||||||
|
BlendFactor alpha_dst;
|
||||||
BlendMask mask;
|
BlendMask mask;
|
||||||
uint32_t rgba;
|
uint32_t rgba;
|
||||||
|
|
||||||
|
@ -61,36 +67,39 @@ namespace Blah
|
||||||
|
|
||||||
BlendMode(BlendOp op, BlendFactor src, BlendFactor dst)
|
BlendMode(BlendOp op, BlendFactor src, BlendFactor dst)
|
||||||
{
|
{
|
||||||
colorOp = op;
|
color_op = op;
|
||||||
colorSrc = src;
|
color_src = src;
|
||||||
colorDst = dst;
|
color_dst = dst;
|
||||||
alphaOp = op;
|
alpha_op = op;
|
||||||
alphaSrc = src;
|
alpha_src = src;
|
||||||
alphaDst = dst;
|
alpha_dst = dst;
|
||||||
mask = BlendMask::RGBA;
|
mask = BlendMask::RGBA;
|
||||||
rgba = 0xffffffff;
|
rgba = 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendMode(BlendOp rgbOp, BlendFactor rgbSrc, BlendFactor rgbDst, BlendOp aOp, BlendFactor aSrc, BlendFactor aDst, BlendMask blendMask, uint32_t blendColor)
|
BlendMode(BlendOp rgbOp, BlendFactor rgbSrc, BlendFactor rgbDst, BlendOp aOp, BlendFactor aSrc, BlendFactor aDst, BlendMask blendMask, uint32_t blendColor)
|
||||||
{
|
{
|
||||||
colorOp = rgbOp;
|
color_op = rgbOp;
|
||||||
colorSrc = rgbSrc;
|
color_src = rgbSrc;
|
||||||
colorDst = rgbDst;
|
color_dst = rgbDst;
|
||||||
alphaOp = aOp;
|
alpha_op = aOp;
|
||||||
alphaSrc = aSrc;
|
alpha_src = aSrc;
|
||||||
alphaDst = aDst;
|
alpha_dst = aDst;
|
||||||
mask = blendMask;
|
mask = blendMask;
|
||||||
rgba = blendColor;
|
rgba = blendColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const BlendMode& rhs) const {
|
inline bool operator==(const BlendMode& rhs) const
|
||||||
return colorOp == rhs.colorOp && colorSrc == rhs.colorSrc && colorDst == rhs.colorDst &&
|
{
|
||||||
alphaOp == rhs.alphaOp && alphaSrc == rhs.alphaSrc && alphaDst == rhs.alphaDst &&
|
return
|
||||||
|
color_op == rhs.color_op && color_src == rhs.color_src && color_dst == rhs.color_dst &&
|
||||||
|
alpha_op == rhs.alpha_op && alpha_src == rhs.alpha_src && alpha_dst == rhs.alpha_dst &&
|
||||||
mask == rhs.mask && rgba == rhs.rgba;
|
mask == rhs.mask && rgba == rhs.rgba;
|
||||||
}
|
}
|
||||||
inline bool operator!=(const BlendMode& rhs) const { return !(*this == rhs); }
|
|
||||||
|
|
||||||
static const BlendMode Normal;
|
inline bool operator!=(const BlendMode& rhs) const
|
||||||
static const BlendMode Subtract;
|
{
|
||||||
|
return !(*this == rhs);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -16,7 +16,18 @@ namespace Blah
|
||||||
|
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
FrameBuffer() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Copy / Moves not allowed
|
||||||
|
FrameBuffer(const FrameBuffer&) = delete;
|
||||||
|
FrameBuffer(FrameBuffer&&) = delete;
|
||||||
|
FrameBuffer& operator=(const FrameBuffer&) = delete;
|
||||||
|
FrameBuffer& operator=(FrameBuffer&&) = delete;
|
||||||
|
|
||||||
|
// Default Destructor
|
||||||
|
virtual ~FrameBuffer() = default;
|
||||||
|
|
||||||
// Creates a new FrameBuffer with a single Color attachment
|
// Creates a new FrameBuffer with a single Color attachment
|
||||||
// If the FrameBuffer creation fails, it will return an invalid FrameBufferRef.
|
// If the FrameBuffer creation fails, it will return an invalid FrameBufferRef.
|
||||||
|
@ -26,8 +37,6 @@ namespace Blah
|
||||||
// If the FrameBuffer creation fails, it will return an invalid FrameBufferRef.
|
// If the FrameBuffer creation fails, it will return an invalid FrameBufferRef.
|
||||||
static FrameBufferRef create(int width, int height, const TextureFormat* attachments, int attachmentCount);
|
static FrameBufferRef create(int width, int height, const TextureFormat* attachments, int attachmentCount);
|
||||||
|
|
||||||
virtual ~FrameBuffer() = default;
|
|
||||||
|
|
||||||
// Gets the list of Attachments from the FrameBuffer
|
// Gets the list of Attachments from the FrameBuffer
|
||||||
virtual Attachments& attachments() = 0;
|
virtual Attachments& attachments() = 0;
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,21 @@ namespace Blah
|
||||||
class Material;
|
class Material;
|
||||||
typedef std::shared_ptr<Material> MaterialRef;
|
typedef std::shared_ptr<Material> MaterialRef;
|
||||||
|
|
||||||
class Material
|
class Material final
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Material(const ShaderRef& shader);
|
Material(const ShaderRef& shader);
|
||||||
Material(const Material& src) = delete;
|
|
||||||
Material(Material&& src) = delete;
|
|
||||||
Material& operator=(const Material& src) = delete;
|
|
||||||
Material& operator=(Material&& src) = delete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Copy / Moves not allowed
|
||||||
|
Material(const Material&) = delete;
|
||||||
|
Material(Material&&) = delete;
|
||||||
|
Material& operator=(const Material&) = delete;
|
||||||
|
Material& operator=(Material&&) = delete;
|
||||||
|
|
||||||
|
// Default destructor
|
||||||
|
~Material() = default;
|
||||||
|
|
||||||
// Creates a new Material from the given Shader.
|
// Creates a new Material from the given Shader.
|
||||||
// If the Shader is invalid, it will return an invalid MaterialRef.
|
// If the Shader is invalid, it will return an invalid MaterialRef.
|
||||||
static MaterialRef create(const ShaderRef& shader);
|
static MaterialRef create(const ShaderRef& shader);
|
||||||
|
|
|
@ -49,13 +49,23 @@ namespace Blah
|
||||||
|
|
||||||
class Mesh
|
class Mesh
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
Mesh() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Copy / Moves not allowed
|
||||||
|
Mesh(const Mesh&) = delete;
|
||||||
|
Mesh(Mesh&&) = delete;
|
||||||
|
Mesh& operator=(const Mesh&) = delete;
|
||||||
|
Mesh& operator=(Mesh&&) = delete;
|
||||||
|
|
||||||
|
// Default Destructor
|
||||||
|
virtual ~Mesh() = default;
|
||||||
|
|
||||||
// Creates a new Mesh.
|
// Creates a new Mesh.
|
||||||
// If the Mesh creation fails, it will return an invalid Mesh.
|
// If the Mesh creation fails, it will return an invalid Mesh.
|
||||||
static MeshRef create();
|
static MeshRef create();
|
||||||
|
|
||||||
virtual ~Mesh() = default;
|
|
||||||
|
|
||||||
// Sets the Vertex Format of the Mesh
|
// Sets the Vertex Format of the Mesh
|
||||||
void vertex_format(const VertexAttribute* attributes, int attribute_count, int stride = -1);
|
void vertex_format(const VertexAttribute* attributes, int attribute_count, int stride = -1);
|
||||||
|
|
||||||
|
|
|
@ -26,21 +26,21 @@ void RenderPass::perform()
|
||||||
// Validate Material
|
// Validate Material
|
||||||
if (!material)
|
if (!material)
|
||||||
{
|
{
|
||||||
Log::warn("Trying to draw with an invalid Material");
|
Log::warn("Trying to draw with an invalid Material; skipping render pass");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate Shader
|
// Validate Shader
|
||||||
if (!material->shader())
|
if (!material->shader())
|
||||||
{
|
{
|
||||||
Log::warn("Trying to draw with an invalid Shader");
|
Log::warn("Trying to draw with an invalid Shader; skipping render pass");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate Mesh
|
// Validate Mesh
|
||||||
if (!mesh)
|
if (!mesh)
|
||||||
{
|
{
|
||||||
Log::warn("Trying to draw with an invalid Mesh");
|
Log::warn("Trying to draw with an invalid Mesh; skipping render pass");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void RenderPass::perform()
|
||||||
if (pass.index_start + pass.index_count > index_count)
|
if (pass.index_start + pass.index_count > index_count)
|
||||||
{
|
{
|
||||||
Log::warn(
|
Log::warn(
|
||||||
"Trying to draw more indices than exist in the index buffer (%i-%i / %i)",
|
"Trying to draw more indices than exist in the index buffer (%i-%i / %i); trimming extra indices",
|
||||||
pass.index_start,
|
pass.index_start,
|
||||||
pass.index_start + pass.index_count,
|
pass.index_start + pass.index_count,
|
||||||
index_count);
|
index_count);
|
||||||
|
@ -75,7 +75,7 @@ void RenderPass::perform()
|
||||||
if (pass.instance_count > instance_count)
|
if (pass.instance_count > instance_count)
|
||||||
{
|
{
|
||||||
Log::warn(
|
Log::warn(
|
||||||
"Trying to draw more instances than exist in the index buffer (%i / %i)",
|
"Trying to draw more instances than exist in the index buffer (%i / %i); trimming extra instances",
|
||||||
pass.instance_count,
|
pass.instance_count,
|
||||||
instance_count);
|
instance_count);
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,23 @@ namespace Blah
|
||||||
|
|
||||||
class Shader
|
class Shader
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
Shader() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Copy / Moves not allowed
|
||||||
|
Shader(const Shader&) = delete;
|
||||||
|
Shader(Shader&&) = delete;
|
||||||
|
Shader& operator=(const Shader&) = delete;
|
||||||
|
Shader& operator=(Shader&&) = delete;
|
||||||
|
|
||||||
|
// Default Destructor
|
||||||
|
virtual ~Shader() = default;
|
||||||
|
|
||||||
// Creates a Shader with the given Shader Data.
|
// Creates a Shader with the given Shader Data.
|
||||||
// If the Shader creation fails, it will return an invalid ShaderRef.
|
// If the Shader creation fails, it will return an invalid ShaderRef.
|
||||||
static ShaderRef create(const ShaderData* data);
|
static ShaderRef create(const ShaderData* data);
|
||||||
|
|
||||||
virtual ~Shader() = default;
|
|
||||||
|
|
||||||
// Gets a list of Shader Uniforms from Shader
|
// Gets a list of Shader Uniforms from Shader
|
||||||
virtual Vector<UniformInfo>& uniforms() = 0;
|
virtual Vector<UniformInfo>& uniforms() = 0;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,18 @@ namespace Blah
|
||||||
|
|
||||||
class Texture
|
class Texture
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
Texture() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Copy / Moves not allowed
|
||||||
|
Texture(const Texture&) = delete;
|
||||||
|
Texture(Texture&&) = delete;
|
||||||
|
Texture& operator=(const Texture&) = delete;
|
||||||
|
Texture& operator=(Texture&&) = delete;
|
||||||
|
|
||||||
|
// Default Destructor
|
||||||
|
virtual ~Texture() = default;
|
||||||
|
|
||||||
// Creates a new Texture.
|
// Creates a new Texture.
|
||||||
// If the Texture creation fails, it will return an invalid TextureRef.
|
// If the Texture creation fails, it will return an invalid TextureRef.
|
||||||
|
@ -57,8 +68,6 @@ namespace Blah
|
||||||
// If the Texture creation fails, it will return an invalid TextureRef.
|
// If the Texture creation fails, it will return an invalid TextureRef.
|
||||||
static TextureRef create(const char* file);
|
static TextureRef create(const char* file);
|
||||||
|
|
||||||
virtual ~Texture() = default;
|
|
||||||
|
|
||||||
// gets the width of the texture
|
// gets the width of the texture
|
||||||
virtual int width() const = 0;
|
virtual int width() const = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user