Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6d16575
chore: add openal submodule
LoayAhmed304 Apr 14, 2026
b6b217b
chore: add audio files decoders
LoayAhmed304 Apr 14, 2026
6db0f6a
refactor: update CMakeLists for OpenAl options
LoayAhmed304 Apr 14, 2026
cd8ce27
refactor: remove stb_vorbis for ogg audio files
LoayAhmed304 Apr 14, 2026
a86cc45
feat: create audio buffer wrapper
LoayAhmed304 Apr 14, 2026
60ac7b8
feat: add utils for reading audio files
LoayAhmed304 Apr 14, 2026
2ffd402
feat: add sound source component and update CMakeLists
LoayAhmed304 Apr 14, 2026
c5a0de7
feat: initialize at application and apply menu music
LoayAhmed304 Apr 15, 2026
fef4255
fix: state switching results to audios not playing correctly
LoayAhmed304 Apr 15, 2026
549571c
feat: add more sounds in play state as a placeholder
LoayAhmed304 Apr 15, 2026
7130edc
perf: use asset loader and cache menu audio buffers
LoayAhmed304 Apr 15, 2026
35c908a
refactor: detach buffer on sound stop and remove unused data member
LoayAhmed304 Apr 15, 2026
b7cf5b8
chore: apply review suggestions
LoayAhmed304 Apr 15, 2026
1c3a5ef
fix: remove compiler path and intellisenseMode from cpp_properties
LoayAhmed304 Apr 17, 2026
82dbc86
perf: destroy menu state audio buffers
LoayAhmed304 Apr 17, 2026
5cefdd9
Merge branch 'main' into feat/audio-system
LoayAhmed304 Apr 17, 2026
0da5ad6
fix(flake.nix): add pipewire to buildInputs for OpenAL backend
AhmedAmrNabil Apr 17, 2026
b8df9c8
refactor: rename custom json configs to playgrounds
LoayAhmed304 Apr 17, 2026
90555b4
Merge branch 'main' into feat/audio-system
LoayAhmed304 Apr 17, 2026
b125e3e
fix: fix cpp extensions configurations in .vscode
LoayAhmed304 Apr 17, 2026
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
8 changes: 6 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
"configurations": [
{
"name": "Default",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"cppStandard": "c++17",
"browse": {
"path": ["${workspaceFolder}/src", "${workspaceFolder}/vendor"]
}
}
],
"version": 4
}
}
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ add_executable(${PROJECT_NAME}
src/game/systems/collision-system.cpp

src/common/systems/forward-renderer.cpp
src/common/systems/audio-system.cpp

src/common/audio/audio-utils.cpp
src/common/components/audio-source.cpp
)

