Skip to content

Commit aa077b1

Browse files
Raelrjonjondev
authored andcommitted
Added text rendering and for showing labels on top of entities
1 parent 67910d6 commit aa077b1

25 files changed

+147
-130
lines changed

engine/core/ResourceSystem.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#include "ResourceSystem.h"
10+
1011
#include <vector>
1112

1213
namespace Siege
@@ -18,15 +19,15 @@ static std::map<String, Texture> textures = std::map<String, Texture>();
1819
void ResourceSystem::RegisterModel(const String& path)
1920
{
2021
String fullPath = baseDir + path;
21-
// if (models.find(fullPath) != models.end()) return;
22-
// models[fullPath] = LoadModel(fullPath);
22+
// if (models.find(fullPath) != models.end()) return;
23+
// models[fullPath] = LoadModel(fullPath);
2324
}
2425

2526
void ResourceSystem::RegisterTexture(const String& path)
2627
{
2728
String fullPath = baseDir + path;
28-
// if (textures.find(fullPath) != textures.end()) return;
29-
// textures[fullPath] = LoadTexture(fullPath);
29+
// if (textures.find(fullPath) != textures.end()) return;
30+
// textures[fullPath] = LoadTexture(fullPath);
3031
}
3132

3233
void* ResourceSystem::GetModel(const String& path)
@@ -48,23 +49,23 @@ void ResourceSystem::FreeResources()
4849
// Iterate over vectors backwards to avoid memory issues
4950
for (auto i = freedModels.rbegin(); i != freedModels.rend(); i++)
5051
{
51-
// UnloadModel(**i);
52+
// UnloadModel(**i);
5253
}
5354
freedModels.clear();
5455
models.clear();
5556

5657
for (auto i = freedTextures.rbegin(); i != freedTextures.rend(); i++)
5758
{
58-
// UnloadTexture(**i);
59+
// UnloadTexture(**i);
5960
}
6061
freedTextures.clear();
6162
textures.clear();
6263
}
6364

6465
void ResourceSystem::ClearResources()
6566
{
66-
// for (auto& model : models) freedModels.push_back(&model.second);
67-
// for (auto& texture : textures) freedTextures.push_back(&texture.second);
67+
// for (auto& model : models) freedModels.push_back(&model.second);
68+
// for (auto& texture : textures) freedTextures.push_back(&texture.second);
6869
}
6970

7071
void ResourceSystem::SetBaseDirectory(const String& dir)

engine/core/ResourceSystem.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
#include <map>
1515
#include <vector>
1616

17-
struct Model {
17+
struct Model
18+
{};
1819

19-
};
20-
21-
struct Texture {
22-
23-
};
20+
struct Texture
21+
{};
2422

2523
namespace Siege
2624
{

engine/core/Statics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
#include "Statics.h"
1010

11+
#include "ResourceSystem.h"
1112
#include "physics/CollisionSystem.h"
1213
#include "scene/SceneSystem.h"
13-
#include "ResourceSystem.h"
1414

1515
namespace Siege
1616
{

engine/core/scene/SceneFile.cpp

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

1414
#include <algorithm>
1515

16-
#include "../entity/Entity.h"
1716
#include "../ResourceSystem.h"
17+
#include "../entity/Entity.h"
1818

1919
namespace Siege
2020
{

engine/core/scene/SceneSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
#include <vector>
1414

15+
#include "../ResourceSystem.h"
1516
#include "../Statics.h"
1617
#include "../entity/Entity.h"
17-
#include "../ResourceSystem.h"
1818
#include "SceneFile.h"
1919

2020
namespace Siege

engine/render/renderer/Renderer.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ class Renderer
3131

3232
~Renderer();
3333

34-
float GetAspectRatio() const
35-
{
36-
return static_cast<float>(window.GetWidth()) / static_cast<float>(window.GetHeight());
37-
}
38-
3934
void SetCamera3D(const Camera& camera)
4035
{
4136
camera3D = camera;

engine/render/renderer/renderer/TextRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ void TextRenderer::Render(Vulkan::CommandBuffer& buffer,
122122
const void* globalData,
123123
uint32_t frameIndex)
124124
{
125-
if (characters.Count() == 0) return;
126-
127125
defaultMaterial.SetUniformData(globalDataId, globalDataSize, globalData);
128126

129127
for (uint32_t i = 0; i < characters.Count(); i++)
130128
{
129+
if (characters[i].Count() == 0) continue;
130+
131131
uint32_t texIndex = i;
132132

133133
defaultMaterial.BindPushConstant(buffer, &texIndex);

engine/window/Input.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
#include "Input.h"
1010

11-
#include "window/platform/glfw/Input.h"
12-
1311
#include <utils/Logging.h>
1412

13+
#include "window/platform/glfw/Input.h"
14+
1515
namespace Siege
1616
{
1717
Glfw::Window Input::primaryWindow = nullptr;

engine/window/Window.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Window
2020
{
2121
public:
2222

23+
static MHArray<const char*> GetRequiredExtensions();
24+
2325
// 'Structors
2426

2527
Window(char const* name, WindowExtents extents);
@@ -52,10 +54,13 @@ class Window
5254

5355
void ResetWindowResized();
5456

55-
static MHArray<const char*> GetRequiredExtensions();
56-
5757
void WaitEvents();
5858

59+
inline float AspectRatio()
60+
{
61+
return static_cast<float>(extents.width) / static_cast<float>(extents.height);
62+
}
63+
5964
private:
6065

6166
// Private variables

examples/game/src/RenderResources.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#include "RenderResources.h"
10+
1011
#include <render/renderer/renderer/ModelRenderer.h>
1112

1213
RenderResources::RenderResources()

0 commit comments

Comments
 (0)