Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4831694
started work on persistence/prefs system
freeeranger Apr 19, 2025
c22efb1
more progress on implementing basic functionality (flush not done yet)
freeeranger Apr 19, 2025
7301069
progress: reading/writing data works (if you do everything correctly …
freeeranger Apr 23, 2025
8866f9a
fixed camera movement
RaxoDev Apr 27, 2025
c74b547
Create README.md
RaxoDev Apr 28, 2025
4e2dbe0
key validation and more types? might not work, im on mac
freeeranger Apr 28, 2025
a000bb7
Commiting work on audio
YayL Apr 28, 2025
147f64c
Fixed segfault and added README
YayL Apr 28, 2025
e9b2ef6
Fixed audio volume control
YayL Apr 29, 2025
83b8223
Added audio files
YayL Apr 29, 2025
e54d41f
Removed fmt and added other audio file
YayL Apr 29, 2025
5b03268
switched to correct logging
freeeranger May 4, 2025
ba26536
started work on persistence/prefs system
freeeranger Apr 19, 2025
ac0c38d
more progress on implementing basic functionality (flush not done yet)
freeeranger Apr 19, 2025
c4dc44e
progress: reading/writing data works (if you do everything correctly …
freeeranger Apr 23, 2025
a357df8
key validation and more types? might not work, im on mac
freeeranger Apr 28, 2025
eb617ce
switched to correct logging
freeeranger May 4, 2025
6499b7a
small fixes
freeeranger May 4, 2025
f5c97d0
fix?
freeeranger May 4, 2025
25695a8
Change game to use ecs and new renderer
Poizon7 Apr 29, 2025
8adbb69
fix: rendering in ecs
Poizon7 May 5, 2025
77e9a13
fix: reimplement delta time
Poizon7 May 5, 2025
68f1a57
Clean up
Poizon7 May 5, 2025
4c76fd2
Enemy changes
RaxoDev May 5, 2025
7522c22
Added double sided support on GLTFs
RaxoDev May 5, 2025
69d63f9
Two ghosts with hover effect and new movement type
RaxoDev May 5, 2025
f57d4cd
Add ability to render rectangles
vidar-h May 5, 2025
e4ba261
Merge branch 'renderer' of https://github.com/INDA24PlusPlus/game-eng…
vidar-h May 5, 2025
834f6bc
Add alpha support to rectangle rendering
vidar-h May 5, 2025
a82cec5
Fix include error + zero initialization of query count
vidar-h May 5, 2025
d289660
Merge remote-tracking branch 'origin/renderer' into game_rewrite
vidar-h May 5, 2025
2fea87e
Added 3D audio
YayL Apr 29, 2025
b282fc0
Added Ghosts and stuff to ECS, bugged tho: ghost only move after 100 …
RaxoDev May 6, 2025
7392d17
fix ghost bug xd
freeeranger May 6, 2025
f5b56c4
ui render system + health bar
freeeranger May 6, 2025
8665fa8
Merged audio and game_rewrite
YayL May 6, 2025
2669577
Begun adding audio to engine
YayL May 7, 2025
e21a785
Fixed query signatures not working
spiknyckel May 7, 2025
c71b15a
Added new logging and fixed some issues
YayL May 7, 2025
0b0d8c9
Implemented basic audio ECS structure
YayL May 7, 2025
99454e8
Merged game_rewrite into audio
YayL May 7, 2025
6ea55bd
Fixed crash and rewrote some functionality into ECS systems
RaxoDev May 7, 2025
aadffa6
killing ghosts
RaxoDev May 8, 2025
5d4ee97
Made ECS static and added a lot of Audio
YayL May 8, 2025
b63a063
Added reverb and made some structure changes to audio
YayL May 8, 2025
bcdad21
helpers to hide some glfw boilerplate etc from main
freeeranger May 8, 2025
ddcfe10
Merged Audio into game_rewrite
YayL May 8, 2025
6ffb724
Fixed strings.h, removed timer and old audio
YayL May 8, 2025
fb43ae0
Working Audio (Windows support?)
YayL May 8, 2025
154e5bc
Changes to manifest
RaxoDev May 9, 2025
7dcf62b
Fix build on windows
vidar-h May 12, 2025
506f8ed
Merge pull request #12 from INDA24PlusPlus/persistence
vidar-h May 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SOURCE_FILES
src/game/main.cpp
src/game/gui.cpp
src/game/player.cpp
src/game/enemy.cpp
src/game/world_gen/map.cpp
src/engine/utils/logging.cpp
src/engine/Renderer.cpp
src/engine/Camera.cpp
src/engine/ecs/ecs.cpp
Expand All @@ -25,16 +26,19 @@ set(SOURCE_FILES
src/engine/ecs/systemmanager.cpp
src/engine/AssetLoader.cpp
src/engine/Input.cpp
src/engine/Prefs.cpp
src/engine/scene/Scene.cpp
src/engine/scene/Node.cpp
src/engine/scene/AssetManifest.cpp
src/engine/graphics/Pipeline.cpp
src/engine/graphics/Image.cpp
src/engine/graphics/Sampler.cpp
src/engine/graphics/GPURingBuffer.cpp
src/engine/Game.cpp
vendor/glad/src/glad.c
)

set(COMMON_COMPILE_FLAGS -Wall -Wextra -Wunused-result -Wno-missing-field-initializers -Wno-unused-function -fno-exceptions)
set(COMMON_COMPILE_FLAGS -Wall -Wextra -Wunused-result -Wno-missing-field-initializers -Wno-unused-function -fno-exceptions -g)

FetchContent_Declare(
glm
Expand All @@ -54,7 +58,13 @@ FetchContent_Declare(
GIT_TAG 3.4
)

FetchContent_MakeAvailable(glm glfw imgui)
FetchContent_Declare(
miniaudio
GIT_REPOSITORY https://github.com/mackron/miniaudio
GIT_TAG 0.11.22
)

FetchContent_MakeAvailable(glm glfw imgui miniaudio)

add_executable(game_engine ${SOURCE_FILES})
set_target_properties(game_engine PROPERTIES
Expand Down Expand Up @@ -92,5 +102,9 @@ target_sources(game_engine PRIVATE ${imgui_SOURCE_DIR}/backends/imgui_impl_openg
# GLAD
target_include_directories(game_engine PRIVATE vendor/glad/include)

# miniaudio
target_include_directories(game_engine PRIVATE ${miniaudio_SOURCE_DIR})
target_link_libraries(game_engine PRIVATE miniaudio)

target_link_libraries(game_engine PRIVATE ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
target_compile_options(game_engine PRIVATE ${COMMON_COMPILE_FLAGS})
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Steps:
1. Download assets from [OneDrive](https://kth-my.sharepoint.com/:f:/g/personal/oscae_ug_kth_se/EkvNSq58i9VEh5Iqsg_l-UIB83xngGy-dJDav7ChcgHiJQ?e=J3qyYU) and put the assets directory in root.
2. Build asset_processor:
```bash
cd tools/asset_processor
cmake . -GNinja -Bbuild
cd build
ninja
cd ../../..
./tools/asset_processor/build/asset_processor manifest.json
```
3. Initial build:
```bash
cmake . -GNinja -Bbuild
cd build
ninja
cd ..
```
4. Build and Run
```bash
cd build; ninja; cd ..; ./build/game_engine
```

### Note:
Build with clang, NOT MinGW:
```bash
CMAKE . -GNinja -B build -DCMAKE_CXX_COMPILER=clang -DCMAKE_C_COMPILER=clang
```
13 changes: 6 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"meshes": [
{
"name": "Helmet",
"path": "assets/SciFiHelmet/glTF/SciFiHelmet.gltf"
},
{
"name": "Sponza",
"path": "assets/Sponza/Sponza.gltf"
"path": "assets/SciFiHelmet/SciFiHelmet.glb"
},
{
"name": "Sword",
Expand All @@ -15,11 +11,14 @@
{
"name": "Cube",
"path": "assets/cube.glb"
},
{
"name": "Ghost",
"path": "assets/ghost.glb"
}
],
"prefabs": [
"prefabs/Player.json",
"prefabs/Scene.json",
"prefabs/Enemy.json"
"prefabs/Ghost.json"
]
}
50 changes: 25 additions & 25 deletions prefabs/Enemy.json → prefabs/Ghost.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "Enemy",
"nodes": [
{
"mesh": "Helmet",
"name": "Enemy",
"rotation": [
0.0,
1.0,
0.0,
0.0
],
"scale": [
1.0,
1.0,
1.0
],
"translation": [
0.0,
0.0,
0.0
]
}
],
"root": 0
{
"name": "Ghost",
"nodes": [
{
"mesh": "Ghost",
"name": "Ghost",
"rotation": [
0.0,
1.0,
0.0,
0.0
],
"scale": [
1.0,
1.0,
1.0
],
"translation": [
0.0,
0.0,
0.0
]
}
],
"root": 0
}
Binary file added shaders/SPIRV/rect.frag.spv
Binary file not shown.
Binary file added shaders/SPIRV/rect.vert.spv
Binary file not shown.
8 changes: 8 additions & 0 deletions shaders/rect.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 460 core

layout (location = 0) in vec4 color;
layout (location = 0) out vec4 frag_color;

void main() {
frag_color = color;
}
17 changes: 17 additions & 0 deletions shaders/rect.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 460 core

layout (location = 0) in vec2 a_pos;
layout (location = 1) in vec4 a_color;

layout (location = 0) out vec4 color;

layout (std140, binding = 0) uniform UBOMatrices {
mat4 model;
mat4 view;
mat4 projection;
};

void main() {
gl_Position = projection * vec4(a_pos, 0.0, 1.0);
color = a_color;
}
64 changes: 64 additions & 0 deletions src/engine/Game.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "Game.h"

#include "utils/logging.h"

static void error_callback(int error, const char *description) {
ERROR("GLFW error with code {}: {}", error, description);
}

static void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
(void)window;
glViewport(0, 0, width, height);
}

game::GameHandle game::init(int width, int height, const std::string& title)
{
if (!glfwInit()) {
FATAL("Failed to initiliaze glfw");
}
INFO("Initialized GLFW");
glfwSetErrorCallback(error_callback);

f32 content_x_scale;
f32 content_y_scale;
glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &content_x_scale,
&content_y_scale);
INFO("Monitor content scale is ({}, {})", content_x_scale, content_y_scale);

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
glfwWindowHint(GLFW_SAMPLES, 8);
#ifndef NDEBUG
glfwWindowHint(GLFW_CONTEXT_DEBUG, GLFW_TRUE);
#else
glfwWindowHint(GLFW_CONTEXT_NO_ERROR, GLFW_TRUE);
#endif

f32 content_scale = std::max(content_x_scale, content_y_scale);
auto window = glfwCreateWindow(1920 / content_scale, 1080 / content_scale,
title.c_str(), nullptr, nullptr);
if (!window) {
FATAL("Failed to create glfw window");
}

glfwMakeContextCurrent(window);

glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

return game::GameHandle {
.window = window,
};
}

bool game::should_run(GameHandle& handle)
{
return !glfwWindowShouldClose(handle.window);
}

void game::end_frame(GameHandle& handle)
{
glfwSwapBuffers(handle.window);
glfwPollEvents();
}
16 changes: 16 additions & 0 deletions src/engine/Game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <string>

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "core.h"

namespace game {
struct GameHandle {
GLFWwindow* window;
};

GameHandle init(int width, int height, const std::string& title);

bool should_run(GameHandle& handle);
void end_frame(GameHandle& handle);
}
1 change: 1 addition & 0 deletions src/engine/Input.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Input.h"
#include <print>

engine::Input::Input(GLFWwindow* window) : window{window}, prevKeyStates{false}, prevMousePosition(get_mouse_position()) {}

Expand Down
Loading