Initial late commit

This commit is contained in:
Erris
2026-01-12 16:57:00 +01:00
commit 9c41714b96
181 changed files with 32168 additions and 0 deletions

8
open_engine/.envrc Normal file
View File

@@ -0,0 +1,8 @@
source ../.envrc
export BINARY_NAME=open_engine
export BUILD_TYPE=Debug
export PROJECT_NAME=open_engine
##export CMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
export imgui_DIR=./build

5
open_engine/.luarc.json Normal file
View File

@@ -0,0 +1,5 @@
{
"workspace.library": ["./resources/lua_library/"],
"runtime.version": "Lua 5.3",
"hint.enable": true
}

54
open_engine/.nvim_session Normal file
View File

@@ -0,0 +1,54 @@
let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/projects/open_engine/open_engine
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
let s:shortmess_save = &shortmess
if &shortmess =~ 'A'
set shortmess=aoOA
else
set shortmess=aoO
endif
badd +1 .luarc.json
argglobal
%argdel
$argadd .luarc.json
edit .luarc.json
argglobal
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 2 - ((1 * winheight(0) + 30) / 60)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 2
normal! 0
tabnext 1
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20
let &shortmess = s:shortmess_save
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
set hlsearch
nohlsearch
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

View File

@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.28)
set(CMAKE_CXX_STANDARD 20)
set(PROJECT_EXECUTABLE_NAME open_engine)
project(OpenEngine
VERSION 0.0.1
)
add_definitions( -DOE_ENABLE_ASSERTS )
find_package(imgui REQUIRED)
file(GLOB_RECURSE SRC_FILES "src/*.cpp")
add_library(${PROJECT_EXECUTABLE_NAME} STATIC
${SRC_FILES}
"vendor/stb_image/stb_image.cpp"
)
target_precompile_headers(${PROJECT_EXECUTABLE_NAME} PRIVATE
include/open_engine/pch.hpp
)
target_include_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include/open_engine"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/stb_image"
)
target_include_directories(${PROJECT_EXECUTABLE_NAME} PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"/home/erris/.conan2/p/b/imguic69fe98538919/p/include"
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
#set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
target_link_libraries(${PROJECT_EXECUTABLE_NAME} PUBLIC
imgui::imgui
spdlog
glad
glfw
glm
dl
X11
)
#target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
# ${PROJECT_SOURCE_DIR}/lib
#)
add_subdirectory(vendor/glad
./lib
)

View File

@@ -0,0 +1 @@
---@meta

View File

@@ -0,0 +1,12 @@
#version 330 core
layout(location = 0) out vec4 color;
in vec3 v_Position;
in vec4 v_Color;
void main()
{
color = vec4(v_Position * 0.5 + 0.5, 1.0f);
color = v_Color;
}

View File

@@ -0,0 +1,148 @@
#version 330 core
out vec4 FragColor;
struct Material {
sampler2D diffuse;
sampler2D specular;
float shininess;
};
struct DirLight {
vec3 direction;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
struct PointLight {
vec3 position;
float constant;
float linear;
float quadratic;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
struct SpotLight {
vec3 position;
vec3 direction;
float cutOff;
float outerCutOff;
float constant;
float linear;
float quadratic;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
#define NR_POINT_LIGHTS 4
in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoords;
uniform vec3 viewPos;
uniform DirLight dirLight;
uniform PointLight pointLights[NR_POINT_LIGHTS];
uniform SpotLight spotLight;
uniform Material material;
// function prototypes
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir);
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
void main()
{
// properties
vec3 norm = normalize(Normal);
vec3 viewDir = normalize(viewPos - FragPos);
// == =====================================================
// Our lighting is set up in 3 phases: directional, point lights and an optional flashlight
// For each phase, a calculate function is defined that calculates the corresponding color
// per lamp. In the main() function we take all the calculated colors and sum them up for
// this fragment's final color.
// == =====================================================
// phase 1: directional lighting
//vec3 result = CalcDirLight(dirLight, norm, viewDir);
vec3 result;
// phase 2: point lights
for(int i = 0; i < NR_POINT_LIGHTS; i++)
result += CalcPointLight(pointLights[0], norm, FragPos, viewDir);
// phase 3: spot light
//result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
FragColor = vec4(result, 1.0);
}
// calculates the color when using a directional light.
vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir)
{
vec3 lightDir = normalize(-light.direction);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// combine results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
return (ambient + diffuse + specular);
}
// calculates the color when using a point light.
vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// combine results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
ambient *= attenuation;
diffuse *= attenuation;
specular *= attenuation;
return (ambient + diffuse + specular);
}
// calculates the color when using a spot light.
vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir)
{
vec3 lightDir = normalize(light.position - fragPos);
// diffuse shading
float diff = max(dot(normal, lightDir), 0.0);
// specular shading
vec3 reflectDir = reflect(-lightDir, normal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
// attenuation
float distance = length(light.position - fragPos);
float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
// spotlight intensity
float theta = dot(lightDir, normalize(-light.direction));
float epsilon = light.cutOff - light.outerCutOff;
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0);
// combine results
vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords));
vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords));
vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords));
ambient *= attenuation * intensity;
diffuse *= attenuation * intensity;
specular *= attenuation * intensity;
return (ambient + diffuse + specular);
}

View File

@@ -0,0 +1,8 @@
#version 330 core
out vec4 FragColor;
uniform vec3 objectColor;
void main() {
FragColor = vec4(objectColor, 1.0);
}

View File

@@ -0,0 +1,11 @@
#version 330 core
layout (location = 0) in vec3 aPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(aPos, 1.0);
}

View File

@@ -0,0 +1,14 @@
#version 330 core
layout(location = 0) in vec3 a_Position;
layout(location = 1) in vec4 a_Color;
out vec3 v_Position;
out vec4 v_Color;
void main()
{
v_Position = a_Position;
v_Color = a_Color;
gl_Position = vec4(a_Position, 1.0);
}

View File

@@ -0,0 +1,21 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec3 FragPos;
out vec3 Normal;
out vec2 TexCoords;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
FragPos = vec3(model * vec4(aPos, 1.0));
Normal = mat3(transpose(inverse(model))) * aNormal;
TexCoords = aTexCoords;
gl_Position = projection * view * vec4(FragPos, 1.0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@@ -0,0 +1,176 @@
[
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -fpch-instantiate-templates -Xclang -emit-pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx -x c++-header -o CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -c /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.cxx",
"file": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.cxx",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/application.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/application.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/application.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/application.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/application.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/core/time.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/core/time.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/core/time.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/core/time.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/core/time.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/events/application_event.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/events/application_event.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/events/application_event.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/events/application_event.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/events/application_event.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/events/key_event.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/events/key_event.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/events/key_event.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/events/key_event.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/events/key_event.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/events/mouse_event.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/events/mouse_event.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/events/mouse_event.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/events/mouse_event.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/events/mouse_event.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/imgui/imgui_layer.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/imgui/imgui_layer.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/imgui/imgui_layer.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/imgui/imgui_layer.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/imgui/imgui_layer.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/input/linux_input.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/input/linux_input.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/input/linux_input.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/input/linux_input.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/input/linux_input.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/layer.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/layer.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/layer.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/layer.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/layer.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/layer_stack.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/layer_stack.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/layer_stack.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/layer_stack.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/layer_stack.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/logging.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/logging.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/logging.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/logging.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/logging.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_build.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_build.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/imgui_build.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/imgui_build.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_build.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_glfw.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_glfw.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/imgui_glfw.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/imgui_glfw.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_glfw.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_opengl.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_opengl.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/imgui_opengl.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/imgui_opengl.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/imgui_opengl.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_buffer.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_buffer.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_buffer.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_buffer.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_buffer.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_context.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_context.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_context.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_context.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_context.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_renderer_api.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_renderer_api.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_renderer_api.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_renderer_api.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_renderer_api.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_shader.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_shader.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_shader.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_shader.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_shader.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_texture.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_texture.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_texture.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_texture.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_texture.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_vertex_array.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_vertex_array.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_vertex_array.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/opengl/opengl_vertex_array.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/opengl/opengl_vertex_array.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/orthographic_camera.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/orthographic_camera.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/orthographic_camera.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/orthographic_camera.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/orthographic_camera.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/renderer/buffer.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/renderer/buffer.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/renderer/buffer.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/renderer/buffer.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/renderer/buffer.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/renderer/renderer.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/renderer/renderer.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/renderer/renderer.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/renderer/renderer.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/renderer/renderer.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/renderer/shader.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/renderer/shader.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/renderer/shader.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/renderer/shader.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/renderer/shader.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/renderer/texture.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/renderer/texture.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/renderer/texture.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/renderer/texture.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/renderer/texture.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/renderer/vertex_array.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/renderer/vertex_array.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/renderer/vertex_array.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/renderer/vertex_array.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/renderer/vertex_array.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/src/open_engine/window/linux_window.cpp.o.modmap -o CMakeFiles/open_engine.dir/src/open_engine/window/linux_window.cpp.o -c /home/erris/projects/open_engine/open_engine/src/open_engine/window/linux_window.cpp",
"file": "/home/erris/projects/open_engine/open_engine/src/open_engine/window/linux_window.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/src/open_engine/window/linux_window.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang++ -DFMT_SHARED -DOE_ENABLE_ASSERTS -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/home/erris/projects/open_engine/open_engine/include/open_engine -I/home/erris/projects/open_engine/open_engine/vendor/stb_image -I/home/erris/projects/open_engine/open_engine/include -I/home/erris/.conan2/p/b/imguic69fe98538919/p/include -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/cmake_pch.hxx @CMakeFiles/open_engine.dir/vendor/stb_image/stb_image.cpp.o.modmap -o CMakeFiles/open_engine.dir/vendor/stb_image/stb_image.cpp.o -c /home/erris/projects/open_engine/open_engine/vendor/stb_image/stb_image.cpp",
"file": "/home/erris/projects/open_engine/open_engine/vendor/stb_image/stb_image.cpp",
"output": "/home/erris/projects/open_engine/open_engine/build/CMakeFiles/open_engine.dir/vendor/stb_image/stb_image.cpp.o"
},
{
"directory": "/home/erris/projects/open_engine/open_engine/build",
"command": "/usr/bin/clang -DOE_ENABLE_ASSERTS -I/home/erris/projects/open_engine/open_engine/vendor/glad/include -g -o lib/CMakeFiles/glad.dir/src/glad/glad.c.o -c /home/erris/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c",
"file": "/home/erris/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c",
"output": "/home/erris/projects/open_engine/open_engine/build/lib/CMakeFiles/glad.dir/src/glad/glad.c.o"
}
]

View File

@@ -0,0 +1,6 @@
[requires]
imgui/1.92.5-docking
[generators]
CMakeDeps
CMakeToolchain

View File

@@ -0,0 +1,23 @@
#ifndef OPEN_ENGINE_HPP
#define OPEN_ENGINE_HPP
#include "open_engine/application.hpp"
#include "open_engine/logging.hpp"
#include "open_engine/events/key_event.hpp"
#include "open_engine/imgui/imgui_layer.hpp"
#include "open_engine/renderer/render_command.hpp"
#include "open_engine/renderer/renderer.hpp"
#include "open_engine/core/time.hpp"
#include "open_engine/input/input_system.hpp"
#include "open_engine/input/keycodes.hpp"
#include "open_engine/renderer/buffer.hpp"
#include "open_engine/renderer/shader.hpp"
#include "open_engine/opengl/opengl_shader.hpp"
#include "open_engine/renderer/texture.hpp"
#include "open_engine/orthographic_camera_controller.hpp"
// Entry Point -------------------------
#include "open_engine/entry_point.hpp"
// -------------------------------------
#endif // OPEN_ENGINE_HPP

View File

@@ -0,0 +1,121 @@
let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/projects/open_engine/open_engine
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
let s:shortmess_save = &shortmess
if &shortmess =~ 'A'
set shortmess=aoOA
else
set shortmess=aoO
endif
badd +1 ~/projects/open_engine/open_engine
badd +13 ~/projects/open_engine/open_engine/include/open_engine/orthographic_camera.hpp
badd +24 ~/projects/open_engine/open_engine/src/open_engine/orthographic_camera.cpp
badd +25 ~/projects/open_engine/open_engine/include/open_engine/application.hpp
badd +18 ~/projects/open_engine/open_engine/src/open_engine/application.cpp
badd +9 ~/projects/open_engine/open_engine/src/open_engine/renderer/renderer.cpp
badd +1654 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_glfw.cpp
badd +8 ~/projects/open_engine/open_engine/src/open_engine/time.cpp
badd +11 ~/projects/open_engine/open_engine/include/open_engine.hpp
badd +22 ~/projects/open_engine/open_engine/include/open_engine/time.hpp
badd +4 ~/projects/open_engine/open_engine/include/open_engine/input/input_system.hpp
badd +1 ~/projects/open_engine/open_engine/include/open_engine/core.hpp
badd +10 ~/projects/open_engine/open_engine/include/open_engine/renderer/shader.hpp
badd +8 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_shader.hpp
badd +211 ~/projects/open_engine/open_engine/src/open_engine/imgui/imgui_layer.cpp
badd +34 ~/projects/open_engine/open_engine/src/open_engine/window/linux_window.cpp
badd +17 ~/projects/open_engine/open_engine/include/open_engine/window/linux_window.hpp
badd +12 ~/projects/open_engine/open_engine/include/open_engine/entry_point.hpp
badd +17 ~/projects/open_engine/open_engine/include/open_engine/window/window.hpp
badd +1 ~/projects/open_engine/open_engine/justfile
argglobal
%argdel
$argadd ~/projects/open_engine/open_engine
edit ~/projects/open_engine/open_engine/include/open_engine.hpp
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe 'vert 1resize ' . ((&columns * 104 + 62) / 125)
exe 'vert 2resize ' . ((&columns * 20 + 62) / 125)
argglobal
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 11 - ((10 * winheight(0) + 29) / 59)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 11
normal! 032|
lcd ~/projects/open_engine/open_engine
wincmd w
argglobal
if bufexists(fnamemodify("~/projects/open_engine/open_engine/include/open_engine/orthographic_camera.hpp", ":p")) | buffer ~/projects/open_engine/open_engine/include/open_engine/orthographic_camera.hpp | else | edit ~/projects/open_engine/open_engine/include/open_engine/orthographic_camera.hpp | endif
if &buftype ==# 'terminal'
silent file ~/projects/open_engine/open_engine/include/open_engine/orthographic_camera.hpp
endif
balt ~/projects/open_engine/open_engine/src/open_engine/orthographic_camera.cpp
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 12 - ((11 * winheight(0) + 29) / 59)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 12
normal! 0
lcd ~/projects/open_engine/open_engine
wincmd w
2wincmd w
exe 'vert 1resize ' . ((&columns * 104 + 62) / 125)
exe 'vert 2resize ' . ((&columns * 20 + 62) / 125)
tabnext 1
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20
let &shortmess = s:shortmess_save
let &winminheight = s:save_winminheight
let &winminwidth = s:save_winminwidth
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
set hlsearch
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

View File

@@ -0,0 +1,49 @@
#ifndef APPLICATION_HPP
#define APPLICATION_HPP
#include "core.hpp"
#include "events/application_event.hpp"
#include "imgui/imgui_layer.hpp"
#include "layer.hpp"
#include "layer_stack.hpp"
#include "window/window.hpp"
#include <memory>
namespace OpenEngine {
class OE_API Application
{
public:
Application();
virtual ~Application() = default;
void Run();
virtual void OnEvent(Event& event);
void PushLayer(Layer* layer);
void PushOverlay(Layer* overlay);
inline static Application& Get() { return *instance; }
inline Window& GetWindow() { return *window; }
inline void StopRunning() { running = false; }
private:
bool OnWindowClose(WindowCloseEvent& event);
bool OnWindowResize(WindowResizeEvent& event);
inline static Application* instance;
bool running = true;
std::unique_ptr<Window> window;
ImGuiLayer* imgui_layer;
LayerStack layer_stack;
};
// Is defined by client
Application* CreateApplication();
}
#endif // APPLICATION_HPP

View File

