From 6ba58a2ec599d4e6219eb3f742f0a331854b262a Mon Sep 17 00:00:00 2001 From: Gabor Galgoczy <ggabor2002@gmail.com> Date: Wed, 14 Feb 2024 13:28:56 +0100 Subject: [PATCH] Revert "Clean code" This reverts commit 47a7c1a708581df73130a7673f6bb23405e6cbf7. --- .clang-format | 195 +++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 115 ++++++++++++++++++++++++++ src/App.cpp | 8 ++ src/App.hpp | 6 ++ src/CMakeLists.txt | 4 + src/main.cpp | 6 ++ 6 files changed, 334 insertions(+) create mode 100644 .clang-format create mode 100644 CMakeLists.txt create mode 100644 src/App.cpp create mode 100644 src/App.hpp create mode 100644 src/CMakeLists.txt create mode 100644 src/main.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..46ee31a --- /dev/null +++ b/.clang-format @@ -0,0 +1,195 @@ +--- +Language: Cpp +BasedOnStyle: Google + +AccessModifierOffset: -4 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: Right +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true +AlignConsecutiveMacros: Consecutive +AlignEscapedNewlines: Left +AlignOperands: AlignAfterOperator +AlignTrailingComments: + Kind: Always + OverEmptyLines: 1 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: [ ] +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: MultiLine + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyNamespace: true +BreakAfterAttributes: Leave +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +BreakBeforeConceptDeclarations: Always +# BreakBeforeInlineASMColon: +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +FixNamespaceComments: true +ForEachMacros: [ 'RANGES_FOR', 'FOREACH' ] +IfMacros: [ 'IF' ] +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^<glm/' + Priority: 1 + - Regex: '^<vulkan/' + Priority: 2 + - Regex: '<vk_mem_alloc.h>' + Priority: 3 + - Regex: '^<glfw/' + Priority: 4 + - Regex: '^<.*\..*' + Priority: 998 + - Regex: '^<.*' + Priority: 1 + - Regex: '\/.*' + Priority: 999 + - Regex: '.*' + Priority: 1000 +IncludeIsMainRegex: '' +# IncludeIsMainSourceRegex: +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: Indent +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: true +InsertBraces: true +InsertNewlineAtEOF: true +IntegerLiteralSeparator: + Binary: 4 + Decimal: 3 + Hex: 2 +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature +LineEnding: LF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +NamespaceMacros: [ ] +PPIndentWidth: 2 +PackConstructorInitializers: CurrentLine +#PenaltyBreakAssignment: 10 +#PenaltyBreakBeforeFirstCallParameter: 30 +#PenaltyBreakComment: 10 +#PenaltyBreakFirstLessLess: 0 +#PenaltyBreakOpenParenthesis: 10 +#PenaltyBreakString: 10 +#PenaltyBreakTemplateDeclaration: 20 +#PenaltyExcessCharacter: 1 +#PenaltyIndentedWhitespace: 0 +#PenaltyReturnTypeOnItsOwnLine: 5 +PointerAlignment: Left +QualifierAlignment: Custom +QualifierOrder: [ 'constexpr', 'inline', 'static', 'volatile', 'const', 'type', 'restrict' ] +RawStringFormats: + - Language: Cpp +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Always +ShortNamespaceLines: 0 +SortIncludes: CaseInsensitive +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: false + AfterFunctionDeclarationName: false + AfterFunctionDefinitionName: false + AfterIfMacros: false + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: true + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 3 +SpacesInAngles: Never +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: [ ] +StatementMacros: [ ] +TabWidth: 4 +TypenameMacros: [ ] +UseTab: Never +WhitespaceSensitiveMacros: [ ] +--- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fc7a882 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,115 @@ +cmake_minimum_required(VERSION 3.25) + +include(FetchContent) +set(FETCHCONTENT_QUIET OFF) + +project(renderer C CXX) + + +add_executable(${PROJECT_NAME}) + + +option(engine_debug "Turn on debug mode" ON) + + +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) + + +if (MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE + /W4 + /WX + ) +else () + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall + -Wextra + -Werror + -Wno-missing-field-initializers + ) +endif () + + +target_precompile_headers(${PROJECT_NAME} PRIVATE + <algorithm> + <concepts> + <expected> + <fstream> + <functional> + <iostream> + <limits> + <memory> + <ranges> + <set> + <span> + <sstream> + <stdexcept> + <string> + <string_view> + <thread> + <type_traits> + <unordered_map> + <utility> + <vector> + <variant> +) + + +# Vulkan +find_package(Vulkan REQUIRED) +target_compile_definitions(${PROJECT_NAME} PRIVATE + VULKAN_HPP_NO_TO_STRING + VULKAN_HPP_NO_CONSTRUCTORS + VULKAN_HPP_NO_SETTERS + VULKAN_HPP_NO_SPACESHIP_OPERATOR +) +if (engine_debug) + target_compile_definitions(${PROJECT_NAME} PRIVATE ENGINE_VULKAN_DEBUG) +endif () +target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Vulkan) + +# VulkanMemoryAllocator +set(STATIC_VULKAN_FUNCTIONS 0) +set(DYNAMIC_VULKAN_FUNCTIONS 1) +FetchContent_Declare(VulkanMemoryAllocator + GIT_REPOSITORY https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git + GIT_TAG 2f382df + GIT_PROGRESS TRUE + SYSTEM +) +FetchContent_MakeAvailable(VulkanMemoryAllocator) +target_compile_definitions(${PROJECT_NAME} PRIVATE + VMA_STATIC_VULKAN_FUNCTIONS=${STATIC_VULKAN_FUNCTIONS} + VMA_DYNAMIC_VULKAN_FUNCTIONS=${DYNAMIC_VULKAN_FUNCTIONS} +) +target_link_libraries(${PROJECT_NAME} PRIVATE VulkanMemoryAllocator) + +# GLFW +FetchContent_Declare(GLFW + GIT_REPOSITORY https://github.com/glfw/glfw.git + GIT_TAG 3.3.9 + GIT_PROGRESS TRUE + SYSTEM +) +FetchContent_MakeAvailable(GLFW) +target_compile_definitions(${PROJECT_NAME} PRIVATE + GLFW_INCLUDE_VULKAN +) +target_link_libraries(${PROJECT_NAME} PRIVATE glfw) + +# glm +FetchContent_Declare(glm + GIT_REPOSITORY https://github.com/g-truc/glm.git + GIT_TAG 0.9.9.8 + GIT_PROGRESS TRUE + SYSTEM +) +FetchContent_MakeAvailable(glm) +target_compile_definitions(${PROJECT_NAME} PRIVATE + GLM_FORCE_DEPTH_ZERO_TO_ONE +) +target_precompile_headers(${PROJECT_NAME} PRIVATE <glm/glm.hpp>) +target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm) + + +add_subdirectory(src) diff --git a/src/App.cpp b/src/App.cpp new file mode 100644 index 0000000..f7f656f --- /dev/null +++ b/src/App.cpp @@ -0,0 +1,8 @@ +#include "App.hpp" + +#include <iostream> + +void App::run() +{ + std::cout << "Hello World!\n"; +} diff --git a/src/App.hpp b/src/App.hpp new file mode 100644 index 0000000..31131e7 --- /dev/null +++ b/src/App.hpp @@ -0,0 +1,6 @@ +#pragma once + +class App { +public: + void run(); +}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..8e99fbf --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(${PROJECT_NAME} PRIVATE + App.cpp + main.cpp +) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..f1161cf --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,6 @@ +#include "App.hpp" + +int main() +{ + App{}.run(); +} -- GitLab