Skip to content

Commit 75aa68b

Browse files
authored
Merge pull request #56 from CapsCollective/feature/raylib-removal
Removed core dependency on raylib, migrated game example render and input to internal modules
2 parents ff41c61 + 415538f commit 75aa68b

File tree

181 files changed

+1383
-1667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+1383
-1667
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
- name: install glfw dependencies
2626
run: sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
2727

28-
- name: install raylib dependencies
29-
run: sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
30-
3128
- name: perform setup
3229
run: ./scripts/setup.sh
3330

.github/workflows/ubuntu.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
- name: install glfw dependencies
2626
run: sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
2727

28-
- name: install raylib dependencies
29-
run: sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
30-
3128
- name: perform setup
3229
run: ./scripts/setup.sh
3330

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
[submodule "vendor/glm"]
88
path = vendor/glm
99
url = https://github.com/g-truc/glm.git
10-
[submodule "vendor/raylib-cpp"]
11-
path = vendor/raylib-cpp
12-
url = https://github.com/robloach/raylib-cpp
1310
[submodule "vendor/utest.h"]
1411
path = vendor/utest.h
1512
url = https://github.com/sheredom/utest.h

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $(renderLib): buildFlags $(utilsLib) $(windowLib)
7171
$(testApp): buildFlags $(utilsLib) $(coreLib)
7272
"$(MAKE)" -C $(testsDir) CXXFLAGS="$(CXXFLAGS)"
7373

74-
$(exampleGameApp): buildFlags $(coreLib)
74+
$(exampleGameApp): buildFlags $(renderLib) $(coreLib)
7575
"$(MAKE)" -C $(examplesDir)/game CXXFLAGS="$(CXXFLAGS)"
7676

7777
$(exampleRenderApp): buildFlags $(renderLib)

engine/core/Makefile

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,16 @@ ifeq ($(platform), windows)
2020
else ifeq ($(platform), macos)
2121
libGenDir := src
2222
endif
23-
raylibIncludeDir := $(vendorDir)/include/raylib
24-
raylibLib := $(vendorDir)/raylib-cpp/vendor/raylib/$(libGenDir)/libraylib.a
2523

2624
# Build the static library
27-
$(coreLib): $(raylibLib) $(raylibIncludeDir) $(coreObjects)
25+
$(coreLib): $(coreObjects)
2826
$(MKDIR) $(call platformpth, $(libDir))
29-
$(RM) $(call platformpth, $(coreLib))
30-
$(call COMBINE_LIBS, $(vendorDir)/raylib-cpp/vendor/raylib/$(libGenDir)/libraylib.a, $(coreObjects), $(libDir), core)
27+
ar -crs $(coreLib) $(coreObjects)
3128

3229
# Add all rules from dependency files
3330
-include $(coreDepends)
3431

3532
# Compile object files to the bin directory
3633
$(coreBinDir)/%.o: $(coreSrcDir)/%.cpp
3734
$(MKDIR) $(call platformpth, $(@D))
38-
$(CXX) -MMD -MP -c $(compileFlags) -I $(raylibIncludeDir) -I $(engineDir) $< -o $@ $(CXXFLAGS)
39-
40-
# TODO move this into setup file
41-
# Copy the relevant header files into includes
42-
$(raylibIncludeDir):
43-
$(MKDIR) $(call platformpth, $(raylibIncludeDir)/raylib)
44-
$(call COPY,$(vendorDir)/raylib-cpp/vendor/raylib/src,$(raylibIncludeDir)/raylib,raylib.h,**)
45-
$(call COPY,$(vendorDir)/raylib-cpp/vendor/raylib/src,$(raylibIncludeDir)/raylib,raymath.h,**)
46-
$(call COPY,$(vendorDir)/raylib-cpp/include,$(raylibIncludeDir)/raylib,*.hpp)
47-
48-
# Build the raylib static library file
49-
$(raylibLib):
50-
"$(MAKE)" -C $(vendorDir)/raylib-cpp/vendor/raylib/src PLATFORM=PLATFORM_DESKTOP
35+
$(CXX) -MMD -MP -c $(compileFlags) -I $(engineDir) $< -o $@ $(CXXFLAGS)

engine/core/render/ResourceSystem.cpp renamed to engine/core/ResourceSystem.cpp

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

99
#include "ResourceSystem.h"
1010

11-
#include <raylib/raylib-cpp.hpp>
1211
#include <vector>
1312