@@ -0,0 +1,36 @@
#ifndef CORE_HPP
#define CORE_HPP
#include <memory>
#ifdef __linux__
#ifdef OE_EXPORT
#define OE_API __attribute__((visibility("default")))
#else
#define OE_API
#endif
#elif defined(_WIN32) || defined(WIN32)
#error Windows is not yet supported
#endif
#ifdef OE_ENABLE_ASSERTS
#include <signal.h>
#define OE_ASSERT(x, ...) { if (!(x)) { OE_ERROR("Assertion Failed: {0}", __VA_ARGS__); raise(SIGTRAP); } }
#define OE_CORE_ASSERT(x, ...) { if (!(x)) { OE_CORE_ERROR("Assertion Failed: {0}", __VA_ARGS__); raise(SIGTRAP); } }
#else
#define OE_ASSERT(x, ...)
#define OE_CORE_ASSERT(x, ...)
#endif
#define BIT(x) (1 << x)
#define BIND_EVENT_FN(function) std::bind(&function, this, std::placeholders::_1)
namespace OpenEngine {
template<typename T>
using Scope = std::unique_ptr<T>;
template<typename T>
using Ref = std::shared_ptr<T>;
}
#endif // CORE_HPP

View File

@@ -0,0 +1,34 @@
#ifndef TIME_HPP
#define TIME_HPP
#include <chrono>
namespace OpenEngine {
class Time
{
public:
Time(const Time&) = delete; // No copy constructor
Time& operator=(const Time&) = delete;
void Update();
static Time& Get()
{
if (instance == nullptr)
instance.reset(new Time);
return *instance;
}
double DeltaTime() const { return delta_time.count(); };
private:
Time() {};
std::chrono::high_resolution_clock::time_point previous_frame;
static std::unique_ptr<Time> instance;
std::chrono::duration<double> delta_time;
};
}
#endif // TIME_HPP

View File

@@ -0,0 +1,17 @@
#ifndef ENTRY_POINT_HPP
#define ENTRY_POINT_HPP
#include "application.hpp"
extern OpenEngine::Application* OpenEngine::CreateApplication();
int main(int argc, char** argv)
{
OpenEngine::Logger::Init();
auto app = OpenEngine::CreateApplication();
app->Run();
delete app;
}
#endif // ENTRY_POINT_HPP

View File

@@ -0,0 +1,53 @@
#ifndef APPLICATION_EVENT_HPP
#define APPLICATION_EVENT_HPP
#include "event.hpp"
namespace OpenEngine {
class OE_API WindowResizeEvent
: public Event
{
public:
WindowResizeEvent(unsigned int width, unsigned int height)
: width(width), height(height)
{
}
inline unsigned int GetWidth() const { return width; }
inline unsigned int GetHeight() const { return height; }
std::string ToString() const override;
EVENT_CLASS_TYPE(WindowResized)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
private:
unsigned int width, height;
};
class OE_API WindowCloseEvent
: public Event
{
public:
WindowCloseEvent() {}
std::string ToString() const override;
EVENT_CLASS_TYPE(WindowClose)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
};
class OE_API AppUpdateEvent
: public Event
{
public:
AppUpdateEvent() {}
std::string ToString() const override;
EVENT_CLASS_TYPE(AppUpdate)
EVENT_CLASS_CATEGORY(EventCategoryApplication)
};
}
#endif // APPLICATION_EVENT_HPP

View File

@@ -0,0 +1,78 @@
#ifndef EVENT_HPP
#define EVENT_HPP
#include "../core.hpp"
#include <string>
namespace OpenEngine {
enum class EventType
{
none = 0,
WindowClose, WindowResized, WindowFocus, WindowLostFocus, WindowMoved,
AppUpdate,
KeyPressed, KeyReleased, KeyTyped,
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
};
enum EventCategory
{
None = 0,
EventCategoryApplication = BIT(0),
EventCategoryInput = BIT(1),
EventCategoryKeyboard = BIT(2),
EventCategoryMouse = BIT(3),
EventCategoryMouseButton = BIT(4)
};
#define EVENT_CLASS_TYPE(type) static EventType GetStaticType() { return EventType::type; }\
virtual EventType GetEventType() const override { return GetStaticType(); }\
virtual const char* GetName() const override { return #type; }
#define EVENT_CLASS_CATEGORY(category) virtual int GetCategoryFlags() const override { return category; }
class OE_API Event
{
public:
virtual EventType GetEventType() const = 0;
virtual const char* GetName() const = 0;
virtual int GetCategoryFlags() const = 0;
virtual std::string ToString() const { return GetName(); }
inline bool IsInCategory(EventCategory category) {
return GetCategoryFlags() & category;
}
bool handled = false;
};
class EventDispatcher
{
public:
EventDispatcher(Event& event)
: event(event)
{
}
template<typename T, typename F>
bool Dispatch(const F& func)
{
if (event.GetEventType() == T::GetStaticType())
{
event.handled = func(static_cast<T&>(event));
return true;
}
return false;
}
private:
Event& event;
};
inline std::ostream& operator<<(std::ostream& os, const Event& e)
{
return os << e.ToString();
}
}
#endif // EVENT_HPP

View File

@@ -0,0 +1,76 @@
#ifndef KEY_EVENT_HPP
#define KEY_EVENT_HPP
#include "event.hpp"
namespace OpenEngine {
class OE_API KeyEvent
: public Event
{
public:
inline int GetKeyCode() const { return keycode; }
inline int GetScanCode() const { return scancode; }
inline int GetMods() const { return mods; }
EVENT_CLASS_CATEGORY(EventCategoryInput | EventCategoryKeyboard)
protected:
KeyEvent(int keycode, int scancode, int mods)
: keycode(keycode), scancode(scancode), mods(mods)
{
}
int keycode;
int scancode;
int mods;
};
class OE_API KeyPressedEvent
: public KeyEvent
{
public:
KeyPressedEvent(int keycode, int scancode, int repeat_count, int mods)
: KeyEvent(keycode, scancode, mods), repeat_count(repeat_count)
{
}
inline int GetRepeatCount() { return repeat_count; };
std::string ToString() const override;
EVENT_CLASS_TYPE(KeyPressed)
private:
int repeat_count;
};
class OE_API KeyReleasedEvent
: public KeyEvent
{
public:
KeyReleasedEvent(int keycode, int scancode, int mods)
: KeyEvent(keycode, scancode, mods)
{
}
std::string ToString() const override;
EVENT_CLASS_TYPE(KeyReleased)
};
class OE_API KeyTypedEvent
: public KeyEvent
{
public:
KeyTypedEvent(int keycode)
: KeyEvent(keycode, 0, 0)
{
}
std::string ToString() const override;
EVENT_CLASS_TYPE(KeyTyped)
};
}
#endif // KEY_EVENT_HPP

View File

@@ -0,0 +1,93 @@
#ifndef MOUSE_EVENT_HPP
#define MOUSE_EVENT_HPP
#include "event.hpp"
namespace OpenEngine {
class OE_API MouseMovedEvent
: public Event
{
public:
MouseMovedEvent(float mouse_x, float mouse_y)
: mouse_x(mouse_x), mouse_y(mouse_y)
{
}
inline float GetX() const { return mouse_x; };
inline float GetY() const { return mouse_y; };
std::string ToString() const override;
EVENT_CLASS_TYPE(MouseMoved)
EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput)
private:
float mouse_x, mouse_y;
};
class OE_API MouseScrolledEvent
: public Event
{
public:
MouseScrolledEvent(float x_offset, float y_offset)
: x_offset(x_offset), y_offset(y_offset)
{
}
inline float GetXOffset() const { return x_offset; }
inline float GetYOffset() const { return y_offset; }
std::string ToString() const override;
EVENT_CLASS_TYPE(MouseScrolled)
EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput)
private:
float x_offset, y_offset;
};
class OE_API MouseButtonEvent
: public Event
{
public:
inline int GetMouseButton() const { return button; }
EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput)
protected:
MouseButtonEvent(int button)
: button(button)
{
}
int button;
};
class OE_API MouseButtonPressedEvent
: public MouseButtonEvent
{
public:
MouseButtonPressedEvent(int button)
: MouseButtonEvent(button)
{
}
std::string ToString() const override;
EVENT_CLASS_TYPE(MouseButtonPressed)
};
class OE_API MouseButtonReleasedEvent
: public MouseButtonEvent
{
public:
MouseButtonReleasedEvent(int button)
: MouseButtonEvent(button) {}
std::string ToString() const override;
EVENT_CLASS_TYPE(MouseButtonReleased)
};
}
#endif // MOUSE_EVENT_HPP

View File

@@ -0,0 +1,26 @@
#ifndef IMGUI_LAYER_HPP
#define IMGUI_LAYER_HPP
#include "../core.hpp"
#include "../layer.hpp"
namespace OpenEngine {
class OE_API ImGuiLayer : public Layer
{
public:
ImGuiLayer();
~ImGuiLayer() = default;
virtual void OnAttach() override;
virtual void OnDetach() override;
virtual void OnImGuiRender() override;
void Begin();
void End();
private:
float previous_frame_time = 0.0f;
};
}
#endif // IMGUI_LAYER_HPP

View File

@@ -0,0 +1,61 @@
#ifndef INPUT_HPP
#define INPUT_HPP
#include "../core.hpp"
#include <map>
#define MAX_AXIS 10
namespace OpenEngine {
class OE_API Input
{
public:
Input(const Input&) = delete;
Input& operator=(const Input&) = delete;
inline static bool IsKeyPressed(int keycode) { return instance->IsKeyPressedImpl(keycode); };
inline static bool IsMouseButtonPressed(int button) { return instance->IsMouseButtonPressedImpl(button); };
inline static std::pair<float, float> GetMousePosition() { return instance->GetMousePositionImpl(); };
inline static bool GetMouseX() { return instance->GetMouseXImpl(); };
inline static bool GetMouseY() { return instance->GetMouseYImpl(); };
inline static bool JoystickExists(unsigned int joystick) { return instance->JoystickExistsImpl(joystick); };
inline static std::map<unsigned int, std::string> GetJoystickList() { return instance->GetJoystickListImpl(); };
inline static float GetJoystickAxis(unsigned int joystick, unsigned int axis) { return instance->GetJoystickAxisImpl(joystick, axis); };
inline static const float* GetJoystickAxes(unsigned int joystick) { return instance->GetJoystickAxesImpl(joystick); };
inline static unsigned int GetJoystickAxesCount(unsigned int joystick) { return instance->GetJoystickAxesCountImpl(joystick); };
inline static bool IsJoystickButtonPressed(unsigned int joystick, unsigned int button) { return instance->IsJoystickButtonPressedImpl(joystick, button); };
protected:
Input() = default;
virtual bool IsKeyPressedImpl(int keycode) = 0;
virtual bool IsMouseButtonPressedImpl(int button) = 0;
virtual std::pair<float, float> GetMousePositionImpl() = 0;
virtual float GetMouseXImpl() = 0;
virtual float GetMouseYImpl() = 0;
virtual bool JoystickExistsImpl(unsigned int joystick) = 0;
virtual std::map<unsigned int, std::string> GetJoystickListImpl() = 0;
virtual const std::string GetJoystickNameImpl(unsigned int joystick) = 0;
virtual float GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) = 0;
virtual const float* GetJoystickAxesImpl(unsigned int joystick) = 0;
virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) = 0;
virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) = 0;
private:
inline static const std::string GetJoystickName(unsigned int joystick) { return instance->GetJoystickNameImpl(joystick); };
static Input* instance;
};
}
#endif // INPUT_HPP

View File

@@ -0,0 +1,127 @@
#ifndef KEYCODES_HPP
#define KEYCODES_HPP
#define OE_KEY_SPACE 32
#define OE_KEY_APOSTROPHE 39 /* ' */
#define OE_KEY_COMMA 44 /* , */
#define OE_KEY_MINUS 45 /* - */
#define OE_KEY_PERIOD 46 /* . */
#define OE_KEY_SLASH 47 /* / */
#define OE_KEY_0 48
#define OE_KEY_1 49
#define OE_KEY_2 50
#define OE_KEY_3 51
#define OE_KEY_4 52
#define OE_KEY_5 53
#define OE_KEY_6 54
#define OE_KEY_7 55
#define OE_KEY_8 56
#define OE_KEY_9 57
#define OE_KEY_SEMICOLON 59 /* ; */
#define OE_KEY_EQUAL 61 /* = */
#define OE_KEY_A 65
#define OE_KEY_B 66
#define OE_KEY_C 67
#define OE_KEY_D 68
#define OE_KEY_E 69
#define OE_KEY_F 70
#define OE_KEY_G 71
#define OE_KEY_H 72
#define OE_KEY_I 73
#define OE_KEY_J 74
#define OE_KEY_K 75
#define OE_KEY_L 76
#define OE_KEY_M 77
#define OE_KEY_N 78
#define OE_KEY_O 79
#define OE_KEY_P 80
#define OE_KEY_Q 81
#define OE_KEY_R 82
#define OE_KEY_S 83
#define OE_KEY_T 84
#define OE_KEY_U 85
#define OE_KEY_V 86
#define OE_KEY_W 87
#define OE_KEY_X 88
#define OE_KEY_Y 89
#define OE_KEY_Z 90
#define OE_KEY_LEFT_BRACKET 91 /* [ */
#define OE_KEY_BACKSLASH 92 /* \ */
#define OE_KEY_RIGHT_BRACKET 93 /* ] */
#define OE_KEY_GRAVE_ACCENT 96 /* ` */
#define OE_KEY_WORLD_1 161 /* non-US #1 */
#define OE_KEY_WORLD_2 162 /* non-US #2 */
/* FunctOEn keys */
#define OE_KEY_ESCAPE 256
#define OE_KEY_ENTER 257
#define OE_KEY_TAB 258
#define OE_KEY_BACKSPACE 259
#define OE_KEY_INSERT 260
#define OE_KEY_DELETE 261
#define OE_KEY_RIGHT 262
#define OE_KEY_LEFT 263
#define OE_KEY_DOWN 264
#define OE_KEY_UP 265
#define OE_KEY_PAGE_UP 266
#define OE_KEY_PAGE_DOWN 267
#define OE_KEY_HOME 268
#define OE_KEY_END 269
#define OE_KEY_CAPS_LOCK 280
#define OE_KEY_SCROLL_LOCK 281
#define OE_KEY_NUM_LOCK 282
#define OE_KEY_PRINT_SCREEN 283
#define OE_KEY_PAUSE 284
#define OE_KEY_F1 290
#define OE_KEY_F2 291
#define OE_KEY_F3 292
#define OE_KEY_F4 293
#define OE_KEY_F5 294
#define OE_KEY_F6 295
#define OE_KEY_F7 296
#define OE_KEY_F8 297
#define OE_KEY_F9 298
#define OE_KEY_F10 299
#define OE_KEY_F11 300
#define OE_KEY_F12 301
#define OE_KEY_F13 302
#define OE_KEY_F14 303
#define OE_KEY_F15 304
#define OE_KEY_F16 305
#define OE_KEY_F17 306
#define OE_KEY_F18 307
#define OE_KEY_F19 308
#define OE_KEY_F20 309
#define OE_KEY_F21 310
#define OE_KEY_F22 311
#define OE_KEY_F23 312
#define OE_KEY_F24 313
#define OE_KEY_F25 314
#define OE_KEY_KP_0 320
#define OE_KEY_KP_1 321
#define OE_KEY_KP_2 322
#define OE_KEY_KP_3 323
#define OE_KEY_KP_4 324
#define OE_KEY_KP_5 325
#define OE_KEY_KP_6 326
#define OE_KEY_KP_7 327
#define OE_KEY_KP_8 328
#define OE_KEY_KP_9 329
#define OE_KEY_KP_DECIMAL 330
#define OE_KEY_KP_DIVIDE 331
#define OE_KEY_KP_MULTIPLY 332
#define OE_KEY_KP_SUBTRACT 333
#define OE_KEY_KP_ADD 334
#define OE_KEY_KP_ENTER 335
#define OE_KEY_KP_EQUAL 336
#define OE_KEY_LEFT_SHIFT 340
#define OE_KEY_LEFT_CONTROL 341
#define OE_KEY_LEFT_ALT 342
#define OE_KEY_LEFT_SUPER 343
#define OE_KEY_RIGHT_SHIFT 344
#define OE_KEY_RIGHT_CONTROL 345
#define OE_KEY_RIGHT_ALT 346
#define OE_KEY_RIGHT_SUPER 347
#define OE_KEY_MENU 348
#endif // KEYCODES_HPP

View File

