Skip to content

Commit 15c0f54

Browse files
authored
Merge pull request #27 from CapsCollective/feature/colour-impl
Added the FColour and IColour types
2 parents 674f979 + e2dc957 commit 15c0f54

26 files changed

+411
-106
lines changed

engine/core/TransitionAdapter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ BoundingBox FromBoundedBox(BoundedBox bbox)
4747
return {FromVec3(bbox.min), FromVec3(bbox.max)};
4848
}
4949

50-
Colour ToColour(Color color)
50+
IColour ToColour(Color color)
5151
{
5252
return {color.r, color.g, color.b, color.a};
5353
}
5454

55-
Color FromColour(Colour color)
55+
Color FromColour(IColour color)
5656
{
5757
return {(unsigned char) color.r,
5858
(unsigned char) color.g,

engine/core/TransitionAdapter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ BoundedBox ToBoundedBox(BoundingBox bbox);
3333

3434
BoundingBox FromBoundedBox(BoundedBox bbox);
3535

36-
Colour ToColour(Color color);
36+
IColour ToColour(Color color);
3737

38-
Color FromColour(Colour color);
38+
Color FromColour(IColour color);
3939
} // namespace Siege
4040

4141
#endif // SIEGE_ENGINE_TRANSITIONADAPTER_H

engine/core/render/RenderSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ void RenderSystem::Remove(Entity* entity)
6262
if (it != renderItems.end()) renderItems.erase(it);
6363
}
6464

65-
void RenderSystem::DrawText2D(const String& text, int posX, int posY, int fontSize, Colour color)
65+
void RenderSystem::DrawText2D(const String& text, int posX, int posY, int fontSize, IColour color)
6666
{
6767
DrawText(text, posX, posY, fontSize, FromColour(color));
6868
}
6969

70-
void RenderSystem::DrawRectangle2D(int posX, int posY, int width, int height, Colour color)
70+
void RenderSystem::DrawRectangle2D(int posX, int posY, int width, int height, IColour color)
7171
{
7272
DrawRectangle(posX, posY, width, height, FromColour(color));
7373
}

engine/core/render/RenderSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class RenderSystem
5151

5252
void DrawFrame();
5353

54-
void DrawText2D(const String& text, int posX, int posY, int fontSize, Colour color);
54+
void DrawText2D(const String& text, int posX, int posY, int fontSize, IColour color);
5555

56-
void DrawRectangle2D(int posX, int posY, int width, int height, Colour color);
56+
void DrawRectangle2D(int posX, int posY, int width, int height, IColour color);
5757

5858
private:
5959

engine/core/render/Window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Window
4646

4747
// Private fields
4848

49-
Colour backgroundColour;
49+
IColour backgroundColour;
5050

5151
static float deltaTime;
5252
};

engine/render/renderer/lights/PointLight.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Siege
1313

1414
PointLight::PointLight() : PointLight(Vec3::Zero, {1.0f, 1.0f, 1.0f, 0.2f}, {1.f, 1.f, 1.f, .2f}) {}
1515

16-
PointLight::PointLight(Vec3 position, Vec4 color, Vec4 ambientColor) :
16+
PointLight::PointLight(Vec3 position, FColour color, FColour ambientColor) :
1717
lightData {color, ambientColor, position}
1818
{}
1919

engine/render/renderer/lights/PointLight.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class PointLight
2121

2222
struct Data
2323
{
24-
Vec4 lightColor = {1.f, 1.f, 1.f, 0.2f};
25-
alignas(16) Vec4 ambientLightColor = {1.f, 1.f, 1.f, .02f};
24+
FColour lightColor = {1.f, 1.f, 1.f, 0.2f};
25+
alignas(16) FColour ambientLightColor = {1.f, 1.f, 1.f, .02f};
2626
alignas(16) Vec3 position = Vec3::Zero;
2727
};
2828

2929
PointLight();
30-
PointLight(Vec3 position, Vec4 color, Vec4 ambientColor);
30+
PointLight(Vec3 position, FColour color, FColour ambientColor);
3131
~PointLight();
3232

3333
Data& GetLightData()
@@ -42,11 +42,11 @@ class PointLight
4242
{
4343
lightData.position = position;
4444
}
45-
void SetColor(Vec4 color)
45+
void SetColor(FColour color)
4646
{
4747
lightData.lightColor = color;
4848
}
49-
void SetAmbientColor(Vec4 ambientColor)
49+
void SetAmbientColor(FColour ambientColor)
5050
{
5151
lightData.ambientLightColor = ambientColor;
5252
}

engine/render/renderer/mesh/Mesh.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef SIEGE_ENGINE_MESH_H
1010
#define SIEGE_ENGINE_MESH_H
1111

12+
#include <utils/Colour.h>
13+
1214
#include "../Core.h"
1315
#include "../buffer/Buffer.h"
1416
#include "render/renderer/platform/vulkan/CommandBuffer.h"
@@ -18,15 +20,15 @@ namespace Siege
1820
struct Vertex
1921
{
2022
Vec3 position;
21-
Vec3 color;
23+
FColour color;
2224
Vec3 normal;
2325
Vec2 uv;
2426
};
2527

2628
struct Vertex2D
2729
{
2830
Vec2 position;
29-
Vec3 color;
31+
FColour color;
3032
};
3133

3234
struct BillboardVertex

engine/render/renderer/model/Model.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ void Model::LoadModelFromFile(const String& filePath)
120120
attrib.vertices[3 * index.vertex_index + 1],
121121
attrib.vertices[3 * index.vertex_index + 2]};
122122

123-
vertex.color = Vec3 {attrib.colors[3 * index.vertex_index + 0],
124-
attrib.colors[3 * index.vertex_index + 1],
125-
attrib.colors[3 * index.vertex_index + 2]};
123+
vertex.color = FColour {attrib.colors[3 * index.vertex_index + 0],
124+
attrib.colors[3 * index.vertex_index + 1],
125+
attrib.colors[3 * index.vertex_index + 2],
126+
1.f};
126127
}
127128

128129
if (index.normal_index >= 0)

engine/render/renderer/renderer/BillboardRenderer.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ void BillboardRenderer::Destroy()
4545
billboardModel.DestroyModel();
4646
}
4747

48-
void BillboardRenderer::DrawBillboard(const Vec3& position, const Vec2& scale, const Vec4& colour)
48+
void BillboardRenderer::DrawBillboard(const Vec3& position,
49+
const Vec2& scale,
50+
const IColour& colour)
4951
{
50-
vertices.Append({{1.f, 1.f, 1.f}, colour});
51-
vertices.Append({{1.f, -1.f, 1.f}, colour});
52-
vertices.Append({{-1.f, -1.f, 1.f}, colour});
53-
vertices.Append({{-1.f, 1.f, 1.f}, colour});
52+
auto fColour = ToFColour(colour);
53+
vertices.Append({{1.f, 1.f, 1.f}, fColour});
54+
vertices.Append({{1.f, -1.f, 1.f}, fColour});
55+
vertices.Append({{-1.f, -1.f, 1.f}, fColour});
56+
vertices.Append({{-1.f, 1.f, 1.f}, fColour});
5457

5558
// Pattern: 0, 1, 3, 1, 2, 3
5659
indices.Append(vertices.Count() - 4);

0 commit comments

Comments
 (0)