1413
namespace Siege
@@ -20,15 +19,15 @@ static std::map<String, Texture> textures = std::map<String, Texture>();
2019
void ResourceSystem::RegisterModel(const String& path)
2120
{
2221
String fullPath = baseDir + path;
23-
if (models.find(fullPath) != models.end()) return;
24-
models[fullPath] = LoadModel(fullPath);
22+
// if (models.find(fullPath) != models.end()) return;
23+
// models[fullPath] = LoadModel(fullPath);
2524
}
2625

2726
void ResourceSystem::RegisterTexture(const String& path)
2827
{
2928
String fullPath = baseDir + path;
30-
if (textures.find(fullPath) != textures.end()) return;
31-
textures[fullPath] = LoadTexture(fullPath);
29+
// if (textures.find(fullPath) != textures.end()) return;
30+
// textures[fullPath] = LoadTexture(fullPath);
3231
}
3332

3433
void* ResourceSystem::GetModel(const String& path)
@@ -50,23 +49,23 @@ void ResourceSystem::FreeResources()
5049
// Iterate over vectors backwards to avoid memory issues
5150
for (auto i = freedModels.rbegin(); i != freedModels.rend(); i++)
5251
{
53-
UnloadModel(**i);
52+
// UnloadModel(**i);
5453
}
5554
freedModels.clear();
5655
models.clear();
5756

5857
for (auto i = freedTextures.rbegin(); i != freedTextures.rend(); i++)
5958
{
60-
UnloadTexture(**i);
59+
// UnloadTexture(**i);
6160
}
6261
freedTextures.clear();
6362
textures.clear();
6463
}
6564

6665
void ResourceSystem::ClearResources()
6766
{
68-
for (auto& model : models) freedModels.push_back(&model.second);
69-
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);
7069
}
7170

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

engine/core/render/ResourceSystem.h renamed to engine/core/ResourceSystem.h

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

17-
typedef struct Model Model;
18-
typedef struct Texture Texture;
17+
struct Model
18+
{};
19+
20+
struct Texture
21+
{};
1922

2023
namespace Siege
2124
{

engine/core/Statics.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
#include "Statics.h"
1010

11-
#include "input/InputSystem.h"
11+
#include "ResourceSystem.h"
1212
#include "physics/CollisionSystem.h"
13-
#include "render/RenderSystem.h"
14-
#include "render/ResourceSystem.h"
1513
#include "scene/SceneSystem.h"
1614

1715
namespace Siege
@@ -22,24 +20,12 @@ CollisionSystem& Statics::Collision()
2220
return system;
2321
}
2422

25-
InputSystem& Statics::Input()
26-
{
27-
static InputSystem system;
28-
return system;
29-
}
30-
3123
ResourceSystem& Statics::Resource()
3224
{
3325
static ResourceSystem system;
3426
return system;
3527
}
3628

37-
RenderSystem& Statics::Render()
38-
{
39-
static RenderSystem system;
40-
return system;
41-
}
42-
4329
SceneSystem& Statics::Scene()
4430
{
4531
static SceneSystem system;

engine/core/Statics.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ class Statics
1717

1818
static class CollisionSystem& Collision();
1919

20-
static class InputSystem& Input();
21-
2220
static class ResourceSystem& Resource();
2321

24-
static class RenderSystem& Render();
25-
2622
static class SceneSystem& Scene();
2723

2824
static class EntitySystem& Entity();

engine/core/Ticker.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Copyright (c) 2022 Jonathan Moallem (@J-Mo63) & Aryeh Zinn (@Raelr)
3+
//
4+
// This code is released under an unmodified zlib license.
5+
// For conditions of distribution and use, please see:
6+
// https://opensource.org/licenses/Zlib
7+
//
8+
9+
#include "Ticker.h"
10+
11+
#include <chrono>
12+
13+
namespace Siege
14+
{
15+
long Ticker::GetCurrentTime()
16+
{
17+
auto now = std::chrono::system_clock::now();
18+
auto seconds = std::chrono::time_point_cast<std::chrono::microseconds>(now);
19+
return seconds.time_since_epoch().count();
20+
}
21+
22+
void Ticker::UpdateTime()
23+
{
24+
static long previousTime = GetCurrentTime();
25+
long currentTime = GetCurrentTime();
26+
deltaTime = (float) (currentTime - previousTime) / 1000000.f;
27+
previousTime = currentTime;
28+
}
29+
30+
float Ticker::GetDeltaTime() const
31+
{
32+
return deltaTime;
33+
}
34+
} // namespace Siege

0 commit comments

Comments
 (0)