@@ -0,0 +1,33 @@
#ifndef LINUX_INPUT_HPP
#define LINUX_INPUT_HPP
#include "input_system.hpp"
namespace OpenEngine {
class LinuxInput : public Input
{
protected:
virtual bool IsKeyPressedImpl(int keycode) override;
virtual bool IsMouseButtonPressedImpl(int button) override;
virtual std::pair<float, float> GetMousePositionImpl() override;
virtual float GetMouseXImpl() override;
virtual float GetMouseYImpl() override;
virtual bool JoystickExistsImpl(unsigned int joystick) override;
virtual float GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) override;
virtual const std::string GetJoystickNameImpl(unsigned int joystick) override;
virtual std::map<unsigned int, std::string> GetJoystickListImpl() override;
virtual const float* GetJoystickAxesImpl(unsigned int joystick) override;
virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) override;
virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) override;
private:
};
}
#endif // LINUX_INPUT_HPP

View File

@@ -0,0 +1,17 @@
#ifndef MOUSE_BUTTONS_CODES_HPP
#define MOUSE_BUTTONS_CODES_HPP
#define HZ_MOUSE_BUTTON_1 0
#define HZ_MOUSE_BUTTON_2 1
#define HZ_MOUSE_BUTTON_3 2
#define HZ_MOUSE_BUTTON_4 3
#define HZ_MOUSE_BUTTON_5 4
#define HZ_MOUSE_BUTTON_6 5
#define HZ_MOUSE_BUTTON_7 6
#define HZ_MOUSE_BUTTON_8 7
#define HZ_MOUSE_BUTTON_LAST HZ_MOUSE_BUTTON_8
#define HZ_MOUSE_BUTTON_LEFT HZ_MOUSE_BUTTON_1
#define HZ_MOUSE_BUTTON_RIGHT HZ_MOUSE_BUTTON_2
#define HZ_MOUSE_BUTTON_MIDDLE HZ_MOUSE_BUTTON_3
#endif // MOUSE_BUTTONS_CODES_HPP

View File

@@ -0,0 +1,27 @@
#ifndef LAYER_HPP
#define LAYER_HPP
#include "events/event.hpp"
#include "core.hpp"
namespace OpenEngine {
class OE_API Layer
{
public:
Layer(const std::string& name = "layer");
virtual ~Layer() = default;
virtual void OnAttach() {}
virtual void OnDetach() {}
virtual void OnUpdate() {}
virtual void OnImGuiRender() {}
virtual void OnEvent(Event& event) {}
inline const std::string& GetName() const { return debug_name; }
protected:
std::string debug_name = "";
};
}
#endif // LAYER_HPP

View File

@@ -0,0 +1,29 @@
#ifndef LAYER_STACK_HPP
#define LAYER_STACK_HPP
#include "core.hpp"
#include "layer.hpp"
#include <vector>
namespace OpenEngine {
class OE_API LayerStack
{
public:
LayerStack();
~LayerStack();
void PushLayer(Layer* layer);
void PopLayer(Layer* layer);
void PushOverlay(Layer* overlay);
void PopOverlay(Layer* overlay);
std::vector<Layer*>::iterator begin() { return layers.begin(); }
std::vector<Layer*>::iterator end() { return layers.end(); }
private:
std::vector<Layer*> layers;
unsigned int layer_insert_index = 0;
};
}
#endif // LAYER_STACK_HPP

View File

@@ -0,0 +1,43 @@
#ifndef LOGGING_HPP
#define LOGGING_HPP
#include "core.hpp"
#include <spdlog/logger.h>
#include <spdlog/spdlog.h>
#include <memory>
#include <string>
namespace OE_API OpenEngine {
spdlog::level::level_enum stringToLogLevel(std::string level_str);
int setupMultisinkLogger(const std::string &file_path);
class Logger
{
public:
static void Init();
inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return core_logger; }
inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return client_logger; }
private:
static std::shared_ptr<spdlog::logger> core_logger;
static std::shared_ptr<spdlog::logger> client_logger;
};
}
#define OE_CORE_TRACE(...) ::OpenEngine::Logger::GetCoreLogger()->trace(__VA_ARGS__)
#define OE_CORE_DEBUG(...) ::OpenEngine::Logger::GetCoreLogger()->debug(__VA_ARGS__)
#define OE_CORE_INFO(...) ::OpenEngine::Logger::GetCoreLogger()->info(__VA_ARGS__)
#define OE_CORE_WARN(...) ::OpenEngine::Logger::GetCoreLogger()->warn(__VA_ARGS__)
#define OE_CORE_ERROR(...) ::OpenEngine::Logger::GetCoreLogger()->error(__VA_ARGS__)
#define OE_CORE_CRITICAL(...) ::OpenEngine::Logger::GetCoreLogger()->critical(__VA_ARGS__)
#define OE_TRACE(...) ::OpenEngine::Logger::GetClientLogger()->trace(__VA_ARGS__)
#define OE_DEBUG(...) ::OpenEngine::Logger::GetClientLogger()->debug(__VA_ARGS__)
#define OE_INFO(...) ::OpenEngine::Logger::GetClientLogger()->info(__VA_ARGS__)
#define OE_WARN(...) ::OpenEngine::Logger::GetClientLogger()->warn(__VA_ARGS__)
#define OE_ERROR(...) ::OpenEngine::Logger::GetClientLogger()->error(__VA_ARGS__)
#define OE_CRITICAL(...) ::OpenEngine::Logger::GetClientLogger()->critical(__VA_ARGS__)
#endif // LOGGING_HPP

View File

@@ -0,0 +1,73 @@
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// (Requires: GLFW 3.0+. Prefer GLFW 3.3+/3.4+ for full feature support.)
// Implemented features:
// [X] Platform: Clipboard support.
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors) with GLFW 3.1+. Resizing cursors requires GLFW 3.4+! Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// [X] Multiple Dear ImGui contexts support.
// Missing features or Issues:
// [ ] Platform: Touch events are only correctly identified as Touch on Windows. This create issues with some interactions. GLFW doesn't provide a way to identify touch inputs from mouse inputs, we cannot call io.AddMouseSourceEvent() to identify the source. We provide a Windows-specific workaround.
// [ ] Platform: Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors.
// [ ] Platform: Multi-viewport: Missing ImGuiBackendFlags_HasParentViewport support. The viewport->ParentViewportID field is ignored, and therefore io.ConfigViewportsNoDefaultParent has no effect either.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
struct GLFWwindow;
struct GLFWmonitor;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
// Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL)
#ifdef __EMSCRIPTEN__
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector);
//static inline void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector) { ImGui_ImplGlfw_InstallEmscriptenCallbacks(nullptr, canvas_selector); } } // Renamed in 1.91.0
#endif
// GLFW callbacks install
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
IMGUI_IMPL_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
// GFLW callbacks options:
// - Set 'chain_for_all_windows=true' to enable chaining callbacks for all windows (including secondary viewports created by backends or by user)
IMGUI_IMPL_API void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows);
// GLFW callbacks (individual callbacks to call yourself if you didn't install callbacks)
IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
// GLFW helpers
IMGUI_IMPL_API void ImGui_ImplGlfw_Sleep(int milliseconds);
IMGUI_IMPL_API float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window);
IMGUI_IMPL_API float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor);
#endif // #ifndef IMGUI_DISABLE

View File

@@ -0,0 +1,69 @@
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
// - Desktop GL: 2.x 3.x 4.x
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
// Implemented features:
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// About WebGL/ES:
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
// - This is done automatically on iOS, Android and Emscripten targets.
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp
// About GLSL version:
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
// (Optional) Called by Init/NewFrame/Shutdown
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
IMGUI_IMPL_API void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex);
// Configuration flags to add in your imconfig file:
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
&& !defined(IMGUI_IMPL_OPENGL_ES3)
// Try to detect GLES on matching platforms
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
#elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
#else
// Otherwise imgui_impl_opengl3_loader.h will be used.
#endif
#endif
#endif // #ifndef IMGUI_DISABLE

View File

@@ -0,0 +1,41 @@
#ifndef OPENGL_BUFFER_HPP
#define OPENGL_BUFFER_HPP
#include "renderer/buffer.hpp"
#include <cstdint>
namespace OpenEngine {
class OpenGLVertexBuffer : public VertexBuffer
{
public:
OpenGLVertexBuffer(float* vertices, uint32_t size);
virtual ~OpenGLVertexBuffer();
virtual void Bind() const override;
virtual void UnBind() const override;
virtual const BufferLayout& GetLayout() const override { return layout; }
virtual void SetLayout(const BufferLayout& layout) override { this->layout = layout; }
private:
BufferLayout layout;
unsigned int id;
};
class OpenGLIndexBuffer : public IndexBuffer
{
public:
OpenGLIndexBuffer(uint32_t* indices, uint32_t count);
virtual ~OpenGLIndexBuffer();
virtual void Bind() const override;
virtual void UnBind() const override;
virtual uint32_t GetCount() const override { return count; };
private:
unsigned int id;
uint32_t count;
};
}
#endif // OPENGL_BUFFER_HPP

View File

@@ -0,0 +1,22 @@
#ifndef OPENGL_CONTEXT_HPP
#define OPENGL_CONTEXT_HPP
#include "renderer/graphics_context.hpp"
struct GLFWwindow;
namespace OpenEngine {
class OpenGLContext : public GraphicsContext
{
public:
OpenGLContext(GLFWwindow* window_handle);
virtual void Init() override;
virtual void SwapBuffers() override;
private:
GLFWwindow* window_handle;
};
}
#endif // OPENGL_CONTEXT_HPP

View File

@@ -0,0 +1,21 @@
#ifndef OPENGL_RENDERER_API_HPP
#define OPENGL_RENDERER_API_HPP
#include "../renderer/renderer_api.hpp"
namespace OpenEngine {
class OpenGLRendererAPI : public RendererAPI
{
public:
virtual void Init() override;
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
virtual void SetClearColor(const glm::vec4& color) override;
virtual void Clear() override;
virtual void DrawIndexed(const std::shared_ptr<VertexArray>& vertex_array) override;
};
}
#endif // OPENGL_RENDEREAPI_HPP

View File

@@ -0,0 +1,45 @@
#ifndef OPENGL_SHADER_HPP
#define OPENGL_SHADER_HPP
#include "../renderer/shader.hpp"
#include <sys/types.h>
#include <string>
#include <glad/glad.h>
#include <unordered_map>
namespace OpenEngine {
class OpenGLShader : public Shader
{
public:
OpenGLShader(const std::string& shader_path);
OpenGLShader(const std::string& name, const std::string& vertex_src, const std::string& frament_src);
virtual ~OpenGLShader() = default;
virtual const std::string& GetName() const override { return name; };
// activate the shader
virtual void Bind() const override;
virtual void Unbind() const override;
// utility uniform functions
virtual void SetBool(const std::string &name, bool value) const;
virtual void SetInt(const std::string &name, int value) const;
virtual void SetFloat(const std::string &name, float value) const;
virtual void SetMat4(const std::string &name, const glm::mat4& value) const;
virtual void SetVec3(const std::string &name, const glm::vec3& value) const;
private:
std::string ReadFile(const std::string& shader_path);
std::unordered_map<GLenum, std::string> PreProcess(const std::string& shader_source);
void Compile(const std::unordered_map<GLenum, std::string> sources);
void CheckCompileErrors(unsigned int shader, const std::string& type);
std::string name;
u_int32_t id;
};
}
#endif // OPENGL_SHADER_HPP

View File

@@ -0,0 +1,27 @@
#ifndef OPENGL_TEXTURE_HPP
#define OPENGL_TEXTURE_HPP
#include <cstdint>
#include <renderer/texture.hpp>
namespace OpenEngine {
class OpenGLTexture2D : public Texture2D
{
public:
OpenGLTexture2D(const std::string& path);
virtual ~OpenGLTexture2D();
virtual uint32_t GetWidth() const override { return width; };
virtual uint32_t GetHeight() const override { return height; };
virtual void Bind(uint32_t slot = 0) const override;
private:
std::string path;
uint32_t width, height;
uint32_t id;
};
}
#endif // OPENGL_TEXTURE_HPP

View File

@@ -0,0 +1,31 @@
#ifndef OPENGL_VERTEX_ARRAY_HPP
#define OPENGL_VERTEX_ARRAY_HPP
#include "renderer/vertex_array.hpp"
namespace OpenEngine {
class OpenGLVertexArray : public VertexArray
{
public:
OpenGLVertexArray();
~OpenGLVertexArray();
virtual void Bind() const override;
virtual void UnBind() const override;
virtual void AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertex_buffer) override;
virtual void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& index_buffer) override;
virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const override { return vertex_buffers; }
virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const override { return index_buffer; }
private:
uint32_t id;
uint32_t index = 0;
std::vector<std::shared_ptr<VertexBuffer>> vertex_buffers;
std::shared_ptr<IndexBuffer> index_buffer;
};
}
#endif // OPENGL_VERTEX_ARRAY_HPP

View File

@@ -0,0 +1,36 @@
#ifndef CAMERA_HPP
#define CAMERA_HPP
#include <glm/fwd.hpp>
#include <glm/glm.hpp>
namespace OpenEngine {
class OrthographicCamera
{
public:
OrthographicCamera(float left, float right, float bottom, float top);
void SetProjection(float left, float right, float bottom, float top);
const glm::vec3& GetPosition() const { return position; };
void SetPosition(const glm::vec3& position) { this->position = position; RecalculateViewMatrix(); };
const float& GetRotation() const { return rotation; };
void SetRotation(float rotation) { this->rotation = rotation; RecalculateViewMatrix(); };
const glm::mat4& GetProjectionMatrix() const { return projection_matrix; };
const glm::mat4& GetViewMatrix() const { return view_matrix; };
const glm::mat4& GetViewProjectionMatrix() const { return view_projection_matrix; };
private:
void RecalculateViewMatrix();
glm::mat4 projection_matrix;
glm::mat4 view_matrix;
glm::mat4 view_projection_matrix;
glm::vec3 position{0.0f};
float rotation = 0.0f;
};
}
#endif // CAMERA_HPP

View File

@@ -0,0 +1,46 @@
#ifndef ORTHOGRAPHIC_CAMERA_CONTROLLER_HPP
#define ORTHOGRAPHIC_CAMERA_CONTROLLER_HPP
#include "open_engine/events/application_event.hpp"
#include "open_engine/events/mouse_event.hpp"
#include "open_engine/events/event.hpp"
#include "open_engine/orthographic_camera.hpp"
#include <glm/fwd.hpp>
namespace OpenEngine {
class OrthographicCameraController
{
public:
OrthographicCameraController(float ratio, float zoom);
void OnUpdate();
void OnEvent(Event& e);
const OrthographicCamera& GetCamera() const { return camera; };
OrthographicCamera GetCamera() { return camera;};
float GetZoom() const { return zoom; }
void SetZoom(float level) { zoom = level; };
private:
bool OnMouseScrolled(MouseScrolledEvent& e);
bool OnWindowResized(WindowResizeEvent& e);
void Translate(const glm::vec3& vector);
void Rotate(float speed);
private:
float aspect_ratio;
float zoom = 1.0f;
OrthographicCamera camera;
bool rotation;
glm::vec3 camera_position = {0.0f, 0.0f, 0.0f};
float camera_rotation = 0.0f;
float translation_speed = 5.0f, rotation_speed = 180.0f;
};
}
#endif // ORTHOGRAPHIC_CAMERA_CONTROLLER_HPP

View File

@@ -0,0 +1,13 @@
#ifndef PCH_HPP
#define PCH_HPP
#include "logging.hpp"
#include <functional>
#include <iostream>
#include <sstream>
#include <memory>
#include <array>
#endif // PCH_HPP

View File

