Skip to content

Commit d1bff05

Browse files
committed
Clean up and update of CmakeLists.txt!
1 parent 8f97951 commit d1bff05

File tree

173 files changed

+1036
-83749
lines changed

Some content is hidden

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

173 files changed

+1036
-83749
lines changed

CMakeLists.txt

+14-41
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,22 @@
1-
2-
cmake_minimum_required(VERSION 3.12)
1+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
32
project(Voxeler)
43

5-
set(PLATFORM "Linux")
6-
set(CONF "Debug")
4+
find_package(OpenGL REQUIRED)
5+
6+
include_directories(thirdparty/glad/include)
7+
include_directories(thirdparty/glfw/include)
8+
include_directories(thirdparty/glm/include)
79

810
add_subdirectory(thirdparty/glad)
911
add_subdirectory(thirdparty/glfw)
1012
add_subdirectory(thirdparty/glm)
11-
add_subdirectory(thirdpart/imgui)
1213

13-
SET(PROGRAM_SRCS
14-
Engine/App.cpp
15-
Engine/Core.hpp
16-
Engine/Core.cpp
17-
Engine/Core/Math.h
18-
Engine/Core/Timer.cpp
19-
Engine/Core/Timer.h
20-
Engine/Core/Window.h
21-
Engine/Core/Window.cpp
22-
Engine/Errors/Errors.h
23-
Engine/Game/game.hpp
24-
Engine/Game/game.cpp
25-
Engine/Game/player.cpp
26-
Engine/Game/player.hpp
27-
Engine/Inputs/Keyboard.cpp
28-
Engine/Inputs/KeyBoard.hpp
29-
Engine/Renderer/Renderer.cpp
30-
Engine/Renderer/Renderer.h
31-
Engine/Renderer/Shader.h
32-
Engine/Renderer/Shader.cpp
33-
Engine/Renderer/Vertex.h
34-
Engine/Renderer/VertexArray.h
35-
Engine/ECS/ECS.h
36-
Engine/ECS/Base/BaseComponent.h
37-
Engine/ECS/Base/BaseSystem.h
38-
Engine/ECS/Base/CompList.h
39-
Engine/ECS/Base/ComponentFactory.h
40-
Engine/ECS/Base/Entity.h
41-
Engine/ECS/Base/EntityManager.h
42-
Engine/ECS/Base/Types.h
43-
Engine/Comp/Camera.h
44-
Engine/Comp/Transform.h
45-
)
14+
file(GLOB_RECURSE Runtime "Engine/**.cpp" "Engine/**.h" "Engine/**.hpp")
15+
16+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/Build/bin")
17+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/Build/bin")
18+
19+
set(CMAKE_CXX_STANDARD 17)
20+
set(CMAKE_CXX_STANDARD_REQUIRED true)
4621

47-
target_link_libraries(Voxeler -lglad)
48-
target_link_libraries(Voxeler -lglfw3)
49-
target_link_libraries(Voxeler -lopengl32)
22+
add_executable(Voxeler ${Runtime})

Engine/App.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ int main(){
1212
Core.Render();
1313
}
1414

15-
return VOX_TRUE;
15+
return VOX_SUCCES;
1616
}

Engine/Core.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22

