From 8c7926588b616988e7b016eaf704acee0ee77cc9 Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Thu, 5 Sep 2024 01:11:42 -0700 Subject: Initial setup --- .gitignore | 41 ++++++++++++++++++++++++++++++++++++ .gitmodules | 12 +++++++++++ CMakeLists.txt | 36 +++++++++++++++++++++++++++++++ ext/argparse | 1 + ext/imgui | 1 + ext/imgui.cmake | 13 ++++++++++++ ext/tinygltf.git | 1 + ext/tinyobjloader | 1 + src/app.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 169 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 ext/argparse create mode 160000 ext/imgui create mode 100644 ext/imgui.cmake create mode 160000 ext/tinygltf.git create mode 160000 ext/tinyobjloader create mode 100644 src/app.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6eb228f --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# clangd cache +.cache/ + +# VSCode settings +.vscode/ + +# CMake build directory +build/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3c3f029 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "ext/tinyobjloader"] + path = ext/tinyobjloader + url = https://github.com/tinyobjloader/tinyobjloader.git +[submodule "ext/imgui"] + path = ext/imgui + url = https://github.com/ocornut/imgui.git +[submodule "ext/argparse"] + path = ext/argparse + url = https://github.com/p-ranav/argparse.git +[submodule "ext/tinygltf.git"] + path = ext/tinygltf.git + url = https://github.com/syoyo/tinygltf.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..05e821f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,36 @@ +# CMakeLists.txt + +cmake_minimum_required(VERSION 3.11) + +project(IrisRenderer VERSION 1.0) + +set(CMAKE_CXX_STANDARD 20) +set(PROJECT_ROOT ${CMAKE_SOURCE_DIR}) +set(SRC_DIR ${PROJECT_ROOT}/src) +set(EXT_DIR ${PROJECT_ROOT}/ext) + +# Add external libraries +include(${EXT_DIR}/imgui.cmake) + +add_library(argparse INTERFACE) +target_include_directories(argparse INTERFACE ${EXT_DIR}/argparse/include) + +add_library(tinygltf INTERFACE) +target_include_directories(tinygltf INTERFACE ${EXT_DIR}/tinygltf) + +add_library(tinyobjloader INTERFACE) +target_include_directories(tinyobjloader INTERFACE ${EXT_DIR}/tinyobjloader) + +# Add your project's source files +file(GLOB_RECURSE SOURCES "${SRC_DIR}/*.cpp") + +# Add executable from your source files +add_executable(IrisRenderer ${SOURCES}) + +find_package(glfw3 REQUIRED) + +# Link external libraries to your project +target_link_libraries(IrisRenderer PRIVATE argparse imgui tinygltf tinyobjloader glfw) + +# Optional: Include additional compiler options or flags +target_compile_options(IrisRenderer PRIVATE -Wall -Wextra) diff --git a/ext/argparse b/ext/argparse new file mode 160000 index 0000000..fd13c28 --- /dev/null +++ b/ext/argparse @@ -0,0 +1 @@ +Subproject commit fd13c2859131ab463e617a5a8abcc69eb7e1d897 diff --git a/ext/imgui b/ext/imgui new file mode 160000 index 0000000..1dfbb10 --- /dev/null +++ b/ext/imgui @@ -0,0 +1 @@ +Subproject commit 1dfbb100d6ca6e7d813102e979c07f66a56546bb diff --git a/ext/imgui.cmake b/ext/imgui.cmake new file mode 100644 index 0000000..42d7c5d --- /dev/null +++ b/ext/imgui.cmake @@ -0,0 +1,13 @@ +set(IMGUI_DIR ${EXT_DIR}/imgui) +add_library(imgui STATIC + ${IMGUI_DIR}/imgui.cpp + ${IMGUI_DIR}/imgui_demo.cpp + ${IMGUI_DIR}/imgui_draw.cpp + ${IMGUI_DIR}/imgui_widgets.cpp + ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp +) + +target_include_directories(imgui PUBLIC + ${IMGUI_DIR} + ${IMGUI_DIR}/backends +) \ No newline at end of file diff --git a/ext/tinygltf.git b/ext/tinygltf.git new file mode 160000 index 0000000..fda7422 --- /dev/null +++ b/ext/tinygltf.git @@ -0,0 +1 @@ +Subproject commit fda7422022ff058b1b7b501d373a97b1cc377bfd diff --git a/ext/tinyobjloader b/ext/tinyobjloader new file mode 160000 index 0000000..50461d0 --- /dev/null +++ b/ext/tinyobjloader @@ -0,0 +1 @@ +Subproject commit 50461d0e0a77c178bb478e9319d7de82f469a848 diff --git a/src/app.cpp b/src/app.cpp new file mode 100644 index 0000000..7ef2310 --- /dev/null +++ b/src/app.cpp @@ -0,0 +1,63 @@ +#include "imgui.h" +#include "imgui_impl_glfw.h" +#include "imgui_impl_vulkan.h" +#include "argparse/argparse.hpp" +#include + +#include + +GLFWwindow *start_up(int width, int height) { + return nullptr; +} + +void main_loop(GLFWwindow *window) { + +} + +void shut_down(GLFWwindow *window) { + +} + +int main(int argc, char** argv) { + argparse::ArgumentParser program("IrisRenderer"); + program.add_argument("width") + .help("display width of the window") + .scan<'i', int>(); + program.add_argument("height") + .help("display height of the window") + .scan<'i', int>(); + + try { + program.parse_args(argc, argv); + } catch (const std::exception& err) { + std::cerr << err.what() << std::endl; + std::cerr << program; + return 1; + } + + int window_width = program.get("width"); + int window_height = program.get("height"); + + if (!glfwInit()) { + const char* description = nullptr; + glfwGetError(&description); + if (description != nullptr) { + std::cerr << "Error: " << description << std::endl; + } else { + std::cerr << "Failed to initialize GLFW" << std::endl; + } + + glfwTerminate(); + return -1; + } + + auto window = start_up(window_width, window_height); + if (window == nullptr) { + return -2; + } + while (!glfwWindowShouldClose(window)) { + main_loop(window); + } + shut_down(window); + return 0; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2