@@ -0,0 +1,220 @@
let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/projects/open_engine/open_engine
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
let s:shortmess_save = &shortmess
if &shortmess =~ 'A'
set shortmess=aoOA
else
set shortmess=aoO
endif
badd +1 ~/projects/open_engine/open_engine
badd +170 ~/projects/open_engine/open_engine/src/open_engine/imgui/imgui_layer.cpp
badd +4 ~/projects/open_engine/open_engine/include/open_engine/opengl/imgui_glfw.h
badd +35 ~/projects/open_engine/open_engine/include/open_engine/opengl/imgui_opengl.h
badd +23 ~/projects/open_engine/open_engine/src/open_engine/application.cpp
badd +47 ~/projects/open_engine/open_engine/CMakeLists.txt
badd +12 ~/projects/open_engine/open_engine/include/open_engine/imgui/imgui_layer.hpp
badd +123 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_opengl.cpp
badd +89 ~/.conan2/p/b/imgui15e51a8fb5246/p/include/imgui.h
badd +7 ~/projects/open_engine/open_engine/.envrc
badd +5 ~/projects/open_engine/open_engine/include/open_engine/core.hpp
badd +11 ~/.conan2/p/b/imgui15e51a8fb5246/p/include/imgui_export_headers.h
badd +1 ~/projects/open_engine/open_engine/src/open_engine/opengl/build_opengl.cpp
badd +4 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_build.cpp
badd +1 ~/projects/open_engine/open_engine/conanfile.txt
badd +1 ~/projects/open_engine/open_engine/build/imguiTargets.cmake
badd +8 ~/projects/open_engine/open_engine/include/open_engine/logging.hpp
badd +4 ~/projects/open_engine/open_engine/src/open_engine/logging.cpp
badd +110 ~/projects/open_engine/open_engine/src/open_engine/opengl/imgui_glfw.cpp
badd +1 ~/projects/open_engine/open_engine/include/open_engine/application.hpp
badd +21 ~/projects/open_engine/open_engine/src/open_engine/window/linux_window.cpp
badd +24 ~/projects/open_engine/open_engine/include/open_engine/window/window.hpp
badd +27 ~/projects/open_engine/open_engine/include/open_engine/window/linux_window.hpp
badd +7 ~/projects/open_engine/open_engine/include/open_engine/renderer/GraphicsContext.hpp
badd +12 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_context.hpp
badd +10 ~/projects/open_engine/open_engine/src/open_engine/input/linux_input.cpp
badd +17 ~/projects/open_engine/open_engine/src/open_engine/opengl/opengl_context.cpp
badd +3295 ~/projects/open_engine/open_engine/vendor/glad/include/glad/glad.h
badd +148 ~/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c
badd +13 ~/projects/open_engine/open_engine/include/open_engine/renderer/graphics_context.hpp
badd +80 ~/projects/open_engine/open_engine/src/open_engine/opengl/opengl_shader.cpp
badd +8 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_shader.hpp
badd +8 ~/projects/open_engine/open_engine/include/open_engine/renderer/shader.hpp
badd +1 ~/projects/open_engine/open_engine/src/open_engine/renderer/shader.cpp
badd +1 ~/projects/open_engine/open_engine/include/open_engine/pch.hpp
badd +3 ~/projects/open_engine/open_engine/assets/shaders/fragment.frag.old
badd +1 ~/projects/open_engine/open_engine/assets/shaders/fragment.frag
badd +5 ~/projects/open_engine/open_engine/assets/shaders/vertex.vert
badd +1 ~/projects/open_engine/open_engine/\'
badd +66 ~/projects/open_engine/open_engine/include/open_engine/renderer/buffer.hpp
badd +56 ~/projects/open_engine/open_engine/src/open_engine/renderer/buffer.cpp
badd +18 ~/projects/open_engine/open_engine/include/open_engine/opengl/opengl_buffer.hpp
badd +34 ~/projects/open_engine/open_engine/src/open_engine/opengl/opengl_buffer.cpp
badd +2 ~/projects/open_engine/open_engine/src/open_engine/renderer/renderer.cpp
badd +5 ~/projects/open_engine/open_engine/include/open_engine/renderer/renderer.hpp
badd +1 ~/projects/open_engine/open_engine/src/open_engine/layer.cpp
badd +12 ~/projects/open_engine/open_engine/include/open_engine/layer.hpp
badd +21 ~/projects/open_engine/open_engine/include/open_engine/events/event.hpp
badd +11 ~/projects/open_engine/open_engine/src/open_engine/renderer/vertex_array.cpp
badd +8 ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp
badd +27 ~/projects/open_engine/open_engine/src/open_engine/layer_stack.cpp
badd +1 ~/projects/open_engine/open_engine/include/open_engine/layer_stack.hpp
argglobal
%argdel
$argadd ~/projects/open_engine/open_engine
set stal=2
tabnew +setlocal\ bufhidden=wipe
tabrewind
edit ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe 'vert 1resize ' . ((&columns * 127 + 127) / 255)
exe 'vert 2resize ' . ((&columns * 127 + 127) / 255)
argglobal
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 8 - ((7 * winheight(0) + 13) / 27)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 8
normal! 0
lcd ~/projects/open_engine/open_engine
wincmd w
argglobal
if bufexists(fnamemodify("~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp", ":p")) | buffer ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp | else | edit ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp | endif
if &buftype ==# 'terminal'
silent file ~/projects/open_engine/open_engine/include/open_engine/renderer/vertex_array.hpp
endif
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 1 - ((0 * winheight(0) + 13) / 27)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 1
normal! 0
lcd ~/projects/open_engine/open_engine
wincmd w
exe 'vert 1resize ' . ((&columns * 127 + 127) / 255)
exe 'vert 2resize ' . ((&columns * 127 + 127) / 255)
tabnext
edit ~/projects/open_engine/open_engine/assets/shaders/fragment.frag
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe 'vert 1resize ' . ((&columns * 254 + 127) / 255)
exe 'vert 2resize ' . ((&columns * 0 + 127) / 255)
argglobal
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 11 - ((8 * winheight(0) + 13) / 27)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 11
normal! 020|
lcd ~/projects/open_engine/open_engine
wincmd w
argglobal
if bufexists(fnamemodify("~/projects/open_engine/open_engine/assets/shaders/vertex.vert", ":p")) | buffer ~/projects/open_engine/open_engine/assets/shaders/vertex.vert | else | edit ~/projects/open_engine/open_engine/assets/shaders/vertex.vert | endif
if &buftype ==# 'terminal'
silent file ~/projects/open_engine/open_engine/assets/shaders/vertex.vert
endif
balt ~/projects/open_engine/open_engine/assets/shaders/fragment.frag
setlocal foldmethod=manual
setlocal foldexpr=0
setlocal foldmarker={{{,}}}
setlocal foldignore=#
setlocal foldlevel=0
setlocal foldminlines=1
setlocal foldnestmax=20
setlocal foldenable
silent! normal! zE
let &fdl = &fdl
let s:l = 12 - ((11 * winheight(0) + 13) / 27)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 12
normal! 022|
lcd ~/projects/open_engine/open_engine
wincmd w
exe 'vert 1resize ' . ((&columns * 254 + 127) / 255)
exe 'vert 2resize ' . ((&columns * 0 + 127) / 255)
tabnext 1
set stal=1
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20
let &shortmess = s:shortmess_save
let &winminheight = s:save_winminheight
let &winminwidth = s:save_winminwidth
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
set hlsearch
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

View File

@@ -0,0 +1,87 @@
#ifndef BUFFER_HPP
#define BUFFER_HPP
#include <cstdint>
#include <vector>
#include <string>
namespace OpenEngine {
enum class ShaderDataType
{
Float = 0, Float2, Float3, Float4, Mat3, Mat4, Int, Int2, Int3, Int4, Bool
};
uint32_t shaderDataTypeSize(ShaderDataType type);
struct BufferLayoutElement
{
std::string name;
ShaderDataType type;
uint32_t size;
uint32_t offset;
bool normalized;
BufferLayoutElement() {};
BufferLayoutElement(ShaderDataType type, const std::string& name, bool normalized = false)
: name(name), type(type), size(shaderDataTypeSize(type)), offset(0), normalized(normalized)
{
}
uint32_t GetComponentCount() const;
};
class BufferLayout
{
public:
BufferLayout() {};
BufferLayout(const std::initializer_list<BufferLayoutElement>& elements)
: elements(elements)
{
CalculateOffsetsAndStride();
}
inline uint32_t GetStride() const { return stride; }
inline const std::vector<BufferLayoutElement>& GetElements() const { return elements; }
std::vector<BufferLayoutElement>::iterator begin() { return elements.begin(); }
std::vector<BufferLayoutElement>::iterator end() { return elements.end(); }
std::vector<BufferLayoutElement>::const_iterator begin() const { return elements.begin(); }
std::vector<BufferLayoutElement>::const_iterator end() const { return elements.end(); }
private:
void CalculateOffsetsAndStride();
std::vector<BufferLayoutElement> elements;
uint32_t stride = 0;
};
class VertexBuffer
{
public:
virtual ~VertexBuffer() = default;
virtual void Bind() const = 0;
virtual void UnBind() const = 0;
virtual const BufferLayout& GetLayout() const = 0;
virtual void SetLayout(const BufferLayout& layout) = 0;
static VertexBuffer* Create(float* vertices, uint32_t size);
};
class IndexBuffer
{
public:
virtual ~IndexBuffer() = default;
virtual void Bind() const = 0;
virtual void UnBind() const = 0;
virtual uint32_t GetCount() const = 0;
static IndexBuffer* Create(uint32_t* indices, uint32_t size);
};
}
#endif // BUFFER_HPP

View File

@@ -0,0 +1,13 @@
#ifndef GRAPHICS_CONTEXT_HPP
#define GRAPHICS_CONTEXT_HPP
namespace OpenEngine {
class GraphicsContext
{
public:
virtual void Init() = 0;
virtual void SwapBuffers() = 0;
};
}
#endif // GRAPHICS_CONTEXT_HPP

View File

@@ -0,0 +1,43 @@
#ifndef RENDER_COMMAND_HPP
#define RENDER_COMMAND_HPP
#include "../renderer/renderer_api.hpp"
#include "../opengl/opengl_renderer_api.hpp"
#include <cstdint>
namespace OpenEngine {
class RenderCommand
{
public:
inline static void Init()
{
api->Init();
}
inline static void SetClearColor(const glm::vec4& color)
{
api->SetClearColor(color);
}
inline static void Clear()
{
api->Clear();
}
inline static void DrawIndexed(const std::shared_ptr<VertexArray>& vertex_array)
{
api->DrawIndexed(vertex_array);
}
inline static void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
{
api->SetViewport(x, y, width, height);
}
private:
static inline RendererAPI* api = new OpenGLRendererAPI();
};
}
#endif // RENDER_COMMAND_HPP

View File

@@ -0,0 +1,39 @@
#ifndef RENDERER_HPP
#define RENDERER_HPP
#include "../renderer/renderer_api.hpp"
#include "../renderer/vertex_array.hpp"
#include "../orthographic_camera.hpp"
#include <open_engine/renderer/shader.hpp>
#include <glm/glm.hpp>
#include <cstdint>
namespace OpenEngine {
class Renderer
{
public:
static void Init();
static void OnWindowResize(uint32_t width, uint32_t height);
static void BeginScene(const OrthographicCamera& camera);
static void EndScene();
static void Submit(const Ref<Shader> shader,
const Ref<VertexArray>& vertex_array,
const glm::mat4& transform = glm::mat4(1.0f));
inline static RendererAPI::API GetApi() { return RendererAPI::GetAPI(); };
private:
struct SceneData
{
glm::mat4 view_projection_matrix;
};
inline static SceneData* scene_data = new SceneData;
};
}
#endif // RENDERER_HPP

View File

@@ -0,0 +1,34 @@
#ifndef RENDERER_API_HPP
#define RENDERER_API_HPP
#include "../renderer/vertex_array.hpp"
#include <glm/glm.hpp>
#include <memory>
namespace OpenEngine {
class RendererAPI
{
public:
enum class API {
None,
OpenGL
};
virtual void Init() = 0;
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) = 0;
virtual void SetClearColor(const glm::vec4& color) = 0;
virtual void Clear() = 0;
virtual void DrawIndexed(const std::shared_ptr<VertexArray>& vertex_array) = 0;
static inline API GetAPI() { return api; };
private:
static inline API api = RendererAPI::API::OpenGL;
};
}
#endif // RENDERER_API_HPP

View File

@@ -0,0 +1,41 @@
#ifndef SHADER_HPP
#define SHADER_HPP
#include <glm/glm.hpp>
#include <string>
#include <unordered_map>
namespace OpenEngine {
class Shader
{
public:
static Ref<Shader> Create(const std::string& shader_path);
static Ref<Shader> Create(const std::string& name, const std::string& vertex_src, const std::string& frament_src);
virtual ~Shader() = default;
virtual const std::string& GetName() const = 0;
virtual void Bind() const = 0;
virtual void Unbind() const = 0;
};
class ShaderLibrary
{
public:
void Add(const Ref<Shader>& shader);
void Add(const std::string& name, const Ref<Shader>& shader);
Ref<Shader> Load(const std::string& path);
Ref<Shader> Load(const std::string& name, const std::string& path);
Ref<Shader> Get(const std::string& name) const;
bool Exists(const std::string& name) const;
private:
std::unordered_map<std::string, Ref<Shader>> shaders;
};
}
#endif // SHADER_HPP

View File

@@ -0,0 +1,26 @@
#ifndef TEXTURE_HPP
#define TEXTURE_HPP
#include "open_engine/core.hpp"
#include <cstdint>
namespace OpenEngine {
class Texture
{
public:
virtual ~Texture() = default;
virtual uint32_t GetWidth() const = 0;
virtual uint32_t GetHeight() const = 0;
virtual void Bind(uint32_t slot = 0) const = 0;
};
class Texture2D : public Texture
{
public:
static Ref<Texture2D> Create(const std::string& path);
};
}
#endif // TEXTURE_HPP

View File

@@ -0,0 +1,27 @@
#ifndef VERTEX_ARRAY_HPP
#define VERTEX_ARRAY_HPP
#include "../renderer/buffer.hpp"
#include <memory>
namespace OpenEngine {
class VertexArray
{
public:
virtual ~VertexArray() = default;
virtual void Bind() const = 0;
virtual void UnBind() const = 0;
virtual void AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertex_buffer) = 0;
virtual void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& index_buffer) = 0;
virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const = 0;
virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const = 0;
static VertexArray* Create();
};
}
#endif // VERTEX_ARRAY_HPP

View File

@@ -0,0 +1,42 @@
#ifndef LINUX_WINDOW_HPP
#define LINUX_WINDOW_HPP
#include <core.hpp>
#include <window/window.hpp>
#include <renderer/graphics_context.hpp>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
namespace OpenEngine {
class OE_API LinuxWindow
: public Window
{
public:
LinuxWindow(const WindowProps& props);
virtual ~LinuxWindow();
void OnUpdate() override;
inline unsigned int GetWidth() const override { return data.width; }
inline unsigned int GetHeight() const override { return data.height; }
inline void SetEventCallback(const EventCallbackFunction& callback) override
{ data.event_callback = callback; }
void SetVSync(bool enabled) override;
bool IsVSync() const override;
inline virtual void* GetNativeWindow() const override { return gl_window; };
private:
virtual void Init(const WindowProps& props);
virtual void Shutdown();
WindowData data;
GLFWwindow* gl_window;
GraphicsContext* context;
};
}
#endif // LINUX_WINDOW_HPP

View File

@@ -0,0 +1,56 @@
#ifndef WINDOW_HPP
#define WINDOW_HPP
#include "../core.hpp"
#include "../events/event.hpp"
#include <functional>
#include <string>
namespace OpenEngine {
struct WindowProps
{
std::string title;
unsigned int width;
unsigned int height;
WindowProps(const std::string& title = "OpenEngine",
unsigned int width = 1280,
unsigned int height = 729)
:title(title), width(width), height(height)
{
}
};
class OE_API Window
{
public:
using EventCallbackFunction = std::function<void(Event&)>;
struct WindowData
{
std::string title;
unsigned int width, height;
bool vsync;
EventCallbackFunction event_callback;
};
virtual ~Window() = default;
virtual void OnUpdate() = 0;
virtual unsigned int GetWidth() const = 0;
virtual unsigned int GetHeight() const = 0;
virtual void SetEventCallback(const EventCallbackFunction& callback) = 0;
virtual void SetVSync(bool enabled) = 0;
virtual bool IsVSync() const = 0;
virtual void* GetNativeWindow() const = 0;
static Window* Create(const WindowProps& props = WindowProps());
};
}
#endif // WINDOW_HPP

31
open_engine/justfile Executable file
View File

