mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-29 17:08:56 +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
|
||||
{
|
||||
GLenum colorOp = gl_get_blend_func(pass.blend.colorOp);
|
||||
GLenum alphaOp = gl_get_blend_func(pass.blend.alphaOp);
|
||||
GLenum colorSrc = gl_get_blend_factor(pass.blend.colorSrc);
|
||||
GLenum colorDst = gl_get_blend_factor(pass.blend.colorDst);
|
||||
GLenum alphaSrc = gl_get_blend_factor(pass.blend.alphaSrc);
|
||||
GLenum alphaDst = gl_get_blend_factor(pass.blend.alphaDst);
|
||||
GLenum colorOp = gl_get_blend_func(pass.blend.color_op);
|
||||
GLenum alphaOp = gl_get_blend_func(pass.blend.alpha_op);
|
||||
GLenum colorSrc = gl_get_blend_factor(pass.blend.color_src);
|
||||
GLenum colorDst = gl_get_blend_factor(pass.blend.color_dst);
|
||||
GLenum alphaSrc = gl_get_blend_factor(pass.blend.alpha_src);
|
||||
GLenum alphaDst = gl_get_blend_factor(pass.blend.alpha_dst);
|
||||
|
||||
gl.Enable(GL_BLEND);
|
||||
gl.BlendEquationSeparate(colorOp, alphaOp);
|
||||
|
|
|
@ -48,12 +48,18 @@ namespace Blah
|
|||
|
||||
struct BlendMode
|
||||
{
|
||||
BlendOp colorOp;
|
||||
BlendFactor colorSrc;
|
||||
BlendFactor colorDst;
|
||||
BlendOp alphaOp;
|
||||
BlendFactor alphaSrc;
|
||||
BlendFactor alphaDst;
|
||||
// Normal, pre-multiplied, Blend Mode
|
||||
static const BlendMode Normal;
|
||||
|
||||
// Subtractive Blend Mode
|
||||
static const BlendMode Subtract;
|
||||
|
||||
BlendOp color_op;
|
||||
BlendFactor color_src;
|
||||
BlendFactor color_dst;
|
||||
BlendOp alpha_op;
|
||||
BlendFactor alpha_src;
|
||||
BlendFactor alpha_dst;
|
||||
BlendMask mask;
|
||||
uint32_t rgba;
|
||||
|
||||
|
@ -61,36 +67,39 @@ namespace Blah
|
|||
|
||||
BlendMode(BlendOp op, BlendFactor src, BlendFactor dst)
|
||||
{
|
||||
colorOp = op;
|
||||
colorSrc = src;
|
||||
colorDst = dst;
|
||||
alphaOp = op;
|
||||
alphaSrc = src;
|
||||
alphaDst = dst;
|
||||
color_op = op;
|
||||
color_src = src;
|
||||
color_dst = dst;
|
||||
alpha_op = op;
|
||||
alpha_src = src;
|
||||
alpha_dst = dst;
|
||||
mask = BlendMask::RGBA;
|
||||
rgba = 0xffffffff;
|
||||
}
|
||||
|
||||
BlendMode(BlendOp rgbOp, BlendFactor rgbSrc, BlendFactor rgbDst, BlendOp aOp, BlendFactor aSrc, BlendFactor aDst, BlendMask blendMask, uint32_t blendColor)
|
||||
{
|
||||
colorOp = rgbOp;
|
||||
colorSrc = rgbSrc;
|
||||
colorDst = rgbDst;
|
||||
alphaOp = aOp;
|
||||
alphaSrc = aSrc;
|
||||
alphaDst = aDst;
|
||||
color_op = rgbOp;
|
||||
color_src = rgbSrc;
|
||||
color_dst = rgbDst;
|
||||
alpha_op = aOp;
|
||||
alpha_src = aSrc;
|
||||
alpha_dst = aDst;
|
||||
mask = blendMask;
|
||||
rgba = blendColor;
|
||||
}
|
||||
|
||||
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 &&
|
||||
inline bool operator==(const BlendMode& rhs) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
inline bool operator!=(const BlendMode& rhs) const { return !(*this == rhs); }
|
||||
|
||||
static const BlendMode Normal;
|
||||
static const BlendMode Subtract;
|
||||
inline bool operator!=(const BlendMode& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -16,7 +16,18 @@ namespace Blah
|
|||
|
||||
class FrameBuffer
|
||||
{
|
||||
protected:
|
||||
FrameBuffer() = default;
|
||||
|
||||
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
|
||||
// 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.
|
||||
static FrameBufferRef create(int width, int height, const TextureFormat* attachments, int attachmentCount);
|
||||
|
||||
virtual ~FrameBuffer() = default;
|
||||
|
||||
// Gets the list of Attachments from the FrameBuffer
|
||||
virtual Attachments& attachments() = 0;
|
||||
|
||||
|
|
|
@ -9,16 +9,21 @@ namespace Blah
|
|||
class Material;
|
||||
typedef std::shared_ptr<Material> MaterialRef;
|
||||
|
||||
class Material
|
||||
class Material final
|
||||
{
|
||||
private:
|
||||
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:
|
||||
// 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.
|
||||
// If the Shader is invalid, it will return an invalid MaterialRef.
|
||||
static MaterialRef create(const ShaderRef& shader);
|
||||
|
|
|
@ -49,13 +49,23 @@ namespace Blah
|
|||
|
||||
class Mesh
|
||||
{
|
||||
protected:
|
||||
Mesh() = default;
|
||||
|
||||
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.
|
||||
// If the Mesh creation fails, it will return an invalid Mesh.
|
||||
static MeshRef create();
|
||||
|
||||
virtual ~Mesh() = default;
|
||||
|
||||
// Sets the Vertex Format of the Mesh
|
||||
void vertex_format(const VertexAttribute* attributes, int attribute_count, int stride = -1);
|
||||
|
||||
|
|
|
@ -26,21 +26,21 @@ void RenderPass::perform()
|
|||
// Validate 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;
|
||||
}
|
||||
|
||||
// Validate 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;
|
||||
}
|
||||
|
||||
// Validate 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;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ void RenderPass::perform()
|
|||
if (pass.index_start + pass.index_count > index_count)
|
||||
{
|
||||
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_count,
|
||||
index_count);
|
||||
|
@ -75,7 +75,7 @@ void RenderPass::perform()
|
|||
if (pass.instance_count > instance_count)
|
||||
{
|
||||
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,
|
||||
instance_count);
|
||||
|
||||
|
|
|
@ -35,14 +35,23 @@ namespace Blah
|
|||
|
||||
class Shader
|
||||
{
|
||||
protected:
|
||||
Shader() = default;
|
||||
|
||||
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.
|
||||
// If the Shader creation fails, it will return an invalid ShaderRef.
|
||||
static ShaderRef create(const ShaderData* data);
|
||||
|
||||
virtual ~Shader() = default;
|
||||
|
||||
// Gets a list of Shader Uniforms from Shader
|
||||
virtual Vector<UniformInfo>& uniforms() = 0;
|
||||
|
||||
|
|
|
@ -35,7 +35,18 @@ namespace Blah
|
|||
|
||||
class Texture
|
||||
{
|
||||
protected:
|
||||
Texture() = default;
|
||||
|
||||
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.
|
||||
// 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.
|
||||
static TextureRef create(const char* file);
|
||||
|
||||
virtual ~Texture() = default;
|
||||
|
||||
// gets the width of the texture
|
||||
virtual int width() const = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user