target_include_directories(${PROJECT_NAME}
Expand Down
Binary file added assets/sounds/gun_reload.wav
Binary file not shown.
Binary file added assets/sounds/gun_shot.wav
Binary file not shown.
Binary file added assets/sounds/gun_shot_2.wav
Binary file not shown.
Binary file added assets/sounds/menu-music.wav
Binary file not shown.
Binary file added assets/sounds/menu-open.wav
Binary file not shown.
Binary file added assets/sounds/menu-select.wav
Binary file not shown.
Binary file added assets/sounds/portal.wav
Binary file not shown.
291 changes: 291 additions & 0 deletions config/playgrounds/sound.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
{
"start-scene": "menu",
"window": {
"title": "Default Game Window",
"size": {
"width": 1280,
"height": 720
},
"fullscreen": false
},
"scene": {
"renderer": {
"sky": "assets/textures/sky.jpg",
"postprocess": "assets/shaders/postprocess/vignette.frag"
},
"assets": {
"shaders": {
"tinted": {
"vs": "assets/shaders/tinted.vert",
"fs": "assets/shaders/tinted.frag"
},
"textured": {
"vs": "assets/shaders/textured.vert",
"fs": "assets/shaders/textured.frag"
}
},
"textures": {
"moon": "assets/textures/moon.jpg",
"grass": "assets/textures/grass_ground_d.jpg",
"wood": "assets/textures/wood.jpg",
"glass": "assets/textures/glass-panels.png",
"monkey": "assets/textures/monkey.png"
},
"meshes": {
"cube": "assets/models/cube.obj",
"monkey": "assets/models/monkey.obj",
"plane": "assets/models/plane.obj",
"sphere": "assets/models/sphere.obj"
},
"samplers": {
"default": {},
"pixelated": {
"MAG_FILTER": "GL_NEAREST"
}
},
"materials": {
"metal": {
"type": "tinted",
"shader": "tinted",
"pipelineState": {
"faceCulling": {
"enabled": false
},
"depthTesting": {
"enabled": true
}
},
"tint": [0.45, 0.4, 0.5, 1]
},
"glass": {
"type": "textured",
"shader": "textured",
"pipelineState": {
"faceCulling": {
"enabled": false
},
"depthTesting": {
"enabled": true
},
"blending": {
"enabled": true,
"sourceFactor": "GL_SRC_ALPHA",
"destinationFactor": "GL_ONE_MINUS_SRC_ALPHA"
},
"depthMask": false
},
"transparent": true,
"tint": [1, 1, 1, 1],
"texture": "glass",
"sampler": "pixelated"
},
"grass": {
"type": "textured",
"shader": "textured",
"pipelineState": {
"faceCulling": {
"enabled": false
},
"depthTesting": {
"enabled": true
}
},
"tint": [1, 1, 1, 1],
"texture": "grass",
"sampler": "default"
},
"monkey": {
"type": "textured",
"shader": "textured",
"pipelineState": {
"faceCulling": {
"enabled": false
},
"depthTesting": {
"enabled": true
}
},
"tint": [1, 1, 1, 1],
"texture": "monkey",
"sampler": "default"
},
"moon": {
"type": "textured",
"shader": "textured",
"pipelineState": {
"faceCulling": {
"enabled": false
},
"depthTesting": {
"enabled": true
}
},
"tint": [1, 1, 1, 1],
"texture": "moon",
"sampler": "default"
}
},
"sounds": {
"gun-reload": "assets/sounds/gun_reload.wav",
"portal": "assets/sounds/portal.wav"
}
},
"world": [
{
"position": [0, 0, 10],
"name": "Player Entity",
"components": [
{
"type": "Camera"
},
{
"type": "Free Camera Controller"
},
{
"type": "Collider",
"shape": "Capsule",
"height": 1.8,
"radius": 0.4,
"layer": "player"
}
],
"children": [
{
"name": "Player Sword",
"position": [1, -1, -1],
"rotation": [45, 45, 0],
"scale": [0.1, 0.1, 1.0],
"components": [
{
"type": "Mesh Renderer",
"mesh": "cube",
"material": "metal"
}
]
}
]
},
{
"rotation": [-45, 0, 0],
"components": [
{
"type": "Mesh Renderer",
"mesh": "monkey",
"material": "monkey"
},
{
"type": "Movement",
"linearVelocity": [0, 0.1, 0],
"angularVelocity": [0, 45, 0]
},
{
"type": "AudioSource",
"soundName": "portal",
"gain": 1.0,
"pitch": 1.0,
"loop": true,
"spatial": true,
"playOnStart": true,
"refDistance": 0.5,
"maxDistance": 5.0
}
]
},
{
"position": [0, -1, 0],
"rotation": [-90, 0, 0],
"scale": [10, 10, 1],
"components": [
{
"type": "Mesh Renderer",
"mesh": "plane",
"material": "grass"
}
]
},
{
"position": [0, 1, 2],
"rotation": [0, 0, 0],
"scale": [2, 2, 2],
"components": [
{
"type": "Mesh Renderer",
"mesh": "plane",
"material": "glass"
}
]
},
{
"position": [0, 1, -2],
"rotation": [0, 0, 0],
"scale": [2, 2, 2],
"components": [
{
"type": "Mesh Renderer",
"mesh": "plane",
"material": "glass"
}
]
},
{
"position": [2, 1, 0],
"rotation": [0, 90, 0],
"scale": [2, 2, 2],
"components": [
{
"type": "Mesh Renderer",
"mesh": "plane",
"material": "glass"
}
]
},
{
"position": [-2, 1, 0],
"rotation": [0, 90, 0],
"scale": [2, 2, 2],
"components": [
{
"type": "Mesh Renderer",
"mesh": "plane",
"material": "glass"
}
]
},
{
"position": [0, 3, 0],
"rotation": [90, 0, 0],
"scale": [2, 2, 2],
"components": [
{
"type": "Mesh Renderer",
"mesh": "plane",
"material": "glass"
}
]
},
{
"name": "Moon Entity",
"position": [0, 10, 0],
"rotation": [45, 45, 0],
"scale": [5, 5, 5],
"components": [
{
"type": "Mesh Renderer",
"mesh": "sphere",
"material": "moon"
},
{
"type": "Movement",
"angularVelocity": [0, 90, 0]
},
{
"type": "Collider",
"shape": "Sphere",
"radius": 5,
"layer": "environment"
}
]
}
]
}
}
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
libGL
libffi

# Audio
pipewire

# Wayland
wayland
wayland-protocols
Expand Down
4 changes: 4 additions & 0 deletions src/common/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ int our::Application::run(int run_for_frames) {
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 330 core");

audioSystem.initialize();

// This part of the code extracts the list of requested screenshots and puts them into a priority queue
using ScreenshotRequest = std::pair<int, std::string>;
std::priority_queue<ScreenshotRequest, std::vector<ScreenshotRequest>, std::greater<ScreenshotRequest>>
Expand Down Expand Up @@ -389,6 +391,8 @@ int our::Application::run(int run_for_frames) {
// Call for cleaning up
if (currentState) currentState->onDestroy();

audioSystem.destroy();

// Shutdown ImGui & destroy the context
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
Expand Down
7 changes: 7 additions & 0 deletions src/common/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "input/keyboard.hpp"
#include "input/mouse.hpp"
#include "systems/audio-system.hpp"

namespace our {

Expand Down Expand Up @@ -73,6 +74,8 @@ namespace our {
State* nextState =
nullptr; // If it is requested to go to another scene, this will contain a pointer to that scene

AudioSystem audioSystem; // The audio system of the application.

// Virtual functions to be overrode and change the default behaviour of the application
// according to the example needs.
virtual void configureOpenGL(); // This function sets OpenGL Window Hints in GLFW.
Expand Down Expand Up @@ -159,5 +162,9 @@ namespace our {
glfwGetWindowSize(window, &(size.x), &(size.y));
return size;
}

AudioSystem& getAudioSystem() {
return audioSystem;
};
};
} // namespace our
Loading