From c958df07d059d8e35f742051add26e9a60dce654 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 11 Apr 2024 20:40:12 -0400 Subject: [PATCH] init commit --- .gitmodules | 3 ++ .idea/.gitignore | 8 ++++ .idea/graphs.iml | 2 + .idea/misc.xml | 4 ++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ CMakeLists.txt | 10 ++-- commit.py | 86 ++++++++++++++++++++++++++++++++++ lib/BLT-With-Graphics-Template | 1 + main.cpp | 7 --- src/main.cpp | 56 ++++++++++++++++++++++ 11 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 .gitmodules create mode 100644 .idea/.gitignore create mode 100644 .idea/graphs.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100755 commit.py create mode 160000 lib/BLT-With-Graphics-Template delete mode 100644 main.cpp create mode 100644 src/main.cpp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ea94d4e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/BLT-With-Graphics-Template"] + path = lib/BLT-With-Graphics-Template + url = https://git.tpgc.me/tri11paragon/BLT-With-Graphics-Template diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/graphs.iml b/.idea/graphs.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/graphs.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0771a44 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d5e637..32b9bab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(graphs) +project(graphs VERSION 0.0.2) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) @@ -7,13 +7,17 @@ option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) set(CMAKE_CXX_STANDARD 17) +add_subdirectory(lib/BLT-With-Graphics-Template) + include_directories(include/) file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") add_executable(graphs ${PROJECT_BUILD_FILES}) -target_compile_options(graphs PRIVATE -Wall -Werror -Wpedantic -Wno-comment) -target_link_options(graphs PRIVATE -Wall -Werror -Wpedantic -Wno-comment) +target_compile_options(graphs PRIVATE -Wall -Wextra -Wpedantic -Wno-comment) +target_link_options(graphs PRIVATE -Wall -Wextra -Wpedantic -Wno-comment) + +target_link_libraries(graphs PUBLIC BLT_WITH_GRAPHICS) if (${ENABLE_ADDRSAN} MATCHES ON) target_compile_options(graphs PRIVATE -fsanitize=address) diff --git a/commit.py b/commit.py new file mode 100755 index 0000000..1a2a41b --- /dev/null +++ b/commit.py @@ -0,0 +1,86 @@ +#!/usr/bin/python3 + +import subprocess + +#--------------------------------------- +# CONFIG +#--------------------------------------- + +VERSION_BEGIN_STR = "project(graphs VERSION " +VERSION_END_STR = ")" +PATCH_LIMIT = 100000 + +#--------------------------------------- +# DO NOT TOUCH +#--------------------------------------- + +def load_cmake(): + cmake_file = open("CMakeLists.txt", 'r') + cmake_text = cmake_file.read() + cmake_file.close() + return cmake_text + +def write_cmake(cmake_text): + cmake_file = open("CMakeLists.txt", 'w') + cmake_file.write(cmake_text) + cmake_file.close() + +def get_version(cmake_text): + begin = cmake_text.find(VERSION_BEGIN_STR) + len(VERSION_BEGIN_STR) + end = cmake_text.find(VERSION_END_STR, begin) + return (cmake_text[begin:end], begin, end) + +def split_version(cmake_text): + version, begin, end = get_version(cmake_text) + version_parts = version.split('.') + return (version_parts, begin, end) + +def recombine(cmake_text, version_parts, begin, end): + constructed_version = version_parts[0] + '.' + version_parts[1] + '.' + version_parts[2] + constructed_text_begin = cmake_text[0:begin] + constrcuted_text_end = cmake_text[end::] + return constructed_text_begin + constructed_version + constrcuted_text_end + + +def inc_major(cmake_text): + version_parts, begin, end = split_version(cmake_text) + version_parts[0] = str(int(version_parts[0]) + 1) + version_parts[1] = '0' + version_parts[2] = '0' + return recombine(cmake_text, version_parts, begin, end) + +def inc_minor(cmake_text): + version_parts, begin, end = split_version(cmake_text) + version_parts[1] = str(int(version_parts[1]) + 1) + version_parts[2] = '0' + return recombine(cmake_text, version_parts, begin, end) + +def inc_patch(cmake_text): + version_parts, begin, end = split_version(cmake_text) + if int(version_parts[2]) + 1 >= PATCH_LIMIT: + return inc_minor(cmake_text) + version_parts[2] = str(int(version_parts[2]) + 1) + return recombine(cmake_text, version_parts, begin, end) + +cmake_text = load_cmake() +cmake_version = get_version(cmake_text)[0] +print(f"Current Version: {cmake_version}") + +try: + type = input("What kind of commit is this ((M)ajor, (m)inor, (p)atch)? ") + + if type.startswith('M'): + print("Selected major") + write_cmake(inc_major(cmake_text)) + elif type.startswith('m'): + print("Selected minor") + write_cmake(inc_minor(cmake_text)) + elif type.startswith('p') or type.startswith('P') or len(type) == 0: + print("Selected patch") + write_cmake(inc_patch(cmake_text)) + + subprocess.call(["git", "add", "*"]) + subprocess.call(["git", "commit"]) + subprocess.call(["sh", "-c", "git remote | xargs -L1 git push --all"]) +except KeyboardInterrupt: + print("\nCancelling!") diff --git a/lib/BLT-With-Graphics-Template b/lib/BLT-With-Graphics-Template new file mode 160000 index 0000000..20a8974 --- /dev/null +++ b/lib/BLT-With-Graphics-Template @@ -0,0 +1 @@ +Subproject commit 20a8974f9b88bec1686c0a4bf0b6ace9850bdda3 diff --git a/main.cpp b/main.cpp deleted file mode 100644 index 4f9de56..0000000 --- a/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..594b7a6 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "blt/gfx/renderer/resource_manager.h" +#include "blt/gfx/renderer/batch_2d_renderer.h" +#include "blt/gfx/renderer/camera.h" +#include + +blt::gfx::matrix_state_manager global_matrices; +blt::gfx::resource_manager resources; +blt::gfx::batch_renderer_2d renderer_2d(resources); +blt::gfx::first_person_camera camera; + +void init() +{ + using namespace blt::gfx; + + global_matrices.create_internals(); + resources.load_resources(); + renderer_2d.create(); +} + +void update(std::int32_t width, std::int32_t height) +{ + global_matrices.update_perspectives(width, height, 90, 0.1, 2000); + + camera.update(); + camera.update_view(global_matrices); + global_matrices.update(); + + renderer_2d.render(); +} + +int main(int argc, const char** argv) +{ + blt::gfx::init(blt::gfx::window_data{"My Sexy Window", init, update}.setSyncInterval(1)); + global_matrices.cleanup(); + resources.cleanup(); + renderer_2d.cleanup(); + blt::gfx::cleanup(); +}