Skip to content

Commit a229718

Browse files
committed
life is pain
1 parent af942d6 commit a229718

File tree

145 files changed

+1023
-10672
lines changed

Some content is hidden

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

145 files changed

+1023
-10672
lines changed

CMakeLists.txt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ FetchContent_Declare(
3434
GIT_TAG v3.4.0
3535
)
3636
FetchContent_MakeAvailable(tomlplusplus)
37+
38+
# Include RRes
39+
FetchContent_Declare(
40+
RRes
41+
GIT_REPOSITORY "https://github.com/raysan5/rres"
42+
GIT_TAG "1.2.0"
43+
)
44+
FetchContent_MakeAvailable(RRes)
45+
46+
# Include RayGui
47+
FetchContent_Declare(
48+
RayGui
49+
GIT_REPOSITORY "https://github.com/raysan5/raygui"
50+
GIT_TAG "4.0"
51+
)
52+
FetchContent_MakeAvailable(RayGui)
53+
3754
# Our Project
3855
# The configurations we support
3956
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
@@ -42,7 +59,7 @@ set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
4259
set(DOUBLE_PRECISION OFF)
4360

4461
# When turning this option on, the library will be compiled with debug symbols
45-
set(GENERATE_DEBUG_SYMBOLS ON)
62+
set(GENERATE_DEBUG_SYMBOLS OFF)
4663

4764
# When turning this option on, the library will be compiled in such a way to attempt to keep the simulation deterministic across platforms
4865
set(CROSS_PLATFORM_DETERMINISTIC OFF)
@@ -80,7 +97,6 @@ FetchContent_Declare(
8097
)
8198
FetchContent_MakeAvailable(JoltPhysics)
8299

83-
84100
# Set linker flags
85101
set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
86102

@@ -92,8 +108,10 @@ SET_INTERPROCEDURAL_OPTIMIZATION()
92108
add_executable(${PROJECT_NAME} main.cpp)
93109
#set(raylib_VERBOSE 1)
94110
target_link_libraries(${PROJECT_NAME} raylib)
95-
target_include_directories(${PROJECT_NAME} PUBLIC ${JoltPhysics_SOURCE_DIR}/..)
111+
96112
target_link_libraries(${PROJECT_NAME} Jolt)
113+
target_include_directories(${PROJECT_NAME} PUBLIC ${JoltPhysics_SOURCE_DIR}/..)
114+
97115

98116
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/resources)
99117

Common.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
#pragma once
55
#include "../build/_deps/raylib-src/src/raylib.h"
66
#include "../build/_deps/raylib-src/src/raymath.h"
7-
7+
#include "../build/_deps/raylib-src/src/rlgl.h"
8+
#include "../build/_deps/raylib-src/src/rcamera.h"
9+
#include "../build/_deps/raygui-src/src/raygui.h"
810
// End of raylib Libraries
911

12+
1013
// C++ Libraries
1114
#include <stdio.h>
1215
#include <stdlib.h>
@@ -45,4 +48,5 @@
4548

4649
// End of External Libraries
4750

51+
4852
// End of Common.h

Engine/Classes/ConfigMan/ConfigRegistry.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <map>
44
#include <vector>
55
#include "../Logging/Logman.h"
6-
#include "../../../lib/raylib.h"
76

87
// Components
98
#include "ConfigFile.h"

Engine/Classes/Env/Light/Light.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#pragma once
2+
#include "../../../../common.h"
3+
4+
#if defined(PLATFORM_DESKTOP)
5+
#define GLSL_VERSION 330
6+
#else // PLATFORM_ANDROID, PLATFORM_WEB
7+
#define GLSL_VERSION 120
8+
#endif
9+
10+
#define MAX_LIGHTS 4 // Max dynamic lights supported by shader
11+
12+
// Light type
13+
typedef enum
14+
{
15+
LIGHT_DIRECTIONAL = 0,
16+
LIGHT_POINT,
17+
LIGHT_SPOT
18+
} LightType;
19+
20+
// Light data
21+
typedef struct {
22+
int type;
23+
int enabled;
24+
Vector3 position;
25+
Vector3 target;
26+
float color[4];
27+
float intensity;
28+
29+
// Shader light parameters locations
30+
int typeLoc;
31+
int enabledLoc;
32+
int positionLoc;
33+
int targetLoc;
34+
int colorLoc;
35+
int intensityLoc;
36+
} Light;
37+
38+
static int lightsCount;
39+
40+
// Send light properties to shader
41+
// NOTE: Light shader locations should be available
42+
static void UpdateLight(Shader shader, Light light)
43+
{
44+
SetShaderValue(shader, light.enabledLoc, &light.enabled, SHADER_UNIFORM_INT);
45+
SetShaderValue(shader, light.typeLoc, &light.type, SHADER_UNIFORM_INT);
46+
47+
// Send to shader light position values
48+
float position[3] = { light.position.x, light.position.y, light.position.z };
49+
SetShaderValue(shader, light.positionLoc, position, SHADER_UNIFORM_VEC3);
50+
51+
// Send to shader light target position values
52+
float target[3] = { light.target.x, light.target.y, light.target.z };
53+
SetShaderValue(shader, light.targetLoc, target, SHADER_UNIFORM_VEC3);
54+
SetShaderValue(shader, light.colorLoc, light.color, SHADER_UNIFORM_VEC4);
55+
SetShaderValue(shader, light.intensityLoc, &light.intensity, SHADER_UNIFORM_FLOAT);
56+
}
57+
// Create light with provided data
58+
// NOTE: It updated the global lightCount and it's limited to MAX_LIGHTS
59+
static Light CreateLight(int type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader)
60+
{
61+
Light light = { 0 };
62+
63+
if (lightsCount < MAX_LIGHTS)
64+
{
65+
light.enabled = 1;
66+
light.type = type;
67+
light.position = position;
68+
light.target = target;
69+
light.color[0] = (float)color.r/255.0f;
70+
light.color[1] = (float)color.g/255.0f;
71+
light.color[2] = (float)color.b/255.0f;
72+
light.color[3] = (float)color.a/255.0f;
73+
light.intensity = intensity;
74+
75+
// NOTE: Shader parameters names for lights must match the requested ones
76+
light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", lightsCount));
77+
light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", lightsCount));
78+
light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", lightsCount));
79+
light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", lightsCount));
80+
light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", lightsCount));
81+
light.intensityLoc = GetShaderLocation(shader, TextFormat("lights[%i].intensity", lightsCount));
82+
83+
UpdateLight(shader, light);
84+
85+
lightsCount++;
86+
}
87+
88+
return light;
89+
}
90+