@@ -0,0 +1,31 @@
default: build_and_run
alias c := config
alias b := build
alias r := run
alias br := build_and_run
alias cln := clean
alias v := valgrind
run:
@echo Running ${BINARY_NAME}
@./build/${BINARY_NAME}
build:
time cmake --build build --config ${BUILD_TYPE}
build_and_run: build
just run
clean:
rm build -rf
config:
@echo Configuring project with build type: ${BUILD_TYPE}
cmake -S . -G Ninja -B build \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=${COMPILE_COMMANDS} \
; cp build/compile_commands.json .
valgrind: build
valgrind --track-origins=yes ./build/${BINARY_NAME}

View File

@@ -0,0 +1,16 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 4.2
# Relative path conversion top directories.
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/erris/projects/open_engine")
set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/erris/projects/open_engine")
# Force unix paths in dependencies.
set(CMAKE_FORCE_UNIX_PATHS 1)
# The C and CXX include file regular expressions for this directory.
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})

View File

@@ -0,0 +1,23 @@
# Consider dependencies only in project.
set(CMAKE_DEPENDS_IN_PROJECT_ONLY OFF)
# The set of languages for which implicit dependencies are needed:
set(CMAKE_DEPENDS_LANGUAGES
)
# The set of dependency files which are needed:
set(CMAKE_DEPENDS_DEPENDENCY_FILES
"/home/erris/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c" "open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o" "gcc" "open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o.d"
)
# Targets to which this target links which contain Fortran sources.
set(CMAKE_Fortran_TARGET_LINKED_INFO_FILES
)
# Targets to which this target links which contain Fortran sources.
set(CMAKE_Fortran_TARGET_FORWARD_LINKED_INFO_FILES
)
# Fortran module output directory.
set(CMAKE_Fortran_TARGET_MODULE_DIR "")

View File

@@ -0,0 +1,114 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 4.2
# Delete rule output on recipe failure.
.DELETE_ON_ERROR:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Disable VCS-based implicit rules.
% : %,v
# Disable VCS-based implicit rules.
% : RCS/%
# Disable VCS-based implicit rules.
% : RCS/%,v
# Disable VCS-based implicit rules.
% : SCCS/s.%
# Disable VCS-based implicit rules.
% : s.%
.SUFFIXES: .hpux_make_needs_suffix_list
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
#Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/erris/projects/open_engine
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/erris/projects/open_engine
# Include any dependencies generated for this target.
include open_engine/lib/CMakeFiles/glad.dir/depend.make
# Include any dependencies generated by the compiler for this target.
include open_engine/lib/CMakeFiles/glad.dir/compiler_depend.make
# Include the progress variables for this target.
include open_engine/lib/CMakeFiles/glad.dir/progress.make
# Include the compile flags for this target's objects.
include open_engine/lib/CMakeFiles/glad.dir/flags.make
open_engine/lib/CMakeFiles/glad.dir/codegen:
.PHONY : open_engine/lib/CMakeFiles/glad.dir/codegen
open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o: open_engine/lib/CMakeFiles/glad.dir/flags.make
open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o: open_engine/vendor/glad/src/glad/glad.c
open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o: open_engine/lib/CMakeFiles/glad.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/home/erris/projects/open_engine/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building C object open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o"
cd /home/erris/projects/open_engine/open_engine/lib && /usr/bin/clang $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -MD -MT open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o -MF CMakeFiles/glad.dir/src/glad/glad.c.o.d -o CMakeFiles/glad.dir/src/glad/glad.c.o -c /home/erris/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c
open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Preprocessing C source to CMakeFiles/glad.dir/src/glad/glad.c.i"
cd /home/erris/projects/open_engine/open_engine/lib && /usr/bin/clang $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -E /home/erris/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c > CMakeFiles/glad.dir/src/glad/glad.c.i
open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Compiling C source to assembly CMakeFiles/glad.dir/src/glad/glad.c.s"
cd /home/erris/projects/open_engine/open_engine/lib && /usr/bin/clang $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -S /home/erris/projects/open_engine/open_engine/vendor/glad/src/glad/glad.c -o CMakeFiles/glad.dir/src/glad/glad.c.s
# Object files for target glad
glad_OBJECTS = \
"CMakeFiles/glad.dir/src/glad/glad.c.o"
# External object files for target glad
glad_EXTERNAL_OBJECTS =
open_engine/lib/libglad.a: open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o
open_engine/lib/libglad.a: open_engine/lib/CMakeFiles/glad.dir/build.make
open_engine/lib/libglad.a: open_engine/lib/CMakeFiles/glad.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --bold --progress-dir=/home/erris/projects/open_engine/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking C static library libglad.a"
cd /home/erris/projects/open_engine/open_engine/lib && $(CMAKE_COMMAND) -P CMakeFiles/glad.dir/cmake_clean_target.cmake
cd /home/erris/projects/open_engine/open_engine/lib && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/glad.dir/link.txt --verbose=$(VERBOSE)
# Rule to build all files generated by this target.
open_engine/lib/CMakeFiles/glad.dir/build: open_engine/lib/libglad.a
.PHONY : open_engine/lib/CMakeFiles/glad.dir/build
open_engine/lib/CMakeFiles/glad.dir/clean:
cd /home/erris/projects/open_engine/open_engine/lib && $(CMAKE_COMMAND) -P CMakeFiles/glad.dir/cmake_clean.cmake
.PHONY : open_engine/lib/CMakeFiles/glad.dir/clean
open_engine/lib/CMakeFiles/glad.dir/depend:
cd /home/erris/projects/open_engine && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/erris/projects/open_engine /home/erris/projects/open_engine/open_engine/vendor/glad /home/erris/projects/open_engine /home/erris/projects/open_engine/open_engine/lib /home/erris/projects/open_engine/open_engine/lib/CMakeFiles/glad.dir/DependInfo.cmake "--color=$(COLOR)" glad
.PHONY : open_engine/lib/CMakeFiles/glad.dir/depend

View File

@@ -0,0 +1,11 @@
file(REMOVE_RECURSE
"CMakeFiles/glad.dir/src/glad/glad.c.o"
"CMakeFiles/glad.dir/src/glad/glad.c.o.d"
"libglad.a"
"libglad.pdb"
)
# Per-language clean rules from dependency scanning.
foreach(lang C)
include(CMakeFiles/glad.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()

View File

@@ -0,0 +1,3 @@
file(REMOVE_RECURSE
"libglad.a"
)

View File

@@ -0,0 +1,2 @@
# Empty compiler generated dependencies file for glad.
# This may be replaced when dependencies are built.

View File

@@ -0,0 +1,2 @@
# CMAKE generated file: DO NOT EDIT!
# Timestamp file for compiler generated dependencies management for glad.

View File

@@ -0,0 +1,2 @@
# Empty dependencies file for glad.
# This may be replaced when dependencies are built.

View File

@@ -0,0 +1,10 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 4.2
# compile C with /usr/bin/clang
C_DEFINES = -DOE_ENABLE_ASSERTS
C_INCLUDES = -I/home/erris/projects/open_engine/open_engine/vendor/glad/include
C_FLAGS =

View File

@@ -0,0 +1,2 @@
/usr/bin/llvm-ar qc libglad.a CMakeFiles/glad.dir/src/glad/glad.c.o
/usr/bin/llvm-ranlib libglad.a

View File

@@ -0,0 +1,3 @@
CMAKE_PROGRESS_1 = 1
CMAKE_PROGRESS_2 = 2

View File

@@ -0,0 +1 @@
2

182
open_engine/lib/Makefile Normal file
View File

@@ -0,0 +1,182 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 4.2
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Disable VCS-based implicit rules.
% : %,v
# Disable VCS-based implicit rules.
% : RCS/%
# Disable VCS-based implicit rules.
% : RCS/%,v
# Disable VCS-based implicit rules.
% : SCCS/s.%
# Disable VCS-based implicit rules.
% : s.%
.SUFFIXES: .hpux_make_needs_suffix_list
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
#Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/erris/projects/open_engine
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/erris/projects/open_engine
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
/usr/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# The main all target
all: cmake_check_build_system
cd /home/erris/projects/open_engine && $(CMAKE_COMMAND) -E cmake_progress_start /home/erris/projects/open_engine/CMakeFiles /home/erris/projects/open_engine/open_engine/lib//CMakeFiles/progress.marks
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 open_engine/lib/all
$(CMAKE_COMMAND) -E cmake_progress_start /home/erris/projects/open_engine/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 open_engine/lib/clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 open_engine/lib/preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 open_engine/lib/preinstall
.PHONY : preinstall/fast
# clear depends
depend:
cd /home/erris/projects/open_engine && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
# Convenience name for target.
open_engine/lib/CMakeFiles/glad.dir/rule:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 open_engine/lib/CMakeFiles/glad.dir/rule
.PHONY : open_engine/lib/CMakeFiles/glad.dir/rule
# Convenience name for target.
glad: open_engine/lib/CMakeFiles/glad.dir/rule
.PHONY : glad
# fast build rule for target.
glad/fast:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f open_engine/lib/CMakeFiles/glad.dir/build.make open_engine/lib/CMakeFiles/glad.dir/build
.PHONY : glad/fast
src/glad/glad.o: src/glad/glad.c.o
.PHONY : src/glad/glad.o
# target to build an object file
src/glad/glad.c.o:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f open_engine/lib/CMakeFiles/glad.dir/build.make open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.o
.PHONY : src/glad/glad.c.o
src/glad/glad.i: src/glad/glad.c.i
.PHONY : src/glad/glad.i
# target to preprocess a source file
src/glad/glad.c.i:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f open_engine/lib/CMakeFiles/glad.dir/build.make open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.i
.PHONY : src/glad/glad.c.i
src/glad/glad.s: src/glad/glad.c.s
.PHONY : src/glad/glad.s
# target to generate assembly for a file
src/glad/glad.c.s:
cd /home/erris/projects/open_engine && $(MAKE) $(MAKESILENT) -f open_engine/lib/CMakeFiles/glad.dir/build.make open_engine/lib/CMakeFiles/glad.dir/src/glad/glad.c.s
.PHONY : src/glad/glad.c.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... rebuild_cache"
@echo "... glad"
@echo "... src/glad/glad.o"
@echo "... src/glad/glad.i"
@echo "... src/glad/glad.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
cd /home/erris/projects/open_engine && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system

View File

@@ -0,0 +1,50 @@
# Install script for directory: /home/erris/projects/open_engine/open_engine/vendor/glad
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Install shared libraries without execute permission?
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
set(CMAKE_INSTALL_SO_NO_EXE "0")
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
# Set path to fallback-tool for dependency-resolution.
if(NOT DEFINED CMAKE_OBJDUMP)
set(CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
endif()
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
"${CMAKE_INSTALL_MANIFEST_FILES}")
if(CMAKE_INSTALL_LOCAL_ONLY)
file(WRITE "/home/erris/projects/open_engine/open_engine/lib/install_local_manifest.txt"
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
endif()

View File

@@ -0,0 +1,84 @@
#include <pch.hpp>
#include <core.hpp>
#include <events/application_event.hpp>
#include <imgui/imgui_layer.hpp>
#include <core/time.hpp>
#include <renderer/renderer.hpp>
#include <application.hpp>
#include <input/input_system.hpp>
#include <imgui.h>
namespace OpenEngine {
Application::Application()
{
OE_CORE_ASSERT(!instance, "Application already exists!");
instance = this;
window = std::unique_ptr<Window>(Window::Create());
window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent));
Renderer::Init();
imgui_layer = new ImGuiLayer();
PushOverlay(imgui_layer);
}
void Application::Run()
{
while(running) {
Time::Get().Update();
for (Layer* layer : layer_stack)
layer->OnUpdate();
imgui_layer->Begin();
for (Layer* layer : layer_stack)
layer->OnImGuiRender();
imgui_layer->End();
window->OnUpdate();
}
}
void Application::OnEvent(Event& event)
{
EventDispatcher dispatcher(event);
dispatcher.Dispatch<WindowCloseEvent>(BIND_EVENT_FN(Application::OnWindowClose));
dispatcher.Dispatch<WindowResizeEvent>(BIND_EVENT_FN(Application::OnWindowResize));
for (auto it = layer_stack.end(); it != layer_stack.begin();) {
(*--it)->OnEvent(event);
if (event.handled)
break;
}
}
bool Application::OnWindowClose(WindowCloseEvent& event)
{
running = false;
return true;
}
bool Application::OnWindowResize(WindowResizeEvent& event)
{
Renderer::OnWindowResize(event.GetWidth(), event.GetHeight());
return false;
}
void Application::PushLayer(Layer* layer)
{
layer_stack.PushLayer(layer);
}
void Application::PushOverlay(Layer* overlay)
{
layer_stack.PushOverlay(overlay);
}
}

View File

@@ -0,0 +1,16 @@
#include <pch.hpp>
#include <core/time.hpp>
namespace OpenEngine {
std::unique_ptr<Time> Time::instance = nullptr;
void Time::Update()
{
std::chrono::high_resolution_clock::time_point current_frame
= std::chrono::high_resolution_clock::now();
delta_time = (current_frame - previous_frame);
previous_frame = current_frame;
}
}

View File

@@ -0,0 +1,24 @@
#include <events/application_event.hpp>
namespace OpenEngine {
std::string WindowResizeEvent::ToString() const
{
std::stringstream ss;
ss << "WindowResizeEvent: " << width << ", " << height;
return ss.str();
}
std::string WindowCloseEvent::ToString() const
{
std::stringstream ss;
ss << "WindowCloseEvent";
return ss.str();
}
std::string AppUpdateEvent::ToString() const
{
std::stringstream ss;
ss << "AppUpdateEvent";
return ss.str();
}
}

View File

@@ -0,0 +1,25 @@
#include <events/key_event.hpp>
namespace OpenEngine {
std::string KeyPressedEvent::ToString() const
{
std::stringstream ss;
ss << "KeyPressedEvent: " << keycode << " (" << repeat_count << " repeat(s))";
return ss.str();
}
std::string KeyReleasedEvent::ToString() const
{
std::stringstream ss;
ss << "KeyReleasedEvent: " << keycode;
return ss.str();
}
std::string KeyTypedEvent::ToString() const
{
std::stringstream ss;
ss << "KeyTypedEvent: " << keycode;
return ss.str();
}
}

View File

@@ -0,0 +1,31 @@
#include <events/mouse_event.hpp>
namespace OpenEngine {
std::string MouseMovedEvent::ToString() const
{
std::stringstream ss;
ss << "MouseMovedEvent: " << mouse_x << ", " << mouse_y;
return ss.str();
}
std::string MouseScrolledEvent::ToString() const
{
std::stringstream ss;
ss << "MouseScrolledEvent: " << GetXOffset() << ", " << GetYOffset();
return ss.str();
}
std::string MouseButtonPressedEvent::ToString() const
{
std::stringstream ss;
ss << "MouseButtonPressedEvent: " << button;
return ss.str();
}
std::string MouseButtonReleasedEvent::ToString() const
{
std::stringstream ss;
ss << "MouseButtonReleasedEvent: " << button;
return ss.str();
}
}

View File