33
namespace Voxeler{
44

5-
void Engine::Initialize() {
5+
uint Engine::Initialize() {
66
MainWindow = new Window(WINDOW_NAME, SCREEN_WIDTH, SCREEN_HEIGHT);
77
GameCore.Initialize(MainWindow);
8+
return VOX_NULL;
89
}
910

10-
void Engine::Render(){}
11+
func Engine::Render(){}
1112

12-
void Engine::Update(){ ECS::Manager.Update(); }
13+
func Engine::Update(){ ECS::Manager.Update(); }
1314

14-
void Exit() {}
15+
uint Engine::Exit() {
16+
std::exit(-1);
17+
return VOX_NULL;
18+
}
1519

16-
void Pause() {std::cin.get();}
20+
func Engine::Pause() {
21+
std::cin.get();
22+
}
1723

1824
};

Engine/Core.hpp

+34-28
Original file line numberDiff line numberDiff line change
@@ -83,39 +83,41 @@
8383
#error "This Platform is not supported yet!"
8484
#endif
8585

86-
#define VOX_NULL NULL
87-
#define VOX_TRUE 0
88-
#define VOX_FALSE 1
89-
#define VOX_TERMS 7
90-
91-
#define ASSERT(boolean) if (!(boolean))();
92-
#define GLCALL(func) GLClearError(); func; ASSERT(GLLogCall(#func, __FILE__, __LINE__))
93-
94-
static void GLClearError() { while (glGetError() != GL_NO_ERROR); }
95-
96-
static bool GLLogCall(const char* function, const char* file, int line) {
97-
while (GLenum error = glGetError()) {
98-
std::cout <<
99-
"\n OpenGL Voxeler Error! [ " << error << " ]\n"
100-
"function ::[ " << function << " ]\n"
101-
"File ::[ " << file << " ]\n"
102-
"line ::[ " << line << " ]"
103-
<< std::endl;
104-
return false;
105-
}
106-
return true;
107-
}
86+
// Defines
10887

88+
#define VOX_NULL 0
89+
#define VOX_SUCCES 0
90+
#define VOX_ERR -1
91+
#define VOX_TRUE true
92+
#define VOX_FALSE false
93+
#define VOX_TERMS 7
10994

11095
using namespace VoxelerNetWork;
11196

97+
// Types
98+
11299
namespace Voxeler
113100
{
114101
using uint = uint32_t;
115102
using uchar = unsigned char;
103+
using vuint32 = unsigned int;
104+
using vuint = vuint32;
105+
using vint = int;
106+
using vfloat = float;
107+
using vufloat = double;
108+
using vlong = long;
109+
using vshort = short;
110+
using vchar = char;
111+
using vstring = char*;
112+
using vbool = bool;
113+
using Matrix4 = glm::mat4;
114+
using Vector3f = glm::fvec3;
115+
using Vector3 = glm::vec3;
116+
using Vector2 = glm::vec2;
116117
typedef void(*func)();
117118
}
118119

120+
// Main Engine class
119121

120122
namespace Voxeler {
121123
class Engine {
@@ -129,28 +131,32 @@ namespace Voxeler {
129131
return reference;
130132
}
131133

132-
void Initialize();
133-
void Render();
134-
void Update();
134+
uint Initialize();
135+
func Render();
136+
func Update();
137+
138+
uint Exit();
139+
func Pause();
135140

136141
inline const vbool Run() const { return IsGameRunning; }
142+
inline Window* GetWindow() { return MainWindow; }
137143

138144
private:
139145
Engine();
140146
private:
147+
Window* MainWindow;
141148
bool IsGameRunning;
142149
};
143150

144151
static Engine& Core = Engine::Ref();
145152
}
146153

147-
// ECS stuff
154+
// Includes:
155+
148156
#include "Core/ECS/ECS.h"
149157

150-
// Network stuff
151158
#include "Network/Network.h"
152159

153-
// Game stuff
154160
#include "Game/game.hpp"
155161
#include "Renderer/Renderer.h"
156162
#include "Core/Window.h"

Engine/Core/Math.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#include "Math.h"
22

33
namespace Voxeler{
4-
float Math::Radians(float degrees) { return degrees * static_cast<float>(0.01745329251994329576923690768489); }
4+
float Math::Radians(float degrees) { return degrees * PI() / 180; }
5+
6+
float Math::Degrees(float radians) { return radians * PI() / 180; }
57

68
float Math::Lerp(float start, float stop, float step) { float v = start; while (v != stop) { v = (stop * step) + (start * 1.0 - step); } return v;}
79

810
float Math::PI() { return 3.14159265359; }
911

10-
float Math::Sine(int deg) {
12+
float Math::Sin(int deg) {
1113
deg %= 360;
1214
float rad = deg * PI() / 180;
1315
float sin = 0;
@@ -21,7 +23,6 @@ namespace Voxeler{
2123
deg %= 360; // make it less than 360
2224
float rad = deg * PI() / 180;
2325
float cos = 0;
24-
2526
int i;
2627
for (i = 0; i < VOX_TERMS; i++) {
2728
cos += power(-1, i) * power(rad, 2 * i) / fact(2 * i);

Engine/Core/Math.h

+3-18
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,17 @@
22

33
#include "../Core.hpp"
44

5-
namespace Voxeler{
6-
using vuint32 = unsigned int;
7-
using vuint = vuint32;
8-
using vint = int;
9-
using vfloat = float;
10-
using vufloat = double;
11-
using vlong = long;
12-
using vshort = short;
13-
using vchar = char;
14-
using vstring = char*;
15-
using vbool = bool;
16-
using Matrix4 = glm::mat4;
17-
using Vector3f = glm::fvec3;
18-
using Vector3 = glm::vec3;
19-
using Vector2 = glm::vec2;
20-
}
21-
225
namespace Voxeler{
236
class Math{
247
public:
258
static float Cos(int deg);
26-
static float Sine(int deg);
9+
static float Sin(int deg);
2710
static float Lerp(float start, float stop, float step);
2811
static float PI();
2912

3013
static float Radians(float degrees);
14+
static float Degrees(float radians);
15+
3116
static float power(float base, int exp);
3217
static int fact(int n);
3318
};

0 commit comments

Comments
 (0)