Project setup
This commit is contained in:
57
.clang-format
Normal file
57
.clang-format
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBraces: Custom
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ContinuationIndentWidth: 8
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*'
|
||||
Priority: 1
|
||||
- Regex: '^".*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 4
|
||||
InsertNewlineAtEOF: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
TabWidth: 4
|
||||
...
|
||||
3
.clangd
Normal file
3
.clangd
Normal file
@@ -0,0 +1,3 @@
|
||||
CompileFlags:
|
||||
Add: -Wno-unknown-warning-option
|
||||
Remove: [-m*, -f*]
|
||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
build/
|
||||
.idea
|
||||
.zed
|
||||
!deps/JoltPhysics/Build
|
||||
.cache
|
||||
.vscode
|
||||
build-clion/
|
||||
bin/
|
||||
16
CMakeLists.txt
Normal file
16
CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# Include the libary
|
||||
add_subdirectory(oatmeal)
|
||||
|
||||
file(GLOB CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake")
|
||||
foreach(cmake_file ${CMAKE_FILES})
|
||||
include(${cmake_file})
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(examples/shared)
|
||||
|
||||
add_subdirectory(examples/basicGLFWWindow)
|
||||
add_subdirectory(examples/logging)
|
||||
0
assets/placeholder
Normal file
0
assets/placeholder
Normal file
14
cmake/compileCommands.cmake
Normal file
14
cmake/compileCommands.cmake
Normal file
@@ -0,0 +1,14 @@
|
||||
##### SETUP COMPILE COMMANDS #####
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/compile_commands.json")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
file(
|
||||
COPY "${CMAKE_BINARY_DIR}/compile_commands.json"
|
||||
DESTINATION "${CMAKE_BINARY_DIR}/../"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
10
cmake/platform.cmake
Normal file
10
cmake/platform.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
message("System name: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
|
||||
add_compile_definitions(PLATFORM_WINDOWS)
|
||||
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
|
||||
add_compile_definitions(PLATFORM_LINUX)
|
||||
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
add_compile_definitions(PLATFORM_MACOS)
|
||||
else()
|
||||
add_compile_definitions(PLATFORM_UNKNOWN)
|
||||
endif()
|
||||
18
examples/basicGLFWWindow/CMakeLists.txt
Normal file
18
examples/basicGLFWWindow/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
add_executable(basicGLFWWindow "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||
target_include_directories(basicGLFWWindow PRIVATE oatmeal SharedUtils)
|
||||
target_link_libraries(basicGLFWWindow oatmeal SharedUtils)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(basicGLFWWindow PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Debug/")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set_target_properties(basicGLFWWindow PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Release/")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
set_target_properties(basicGLFWWindow PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Relwithdeb/")
|
||||
endif()
|
||||
|
||||
10
examples/basicGLFWWindow/main.cpp
Normal file
10
examples/basicGLFWWindow/main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "shared/logger.h"
|
||||
|
||||
int main() {
|
||||
OatmealUtils::initLogging();
|
||||
OatmealUtils::createLogger("window", nullptr);
|
||||
|
||||
OatmealUtils::get("window")->info("Test");
|
||||
|
||||
return 0;
|
||||
}
|
||||
18
examples/logging/CMakeLists.txt
Normal file
18
examples/logging/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
add_executable(logging "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||
target_include_directories(logging PRIVATE oatmeal SharedUtils)
|
||||
target_link_libraries(logging oatmeal SharedUtils)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(logging PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Debug/")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set_target_properties(logging PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Release/")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
set_target_properties(logging PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Relwithdeb/")
|
||||
endif()
|
||||
|
||||
17
examples/logging/main.cpp
Normal file
17
examples/logging/main.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <cstdint>
|
||||
#include "shared/logger.h"
|
||||
|
||||
int main() {
|
||||
OatmealUtils::initLogging();
|
||||
OatmealUtils::createLogger("logger", nullptr);
|
||||
|
||||
OatmealUtils::get("logger")->debug("This is a debug message!");
|
||||
OatmealUtils::get("logger")->info("This is an info message!");
|
||||
OatmealUtils::get("logger")->warn("This is a warning message!");
|
||||
OatmealUtils::get("logger")->critical("This is a critical message!");
|
||||
uint32_t a = 5;
|
||||
std::string b = "Test string arg!";
|
||||
OatmealUtils::get("logger")->info("String arg: {} uint32_t args: {}", b, a);
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
examples/shared/CMakeLists.txt
Normal file
20
examples/shared/CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
CPMAddPackage(
|
||||
URI "gh:gabime/spdlog@1.17.0"
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/shared/*.cpp")
|
||||
file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/shared/*.h")
|
||||
add_library(SharedUtils STATIC ${SRC_FILES} ${HEADER_FILES})
|
||||
|
||||
target_include_directories(SharedUtils PUBLIC
|
||||
${spdlog_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(SharedUtils PUBLIC
|
||||
spdlog
|
||||
)
|
||||
48
examples/shared/shared/logger.cpp
Normal file
48
examples/shared/shared/logger.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "logger.h"
|
||||
#include <memory>
|
||||
#include <spdlog/async_logger.h>
|
||||
#include <spdlog/common.h>
|
||||
#include "spdlog/async.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace OatmealUtils {
|
||||
|
||||
void initLogging() {
|
||||
spdlog::init_thread_pool(8192, 1);
|
||||
spdlog::flush_every(std::chrono::seconds(1));
|
||||
}
|
||||
|
||||
void createLogger(const char *name, const char *filename) {
|
||||
std::vector<spdlog::sink_ptr> sinks{};
|
||||
|
||||
const auto stdoutSink = std::make_shared<spdlog::sinks::stderr_color_sink_mt>();
|
||||
stdoutSink->set_level(spdlog::level::debug);
|
||||
stdoutSink->set_pattern("%^[%D %r %z] [%n] [%l] [thread %t] %v%$");
|
||||
sinks.emplace_back(stdoutSink);
|
||||
|
||||
if (filename != nullptr) {
|
||||
const auto fileSink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(filename);
|
||||
fileSink->set_level(spdlog::level::debug);
|
||||
fileSink->set_pattern("%^[%D %r %z] [%n] [%l] [thread %t] %v%$");
|
||||
sinks.emplace_back(fileSink);
|
||||
}
|
||||
|
||||
const auto logger = std::make_shared<spdlog::async_logger>(
|
||||
name, sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
|
||||
|
||||
logger->flush_on(spdlog::level::warn);
|
||||
#ifndef NDEBUG
|
||||
logger->set_level(spdlog::level::debug);
|
||||
#else
|
||||
logger->set_level(spdlog::level::info);
|
||||
#endif // !NDEBUG
|
||||
|
||||
spdlog::register_logger(logger);
|
||||
}
|
||||
|
||||
void createLogger(std::string name, std::string filename) { createLogger(name.c_str(), filename.c_str()); }
|
||||
std::shared_ptr<logger> get(const char *name) { return spdlog::get(name); }
|
||||
std::shared_ptr<logger> get(std::string name) { return spdlog::get(name); }
|
||||
} // namespace OatmealUtils
|
||||
20
examples/shared/shared/logger.h
Normal file
20
examples/shared/shared/logger.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef OATMEAL_LOGGER
|
||||
#define OATMEAL_LOGGER
|
||||
|
||||
#include <memory>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include "string"
|
||||
|
||||
namespace OatmealUtils {
|
||||
|
||||
using logger = spdlog::logger;
|
||||
|
||||
void initLogging();
|
||||
void createLogger(const char *name, const char *filename);
|
||||
void createLogger(std::string name, std::string filename);
|
||||
std::shared_ptr<logger> get(const char *name);
|
||||
std::shared_ptr<logger> get(std::string name);
|
||||
|
||||
} // namespace OatmealUtils
|
||||
|
||||
#endif // !OATMEAL_LOGGER
|
||||
42
oatmeal/CMakeLists.txt
Normal file
42
oatmeal/CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
if((${CMAKE_BUILD_TYPE} STREQUAL "Debug") AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"))
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
else()
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
endif()
|
||||
|
||||
##### Dependencies #####s
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
||||
option(ENABLE_CPP20_MODULE "Enable C++ 20 module support for Vulkan" OFF)
|
||||
|
||||
file(GLOB REQUIRED_CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.required.cmake")
|
||||
foreach(cmake_file ${REQUIRED_CMAKE_FILES})
|
||||
include(${cmake_file})
|
||||
endforeach()
|
||||
|
||||
file(GLOB CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake")
|
||||
foreach(cmake_file ${CMAKE_FILES})
|
||||
include(${cmake_file})
|
||||
endforeach()
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||
file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
|
||||
add_library(oatmeal ${SRC_FILES} ${HEADER_FILES})
|
||||
|
||||
target_include_directories(oatmeal PUBLIC
|
||||
"${glfw_SOURCE_DIR}/include"
|
||||
"${glm_SOURCE_DIR}"
|
||||
"${stb-cmake-wrapper_SOURCE_DIR}"
|
||||
"${ktx_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
target_link_libraries(oatmeal PUBLIC
|
||||
glfw
|
||||
Vulkan::cppm
|
||||
glm
|
||||
stb::image
|
||||
ktx
|
||||
)
|
||||
24
oatmeal/cmake/CPM.required.cmake
Normal file
24
oatmeal/cmake/CPM.required.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
||||
|
||||
set(CPM_DOWNLOAD_VERSION 0.42.1)
|
||||
set(CPM_HASH_SUM "f3a6dcc6a04ce9e7f51a127307fa4f699fb2bade357a8eb4c5b45df76e1dc6a5")
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
|
||||
file(DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
||||
)
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
||||
11
oatmeal/cmake/GLFW.cmake
Normal file
11
oatmeal/cmake/GLFW.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# add check for CPM
|
||||
|
||||
|
||||
CPMAddPackage (
|
||||
URI "https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip"
|
||||
OPTIONS "GLFW_BUILD_DOCS OFF"
|
||||
OPTIONS "GLFW_BUILD_TEST OFF"
|
||||
OPTIONS "GLFW_BUILD_EXAMPLES OFF"
|
||||
OPTIONS "GLFW_BUILD_X11 OFF"
|
||||
OPTIONS "GLFW_BUILD_WAYLAND ON"
|
||||
)
|
||||
8
oatmeal/cmake/GLM.cmake
Normal file
8
oatmeal/cmake/GLM.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
# add check for cpm
|
||||
|
||||
CPMAddPackage(
|
||||
URI "https://github.com/g-truc/glm/releases/download/1.0.3/glm-1.0.3.zip"
|
||||
OPTIONS "GLM_BUILD_LIBRARY ON"
|
||||
OPTIONS "GLM_BUILD_TESTS OFF"
|
||||
OPTIONS "GLM_ENABLE_CXX_20 ON"
|
||||
)
|
||||
57
oatmeal/cmake/Vulkan.cmake
Normal file
57
oatmeal/cmake/Vulkan.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
# Vulkan #
|
||||
if(ENABLE_CPP20_MODULE)
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
|
||||
endif()
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
if(ENABLE_CPP20_MODULE)
|
||||
add_library(VulkanCppModule)
|
||||
add_library(Vulkan::cppm ALIAS VulkanCppModule)
|
||||
|
||||
target_compile_definitions(VulkanCppModule
|
||||
PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1
|
||||
)
|
||||
target_include_directories(VulkanCppModule
|
||||
PUBLIC
|
||||
"${Vulkan_INCLUDE_DIR}"
|
||||
)
|
||||
target_link_libraries(VulkanCppModule
|
||||
PUBLIC
|
||||
Vulkan::Vulkan
|
||||
)
|
||||
|
||||
set_target_properties(VulkanCppModule PROPERTIES CXX_STANDARD 20)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(VulkanCppModule PRIVATE
|
||||
/std:c++latest
|
||||
/permissive-
|
||||
/Zc:__cplusplus
|
||||
/EHsc
|
||||
/Zc:preprocessor
|
||||
/translateInclude
|
||||
)
|
||||
endif()
|
||||
|
||||
target_sources(VulkanCppModule
|
||||
PUBLIC
|
||||
FILE_SET cxx_modules TYPE CXX_MODULES
|
||||
BASE_DIRS
|
||||
"${Vulkan_INCLUDE_DIR}"
|
||||
FILES
|
||||
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
|
||||
)
|
||||
|
||||
target_sources(VulkanCppModule
|
||||
PRIVATE
|
||||
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
|
||||
)
|
||||
else()
|
||||
add_library(VulkanCppModule INTERFACE)
|
||||
add_library(Vulkan::cppm ALIAS VulkanCppModule)
|
||||
target_link_libraries(VulkanCppModule INTERFACE Vulkan::Vulkan)
|
||||
target_compile_definitions(VulkanCppModule
|
||||
INTERFACE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1
|
||||
)
|
||||
endif()
|
||||
|
||||
37
oatmeal/cmake/glsl.cmake
Normal file
37
oatmeal/cmake/glsl.cmake
Normal file
@@ -0,0 +1,37 @@
|
||||
option(SHADERS_DIR "Directory to look for GLSL shaders" "assets/shaders")
|
||||
|
||||
find_program(GLSLC_EXECUTABLE NAMES glslc)
|
||||
if(NOT GLSLC_EXECUTABLE)
|
||||
message(FATAL_ERROR "glslc executable not found.")
|
||||
else()
|
||||
message(STATUS "Found glslc executable: ${GLSLC_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
function(create_glslc_shader_target TARGET SOURCE_DIR OUTPUT_DIR)
|
||||
file(MAKE_DIRECTORY ${OUTPUT_DIR})
|
||||
message(STATUS "GLSL Shader output directory: ${OUTPUT_DIR}")
|
||||
file (GLOB SHADER_FILES "${SOURCE_DIR}/*.vert")
|
||||
file(GLOB FRAG_FILES "${SOURCE_DIR}/*.frag")
|
||||
list(APPEND SHADER_FILES ${FRAG_FILES})
|
||||
message(STATUS "Found glsl shaders: ${SHADER_FILES}")
|
||||
set(OUTPUT_FILES "")
|
||||
foreach(SHADER_FILE ${SHADER_FILES})
|
||||
get_filename_component(SHADER_NAME ${SHADER_FILE} NAME)
|
||||
set(OUTPUT_FILE "${OUTPUT_DIR}/${SHADER_NAME}.spv")
|
||||
list(APPEND OUTPUT_FILES ${OUTPUT_FILE})
|
||||
message(STATUS "Compiling ${SHADER_FILE} to ${OUTPUT_FILE}")
|
||||
add_custom_command (
|
||||
OUTPUT ${OUTPUT_FILE}
|
||||
COMMAND ${GLSLC_EXECUTABLE} ${SHADER_FILE} -o ${OUTPUT_FILE}
|
||||
DEPENDS ${SHADER_FILE}
|
||||
COMMENT "Compiling ${SHADER_FILE} -> ${OUTPUT_FILE}"
|
||||
VERBATIM
|
||||
)
|
||||
endforeach()
|
||||
add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILES})
|
||||
endfunction()
|
||||
|
||||
create_glslc_shader_target(glsl_shaders
|
||||
"${SHADERS_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${SHADERS_DIR}"
|
||||
)
|
||||
5
oatmeal/cmake/ktx.cmake
Normal file
5
oatmeal/cmake/ktx.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
CPMAddPackage(
|
||||
URI "gh:KhronosGroup/KTX-Software@4.4.2"
|
||||
OPTIONS "KTX_FEATURE_TESTS OFF"
|
||||
OPTIONS "KTX_FEATURE_JS OFF"
|
||||
)
|
||||
10
oatmeal/cmake/platform.cmake
Normal file
10
oatmeal/cmake/platform.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
message("System name: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
|
||||
add_compile_definitions(PLATFORM_WINDOWS)
|
||||
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
|
||||
add_compile_definitions(PLATFORM_LINUX)
|
||||
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
add_compile_definitions(PLATFORM_MACOS)
|
||||
else()
|
||||
add_compile_definitions(PLATFORM_UNKNOWN)
|
||||
endif()
|
||||
36
oatmeal/cmake/slang.cmake
Normal file
36
oatmeal/cmake/slang.cmake
Normal file
@@ -0,0 +1,36 @@
|
||||
option(SHADERS_DIR "Directory to look for SLANG shaders" "assets/shaders")
|
||||
|
||||
find_program(SLANGC_EXECUTABLE NAMES slangc)
|
||||
if(NOT SLANGC_EXECUTABLE)
|
||||
message(FATAL_ERROR "slangc executable not found.")
|
||||
else()
|
||||
message(STATUS "Found slangc executable: ${SLANGC_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
function(create_slang_shader_target TARGET SOURCE_DIR OUTPUT_DIR)
|
||||
file(MAKE_DIRECTORY ${OUTPUT_DIR})
|
||||
message(STATUS "Shader output directory: ${OUTPUT_DIR}")
|
||||
file(GLOB SHADER_FILES "${SOURCE_DIR}/*.slang")
|
||||
message(STATUS "Found shaders: ${SHADER_FILES}")
|
||||
set(ENTRY_POINTS -entry vertMain -entry fragMain)
|
||||
set(OUTPUT_FILES "")
|
||||
foreach(SHADER_FILE ${SHADER_FILES})
|
||||
get_filename_component(SHADER_NAME ${SHADER_FILE} NAME_WE)
|
||||
set(OUTPUT_FILE "${OUTPUT_DIR}/${SHADER_NAME}.spv")
|
||||
list(APPEND OUTPUT_FILES ${OUTPUT_FILE})
|
||||
message(STATUS "Compiling ${SHADER_FILE} to ${OUTPUT_FILE}")
|
||||
add_custom_command(
|
||||
OUTPUT ${OUTPUT_FILE}
|
||||
COMMAND ${SLANGC_EXECUTABLE} ${SHADER_FILE} -target spirv -profile spirv_1_4 -emit-spirv-directly -fvk-use-entrypoint-name ${ENTRY_POINTS} -o ${OUTPUT_FILE}
|
||||
DEPENDS ${SHADER_FILE}
|
||||
COMMENT "Compiling ${SHADER_FILE} -> ${OUTPUT_FILE}"
|
||||
VERBATIM
|
||||
)
|
||||
endforeach()
|
||||
add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILES})
|
||||
endfunction()
|
||||
|
||||
create_slang_shader_target(slang_shaders
|
||||
"${SHADERS_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${SHADERS_DIR}"
|
||||
)
|
||||
4
oatmeal/cmake/stb.cmake
Normal file
4
oatmeal/cmake/stb.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
||||
CPMAddPackage(
|
||||
URI "gh:ovis-interactive/stb-cmake-wrapper@0.1"
|
||||
)
|
||||
11
oatmeal/src/ctx.cpp
Normal file
11
oatmeal/src/ctx.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "ctx.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace Oatmeal {
|
||||
ctx::ctx() {}
|
||||
|
||||
ctx::~ctx() {}
|
||||
|
||||
void ctx::test() { std::cout << "Test" << std::endl; }
|
||||
|
||||
} // namespace Oatmeal
|
||||
12
oatmeal/src/ctx.h
Normal file
12
oatmeal/src/ctx.h
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Oatmeal {
|
||||
|
||||
class ctx {
|
||||
public:
|
||||
ctx();
|
||||
~ctx();
|
||||
|
||||
void test();
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace Oatmeal
|
||||
8
scripts/build-debug.sh
Executable file
8
scripts/build-debug.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#/bin/bash
|
||||
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p debug
|
||||
cd debug
|
||||
ninja
|
||||
8
scripts/build-release.sh
Executable file
8
scripts/build-release.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#/bin/bash
|
||||
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p release
|
||||
cd release
|
||||
ninja
|
||||
8
scripts/build-relwithdeb.sh
Executable file
8
scripts/build-relwithdeb.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#/bin/bash
|
||||
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p relwithdeb
|
||||
cd relwithdeb
|
||||
ninja
|
||||
32
scripts/build.sh
Executable file
32
scripts/build.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ../
|
||||
mkdir -p build
|
||||
cd build || exit
|
||||
mkdir -p debug
|
||||
mkdir -p release
|
||||
mkdir -p relwithdeb
|
||||
|
||||
cd debug || exit
|
||||
cmake ../../ -G Ninja -DCMAKE_BUILD_TYPE=Debug &
|
||||
cd ../
|
||||
cd release || exit
|
||||
cmake ../../ -G Ninja -DCMAKE_BUILD_TYPE=Release &
|
||||
cd ../
|
||||
cd relwithdeb || exit
|
||||
cmake ../../ -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo &
|
||||
cd ../
|
||||
|
||||
wait
|
||||
|
||||
cd debug || exit
|
||||
ninja &
|
||||
cd ../
|
||||
cd release || exit
|
||||
ninja &
|
||||
cd ../
|
||||
cd relwithdeb || exit
|
||||
ninja &
|
||||
cd ../..
|
||||
|
||||
wait
|
||||
13
scripts/clean.sh
Executable file
13
scripts/clean.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ..
|
||||
cd build/debug || exit
|
||||
ninja clean
|
||||
|
||||
cd ..
|
||||
cd release || exit
|
||||
ninja clean
|
||||
|
||||
cd ..
|
||||
cd relwithdeb || exit
|
||||
ninja clean
|
||||
8
scripts/configure-debug.sh
Executable file
8
scripts/configure-debug.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#/bin/bash
|
||||
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p debug
|
||||
cd debug
|
||||
cmake ../../ -G Ninja -DCMAKE_BUILD_TYPE=Debug
|
||||
8
scripts/configure-release.sh
Executable file
8
scripts/configure-release.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#/bin/bash
|
||||
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p release
|
||||
cd release
|
||||
cmake ../../ -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
8
scripts/configure-relwithdeb.sh
Executable file
8
scripts/configure-relwithdeb.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#/bin/bash
|
||||
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p relwithdeb
|
||||
cd relwithdeb
|
||||
cmake ../../ -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
Reference in New Issue
Block a user