@@ -0,0 +1,324 @@
#include <pch.hpp>
#include "application.hpp"
#include "layer.hpp"
#include <imgui/imgui_layer.hpp>
#include "opengl/imgui_opengl.h"
#include "opengl/imgui_glfw.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
namespace OpenEngine {
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode)
{
IM_UNUSED(scancode);
switch (keycode)
{
case GLFW_KEY_TAB: return ImGuiKey_Tab;
case GLFW_KEY_LEFT: return ImGuiKey_LeftArrow;
case GLFW_KEY_RIGHT: return ImGuiKey_RightArrow;
case GLFW_KEY_UP: return ImGuiKey_UpArrow;
case GLFW_KEY_DOWN: return ImGuiKey_DownArrow;
case GLFW_KEY_PAGE_UP: return ImGuiKey_PageUp;
case GLFW_KEY_PAGE_DOWN: return ImGuiKey_PageDown;
case GLFW_KEY_HOME: return ImGuiKey_Home;
case GLFW_KEY_END: return ImGuiKey_End;
case GLFW_KEY_INSERT: return ImGuiKey_Insert;
case GLFW_KEY_DELETE: return ImGuiKey_Delete;
case GLFW_KEY_BACKSPACE: return ImGuiKey_Backspace;
case GLFW_KEY_SPACE: return ImGuiKey_Space;
case GLFW_KEY_ENTER: return ImGuiKey_Enter;
case GLFW_KEY_ESCAPE: return ImGuiKey_Escape;
case GLFW_KEY_APOSTROPHE: return ImGuiKey_Apostrophe;
case GLFW_KEY_COMMA: return ImGuiKey_Comma;
case GLFW_KEY_MINUS: return ImGuiKey_Minus;
case GLFW_KEY_PERIOD: return ImGuiKey_Period;
case GLFW_KEY_SLASH: return ImGuiKey_Slash;
case GLFW_KEY_SEMICOLON: return ImGuiKey_Semicolon;
case GLFW_KEY_EQUAL: return ImGuiKey_Equal;
case GLFW_KEY_LEFT_BRACKET: return ImGuiKey_LeftBracket;
case GLFW_KEY_BACKSLASH: return ImGuiKey_Backslash;
case GLFW_KEY_WORLD_1: return ImGuiKey_Oem102;
case GLFW_KEY_WORLD_2: return ImGuiKey_Oem102;
case GLFW_KEY_RIGHT_BRACKET: return ImGuiKey_RightBracket;
case GLFW_KEY_GRAVE_ACCENT: return ImGuiKey_GraveAccent;
case GLFW_KEY_CAPS_LOCK: return ImGuiKey_CapsLock;
case GLFW_KEY_SCROLL_LOCK: return ImGuiKey_ScrollLock;
case GLFW_KEY_NUM_LOCK: return ImGuiKey_NumLock;
case GLFW_KEY_PRINT_SCREEN: return ImGuiKey_PrintScreen;
case GLFW_KEY_PAUSE: return ImGuiKey_Pause;
case GLFW_KEY_KP_0: return ImGuiKey_Keypad0;
case GLFW_KEY_KP_1: return ImGuiKey_Keypad1;
case GLFW_KEY_KP_2: return ImGuiKey_Keypad2;
case GLFW_KEY_KP_3: return ImGuiKey_Keypad3;
case GLFW_KEY_KP_4: return ImGuiKey_Keypad4;
case GLFW_KEY_KP_5: return ImGuiKey_Keypad5;
case GLFW_KEY_KP_6: return ImGuiKey_Keypad6;
case GLFW_KEY_KP_7: return ImGuiKey_Keypad7;
case GLFW_KEY_KP_8: return ImGuiKey_Keypad8;
case GLFW_KEY_KP_9: return ImGuiKey_Keypad9;
case GLFW_KEY_KP_DECIMAL: return ImGuiKey_KeypadDecimal;
case GLFW_KEY_KP_DIVIDE: return ImGuiKey_KeypadDivide;
case GLFW_KEY_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
case GLFW_KEY_KP_SUBTRACT: return ImGuiKey_KeypadSubtract;
case GLFW_KEY_KP_ADD: return ImGuiKey_KeypadAdd;
case GLFW_KEY_KP_ENTER: return ImGuiKey_KeypadEnter;
case GLFW_KEY_KP_EQUAL: return ImGuiKey_KeypadEqual;
case GLFW_KEY_LEFT_SHIFT: return ImGuiKey_LeftShift;
case GLFW_KEY_LEFT_CONTROL: return ImGuiKey_LeftCtrl;
case GLFW_KEY_LEFT_ALT: return ImGuiKey_LeftAlt;
case GLFW_KEY_LEFT_SUPER: return ImGuiKey_LeftSuper;
case GLFW_KEY_RIGHT_SHIFT: return ImGuiKey_RightShift;
case GLFW_KEY_RIGHT_CONTROL: return ImGuiKey_RightCtrl;
case GLFW_KEY_RIGHT_ALT: return ImGuiKey_RightAlt;
case GLFW_KEY_RIGHT_SUPER: return ImGuiKey_RightSuper;
case GLFW_KEY_MENU: return ImGuiKey_Menu;
case GLFW_KEY_0: return ImGuiKey_0;
case GLFW_KEY_1: return ImGuiKey_1;
case GLFW_KEY_2: return ImGuiKey_2;
case GLFW_KEY_3: return ImGuiKey_3;
case GLFW_KEY_4: return ImGuiKey_4;
case GLFW_KEY_5: return ImGuiKey_5;
case GLFW_KEY_6: return ImGuiKey_6;
case GLFW_KEY_7: return ImGuiKey_7;
case GLFW_KEY_8: return ImGuiKey_8;
case GLFW_KEY_9: return ImGuiKey_9;
case GLFW_KEY_A: return ImGuiKey_A;
case GLFW_KEY_B: return ImGuiKey_B;
case GLFW_KEY_C: return ImGuiKey_C;
case GLFW_KEY_D: return ImGuiKey_D;
case GLFW_KEY_E: return ImGuiKey_E;
case GLFW_KEY_F: return ImGuiKey_F;
case GLFW_KEY_G: return ImGuiKey_G;
case GLFW_KEY_H: return ImGuiKey_H;
case GLFW_KEY_I: return ImGuiKey_I;
case GLFW_KEY_J: return ImGuiKey_J;
case GLFW_KEY_K: return ImGuiKey_K;
case GLFW_KEY_L: return ImGuiKey_L;
case GLFW_KEY_M: return ImGuiKey_M;
case GLFW_KEY_N: return ImGuiKey_N;
case GLFW_KEY_O: return ImGuiKey_O;
case GLFW_KEY_P: return ImGuiKey_P;
case GLFW_KEY_Q: return ImGuiKey_Q;
case GLFW_KEY_R: return ImGuiKey_R;
case GLFW_KEY_S: return ImGuiKey_S;
case GLFW_KEY_T: return ImGuiKey_T;
case GLFW_KEY_U: return ImGuiKey_U;
case GLFW_KEY_V: return ImGuiKey_V;
case GLFW_KEY_W: return ImGuiKey_W;
case GLFW_KEY_X: return ImGuiKey_X;
case GLFW_KEY_Y: return ImGuiKey_Y;
case GLFW_KEY_Z: return ImGuiKey_Z;
case GLFW_KEY_F1: return ImGuiKey_F1;
case GLFW_KEY_F2: return ImGuiKey_F2;
case GLFW_KEY_F3: return ImGuiKey_F3;
case GLFW_KEY_F4: return ImGuiKey_F4;
case GLFW_KEY_F5: return ImGuiKey_F5;
case GLFW_KEY_F6: return ImGuiKey_F6;
case GLFW_KEY_F7: return ImGuiKey_F7;
case GLFW_KEY_F8: return ImGuiKey_F8;
case GLFW_KEY_F9: return ImGuiKey_F9;
case GLFW_KEY_F10: return ImGuiKey_F10;
case GLFW_KEY_F11: return ImGuiKey_F11;
case GLFW_KEY_F12: return ImGuiKey_F12;
case GLFW_KEY_F13: return ImGuiKey_F13;
case GLFW_KEY_F14: return ImGuiKey_F14;
case GLFW_KEY_F15: return ImGuiKey_F15;
case GLFW_KEY_F16: return ImGuiKey_F16;
case GLFW_KEY_F17: return ImGuiKey_F17;
case GLFW_KEY_F18: return ImGuiKey_F18;
case GLFW_KEY_F19: return ImGuiKey_F19;
case GLFW_KEY_F20: return ImGuiKey_F20;
case GLFW_KEY_F21: return ImGuiKey_F21;
case GLFW_KEY_F22: return ImGuiKey_F22;
case GLFW_KEY_F23: return ImGuiKey_F23;
case GLFW_KEY_F24: return ImGuiKey_F24;
default: return ImGuiKey_None;
}
}
void setupCatppuccinMochaTheme()
{
ImGuiStyle& style = ImGui::GetStyle();
ImVec4* colors = style.Colors;
// Catppuccin Mocha Palette
// --------------------------------------------------------
const ImVec4 base = ImVec4(0.117f, 0.117f, 0.172f, 1.0f); // #1e1e2e
const ImVec4 mantle = ImVec4(0.109f, 0.109f, 0.156f, 1.0f); // #181825
const ImVec4 surface0 = ImVec4(0.200f, 0.207f, 0.286f, 1.0f); // #313244
const ImVec4 surface1 = ImVec4(0.247f, 0.254f, 0.337f, 1.0f); // #3f4056
const ImVec4 surface2 = ImVec4(0.290f, 0.301f, 0.388f, 1.0f); // #4a4d63
const ImVec4 overlay0 = ImVec4(0.396f, 0.403f, 0.486f, 1.0f); // #65677c
const ImVec4 overlay2 = ImVec4(0.576f, 0.584f, 0.654f, 1.0f); // #9399b2
const ImVec4 text = ImVec4(0.803f, 0.815f, 0.878f, 1.0f); // #cdd6f4
const ImVec4 subtext0 = ImVec4(0.639f, 0.658f, 0.764f, 1.0f); // #a3a8c3
const ImVec4 mauve = ImVec4(0.796f, 0.698f, 0.972f, 1.0f); // #cba6f7
const ImVec4 peach = ImVec4(0.980f, 0.709f, 0.572f, 1.0f); // #fab387
const ImVec4 yellow = ImVec4(0.980f, 0.913f, 0.596f, 1.0f); // #f9e2af
const ImVec4 green = ImVec4(0.650f, 0.890f, 0.631f, 1.0f); // #a6e3a1
const ImVec4 teal = ImVec4(0.580f, 0.886f, 0.819f, 1.0f); // #94e2d5
const ImVec4 sapphire = ImVec4(0.458f, 0.784f, 0.878f, 1.0f); // #74c7ec
const ImVec4 blue = ImVec4(0.533f, 0.698f, 0.976f, 1.0f); // #89b4fa
const ImVec4 lavender = ImVec4(0.709f, 0.764f, 0.980f, 1.0f); // #b4befe
// Main window and backgrounds
colors[ImGuiCol_WindowBg] = base;
colors[ImGuiCol_ChildBg] = base;
colors[ImGuiCol_PopupBg] = surface0;
colors[ImGuiCol_Border] = surface1;
colors[ImGuiCol_BorderShadow] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
colors[ImGuiCol_FrameBg] = surface0;
colors[ImGuiCol_FrameBgHovered] = surface1;
colors[ImGuiCol_FrameBgActive] = surface2;
colors[ImGuiCol_TitleBg] = mantle;
colors[ImGuiCol_TitleBgActive] = surface0;
colors[ImGuiCol_TitleBgCollapsed] = mantle;
colors[ImGuiCol_MenuBarBg] = mantle;
colors[ImGuiCol_ScrollbarBg] = surface0;
colors[ImGuiCol_ScrollbarGrab] = surface2;
colors[ImGuiCol_ScrollbarGrabHovered] = overlay0;
colors[ImGuiCol_ScrollbarGrabActive] = overlay2;
colors[ImGuiCol_CheckMark] = green;
colors[ImGuiCol_SliderGrab] = sapphire;
colors[ImGuiCol_SliderGrabActive] = blue;
colors[ImGuiCol_Button] = surface0;
colors[ImGuiCol_ButtonHovered] = surface1;
colors[ImGuiCol_ButtonActive] = surface2;
colors[ImGuiCol_Header] = surface0;
colors[ImGuiCol_HeaderHovered] = surface1;
colors[ImGuiCol_HeaderActive] = surface2;
colors[ImGuiCol_Separator] = surface1;
colors[ImGuiCol_SeparatorHovered] = mauve;
colors[ImGuiCol_SeparatorActive] = mauve;
colors[ImGuiCol_ResizeGrip] = surface2;
colors[ImGuiCol_ResizeGripHovered] = mauve;
colors[ImGuiCol_ResizeGripActive] = mauve;
colors[ImGuiCol_Tab] = surface0;
colors[ImGuiCol_TabHovered] = surface2;
colors[ImGuiCol_TabActive] = surface1;
colors[ImGuiCol_TabUnfocused] = surface0;
colors[ImGuiCol_TabUnfocusedActive] = surface1;
colors[ImGuiCol_DockingPreview] = sapphire;
colors[ImGuiCol_DockingEmptyBg] = base;
colors[ImGuiCol_PlotLines] = blue;
colors[ImGuiCol_PlotLinesHovered] = peach;
colors[ImGuiCol_PlotHistogram] = teal;
colors[ImGuiCol_PlotHistogramHovered] = green;
colors[ImGuiCol_TableHeaderBg] = surface0;
colors[ImGuiCol_TableBorderStrong] = surface1;
colors[ImGuiCol_TableBorderLight] = surface0;
colors[ImGuiCol_TableRowBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.0f, 1.0f, 1.0f, 0.06f);
colors[ImGuiCol_TextSelectedBg] = surface2;
colors[ImGuiCol_DragDropTarget] = yellow;
colors[ImGuiCol_NavHighlight] = lavender;
colors[ImGuiCol_NavWindowingHighlight]= ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.8f, 0.8f, 0.8f, 0.2f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.35f);
colors[ImGuiCol_Text] = text;
colors[ImGuiCol_TextDisabled] = subtext0;
// Rounded corners
style.WindowRounding = 6.0f;
style.ChildRounding = 6.0f;
style.FrameRounding = 4.0f;
style.PopupRounding = 4.0f;
style.ScrollbarRounding = 9.0f;
style.GrabRounding = 4.0f;
style.TabRounding = 4.0f;
// Padding and spacing
style.WindowPadding = ImVec2(8.0f, 8.0f);
style.FramePadding = ImVec2(5.0f, 3.0f);
style.ItemSpacing = ImVec2(8.0f, 4.0f);
style.ItemInnerSpacing = ImVec2(4.0f, 4.0f);
style.IndentSpacing = 21.0f;
style.ScrollbarSize = 14.0f;
style.GrabMinSize = 10.0f;
// Borders
style.WindowBorderSize = 1.0f;
style.ChildBorderSize = 1.0f;
style.PopupBorderSize = 1.0f;
style.FrameBorderSize = 0.0f;
style.TabBorderSize = 0.0f;
}
ImGuiLayer::ImGuiLayer()
: Layer("ImGuiLayer")
{
}
void ImGuiLayer::OnAttach()
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
Application& app = Application::Get();
GLFWwindow* window = static_cast<GLFWwindow*>(app.GetWindow().GetNativeWindow());
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 410");
setupCatppuccinMochaTheme();
}
void ImGuiLayer::OnDetach()
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void ImGuiLayer::Begin()
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void ImGuiLayer::End()
{
ImGuiIO& io = ImGui::GetIO();
Application& app = Application::Get();
io.DisplaySize = ImVec2((float)app.GetWindow().GetWidth(), (float)app.GetWindow().GetHeight());
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
}
void ImGuiLayer::OnImGuiRender()
{
static bool show = true;
if (show)
ImGui::ShowDemoWindow(&show);
}
}

View File

@@ -0,0 +1,146 @@
#include <pch.hpp>
#include "application.hpp"
#include "logging.hpp"
#include <input/linux_input.hpp>
#include <GLFW/glfw3.h>
namespace OpenEngine {
Input* Input::instance = new LinuxInput();
bool LinuxInput::IsKeyPressedImpl(int keycode)
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto state = glfwGetKey(window, keycode);
return state == GLFW_PRESS || state == GLFW_REPEAT;
}
bool LinuxInput::IsMouseButtonPressedImpl(int keycode)
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto state = glfwGetMouseButton(window, keycode);
return state == GLFW_PRESS;
}
std::pair<float, float> LinuxInput::GetMousePositionImpl()
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
double x, y;
glfwGetCursorPos(window, &x, &y);
return {(float)x, (float)y};
}
float LinuxInput::GetMouseXImpl()
{
auto [x, y] = GetMousePositionImpl();
return (float)x;
}
float LinuxInput::GetMouseYImpl()
{
auto [x, y] = GetMousePositionImpl();
return (float)y;
int count;
auto axes = glfwGetJoystickAxes(0, &count);
}
bool LinuxInput::JoystickExistsImpl(unsigned int joystick)
{
bool status = glfwJoystickPresent(joystick);
return status;
}
const float* LinuxInput::GetJoystickAxesImpl(unsigned int joystick)
{
if (!JoystickExistsImpl(joystick)) {
OE_CORE_WARN("Joystick number {} is not present.", joystick);
return nullptr;
}
int count;
auto axes = glfwGetJoystickAxes(joystick, &count);
return axes;
}
float LinuxInput::GetJoystickAxisImpl(unsigned int joystick, unsigned int axis)
{
if (!JoystickExistsImpl(joystick)) {
OE_CORE_WARN("Joystick number {} is not present.", joystick);
return 0.0f;
}
int count;
auto axes = glfwGetJoystickAxes(joystick, &count);
if (axis >= count) {
OE_CORE_WARN("Axis number {} is greate than axis count ({})", axis, count);
return 0.0f;
}
return axes[axis];
}
const std::string LinuxInput::GetJoystickNameImpl(unsigned int joystick)
{
auto name = glfwGetJoystickName(joystick);
if (!name) {
OE_CORE_WARN("Joystick number {} is not present.", joystick);
return "N/A";
}
return name;
}
std::map<unsigned int, std::string> LinuxInput::GetJoystickListImpl()
{
std::map<unsigned int, std::string> joysticks;
for (size_t i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
auto name = glfwGetJoystickName(i);
if (name)
joysticks[i] = name;
}
return joysticks;
}
unsigned int LinuxInput::GetJoystickAxesCountImpl(unsigned int joystick)
{
if (!JoystickExistsImpl(joystick)) {
OE_CORE_WARN("Joystick number {} is not present.", joystick);
return 0;
}
int count;
glfwGetJoystickAxes(joystick, &count);
return count;
}
bool LinuxInput::IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button)
{
if (!JoystickExistsImpl(joystick))
OE_CORE_WARN("Joystick number {} is not present.", joystick);
int count;
const unsigned char* buttons = glfwGetJoystickButtons(joystick, &count);
if (button >= count)
OE_CORE_WARN("Button number {} is greater than button count ({}).", button, count);
return buttons[button];
}
}