Engine/Classes/Env/Light/LightObject.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

Engine/Classes/GUIs/Console/Console.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "../../../../lib/raylib.h"
2+
33
#include "../../Logging/Logman.h"
44

55
#include <stdio.h>

Engine/Classes/GUIs/Core/MenuCamera.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "../../../../lib/raylib.h"
2+
#include "../../../../common.h"
33
#include "../../GameObject/Gameobject.h"
44

55
#pragma

Engine/Classes/GameObject/Gameobject.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#pragma once
2-
#include "../../../lib/raylib.h"
2+
#include "../../../common.h"
33
#include "../../DataSets/Globals.h"
44
#include "../Logging/Logman.h"
55
#include <stdio.h>
66
#include <stdlib.h>
77
#include <vector>
88
#include <thread>
99
#include <mutex>
10+
1011
typedef enum type
1112
{
1213
BLOCK = 0, // Game object is a block
@@ -183,7 +184,7 @@ class GameObject
183184
*/
184185
static inline void Update()
185186
{
186-
Render();
187+
RenderObjects();
187188
for (auto &GameObject : GameObjects)
188189
{
189190

@@ -203,7 +204,7 @@ class GameObject
203204
GameObjects.push_back(_obj);
204205
}
205206

206-
static inline void Render()
207+
static inline void RenderObjects()
207208
{
208209

209210
for (auto &obj : GameObjects)

Engine/Classes/GameObject/Object.h

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,44 @@
11
#pragma once
22
#include "Gameobject.h"
3-
#include "ObjectTransform.h"
4-
#include "../Physics/RigidBody.h"
3+
#include "../Project/Game/Game.h"
54

6-
#include "../../../lib/rlgl.h"
7-
#include "../../../lib/raymath.h"
8-
class Object : public GameObject {
9-
public:
5+
typedef struct
6+
{
7+
MaterialMap albedo;
8+
MaterialMap normal;
9+
MaterialMap emissive;
10+
MaterialMap metallic;
11+
MaterialMap roughness;
12+
MaterialMap ao;
1013

14+
MaterialMap MRAO;
15+
} MaterialMapList;
1116

17+
class Object : public GameObject
18+
{
19+
public:
20+
Object(Model model, MaterialMapList materialMapList)
21+
{
1222

13-
Object(Model model, ObjectTransform transform) {
1423

15-
this->model = model;
16-
this->transform = new ObjectTransform(transform);
17-
18-
};
24+
};
1925

20-
void Destroy() {
21-
this->~Object();
22-
}
23-
24-
void onUpdate() override {
25-
26-
}
26+
void Destroy()
27+
{
28+
this->~Object();
29+
}
2730

28-
void Draw() override {
29-
DrawModel(this->model, this->position, this->scale, )
30-
}
31+
void onUpdate() override
32+
{
33+
}
3134

32-
Vector3 position;
33-
float scale;
35+
void Draw() override
36+
{
37+
}
3438

35-
36-
Model model;
39+
Vector3 position;
40+
float scale;
41+
Model model;
3742

38-
private:
39-
~Object() {
40-
delete this;
41-
}
42-
43-
void GenCubemap(float roughness) {
44-
45-
}
46-
43+
MaterialMapList materialMapList;
4744
};
48-

Engine/Classes/Logging/Logman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdlib.h>
44
#include <time.h>
55

6-
#include "../../../lib/raylib.h"
6+
#include "../../../../build/_deps/raylib-src/src/raylib.h"
77

88
// handles logging
99
class Logman {

Engine/Classes/Player/CameraComp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "../../../lib/raylib.h"
2+
33
#include "CameraData.h"
44
#include <vector>
55
#include <stdio.h>

Engine/Classes/Player/CameraData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "../../../lib/raylib.h"
2+
#include "../../../common.h"
33

44

55
class CameraData

0 commit comments

Comments
 (0)