View File

@@ -0,0 +1,8 @@
#include <layer.hpp>
namespace OpenEngine {
Layer::Layer(const std::string& name)
: debug_name(name)
{
}
}

View File

@@ -0,0 +1,45 @@
#include <layer_stack.hpp>
namespace OpenEngine {
LayerStack::LayerStack()
{
}
LayerStack::~LayerStack()
{
for (Layer* layer : layers)
delete layer;
}
void LayerStack::PushLayer(Layer* layer)
{
layers.emplace(layers.begin() + layer_insert_index, layer);
layer_insert_index++;
layer->OnAttach();
}
void LayerStack::PushOverlay(Layer* overlay)
{
layers.emplace_back(overlay);
overlay->OnAttach();
}
void LayerStack::PopLayer(Layer* layer)
{
auto it = std::find(layers.begin(), layers.begin() + layer_insert_index, layer);
if (it != layers.end()) {
layer->OnDetach();
layers.erase(it);
layer_insert_index--;
}
}
void LayerStack::PopOverlay(Layer* overlay)
{
auto it = std::find(layers.begin() + layer_insert_index, layers.end(), overlay);
if (it != layers.end()) {
overlay->OnDetach();
layers.erase(it);
}
}
}

View File

@@ -0,0 +1,50 @@
#include <logging.hpp>
#include <spdlog/spdlog.h>
#include <spdlog/common.h>
#include <spdlog/logger.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/basic_file_sink.h>
namespace OpenEngine {
std::shared_ptr<spdlog::logger> Logger::core_logger;
std::shared_ptr<spdlog::logger> Logger::client_logger;
void Logger::Init()
{
spdlog::set_pattern("%^[%H:%M:%S] [%l] %n: %v%$");
core_logger = spdlog::stdout_color_mt("OpenEngine");
core_logger->set_level(spdlog::level::trace);
client_logger = spdlog::stdout_color_mt("App");
client_logger->set_level(spdlog::level::trace);
}
int setupMultisinkLogger(const std::string &file_path)
{
if (spdlog::get("open-engine_logger"))
return 1;
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(file_path);
console_sink->set_level(spdlog::level::info);
file_sink->set_level(spdlog::level::debug);
auto logger = std::make_shared<spdlog::logger>("open-engine_logger", spdlog::sinks_init_list({console_sink, file_sink}));
logger->set_pattern("[%H:%M:%S] [%^%l%$] %n: %v");
logger->flush_on(spdlog::level::info);
if (!logger) {
std::cerr << "FATAL: Failed to get logger." << std::endl;
return 1;
}
spdlog::register_logger(logger);
spdlog::set_default_logger(logger);
logger->info("Logger ready.");
return 0;
}
}

View File

@@ -0,0 +1,5 @@
#include <pch.hpp>
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
#include "imgui_opengl.cpp"
#include "imgui_glfw.cpp"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
#include <cstdint>
#include <pch.hpp>
#include <opengl/opengl_buffer.hpp>
#include <glad/glad.h>
namespace OpenEngine {
// ==================================================================
// Vertex Buffer ====================================================
// ==================================================================
OpenGLVertexBuffer::OpenGLVertexBuffer(float* vertices, uint32_t size)
{
glCreateBuffers(1, &id);
glBindBuffer(GL_ARRAY_BUFFER, id);
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
}
OpenGLVertexBuffer::~OpenGLVertexBuffer()
{
glDeleteBuffers(1, &id);
}
void OpenGLVertexBuffer::Bind() const
{
glBindBuffer(GL_ARRAY_BUFFER, id);
}
void OpenGLVertexBuffer::UnBind() const
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
// ==================================================================
// Index Buffer =====================================================
// ==================================================================
OpenGLIndexBuffer::OpenGLIndexBuffer(uint32_t* indices, uint32_t count)
: count(count)
{
glCreateBuffers(1, &id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), indices, GL_STATIC_DRAW);
}
OpenGLIndexBuffer::~OpenGLIndexBuffer()
{
glDeleteBuffers(1, &id);
}
void OpenGLIndexBuffer::Bind() const
{
glBindBuffer(GL_ARRAY_BUFFER, id);
}
void OpenGLIndexBuffer::UnBind() const
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}

View File

@@ -0,0 +1,31 @@
#include <pch.hpp>
#include "opengl/opengl_context.hpp"
#include "logging.hpp"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
namespace OpenEngine {
OpenGLContext::OpenGLContext(GLFWwindow* window_handle)
: window_handle(window_handle)
{
OE_CORE_ASSERT(window_handle, "Handle is null!");
}
void OpenGLContext::Init()
{
glfwMakeContextCurrent(window_handle);
int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
OE_CORE_ASSERT(status, "Failed to initialize Glad!");
OE_CORE_INFO("Opengl info:");
OE_CORE_INFO("\tVendor: {}", (char*)glGetString(GL_VENDOR));
OE_CORE_INFO("\tRenderer: {}", (char*)glGetString(GL_RENDERER));
OE_CORE_INFO("\tVersion: {}", (char*)glGetString(GL_VERSION));
}
void OpenGLContext::SwapBuffers()
{
glfwSwapBuffers(window_handle);
}
}

View File

@@ -0,0 +1,34 @@
#include <pch.hpp>
#include "opengl/opengl_renderer_api.hpp"
#include <glm/ext/vector_float4.hpp>
#include <glad/glad.h>
namespace OpenEngine {
void OpenGLRendererAPI::Init()
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void OpenGLRendererAPI::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
{
glViewport(x, y, width, height);
}
void OpenGLRendererAPI::SetClearColor(const glm::vec4& color)
{
glClearColor(color.r, color.g, color.b, color.a);
}
void OpenGLRendererAPI::Clear()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void OpenGLRendererAPI::DrawIndexed(const std::shared_ptr<VertexArray>& vertex_array)
{
glDrawElements(GL_TRIANGLES, vertex_array->GetIndexBuffer()->GetCount(), GL_UNSIGNED_INT, nullptr);
}
}

View File

@@ -0,0 +1,223 @@
#include <alloca.h>
#include <pch.hpp>
#include "logging.hpp"
#include <cstddef>
#include <fstream>
#include <opengl/opengl_shader.hpp>
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
namespace OpenEngine {
static GLenum ShaderTypeFromString(const std::string& type)
{
if (type == "vertex")
return GL_VERTEX_SHADER;
if (type == "fragment" || type == "pixel")
return GL_FRAGMENT_SHADER;
OE_CORE_ERROR("Could not compile shader! Unkown shader type: {}", type);
return 0;
}
OpenGLShader::OpenGLShader(const std::string& name, const std::string& vertex_src, const std::string& fragment_src)
: name(name)
{
std::unordered_map<GLenum, std::string> sources;
sources[GL_VERTEX_SHADER] = vertex_src;
sources[GL_FRAGMENT_SHADER] = fragment_src;
Compile(sources);
}
OpenGLShader::OpenGLShader(const std::string& shader_path)
{
std::string source = ReadFile(shader_path);
auto shader_sources = PreProcess(source);
Compile(shader_sources);
// Getting file name
auto last_slash = shader_path.find_last_of("/\\");
last_slash = last_slash == std::string::npos ? 0 : last_slash + 1;
auto last_dot = shader_path.rfind('.');
auto count = last_dot == std::string::npos ? shader_path.size() - last_slash : last_dot - last_slash;
name = shader_path.substr(last_slash, count);
}
void OpenGLShader::Compile(const std::unordered_map<GLenum, std::string> sources)
{
GLuint program = glCreateProgram();
GLenum *gl_shader_ids = (GLenum*)alloca(sources.size());
size_t shader_index = 0;
for (auto& kv_pair : sources)
{
GLenum type = kv_pair.first;
const std::string& source = kv_pair.second;
GLuint shader = glCreateShader(type);
const GLchar* source_cstr = source.c_str();
glShaderSource(shader, 1, &source_cstr, 0);
glCompileShader(shader);
GLint is_compiled = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &is_compiled);
if (is_compiled == GL_FALSE)
{
GLint max_length = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &max_length);
std::vector<GLchar> info_log(max_length);
glGetShaderInfoLog(shader, max_length, &max_length, &info_log[0]);
glDeleteShader(shader);
OE_CORE_ERROR("{0}", info_log.data());
OE_CORE_ERROR("Shader compilation failure!");
break;
}
glAttachShader(program, shader);
gl_shader_ids[shader_index++] = shader;
}
id = program;
glLinkProgram(program);
GLint is_linked = 0;
glGetProgramiv(program, GL_LINK_STATUS, (int*)&is_linked);
if (is_linked == GL_FALSE)
{
GLint max_length = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &max_length);
// The maxLength includes the NULL character
std::vector<GLchar> infoLog(max_length);
glGetProgramInfoLog(program, max_length, &max_length, &infoLog[0]);
// We don't need the program anymore.
glDeleteProgram(program);
for (int i = 0; i < sources.size(); i++)
glDeleteShader(gl_shader_ids[i]);
OE_CORE_ERROR("{0}", infoLog.data());
OE_CORE_ERROR("Shader link failure!");
return;
}
for (int i = 0; i < sources.size(); i++)
glDetachShader(program, gl_shader_ids[i]);
}
std::unordered_map<GLenum, std::string> OpenGLShader::PreProcess(const std::string& shader_source)
{
// TODO: Perhaps consider using getline to get the position of errors. or even regexes
std::unordered_map<GLenum, std::string> sources;
const char* type_token = "#type";
size_t type_token_lenght = strlen(type_token);
size_t pos = shader_source.find(type_token, 0);
while (pos != std::string::npos) {
size_t eol = shader_source.find("\n", pos);
if (eol == std::string::npos)
OE_CORE_ERROR("Syntax error.");
size_t begin = pos + type_token_lenght + 1;
std::string type = shader_source.substr(begin, eol - begin);
if (type != "vertex" && type != "fragment" && type != "pixel")
OE_CORE_ERROR("Invalid shader type.");
size_t next_line_pos = shader_source.find_first_not_of("\n", eol);
pos = shader_source.find(type_token, next_line_pos);
sources[ShaderTypeFromString(type)] =
shader_source.substr(next_line_pos, pos - (next_line_pos == std::string::npos ? shader_source.size() - 1 : next_line_pos));
}
return sources;
}
std::string OpenGLShader::ReadFile(const std::string& shader_path)
{
std::string result;
std::ifstream input(shader_path);
if (input) {
input.seekg(0, std::ios::end);
result.resize(input.tellg());
input.seekg(0, std::ios::beg);
input.read(&result[0], result.size());
input.close();
} else {
OE_CORE_ERROR("Shader file could not be open or does not exist: {}", shader_path);
}
return result;
}
void OpenGLShader::Bind() const
{
glUseProgram(id);
}
void OpenGLShader::Unbind() const
{
glUseProgram(0);
}
void OpenGLShader::SetBool(const std::string &name, bool value) const
{
glUniform1i(glGetUniformLocation(id, name.c_str()), (int)value);
}
void OpenGLShader::SetInt(const std::string &name, int value) const
{
glUniform1i(glGetUniformLocation(id, name.c_str()), value);
}
void OpenGLShader::SetFloat(const std::string &name, float value) const
{
glUniform1f(glGetUniformLocation(id, name.c_str()), value);
}
void OpenGLShader::SetMat4(const std::string &name, const glm::mat4& value) const
{
glUniformMatrix4fv(glGetUniformLocation(id, name.c_str()), 1, GL_FALSE, glm::value_ptr(value));
}
void OpenGLShader::SetVec3(const std::string &name, const glm::vec3& value) const
{
glUniform3fv(glGetUniformLocation(id, name.c_str()), 1, glm::value_ptr(value));
}
void OpenGLShader::CheckCompileErrors(unsigned int shader, const std::string& type)
{
int success = GL_FALSE;
char infoLog[1024];
if (type != "PROGRAM") {
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
if (success == GL_FALSE) {
glGetShaderInfoLog(shader, 1024, NULL, infoLog);
OE_CORE_ERROR("Shader of type {}, couldn't be compiled:", type);
OE_CORE_ERROR("\t{}", infoLog);
}
} else {
if (glGetProgramiv == nullptr) {
OE_CORE_ERROR("OpenGL functions are not loaded!");
return;
}
glGetProgramiv(shader, GL_LINK_STATUS, &success);
if (success == GL_FALSE)
{
glGetProgramInfoLog(shader, 1024, NULL, infoLog);
OE_CORE_ERROR("Program of type {}, couldn't be compiled:", type);
OE_CORE_ERROR("\t{}", infoLog);
}
}
}
}

View File

@@ -0,0 +1,54 @@
#include <cstdint>
#include <pch.hpp>
#include "core.hpp"
#include <glad/glad.h>
#include <renderer/texture.hpp>
#include <opengl/opengl_texture.hpp>
#include <stb_image.h>
namespace OpenEngine {
OpenGLTexture2D::OpenGLTexture2D(const std::string& path)
: path(path)
{
int image_width, image_height, channels;
stbi_uc* data = stbi_load(path.c_str(), &image_width, &image_height, &channels, 0);
stbi_set_flip_vertically_on_load(1);
OE_CORE_ASSERT(data, "Image could not be loaded!");
width = image_width;
height = image_height;
GLenum internal_format, data_format = 0;
if (channels == 4) {
internal_format = GL_RGBA8;
data_format = GL_RGBA;
} else if (channels == 3) {
internal_format = GL_RGB8;
data_format = GL_RGB;
}
OE_CORE_ASSERT(internal_format & data_format, "Image format is unsupported!");
glCreateTextures(GL_TEXTURE_2D, 1, &id);
glTextureStorage2D(id, 1, internal_format, width, height);
glTextureParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTextureParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTextureSubImage2D(id, 0, 0, 0, width, height, data_format, GL_UNSIGNED_BYTE, data);
stbi_image_free(data);
}
OpenGLTexture2D::~OpenGLTexture2D()
{
glDeleteTextures(1, &id);
}
void OpenGLTexture2D::Bind(uint32_t slot) const
{
glBindTextureUnit(slot, id);
}
}

View File

@@ -0,0 +1,80 @@
#include "core.hpp"
#include <cstdint>
#include <pch.hpp>
#include <opengl/opengl_vertex_array.hpp>
#include <glad/glad.h>
namespace OpenEngine {
static GLenum ShaderDataTypeToOpenGLBaseType(ShaderDataType type)
{
switch (type)
{
case OpenEngine::ShaderDataType::Float: return GL_FLOAT;
case OpenEngine::ShaderDataType::Float2: return GL_FLOAT;
case OpenEngine::ShaderDataType::Float3: return GL_FLOAT;
case OpenEngine::ShaderDataType::Float4: return GL_FLOAT;
case OpenEngine::ShaderDataType::Mat3: return GL_FLOAT;
case OpenEngine::ShaderDataType::Mat4: return GL_FLOAT;
case OpenEngine::ShaderDataType::Int: return GL_INT;
case OpenEngine::ShaderDataType::Int2: return GL_INT;
case OpenEngine::ShaderDataType::Int3: return GL_INT;
case OpenEngine::ShaderDataType::Int4: return GL_INT;
case OpenEngine::ShaderDataType::Bool: return GL_BOOL;
}
OE_CORE_ASSERT(false, "Unknown ShaderDataType!");
return 0;
}
OpenGLVertexArray::OpenGLVertexArray()
{
glCreateVertexArrays(1, &id);
}
OpenGLVertexArray::~OpenGLVertexArray()
{
glDeleteVertexArrays(1, &id);
}
void OpenGLVertexArray::Bind() const
{
glBindVertexArray(id);
}
void OpenGLVertexArray::UnBind() const
{
glBindVertexArray(0);
}
void OpenGLVertexArray::AddVertexBuffer(const std::shared_ptr<VertexBuffer>& vertex_buffer)
{
glBindVertexArray(id);
vertex_buffer->Bind();
OE_CORE_ASSERT(vertex_buffer->GetLayout().GetElements().size(), "Vertex Buffer has no layout!");
const auto& layout = vertex_buffer->GetLayout();
for (const auto& element : layout) {
glEnableVertexAttribArray(index);
glVertexAttribPointer(index,
element.GetComponentCount(),
ShaderDataTypeToOpenGLBaseType(element.type),
element.normalized? GL_TRUE : GL_FALSE,
layout.GetStride(),
(const void*)(intptr_t)element.offset);
index++;
}
vertex_buffers.emplace_back(vertex_buffer);
}
void OpenGLVertexArray::SetIndexBuffer(const std::shared_ptr<IndexBuffer>& index_buffer)
{
glBindVertexArray(id);
index_buffer->Bind();
this->index_buffer = index_buffer;
}
}

View File

@@ -0,0 +1,28 @@
#include <glm/trigonometric.hpp>
#include <pch.hpp>
#include <orthographic_camera.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace OpenEngine {
OrthographicCamera::OrthographicCamera(float left, float right, float bottom, float top)
: projection_matrix(glm::ortho(left, right, bottom, top, -1.0f, 1.0f)), view_matrix(1)
{
view_projection_matrix = projection_matrix * view_matrix;
}
void OrthographicCamera::SetProjection(float left, float right, float bottom, float top)
{
projection_matrix = glm::ortho(left, right, bottom, top, -1.0f, 1.0f);
view_projection_matrix = projection_matrix * view_matrix;
}
void OrthographicCamera::RecalculateViewMatrix() {
glm::mat4 transform = glm::translate(glm::mat4(1.0f), position);
transform *= glm::rotate(glm::mat4(1.0f), glm::radians(rotation), glm::vec3(0.0f, 0.0f, 1.0f));
view_matrix = glm::inverse(transform);
view_projection_matrix = projection_matrix * view_matrix;
}
}

View File

@@ -0,0 +1,77 @@
#include <pch.hpp>
#include "open_engine/orthographic_camera_controller.hpp"
#include "open_engine/events/application_event.hpp"
#include "open_engine/events/event.hpp"
#include "open_engine/events/mouse_event.hpp"
#include "open_engine/core/time.hpp"
#include "open_engine/input/keycodes.hpp"
#include "open_engine/input/input_system.hpp"
#include "open_engine/orthographic_camera.hpp"
#include <glm/fwd.hpp>
namespace OpenEngine {
OrthographicCameraController::OrthographicCameraController(float ratio, float zoom = 1.0f)
: aspect_ratio(ratio), zoom(zoom),
camera(-aspect_ratio * zoom, aspect_ratio * zoom, -zoom, zoom)
{
}
void OrthographicCameraController::Translate(const glm::vec3& vector)
{
float velocity = translation_speed * Time::Get().DeltaTime();
camera_position += vector * velocity;
}
void OrthographicCameraController::Rotate(float speed)
{
float multiple = rotation_speed * Time::Get().DeltaTime();
camera_rotation += speed * multiple;
}
void OrthographicCameraController::OnUpdate()
{
if (Input::IsKeyPressed(OE_KEY_W))
Translate({0, -1, 0});
if (Input::IsKeyPressed(OE_KEY_A))
Translate({1, 0, 0});
if (Input::IsKeyPressed(OE_KEY_S))
Translate({0, 1, 0});
if (Input::IsKeyPressed(OE_KEY_D))
Translate({-1, 0, 0});
if (rotation) {
if (Input::IsKeyPressed(OE_KEY_Q))
Rotate(10);
if (Input::IsKeyPressed(OE_KEY_E))
Rotate(-10);
camera.SetRotation(camera_rotation);
}
camera.SetPosition(camera_position);
}
void OrthographicCameraController::OnEvent(Event& e)
{
EventDispatcher dispatcher(e);
dispatcher.Dispatch<MouseScrolledEvent>(BIND_EVENT_FN(OrthographicCameraController::OnMouseScrolled));
dispatcher.Dispatch<WindowResizeEvent>(BIND_EVENT_FN(OrthographicCameraController::OnWindowResized));
}
bool OrthographicCameraController::OnMouseScrolled(MouseScrolledEvent& e)
{
zoom -= e.GetYOffset() * 0.25f;
zoom = std::max(zoom, 0.25f);
camera.SetProjection(-aspect_ratio * zoom, aspect_ratio * zoom, -zoom, zoom);
return false;
}
bool OrthographicCameraController::OnWindowResized(WindowResizeEvent& e)
{
aspect_ratio = (float)e.GetWidth() / (float)e.GetHeight();
camera.SetProjection(-aspect_ratio * zoom, aspect_ratio * zoom, -zoom, zoom);
return false;
}
}

View File

@@ -0,0 +1,86 @@
#include "core.hpp"
#include "opengl/opengl_buffer.hpp"
#include <cstdint>
#include <pch.hpp>
#include <renderer/buffer.hpp>
#include <renderer/renderer.hpp>
namespace OpenEngine {
uint32_t shaderDataTypeSize(ShaderDataType type)
{
switch (type)
{
case ShaderDataType::Float: return 4;
case ShaderDataType::Float2: return 4 * 2;
case ShaderDataType::Float3: return 4 * 3;
case ShaderDataType::Float4: return 4 * 4;
case ShaderDataType::Mat3: return 4 * 3 * 3;
case ShaderDataType::Mat4: return 4 * 4 * 4;
case ShaderDataType::Int: return 4;
case ShaderDataType::Int2: return 4 * 2;
case ShaderDataType::Int3: return 4 * 3;
case ShaderDataType::Int4: return 4 * 4;
case ShaderDataType::Bool: return 1;
}
OE_CORE_ASSERT(false, "Unknown ShaderDataType!");
return 0;
}
uint32_t BufferLayoutElement::GetComponentCount() const
{
switch (type)
{
case ShaderDataType::Float: return 1;
case ShaderDataType::Float2: return 2;
case ShaderDataType::Float3: return 3;
case ShaderDataType::Float4: return 4;
case ShaderDataType::Mat3: return 3 * 3;
case ShaderDataType::Mat4: return 4 * 4;
case ShaderDataType::Int: return 1;
case ShaderDataType::Int2: return 2;
case ShaderDataType::Int3: return 3;
case ShaderDataType::Int4: return 4;
case ShaderDataType::Bool: return 1;
}
OE_CORE_ASSERT(false, "Unknown ShaderDataType!");
return 0;
}
void BufferLayout::CalculateOffsetsAndStride()
{
uint32_t offset = 0;
stride = 0;
for (auto& element : elements)
{
element.offset = offset;
offset += element.size;
stride += element.size;
}
}
VertexBuffer* VertexBuffer::Create(float* vertices, uint32_t size)
{
switch (Renderer::GetApi()) {
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
case RendererAPI::API::OpenGL : return new OpenGLVertexBuffer(vertices, size);
}
OE_CORE_ASSERT(false, "Selected API not supported");
return nullptr;
}
IndexBuffer* IndexBuffer::Create(uint32_t* indices, uint32_t count)
{
switch (Renderer::GetApi()) {
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
case RendererAPI::API::OpenGL : return new OpenGLIndexBuffer(indices, count);
}
OE_CORE_ASSERT(false, "Selected API not supported");
return nullptr;
}
}

View File

@@ -0,0 +1,41 @@
#include <memory>
#include <pch.hpp>
#include <renderer/renderer.hpp>
#include "opengl/opengl_shader.hpp"
#include "renderer/render_command.hpp"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
namespace OpenEngine {
void Renderer::Init()
{
RenderCommand::Init();
}
void Renderer::OnWindowResize(uint32_t width, uint32_t height)
{
RenderCommand::SetViewport(0, 0, width, height);
}
void Renderer::BeginScene(const OrthographicCamera& camera)
{
scene_data->view_projection_matrix = camera.GetViewProjectionMatrix();
}
void Renderer::EndScene()
{
}
void Renderer::Submit(const std::shared_ptr<Shader> shader,
const std::shared_ptr<VertexArray>& vertex_array,
const glm::mat4& transform)
{
shader->Bind();
std::dynamic_pointer_cast<OpenGLShader>(shader)->SetMat4("u_ViewProjection", scene_data->view_projection_matrix);
std::dynamic_pointer_cast<OpenGLShader>(shader)->SetMat4("u_Transform", transform);
vertex_array->Bind();
RenderCommand::DrawIndexed(vertex_array);
}
}

View File

@@ -0,0 +1,76 @@
#include "logging.hpp"
#include <pch.hpp>
#include <open_engine/renderer/shader.hpp>
#include <open_engine/renderer/renderer.hpp>
#include <open_engine/renderer/renderer_api.hpp>
#include <opengl/opengl_shader.hpp>
#include <core.hpp>
namespace OpenEngine {
Ref<Shader> Shader::Create(const std::string& shader_path)
{
switch (Renderer::GetApi())
{
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
case RendererAPI::API::OpenGL: return std::make_shared<OpenGLShader>(shader_path);
}
OE_CORE_ASSERT(false, "Unknown RendererAPI!");
return nullptr;
};
Ref<Shader> Shader::Create(const std::string& name, const std::string& vertex_src, const std::string& frament_src)
{
switch (Renderer::GetApi())
{
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
case RendererAPI::API::OpenGL: return std::make_shared<OpenGLShader>(name, vertex_src, frament_src);
}
OE_CORE_ASSERT(false, "Unknown RendererAPI!");
return nullptr;
};
void ShaderLibrary::Add(const Ref<Shader>& shader)
{
auto shader_name = shader->GetName();
Add(shader_name, shader);
}
void ShaderLibrary::Add(const std::string& name, const Ref<Shader>& shader)
{
if (Exists(name))
OE_CORE_ERROR("Shader with this name already exists: ", name);
shaders[name] = shader;
}
Ref<Shader> ShaderLibrary::Load(const std::string& path)
{
auto shader = Shader::Create(path);
Add(shader);
return shader;
}
Ref<Shader> ShaderLibrary::Load(const std::string& name, const std::string& path)
{
auto shader = Shader::Create(path);
Add(name, shader);
return shader;
}
Ref<Shader> ShaderLibrary::Get(const std::string& name) const
{
if (!Exists(name))
OE_CORE_ERROR("Shader with this name doesn't exists: ", name);
return shaders.find(name)->second;
}
bool ShaderLibrary::Exists(const std::string& name) const
{
return shaders.find(name) != shaders.end();
}
}

View File

@@ -0,0 +1,18 @@
#include <pch.hpp>
#include <open_engine/renderer/texture.hpp>
#include <open_engine/renderer/renderer.hpp>
#include <open_engine/opengl/opengl_texture.hpp>
namespace OpenEngine {
Ref<Texture2D> Texture2D::Create(const std::string &path)
{
switch (Renderer::GetApi()) {
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
case RendererAPI::API::OpenGL : return std::make_shared<OpenGLTexture2D>(path);
}
OE_CORE_ASSERT(false, "Selected API not supported");
return nullptr;
}
}

View File

@@ -0,0 +1,19 @@
#include <pch.hpp>
#include "opengl/opengl_vertex_array.hpp"
#include "renderer/renderer.hpp"
#include <renderer/vertex_array.hpp>
namespace OpenEngine {
VertexArray* VertexArray::Create()
{
switch (Renderer::GetApi()) {
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
case RendererAPI::API::OpenGL : return new OpenGLVertexArray();
}
OE_CORE_ASSERT(false, "Selected API not supported");
return nullptr;
}
}

View File

@@ -0,0 +1,181 @@
#include "core.hpp"
#include "events/application_event.hpp"
#include "events/key_event.hpp"
#include "events/mouse_event.hpp"
#include "logging.hpp"
#include <GLFW/glfw3.h>
#include <window/linux_window.hpp>
#include <opengl/opengl_context.hpp>
#include "renderer/graphics_context.hpp"
namespace OpenEngine {
static bool glfw_initialized = false;
static void GLFWErrorCallback(int error, const char* description)
{
OE_CORE_ERROR("GLFW Error {}: {}", error, description);
}
Window* Window::Create(const WindowProps& props)
{
return new LinuxWindow(props);
}
LinuxWindow::LinuxWindow(const WindowProps& props)
{
Init(props);
}
LinuxWindow::~LinuxWindow()
{
Shutdown();
}
void LinuxWindow::Init(const WindowProps& props)
{
data.title = props.title;
data.height = props.height;
data.width = props.width;
OE_CORE_INFO("Creating window {} ({} {})", props.title, props.width, props.height);
if (!glfw_initialized) {
int success = glfwInit();
OE_CORE_ASSERT(success, "Could not initialize GLFW!");
spdlog::trace("Setting GLFW context version to: 3.3");
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
spdlog::trace("Setting opengl profile to core.");
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwSetErrorCallback(GLFWErrorCallback);
glfw_initialized = true;
}
gl_window = glfwCreateWindow((int)props.width, (int)props.height, props.title.c_str(), nullptr, nullptr);
context = new OpenGLContext(gl_window);
context->Init();
glfwSetWindowUserPointer(gl_window, &data);
SetVSync(true);
glfwSetWindowSizeCallback(gl_window, [](GLFWwindow* window, int width, int height)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
data.width = width;
data.height = height;
WindowResizeEvent event(width, height);
data.event_callback(event);
});
glfwSetWindowCloseCallback(gl_window, [](GLFWwindow* window)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
WindowCloseEvent event;
data.event_callback(event);
});
glfwSetKeyCallback(gl_window, [](GLFWwindow* window, int key, int scancode, int action, int mods)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
switch (action) {
case GLFW_PRESS:
{
KeyPressedEvent event(key, scancode, 0, mods);
data.event_callback(event);
break;
}
case GLFW_RELEASE:
{
KeyReleasedEvent event(key, scancode, mods);
data.event_callback(event);
break;
}
case GLFW_REPEAT:
{
KeyPressedEvent event(key, scancode, 1, mods);
data.event_callback(event);
break;
}
}
});
glfwSetCharCallback(gl_window, [] (GLFWwindow* window, unsigned int keycode)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
KeyTypedEvent event(keycode);
data.event_callback(event);
});
glfwSetMouseButtonCallback(gl_window, [](GLFWwindow* window, int button, int action, int mods)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
switch (action) {
case GLFW_PRESS:
{
MouseButtonPressedEvent event(button);
data.event_callback(event);
break;
}
case GLFW_RELEASE:
{
MouseButtonReleasedEvent event(button);
data.event_callback(event);
break;
}
}
});
glfwSetScrollCallback(gl_window, [](GLFWwindow* window, double xoffset, double yoffset)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
MouseScrolledEvent event((float) xoffset, (float)yoffset);
data.event_callback(event);
});
glfwSetCursorPosCallback(gl_window, [](GLFWwindow* window, double xpos, double ypos)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
MouseMovedEvent event((float) xpos, (float)ypos);
data.event_callback(event);
});
//glViewport(0, 0, 100, 100);
}
void LinuxWindow::Shutdown()
{
glfwDestroyWindow(gl_window);
}
void LinuxWindow::OnUpdate()
{
glfwPollEvents();
context->SwapBuffers();
}
void LinuxWindow::SetVSync(bool enabled)
{
if (enabled)
glfwSwapInterval(1);
else
glfwSwapInterval(0);
data.vsync = enabled;
}
bool LinuxWindow::IsVSync() const
{
return data.vsync;
}
}

Some files were not shown because too many files have changed in this diff Show More