refactor: directory structure & cmake
|  | @ -1,28 +1,23 @@ | |||
| --- | ||||
| # Core | ||||
| Language: Cpp | ||||
| Standard: Cpp11 | ||||
| ColumnLimit: '0' # No limit | ||||
| Standard: Latest | ||||
| ColumnLimit: '100' | ||||
| 
 | ||||
| ### Bin pack ### | ||||
| BinPackArguments: 'true' | ||||
| BinPackParameters: 'true' | ||||
| # Bin pack | ||||
| BinPackArguments: 'false' | ||||
| BinPackParameters: 'false' | ||||
| 
 | ||||
| # Includes | ||||
| SortIncludes: 'true' | ||||
| IncludeBlocks: Regroup | ||||
| IncludeCategories: | ||||
|     # Current Project | ||||
|     - Regex: '"' | ||||
|       Priority: 001 | ||||
|      | ||||
|     # Custom Project Categories... | ||||
| 
 | ||||
|     # Dependecies | ||||
|     # Normal includes | ||||
|     - Regex: '<' | ||||
|       Priority: 500 | ||||
|      | ||||
|     # Custom Deependencies Categories... | ||||
|     # Custom include categories... | ||||
| 
 | ||||
|     # C++ includes | ||||
|     - Regex: '[^.h .hpp]>' | ||||
|  | @ -82,20 +77,20 @@ SpacesInContainerLiterals: 'false' | |||
| SpacesInParentheses: 'false' | ||||
| SpacesInSquareBrackets: 'false' | ||||
| 
 | ||||
| ### Alignment ### | ||||
| PointerAlignment: Left | ||||
| # Alignment  | ||||
| PointerAlignment: Right | ||||
| DerivePointerAlignment: 'false' | ||||
| AlignAfterOpenBracket: Align | ||||
| AlignEscapedNewlines: Left | ||||
| AlignAfterOpenBracket: BlockIndent | ||||
| AlignConsecutiveDeclarations: 'false' | ||||
| AlignConsecutiveAssignments: 'true' | ||||
| AlignConsecutiveAssignments: 'false' | ||||
| AlignConsecutiveMacros: 'true' | ||||
| AlignOperands: 'true' | ||||
| AlignTrailingComments: 'true' | ||||
| 
 | ||||
| ### Single Line ### | ||||
| # Single Line  | ||||
| AllowShortCaseLabelsOnASingleLine: 'true' | ||||
| AllowShortFunctionsOnASingleLine: Inline | ||||
| AllowShortFunctionsOnASingleLine: 'false' | ||||
| AllowShortLambdasOnASingleLine: Inline | ||||
| AllowAllArgumentsOnNextLine: 'false' | ||||
| AllowShortLoopsOnASingleLine: 'false' | ||||
|  | @ -103,33 +98,32 @@ AllowShortBlocksOnASingleLine: 'false' | |||
| AllowAllParametersOfDeclarationOnNextLine: 'false' | ||||
| AllowShortIfStatementsOnASingleLine: Never | ||||
| 
 | ||||
| ### Break ### | ||||
| # Break  | ||||
| AlwaysBreakAfterReturnType: None | ||||
| AlwaysBreakBeforeMultilineStrings: 'false' | ||||
| AlwaysBreakTemplateDeclarations: 'Yes' | ||||
| BreakBeforeBinaryOperators: None | ||||
| BreakBeforeBinaryOperators: All | ||||
| BreakBeforeTernaryOperators: 'false' | ||||
| BreakInheritanceList: BeforeComma | ||||
| BreakStringLiterals: 'false' | ||||
| BreakStringLiterals: 'true' | ||||
| 
 | ||||
| # Penalties | ||||
| PenaltyBreakAssignment: '0' | ||||
| PenaltyBreakAssignment: '99999' | ||||
| PenaltyBreakBeforeFirstCallParameter: '0' | ||||
| PenaltyBreakComment: '0' | ||||
| PenaltyBreakFirstLessLess: '0' | ||||
| PenaltyBreakString: '0' | ||||
| PenaltyBreakTemplateDeclaration: '0' | ||||
| PenaltyExcessCharacter: '0' | ||||
| PenaltyExcessCharacter: '999999999' | ||||
| PenaltyReturnTypeOnItsOwnLine: '999999999' # Nope | ||||
| 
 | ||||
| # Constructor Initializers | ||||
| ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' | ||||
| AllowAllConstructorInitializersOnNextLine: 'true' | ||||
| AllowAllConstructorInitializersOnNextLine: 'false' | ||||
| BreakConstructorInitializers: BeforeComma | ||||
| 
 | ||||
| # Comments | ||||
| ReflowComments: 'false' | ||||
| CommentPragmas: '^ TODO@:' | ||||
| ReflowComments: 'true' | ||||
| FixNamespaceComments: 'true' | ||||
| 
 | ||||
| # Misc | ||||
|  | @ -137,3 +131,5 @@ Cpp11BracedListStyle: 'false' | |||
| SortUsingDeclarations: 'true' | ||||
| KeepEmptyLinesAtTheStartOfBlocks: 'false' | ||||
| MaxEmptyLinesToKeep: '2' | ||||
| 
 | ||||
| ExperimentalAutoDetectBinPacking: false | ||||
|  |  | |||
							
								
								
									
										250
									
								
								.clang-tidy
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,250 @@ | |||
| --- | ||||
| Checks: "-*, | ||||
| 
 | ||||
| performance-unnecessary-value-param, | ||||
| performance-unnecessary-copy-initialization, | ||||
| performance-type-promotion-in-math-fn, | ||||
| performance-trivially-destructible, | ||||
| performance-noexcept-swap, | ||||
| performance-noexcept-move-constructor, | ||||
| performance-noexcept-destructor, | ||||
| performance-no-int-to-ptr, | ||||
| performance-no-automatic-move, | ||||
| performance-move-constructor-init, | ||||
| performance-move-const-arg, | ||||
| performance-inefficient-vector-operation, | ||||
| performance-inefficient-string-concatenation, | ||||
| performance-inefficient-algorithm, | ||||
| performance-implicit-conversion-in-loop, | ||||
| performance-for-range-copy, | ||||
| performance-faster-string-find, | ||||
| performance-enum-size, | ||||
| performance-avoid-endl, | ||||
| 
 | ||||
| readability-avoid-const-params-in-decls, | ||||
| readability-avoid-nested-conditional-operator, | ||||
| readability-avoid-return-with-void-value, | ||||
| readability-avoid-unconditional-preprocessor-if, | ||||
| readability-braces-around-statements, | ||||
| readability-const-return-type, | ||||
| readability-container-contains, | ||||
| readability-container-data-pointdr, | ||||
| readability-container-size-empty, | ||||
| readability-delete-null-pointer, | ||||
| readability-duplicate-include, | ||||
| readability-else-after-return, | ||||
| readability-inconsistent-declaration-parameter-name, | ||||
| readability-isolate-declaration, | ||||
| readability-make-member-function-const, | ||||
| readability-misleading-indentation, | ||||
| readability-misplaced-array-index, | ||||
| readability-named-parameter, | ||||
| readability-non-const-parameter, | ||||
| readability-qualified-auto, | ||||
| readability-redundant-access-specifiers, | ||||
| readability-redundant-casting, | ||||
| readability-redundant-control-flow, | ||||
| readability-redundant-declaration, | ||||
| readability-redundant-function-ptr-dereference, | ||||
| readability-redundant-inline-specifier, | ||||
| readability-redundant-member-init, | ||||
| readability-redundant-preprocessor, | ||||
| readability-redundant-smartptr-get, | ||||
| readability-redundant-string-cstr, | ||||
| readability-reference-to-constructed-temporary, | ||||
| readability-simplify-boolean-expr, | ||||
| readability-simplify-subscript-expr, | ||||
| readability-static-accessed-through-instance, | ||||
| readability-static-definition-in-anonymous-namespace, | ||||
| readability-string-compare, | ||||
| readability-suspicious-call-argument, | ||||
| readability-uniqueptr-delete-release, | ||||
| readability-use-anyofallof | ||||
| readability-use-std-min-max, | ||||
| readability-function-cognitive-complexity | ||||
| readability-function-size | ||||
| readability-identifier-naming | ||||
| readability-identifier-length | ||||
| readability-magic-numbers | ||||
| 
 | ||||
| modernize-avoid-bind, | ||||
| modernize-avoid-c-arrays, | ||||
| modernize-concat-nested-namespaces, | ||||
| modernize-deprecated-headers, | ||||
| modernize-deprecated-ios-base-aliases, | ||||
| modernize-loop-convert, | ||||
| modernize-macro-to-enum, | ||||
| modernize-make-shared, | ||||
| modernize-make-unique, | ||||
| modernize-pass-by-value, | ||||
| modernize-raw-string-literal, | ||||
| modernize-redundant-void-arg, | ||||
| modernize-replace-auto-ptr, | ||||
| modernize-replace-disallow-copy-and-assign-macro, | ||||
| modernize-replace-random-shuffle, | ||||
| modernize-return-braced-init-list, | ||||
| modernize-shrink-to-fit, | ||||
| modernize-type-traits, | ||||
| modernize-unary-static-assert, | ||||
| modernize-use-auto, | ||||
| modernize-use-bool-literals, | ||||
| modernize-use-constraints, | ||||
| modernize-use-default-member-init, | ||||
| modernize-use-designated-initializers, | ||||
| modernize-use-emplace, | ||||
| modernize-use-equals-default, | ||||
| modernize-use-equals-delete, | ||||
| modernize-use-nodiscard, | ||||
| modernize-use-noexcept, | ||||
| modernize-use-nullptr, | ||||
| modernize-use-override, | ||||
| modernize-use-starts-ends-with, | ||||
| modernize-use-std-numbers, | ||||
| modernize-use-std-print, | ||||
| modernize-use-transparent-functors, | ||||
| modernize-use-uncaught-exceptions, | ||||
| modernize-use-using | ||||
| modernize-min-max-use-initializer-list, | ||||
| 
 | ||||
| cppcoreguidelines-avoid-capturing-lambda-coroutines, | ||||
| cppcoreguidelines-avoid-const-or-ref-data-members, | ||||
| cppcoreguidelines-avoid-do-while, | ||||
| cppcoreguidelines-avoid-goto, | ||||
| cppcoreguidelines-avoid-non-const-global-variables, | ||||
| cppcoreguidelines-avoid-reference-coroutine-parameters, | ||||
| cppcoreguidelines-init-variables, | ||||
| cppcoreguidelines-interfaces-global-init, | ||||
| cppcoreguidelines-macro-usage, | ||||
| cppcoreguidelines-misleading-capture-default-by-value, | ||||
| cppcoreguidelines-missing-std-forward, | ||||
| cppcoreguidelines-narrowing-conversions, | ||||
| cppcoreguidelines-no-malloc, | ||||
| cppcoreguidelines-no-suspend-with-lock, | ||||
| cppcoreguidelines-owning-memory, | ||||
| cppcoreguidelines-prefer-member-initializer, | ||||
| cppcoreguidelines-pro-bounds-array-to-pointer-decay, | ||||
| cppcoreguidelines-pro-bounds-pointer-arithmetic, | ||||
| cppcoreguidelines-pro-type-const-cast, | ||||
| cppcoreguidelines-pro-type-cstyle-cast, | ||||
| cppcoreguidelines-pro-type-member-init, | ||||
| cppcoreguidelines-pro-type-reinterpret-cast, | ||||
| cppcoreguidelines-pro-type-static-cast-downcast, | ||||
| cppcoreguidelines-pro-type-union-access, | ||||
| cppcoreguidelines-pro-type-vararg, | ||||
| cppcoreguidelines-rvalue-reference-param-not-moved, | ||||
| cppcoreguidelines-slicing, | ||||
| cppcoreguidelines-special-member-functions, | ||||
| cppcoreguidelines-virtual-class-destructor, | ||||
| 
 | ||||
| bugprone-argument-comment, | ||||
| bugprone-assert-side-effect, | ||||
| bugprone-assignment-in-if-condition, | ||||
| bugprone-bad-signal-to-kill-thread, | ||||
| bugprone-bool-pointer-implicit-conversion, | ||||
| bugprone-branch-clone, | ||||
| bugprone-casting-through-void, | ||||
| bugprone-chained-comparison, | ||||
| bugprone-compare-pointer-to-member-virtual-function, | ||||
| bugprone-copy-constructor-init, | ||||
| bugprone-crtp-constructor-accessibility, | ||||
| bugprone-dangling-handle, | ||||
| bugprone-empty-catch, | ||||
| bugprone-exception-escape, | ||||
| bugprone-fold-init-type, | ||||
| bugprone-forward-declaration-namespace, | ||||
| bugprone-forwarding-reference-overload, | ||||
| bugprone-implicit-widening-of-multiplication-result, | ||||
| bugprone-inaccurate-erase, | ||||
| bugprone-inc-dec-in-conditions, | ||||
| bugprone-incorrect-enable-if, | ||||
| bugprone-incorrect-roundings, | ||||
| bugprone-infinite-loop, | ||||
| bugprone-integer-division, | ||||
| bugprone-lambda-function-name, | ||||
| bugprone-macro-parentheses, | ||||
| bugprone-macro-repeated-side-effects, | ||||
| bugprone-misplaced-operator-in-strlen-in-alloc, | ||||
| bugprone-misplaced-pointer-arithmetic-in-alloc, | ||||
| bugprone-misplaced-widening-cast, | ||||
| bugprone-move-forwarding-reference, | ||||
| bugprone-multi-level-implicit-pointer-conversion, | ||||
| bugprone-multiple-new-in-one-expression, | ||||
| bugprone-multiple-statement-macro, | ||||
| bugprone-no-escape, | ||||
| bugprone-non-zero-enum-to-bool-conversion, | ||||
| bugprone-not-null-terminated-result, | ||||
| bugprone-optional-value-conversion, | ||||
| bugprone-parent-virtual-call, | ||||
| bugprone-posix-return, | ||||
| bugprone-redundant-branch-condition, | ||||
| bugprone-reserved-identifier, | ||||
| bugprone-return-const-ref-from-parameter, | ||||
| bugprone-shared-ptr-array-mismatch, | ||||
| bugprone-signal-handler, | ||||
| bugprone-signed-char-misuse, | ||||
| bugprone-sizeof-container, | ||||
| bugprone-sizeof-expression, | ||||
| bugprone-spuriously-wake-up-functions, | ||||
| bugprone-standalone-empty, | ||||
| bugprone-string-constructor, | ||||
| bugprone-string-integer-assignment, | ||||
| bugprone-string-literal-with-embedded-nul, | ||||
| bugprone-stringview-nullptr, | ||||
| bugprone-suspicious-enum-usage, | ||||
| bugprone-suspicious-include, | ||||
| bugprone-suspicious-memory-comparison, | ||||
| bugprone-suspicious-memset-usage, | ||||
| bugprone-suspicious-missing-comma, | ||||
| bugprone-suspicious-realloc-usage, | ||||
| bugprone-suspicious-semicolon, | ||||
| bugprone-suspicious-string-compare, | ||||
| bugprone-suspicious-stringview-data-usage, | ||||
| bugprone-swapped-arguments, | ||||
| bugprone-switch-missing-default-case, | ||||
| bugprone-terminating-continue, | ||||
| bugprone-throw-keyword-missing, | ||||
| bugprone-too-small-loop-variable, | ||||
| bugprone-unchecked-optional-access, | ||||
| bugprone-undefined-memory-manipulation, | ||||
| bugprone-undelegated-constructor, | ||||
| bugprone-unhandled-exception-at-new, | ||||
| bugprone-unhandled-self-assignment, | ||||
| bugprone-unique-ptr-array-mismatch, | ||||
| bugprone-unsafe-functions, | ||||
| bugprone-unused-local-non-trivial-variable, | ||||
| bugprone-unused-raii, | ||||
| bugprone-unused-return-value, | ||||
| bugprone-use-after-move, | ||||
| bugprone-virtual-near-miss, | ||||
| 
 | ||||
| concurrency-mt-unsafe, | ||||
| concurrency-thread-canceltype-asynchronous, | ||||
| 
 | ||||
| misc-use-anonymous-namespace, | ||||
| misc-unused-using-decls, | ||||
| misc-unused-parameters, | ||||
| misc-unused-alias-decls, | ||||
| misc-uniqueptr-reset-release, | ||||
| misc-unconventional-assign-operator, | ||||
| misc-throw-by-value-catch-by-reference, | ||||
| misc-static-assert, | ||||
| misc-redundant-expression, | ||||
| misc-non-private-member-variables-in-classes, | ||||
| misc-non-copyable-objects, | ||||
| misc-no-recursion, | ||||
| misc-new-delete-overloads, | ||||
| misc-misplaced-const, | ||||
| misc-misleading-identifier, | ||||
| misc-misleading-bidirectional, | ||||
| misc-header-include-cycle, | ||||
| misc-definitions-in-headers, | ||||
| misc-coroutine-hostile-raii, | ||||
| misc-const-correctness, | ||||
| misc-confusable-identifiers, | ||||
| 
 | ||||
| hicpp-signed-bitwise, | ||||
| hicpp-no-assembler, | ||||
| hicpp-multiway-paths-covered, | ||||
| hicpp-ignored-remove-result, | ||||
| hicpp-exception-baseclass, | ||||
| " | ||||
							
								
								
									
										25
									
								
								.gitmodules
									
										
									
									
										vendored
									
									
								
							
							
						
						|  | @ -1,25 +1,4 @@ | |||
| [submodule "Dependencies/spdlog"] | ||||
| 	path = Dependencies/spdlog | ||||
| 	url = https://github.com/gabime/spdlog | ||||
| [submodule "Dependencies/GLFW"] | ||||
| 	path = Dependencies/GLFW | ||||
| 	url = https://github.com/glfw/glfw | ||||
| [submodule "Dependencies/glm"] | ||||
| 	path = Dependencies/glm | ||||
| 	url = https://github.com/g-truc/glm | ||||
| [submodule "Dependencies/imgui"] | ||||
| 	path = Dependencies/imgui | ||||
| [submodule "external/imgui"] | ||||
| 	path = external/imgui | ||||
| 	url = https://github.com/ocornut/imgui | ||||
| 	branch = docking | ||||
| [submodule "Dependencies/entt"] | ||||
| 	path = Dependencies/entt | ||||
| 	url = https://github.com/skypjack/entt | ||||
| [submodule "Dependencies/yaml-cpp"] | ||||
| 	path = Dependencies/yaml-cpp | ||||
| 	url = https://github.com/jbeder/yaml-cpp | ||||
| [submodule "Dependencies/shaderc"] | ||||
| 	path = Dependencies/shaderc | ||||
| 	url = https://github.com/google/shaderc | ||||
| [submodule "Dependencies/spirv-cross"] | ||||
| 	path = Dependencies/spirv-cross | ||||
| 	url = https://github.com/KhronosGroup/SPIRV-Cross | ||||
|  |  | |||
|  | @ -1,23 +1,8 @@ | |||
| cmake_minimum_required(VERSION 4.0) | ||||
| 
 | ||||
| 
 | ||||
| project(Light) | ||||
| set(CMAKE_CXX_STANDARD 20) | ||||
| set(CMAKE_CXX_STANDARD 23) | ||||
| 
 | ||||
| # directories | ||||
| set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||||
| set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | ||||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||||
| 
 | ||||
| set(CMAKE_EXPORT_COMPILE_COMMANDS True) | ||||
| 
 | ||||
| set(MIRROR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Mirror/) | ||||
| set(ENGINE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Engine/) | ||||
| set(DEPENDENCIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/) | ||||
| 
 | ||||
| if(NOT MSV) | ||||
|   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") | ||||
| endif() | ||||
| include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/macros.cmake) | ||||
| 
 | ||||
| if(WIN32) | ||||
|   add_compile_definitions(LIGHT_PLATFORM_WINDOWS) | ||||
|  | @ -25,11 +10,6 @@ elseif(UNIX) | |||
|   add_compile_definitions(LIGHT_PLATFORM_LINUX) | ||||
| endif() | ||||
| 
 | ||||
| # Projects | ||||
| add_subdirectory(${ENGINE_DIR}/) | ||||
| add_subdirectory(${MIRROR_DIR}/) | ||||
| 
 | ||||
| # Dependencies | ||||
| find_package(glfw3 REQUIRED) | ||||
| find_package(glm REQUIRED) | ||||
| find_package(spdlog REQUIRED) | ||||
|  | @ -38,44 +18,5 @@ find_package(yaml-cpp REQUIRED) | |||
| find_package(EnTT REQUIRED) | ||||
| find_package(opengl_system REQUIRED) | ||||
| 
 | ||||
| add_subdirectory(${DEPENDENCIES_DIR}) | ||||
| add_subdirectory(external/glad/) | ||||
| 
 | ||||
| # Link | ||||
| target_link_libraries( | ||||
|   imgui | ||||
|   PUBLIC glad | ||||
|   PUBLIC opengl::opengl | ||||
|   PUBLIC glm::glm  | ||||
|   PUBLIC glfw | ||||
| ) | ||||
| 
 | ||||
| target_link_libraries( | ||||
|   Engine | ||||
|   PUBLIC glad | ||||
|   PUBLIC opengl::opengl | ||||
|   PUBLIC glfw | ||||
|   PUBLIC spdlog::spdlog | ||||
|   PUBLIC imgui | ||||
|   PUBLIC stb::stb | ||||
|   PUBLIC yaml-cpp::yaml-cpp | ||||
|   PUBLIC EnTT::EnTT | ||||
| ) | ||||
| 
 | ||||
| target_link_libraries( | ||||
|   Mirror | ||||
|   PRIVATE Engine | ||||
|   PRIVATE opengl::opengl | ||||
|   PRIVATE imgui | ||||
| ) | ||||
| 
 | ||||
| # Precompiled headers | ||||
| target_precompile_headers(Engine PUBLIC ${ENGINE_DIR}src/Engine/ltpch.hpp) | ||||
| 
 | ||||
| if(MSVC) | ||||
|   set_property(DIRECTORY ${CMAE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Mirror) | ||||
| endif() | ||||
| 
 | ||||
| 
 | ||||
| set(CMAKE_BUILD_TYPE debug) | ||||
| set(CMAKE_EXPORT_COMPILE_COMMANDS_ON) | ||||
| add_subdirectory(./modules) | ||||
| add_subdirectory(./external) | ||||
|  |  | |||
|  | @ -1,139 +0,0 @@ | |||
| --- | ||||
| # Core | ||||
| Language: Cpp | ||||
| Standard: Cpp11 | ||||
| ColumnLimit: '0' # No limit | ||||
| 
 | ||||
| ### Bin pack ### | ||||
| BinPackArguments: 'true' | ||||
| BinPackParameters: 'true' | ||||
| 
 | ||||
| # Includes | ||||
| SortIncludes: 'true' | ||||
| IncludeBlocks: Regroup | ||||
| IncludeCategories: | ||||
|     # Current Project | ||||
|     - Regex: '"' | ||||
|       Priority: 001 | ||||
|      | ||||
|     # Custom Project Categories... | ||||
| 
 | ||||
|     # Dependecies | ||||
|     - Regex: '<' | ||||
|       Priority: 500 | ||||
|      | ||||
|     # Custom Deependencies Categories... | ||||
| 
 | ||||
|     # C++ includes | ||||
|     - Regex: '[^.h .hpp]>' | ||||
|       Priority: 998 | ||||
| 
 | ||||
|     # C includes | ||||
|     - Regex: '<[^/\n]+[.]h>' | ||||
|       Priority: 999 | ||||
| 
 | ||||
| # Braces | ||||
| BreakBeforeBraces: Custom | ||||
| BraceWrapping: | ||||
|     AfterCaseLabel: true | ||||
|     AfterClass: true | ||||
|     AfterControlStatement: true | ||||
|     AfterEnum: true | ||||
|     AfterFunction: true | ||||
|     AfterNamespace: false | ||||
|     AfterObjCDeclaration: true | ||||
|     AfterStruct: true | ||||
|     AfterUnion: true | ||||
|     AfterExternBlock: true | ||||
|     BeforeCatch: true | ||||
|     BeforeElse: true | ||||
|     IndentBraces: false | ||||
|     SplitEmptyFunction: true | ||||
|     SplitEmptyRecord: true | ||||
|     SplitEmptyNamespace: true | ||||
| 
 | ||||
| # Indentation | ||||
| UseTab: ForIndentation | ||||
| TabWidth: '4' | ||||
| IndentWidth: '4' | ||||
| ContinuationIndentWidth: '4' | ||||
| ConstructorInitializerIndentWidth: '4' | ||||
| IndentCaseLabels: 'false' | ||||
| IndentWrappedFunctionNames: 'true' | ||||
| IndentPPDirectives: BeforeHash | ||||
| NamespaceIndentation: None | ||||
| AccessModifierOffset: '-4' | ||||
| 
 | ||||
| # Space | ||||
| SpaceAfterCStyleCast: 'false' | ||||
| SpaceAfterLogicalNot: 'false' | ||||
| SpaceAfterTemplateKeyword: 'false' | ||||
| SpaceBeforeAssignmentOperators: 'true' | ||||
| SpaceBeforeCpp11BracedList: 'true' | ||||
| SpaceBeforeCtorInitializerColon: 'false' | ||||
| SpaceBeforeInheritanceColon: 'false' | ||||
| SpaceBeforeParens: ControlStatements | ||||
| SpaceBeforeRangeBasedForLoopColon: 'true' | ||||
| SpaceInEmptyParentheses: 'false' | ||||
| SpacesBeforeTrailingComments: '1' | ||||
| SpacesInAngles: 'false' | ||||
| SpacesInCStyleCastParentheses: 'false' | ||||
| SpacesInContainerLiterals: 'false' | ||||
| SpacesInParentheses: 'false' | ||||
| SpacesInSquareBrackets: 'false' | ||||
| 
 | ||||
| ### Alignment ### | ||||
| PointerAlignment: Left | ||||
| DerivePointerAlignment: 'false' | ||||
| AlignAfterOpenBracket: Align | ||||
| AlignEscapedNewlines: Left | ||||
| AlignConsecutiveDeclarations: 'false' | ||||
| AlignConsecutiveAssignments: 'true' | ||||
| AlignConsecutiveMacros: 'true' | ||||
| AlignOperands: 'true' | ||||
| AlignTrailingComments: 'true' | ||||
| 
 | ||||
| ### Single Line ### | ||||
| AllowShortCaseLabelsOnASingleLine: 'true' | ||||
| AllowShortFunctionsOnASingleLine: Inline | ||||
| AllowShortLambdasOnASingleLine: Inline | ||||
| AllowAllArgumentsOnNextLine: 'false' | ||||
| AllowShortLoopsOnASingleLine: 'false' | ||||
| AllowShortBlocksOnASingleLine: 'false' | ||||
| AllowAllParametersOfDeclarationOnNextLine: 'false' | ||||
| AllowShortIfStatementsOnASingleLine: Never | ||||
| 
 | ||||
| ### Break ### | ||||
| AlwaysBreakAfterReturnType: None | ||||
| AlwaysBreakBeforeMultilineStrings: 'false' | ||||
| AlwaysBreakTemplateDeclarations: 'Yes' | ||||
| BreakBeforeBinaryOperators: None | ||||
| BreakBeforeTernaryOperators: 'false' | ||||
| BreakInheritanceList: BeforeComma | ||||
| BreakStringLiterals: 'false' | ||||
| 
 | ||||
| # Penalties | ||||
| PenaltyBreakAssignment: '0' | ||||
| PenaltyBreakBeforeFirstCallParameter: '0' | ||||
| PenaltyBreakComment: '0' | ||||
| PenaltyBreakFirstLessLess: '0' | ||||
| PenaltyBreakString: '0' | ||||
| PenaltyBreakTemplateDeclaration: '0' | ||||
| PenaltyExcessCharacter: '0' | ||||
| PenaltyReturnTypeOnItsOwnLine: '999999999' # Nope | ||||
| 
 | ||||
| # Constructor Initializers | ||||
| ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' | ||||
| AllowAllConstructorInitializersOnNextLine: 'true' | ||||
| BreakConstructorInitializers: BeforeComma | ||||
| 
 | ||||
| # Comments | ||||
| ReflowComments: 'false' | ||||
| CommentPragmas: '^ TODO@:' | ||||
| FixNamespaceComments: 'true' | ||||
| 
 | ||||
| # Misc | ||||
| Cpp11BracedListStyle: 'false' | ||||
| SortUsingDeclarations: 'true' | ||||
| KeepEmptyLinesAtTheStartOfBlocks: 'false' | ||||
| MaxEmptyLinesToKeep: '2' | ||||
|  | @ -1,56 +0,0 @@ | |||
| cmake_minimum_required(VERSION 3.16) | ||||
| 
 | ||||
| if(CMAKE_COMPILER_IS_GNUCC) | ||||
|   add_compile_options(-w) | ||||
| endif() | ||||
| 
 | ||||
| if(MSVC) | ||||
|   add_compile_options(/MP) | ||||
|   add_compile_options(/W0) | ||||
| endif() | ||||
| 
 | ||||
| file(GLOB_RECURSE ENGINE_ALL_FILES true ABSOLUTE ${ENGINE_DIR}src/*) | ||||
| file(GLOB_RECURSE ENGINE_RES_FILES true ABSOLUTE ${ENGINE_DIR}res/*) | ||||
| list(LENGTH ENGINE_ALL_FILES ENGINE_ALL_FILES_COUNT) | ||||
| 
 | ||||
| if(NOT WIN32) | ||||
|   set(DX_DIR ${ENGINE_DIR}src/Platform/GraphicsAPI/DirectX/) | ||||
|   set(WIN_DIR ${ENGINE_DIR}src/Platform/OS/Windows/) | ||||
| 
 | ||||
|   list( | ||||
|     REMOVE_ITEM ENGINE_ALL_FILES | ||||
|     ${DX_DIR}dxBlender.cpp | ||||
|     ${DX_DIR}dxBuffers.cpp | ||||
|     ${DX_DIR}dxFramebuffer.cpp | ||||
|     ${DX_DIR}dxGraphicsContext.cpp | ||||
|     ${DX_DIR}dxRenderCommand.cpp | ||||
|     ${DX_DIR}dxShader.cpp | ||||
|     ${DX_DIR}dxSharedContext.cpp | ||||
|     ${DX_DIR}dxTexture.cpp | ||||
|     ${DX_DIR}dxUserInterface.cpp | ||||
|     ${DX_DIR}dxVertexLayout.cpp | ||||
|     ${WIN_DIR}wWindow.cpp | ||||
|   ) | ||||
| else() | ||||
|   file(GLOB_RECURSE HLSL_FILES true ABSOLUTE ${ENGINE_DIR}res/*.hlsl) | ||||
|   set_source_files_properties(${HLSL_FILES} PROPERTIES VS_TOOL_OVERRIDE "None") | ||||
| endif() | ||||
| 
 | ||||
| list(LENGTH ENGINE_ALL_FILES ENGINE_ALL_FILES_COUNT) | ||||
| 
 | ||||
| include_directories( | ||||
|   ${ENGINE_DIR}src/Engine/ | ||||
|   ${ENGINE_DIR}src/Platform/GraphicsAPI/ | ||||
|   ${ENGINE_DIR}src/Platform/OS/ | ||||
|   ${DEPENDENCIES_DIR}GLAD/include/ | ||||
|   ${DEPENDENCIES_DIR}GLFW/include/ | ||||
|   ${DEPENDENCIES_DIR}glm/ | ||||
|   ${DEPENDENCIES_DIR}imgui/ | ||||
|   ${DEPENDENCIES_DIR}spdlog/include/ | ||||
|   ${DEPENDENCIES_DIR}stb_image/ | ||||
|   ${DEPENDENCIES_DIR}yaml-cpp/include/ | ||||
|   ${DEPENDENCIES_DIR}shaderc/libshaderc/include | ||||
| ) | ||||
| 
 | ||||
| source_group(TREE ${ENGINE_DIR} FILES ${ENGINE_ALL_FILES} ${ENGINE_RES_FILES}) | ||||
| add_library(Engine STATIC ${ENGINE_ALL_FILES} ${ENGINE_RES_FILES}) | ||||
|  | @ -1,6 +0,0 @@ | |||
| #include "Camera.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | @ -1,27 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Camera | ||||
| { | ||||
| private: | ||||
| 	glm::vec4 m_BackgroundColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); | ||||
| 
 | ||||
| protected: | ||||
| 	glm::mat4 m_Projection; | ||||
| 
 | ||||
| public: | ||||
| 	Camera() = default; | ||||
| 
 | ||||
| 	inline const glm::mat4& GetProjection() const { return m_Projection; } | ||||
| 
 | ||||
| 	inline const glm::vec4& GetBackgroundColor() const { return m_BackgroundColor; } | ||||
| 
 | ||||
| 	inline void SetBackgroundColor(const glm::vec4& color) { m_BackgroundColor = color; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,38 +0,0 @@ | |||
| #include "OrthographicCamera.hpp" | ||||
| 
 | ||||
| #include <glm/gtc/matrix_transform.hpp> | ||||
| #include <glm/matrix.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| OrthographicCamera::OrthographicCamera(const glm::vec2& position, float aspectRatio, float zoomLevel, const glm::vec4& clearColor /* = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f) */) | ||||
|     : m_Up(0.0f, 1.0f, 0.0f), m_Position(position), m_AspectRatio(aspectRatio), m_ZoomLevel(zoomLevel), m_ClearColor(clearColor) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void OrthographicCamera::CalculateView() | ||||
| { | ||||
| 	m_View = glm::lookAt(glm::vec3(m_Position, 100.0f), glm::vec3(m_Position, 0.0f), m_Up); | ||||
| } | ||||
| 
 | ||||
| void OrthographicCamera::CalculateProjection() | ||||
| { | ||||
| 	m_Projection = glm::ortho(-m_ZoomLevel * m_AspectRatio, | ||||
| 	                          +m_ZoomLevel * m_AspectRatio, | ||||
| 	                          -m_ZoomLevel, | ||||
| 	                          +m_ZoomLevel, | ||||
| 	                          FLT_MAX, FLT_MIN); | ||||
| } | ||||
| 
 | ||||
| void OrthographicCamera::OnResize(const glm::vec2& size) | ||||
| { | ||||
| 	m_AspectRatio = size.x / size.y; | ||||
| 	CalculateProjection(); | ||||
| } | ||||
| 
 | ||||
| void OrthographicCamera::Move(const glm::vec2& position) | ||||
| { | ||||
| 	m_Position += position; | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,41 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class OrthographicCamera | ||||
| { | ||||
| private: | ||||
| 	glm::vec2 m_Position; | ||||
| 	float m_AspectRatio; | ||||
| 	float m_ZoomLevel; | ||||
| 
 | ||||
| 	const glm::vec3 m_Up; | ||||
| 
 | ||||
| 	glm::mat4 m_Projection; | ||||
| 	glm::mat4 m_View; | ||||
| 
 | ||||
| 	glm::vec4 m_ClearColor; | ||||
| 
 | ||||
| public: | ||||
| 	OrthographicCamera(const glm::vec2& position, float aspectRatio, float zoomLevel, const glm::vec4& clearColor = glm::vec4(0.1f, 0.3f, 0.7f, 1.0f)); | ||||
| 
 | ||||
| 	// CAMERA //
 | ||||
| 	void CalculateView(); | ||||
| 	void CalculateProjection(); | ||||
| 
 | ||||
| 	void OnResize(const glm::vec2& size); | ||||
| 
 | ||||
| 	inline const glm::mat4& GetView() const { return m_View; } | ||||
| 	inline const glm::mat4& GetProjection() const { return m_Projection; } | ||||
| 
 | ||||
| 	inline const glm::vec4& GetClearColor() const { return m_ClearColor; } | ||||
| 
 | ||||
| 	// CAMERA_CONTROLLER //
 | ||||
| 	void Move(const glm::vec2& position); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,54 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Debug/Instrumentor.hpp" | ||||
| #include "Input/Input.hpp" | ||||
| #include "Layer/LayerStack.hpp" | ||||
| #include "Utility/ResourceManager.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Window; | ||||
| class Event; | ||||
| 
 | ||||
| class Instrumentor; | ||||
| 
 | ||||
| class Application /* singleton */ | ||||
| { | ||||
| private: | ||||
| 	static Application* s_Context; | ||||
| 
 | ||||
| private: | ||||
| 	Scope<Logger> m_Logger; | ||||
| 	Scope<Instrumentor> m_Instrumentor; | ||||
| 	Scope<LayerStack> m_LayerStack; | ||||
| 	Scope<Input> m_Input; | ||||
| 	Scope<ResourceManager> m_ResourceManager; | ||||
| 
 | ||||
| protected: | ||||
| 	Scope<Window> m_Window; | ||||
| 
 | ||||
| public: | ||||
| 	Application(const Application&) = delete; | ||||
| 	Application& operator=(const Application&) = delete; | ||||
| 
 | ||||
| 	virtual ~Application(); | ||||
| 
 | ||||
| 	void GameLoop(); | ||||
| 
 | ||||
| 	// To be defined in client project
 | ||||
| 
 | ||||
| 	static void Quit(); | ||||
| 
 | ||||
| protected: | ||||
| 	Application(std::string execName, std::vector<std::string> args); | ||||
| 
 | ||||
| private: | ||||
| 	void OnEvent(const Event& event); | ||||
| 
 | ||||
| 	void LogDebugData(); | ||||
| }; | ||||
| 
 | ||||
| extern Application* CreateApplication(std::string execName, std::vector<std::string> args); | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,35 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <random> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| 	class UUID | ||||
| 	{ | ||||
| 	private: | ||||
| 		static std::mt19937_64 s_Engine; | ||||
| 		static std::uniform_int_distribution<uint64_t> s_UniformDistribution; | ||||
| 
 | ||||
| 	private: | ||||
| 		uint64_t m_UUID; | ||||
| 
 | ||||
| 	public: | ||||
| 		UUID(uint64_t uuid = -1); | ||||
| 
 | ||||
| 		operator uint64_t() const { return m_UUID; } | ||||
| 	}; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| namespace std { | ||||
| 
 | ||||
| 	template <> | ||||
| 	struct hash<Light::UUID> | ||||
| 	{ | ||||
| 		std::size_t operator()(const Light::UUID& uuid) const | ||||
| 		{ | ||||
| 			return hash<uint64_t>()(static_cast<uint64_t>(uuid)); | ||||
| 		} | ||||
| 	}; | ||||
| 
 | ||||
| } | ||||
|  | @ -1,73 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Event; | ||||
| 
 | ||||
| class GraphicsContext; | ||||
| 
 | ||||
| struct WindowProperties | ||||
| { | ||||
| 	std::string title; | ||||
| 	glm::uvec2 size; | ||||
| 	bool vsync, visible; | ||||
| }; | ||||
| 
 | ||||
| class Window | ||||
| { | ||||
| protected: | ||||
| 	Scope<GraphicsContext> m_GraphicsContext; | ||||
| 	WindowProperties m_Properties; | ||||
| 	bool b_Closed; | ||||
| 
 | ||||
| public: | ||||
| 	static Scope<Window> Create(std::function<void(Event&)> callback); | ||||
| 
 | ||||
| 	Window() | ||||
| 	    : m_GraphicsContext(nullptr), m_Properties {}, b_Closed(false) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	Window(const Window&) = delete; | ||||
| 	Window& operator=(const Window&) = delete; | ||||
| 
 | ||||
| 	virtual ~Window() = default; | ||||
| 
 | ||||
| 	/* events */ | ||||
| 	virtual void PollEvents()                = 0; | ||||
| 	virtual void OnEvent(const Event& event) = 0; | ||||
| 
 | ||||
| 	//======================================== SETTERS ========================================//
 | ||||
| 	virtual void SetProperties(const WindowProperties& properties, bool affectVisibility = false) = 0; | ||||
| 
 | ||||
| 	virtual void SetTitle(const std::string& title) = 0; | ||||
| 
 | ||||
| 	virtual void SetSize(const glm::uvec2& size, bool additive = false) = 0; // pass 0 for width or height for single dimension resizing
 | ||||
| 
 | ||||
| 	inline void Close() { b_Closed = true; } | ||||
| 	virtual void SetVSync(bool vsync, bool toggle = false)        = 0; | ||||
| 	virtual void SetVisibility(bool visible, bool toggle = false) = 0; | ||||
| 	//======================================== SETTERS ========================================//
 | ||||
| 
 | ||||
| 	//============================== GETTERS ==============================//
 | ||||
| 	inline GraphicsContext* GetGfxContext() const { return m_GraphicsContext.get(); } | ||||
| 
 | ||||
| 	inline const WindowProperties& GetProperties() const { return m_Properties; } | ||||
| 
 | ||||
| 	inline const std::string& GetTitle() const { return m_Properties.title; } | ||||
| 
 | ||||
| 	inline const glm::uvec2& GetSize() const { return m_Properties.size; } | ||||
| 
 | ||||
| 	inline bool IsClosed() const { return b_Closed; } | ||||
| 	inline bool IsVSync() const { return m_Properties.vsync; } | ||||
| 	inline bool IsVisible() const { return m_Properties.visible; } | ||||
| 	//============================== GETTERS ==============================//
 | ||||
| 
 | ||||
| protected: | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,43 +0,0 @@ | |||
| #pragma once | ||||
| #ifndef LIGHT_LOGGER_H | ||||
| 	#define LIGHT_LOGGER_H | ||||
| 
 | ||||
| 	#include "Base/Base.hpp" | ||||
| 
 | ||||
| 	#include <spdlog/spdlog.h> | ||||
| 
 | ||||
| 	#define LT_LOG_FILE_LOCATION "Logs/Logger.txt" | ||||
| 
 | ||||
| 	#ifndef LIGHT_DIST | ||||
| 		#define LOG(logLevel, ...) SPDLOG_LOGGER_CALL(::Light::Logger::GetEngineLogger(), spdlog::level::logLevel, __VA_ARGS__) | ||||
| 	#else | ||||
| 		#define LOG(logLevel, ...) SPDLOG_LOGGER_CALL(::Light::Logger::GetFileLogger(), spdlog::level::logLevel, __VA_ARGS__) | ||||
| 	#endif | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| // #todo: extend
 | ||||
| class Logger /* singleton */ | ||||
| { | ||||
| private: | ||||
| 	static Logger* s_Context; | ||||
| 
 | ||||
| private: | ||||
| 	Ref<spdlog::logger> m_EngineLogger, m_FileLogger; | ||||
| 	std::string m_LogFilePath; | ||||
| 
 | ||||
| public: | ||||
| 	static Scope<Logger> Create(); | ||||
| 
 | ||||
| 	static inline Ref<spdlog::logger> GetEngineLogger() { return s_Context->m_EngineLogger; } | ||||
| 	static inline Ref<spdlog::logger> GetFileLogger() { return s_Context->m_FileLogger; } | ||||
| 
 | ||||
| 	void LogDebugData(); | ||||
| 
 | ||||
| private: | ||||
| 	Logger(); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,57 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| enum class EventType | ||||
| { | ||||
| 	None = 0, | ||||
| 
 | ||||
| 	// input
 | ||||
| 	MouseMoved, | ||||
| 	WheelScrolled, | ||||
| 	ButtonPressed, | ||||
| 	ButtonReleased, | ||||
| 	KeyPressed, | ||||
| 	KeyRepeated, | ||||
| 	KeyReleased, | ||||
| 	SetChar, | ||||
| 
 | ||||
| 	// window
 | ||||
| 	WindowMoved, | ||||
| 	WindowResized, | ||||
| 	WindowClosed, | ||||
| 	WindowLostFocus, | ||||
| 	WindowGainFocus, | ||||
| }; | ||||
| 
 | ||||
| enum EventCategory | ||||
| { | ||||
| 	None = 0, | ||||
| 
 | ||||
| 	WindowEventCategory   = BIT(0), | ||||
| 	InputEventCategory    = BIT(1), | ||||
| 	KeyboardEventCategory = BIT(2), | ||||
| 	MouseEventCategory    = BIT(3), | ||||
| }; | ||||
| 
 | ||||
| #define EVENT_TYPE(type) \ | ||||
| 	EventType GetEventType() const override { return ::Light::EventType::type; } | ||||
| #define EVENT_CATEGORY(eCategory) \ | ||||
| 	inline bool HasCategory(EventCategory category) const override { return (eCategory)&category; } | ||||
| 
 | ||||
| class Event | ||||
| { | ||||
| public: | ||||
| 	virtual EventType GetEventType() const                 = 0; | ||||
| 	virtual std::string GetInfoLog() const                 = 0; | ||||
| 	virtual bool HasCategory(EventCategory category) const = 0; | ||||
| 
 | ||||
| 	friend std::ostream& operator<<(std::ostream& os, const Event& e) | ||||
| 	{ | ||||
| 		return os << e.GetInfoLog(); | ||||
| 	} | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,29 +0,0 @@ | |||
| #include "Blender.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glBlender.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxBlender.hpp" | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Scope<Blender> Blender::Create(Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateScope<glBlender>(); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateScope<dxBlender>(std::static_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,69 +0,0 @@ | |||
| #include "Buffers.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glBuffers.hpp" | ||||
| #include "SharedContext.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxBuffers.hpp" | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| //================================================== CONSTANT_BUFFER ==================================================//
 | ||||
| Scope<ConstantBuffer> ConstantBuffer::Create(ConstantBufferIndex index, unsigned int size, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateScope<glConstantBuffer>(index, size); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateScope<dxConstantBuffer>(index, size, std::static_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| //================================================== CONSTANT_BUFFER ==================================================//
 | ||||
| 
 | ||||
| //================================================== VERTEX_BUFFER ==================================================//
 | ||||
| Ref<VertexBuffer> VertexBuffer::Create(float* vertices, unsigned int stride, unsigned int count, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateRef<glVertexBuffer>(vertices, stride, count); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateRef<dxVertexBuffer>(vertices, stride, count, std::static_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| //================================================== VERTEX_BUFFER ==================================================//
 | ||||
| 
 | ||||
| //======================================== INDEX_BUFFER ========================================//
 | ||||
| Ref<IndexBuffer> IndexBuffer::Create(unsigned int* indices, unsigned int count, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateRef<glIndexBuffer>(indices, count); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateRef<dxIndexBuffer>(indices, count, std::dynamic_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| //======================================== INDEX_BUFFER ========================================//
 | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,30 +0,0 @@ | |||
| #include "Framebuffer.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glFramebuffer.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxFramebuffer.hpp" | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Ref<Framebuffer> Framebuffer::Create(const FramebufferSpecification& specification, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateRef<glFramebuffer>(specification); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateRef<dxFramebuffer>(specification, std::static_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,79 +0,0 @@ | |||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glGraphicsContext.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxGraphicsContext.hpp" | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "Blender.hpp"                     // required for forward declaration
 | ||||
| #include "Buffers.hpp"                     // required for forward declaration
 | ||||
| #include "RenderCommand.hpp"               // required for forward declaration
 | ||||
| #include "Renderer.hpp"                    // required for forward declaration
 | ||||
| #include "UserInterface/UserInterface.hpp" // required for forward declaration
 | ||||
| #include "Utility/ResourceManager.hpp"     // required for forward declaration
 | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| GraphicsContext* GraphicsContext::s_Context = nullptr; | ||||
| 
 | ||||
| GraphicsContext::~GraphicsContext() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Scope<GraphicsContext> GraphicsContext::Create(GraphicsAPI api, GLFWwindow* windowHandle) | ||||
| { | ||||
| 	// terminate 'GraphicsContext' dependent classes
 | ||||
| 	if (s_Context) | ||||
| 	{ | ||||
| 		s_Context->m_Renderer.reset(); | ||||
| 		s_Context->m_UserInterface.reset(); | ||||
| 
 | ||||
| 		delete s_Context; | ||||
| 	} | ||||
| 
 | ||||
| 	// determine the default api
 | ||||
| 	if (api == GraphicsAPI::Default) | ||||
| 	{ | ||||
| #if defined(LIGHT_PLATFORM_WINDOWS) | ||||
| 		api = GraphicsAPI::DirectX; | ||||
| #elif defined(LIGHT_PLATFORM_LINUX) | ||||
| 		api = GraphicsAPI::OpenGL; | ||||
| #elif defined(LIGHT_PLATFORM_MAC) | ||||
| 		api = GraphicsAPI::OpenGL; | ||||
| #endif | ||||
| 	} | ||||
| 
 | ||||
| 	// create gfx context
 | ||||
| 	Scope<GraphicsContext> scopeGfx; | ||||
| 	switch (api) | ||||
| 	{ | ||||
| 	// opengl
 | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		scopeGfx  = CreateScope<glGraphicsContext>(windowHandle); | ||||
| 		s_Context = scopeGfx.get(); | ||||
| 		break; | ||||
| 	// directx
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		scopeGfx  = CreateScope<dxGraphicsContext>(windowHandle); | ||||
| 		s_Context = scopeGfx.get(); | ||||
| 		break;) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", Stringifier::GraphicsAPIToString(api)); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| 
 | ||||
| 	// create 'GraphicsContext' dependent classes
 | ||||
| 	s_Context->m_UserInterface = UserInterface::Create(windowHandle, s_Context->m_SharedContext); | ||||
| 	s_Context->m_Renderer      = Renderer::Create(windowHandle, s_Context->m_SharedContext); | ||||
| 
 | ||||
| 	// check
 | ||||
| 	ASSERT(s_Context->m_UserInterface, "Failed to create UserInterface"); | ||||
| 	ASSERT(s_Context->m_Renderer, "Failed to create Renderer"); | ||||
| 
 | ||||
| 	return std::move(scopeGfx); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,30 +0,0 @@ | |||
| #include "RenderCommand.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glRenderCommand.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxRenderCommand.hpp" | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Scope<RenderCommand> RenderCommand::Create(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateScope<glRenderCommand>(windowHandle); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateScope<dxRenderCommand>((std::static_pointer_cast<dxSharedContext>)(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,37 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| struct GLFWwindow; | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class SharedContext; | ||||
| 
 | ||||
| class RenderCommand | ||||
| { | ||||
| public: | ||||
| 	static Scope<RenderCommand> Create(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext); | ||||
| 
 | ||||
| 	RenderCommand(const RenderCommand&) = delete; | ||||
| 	RenderCommand& operator=(const RenderCommand&) = delete; | ||||
| 
 | ||||
| 	virtual ~RenderCommand() = default; | ||||
| 
 | ||||
| 	virtual void SwapBuffers()                                = 0; | ||||
| 	virtual void ClearBackBuffer(const glm::vec4& clearColor) = 0; | ||||
| 
 | ||||
| 	virtual void Draw(unsigned int count)        = 0; | ||||
| 	virtual void DrawIndexed(unsigned int count) = 0; | ||||
| 
 | ||||
| 	virtual void DefaultTargetFramebuffer() = 0; | ||||
| 
 | ||||
| 	virtual void SetViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height) = 0; | ||||
| 
 | ||||
| protected: | ||||
| 	RenderCommand() = default; | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,84 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "RendererPrograms/QuadRendererProgram.hpp" | ||||
| #include "RendererPrograms/TextureRendererProgram.hpp" | ||||
| #include "RendererPrograms/TintedTextureRendererProgram.hpp" | ||||
| 
 | ||||
| #define LT_MAX_QUAD_RENDERER_VERTICES           1028u * 4u | ||||
| #define LT_MAX_TEXTURE_RENDERER_VERTICES        1028u * 4u | ||||
| #define LT_MAX_TINTED_TEXTURE_RENDERER_VERTICES 1028u * 4u | ||||
| 
 | ||||
| struct GLFWwindow; | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Blender; | ||||
| class ConstantBuffer; | ||||
| class Framebuffer; | ||||
| class RenderCommand; | ||||
| class Texture; | ||||
| 
 | ||||
| class SharedContext; | ||||
| 
 | ||||
| class Camera; | ||||
| 
 | ||||
| class WindowResizedEvent; | ||||
| 
 | ||||
| class Renderer | ||||
| { | ||||
| private: | ||||
| 	static Renderer* s_Context; | ||||
| 
 | ||||
| 	// renderer programs
 | ||||
| 	QuadRendererProgram m_QuadRenderer; | ||||
| 	TextureRendererProgram m_TextureRenderer; | ||||
| 	TintedTextureRendererProgram m_TintedTextureRenderer; | ||||
| 
 | ||||
| 	// constant buffers
 | ||||
| 	Scope<ConstantBuffer> m_ViewProjectionBuffer; | ||||
| 
 | ||||
| 	Scope<RenderCommand> m_RenderCommand; | ||||
| 	Scope<Blender> m_Blender; | ||||
| 
 | ||||
| 	Camera* m_DefaultFramebufferCamera; | ||||
| 	Ref<Framebuffer> m_TargetFramebuffer; | ||||
| 
 | ||||
| 	bool m_ShouldClearBackbuffer; | ||||
| 
 | ||||
| public: | ||||
| 	static Scope<Renderer> Create(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext); | ||||
| 
 | ||||
| 	static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint, Ref<Texture> texture) { s_Context->DrawQuadImpl(position, size, tint, texture); } | ||||
| 	static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint) { s_Context->DrawQuadImpl(position, size, tint); } | ||||
| 	static inline void DrawQuad(const glm::vec3& position, const glm::vec2& size, Ref<Texture> texture) { s_Context->DrawQuadImpl(position, size, texture); } | ||||
| 
 | ||||
| 	static void DrawQuad(const glm::mat4& transform, const glm::vec4& tint, Ref<Texture> texture) { s_Context->DrawQuadImpl(transform, tint, texture); } | ||||
| 	static void DrawQuad(const glm::mat4& transform, const glm::vec4& tint) { s_Context->DrawQuadImpl(transform, tint); } | ||||
| 	static void DrawQuad(const glm::mat4& transform, Ref<Texture> texture) { s_Context->DrawQuadImpl(transform, texture); } | ||||
| 
 | ||||
| 	static inline void BeginScene(Camera* camera, const glm::mat4& cameraTransform, const Ref<Framebuffer>& targetFrameBuffer = nullptr) { s_Context->BeginSceneImpl(camera, cameraTransform, targetFrameBuffer); } | ||||
| 	static inline void EndScene() { s_Context->EndSceneImpl(); } | ||||
| 
 | ||||
| 	void OnWindowResize(const WindowResizedEvent& event); | ||||
| 
 | ||||
| 	void BeginFrame(); | ||||
| 	void EndFrame(); | ||||
| 
 | ||||
| private: | ||||
| 	Renderer(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext); | ||||
| 
 | ||||
| 	void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint, Ref<Texture> texture); | ||||
| 	void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, const glm::vec4& tint); | ||||
| 	void DrawQuadImpl(const glm::vec3& position, const glm::vec2& size, Ref<Texture> texture); | ||||
| 
 | ||||
| 	void DrawQuadImpl(const glm::mat4& transform, const glm::vec4& tint, Ref<Texture> texture); | ||||
| 	void DrawQuadImpl(const glm::mat4& transform, const glm::vec4& tint); | ||||
| 	void DrawQuadImpl(const glm::mat4& transform, Ref<Texture> texture); | ||||
| 
 | ||||
| 	void BeginSceneImpl(Camera* camera, const glm::mat4& cameraTransform, const Ref<Framebuffer>& targetFrameBuffer = nullptr); | ||||
| 	void FlushScene(); | ||||
| 	void EndSceneImpl(); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,58 +0,0 @@ | |||
| #include "QuadRendererProgram.hpp" | ||||
| 
 | ||||
| #include "Camera/Camera.hpp" | ||||
| #include "Graphics/Buffers.hpp" | ||||
| #include "Graphics/Shader.hpp" | ||||
| #include "Graphics/VertexLayout.hpp" | ||||
| #include "Utility/ResourceManager.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| QuadRendererProgram::QuadRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext) | ||||
|     : m_Shader(nullptr), m_IndexBuffer(nullptr), m_VertexLayout(nullptr), m_MapCurrent(nullptr), m_MapEnd(nullptr), m_QuadCount(0u), m_MaxVertices(maxVertices) | ||||
| { | ||||
| 	// #todo: don't use relative path
 | ||||
| 	ResourceManager::LoadShader("LT_ENGINE_RESOURCES_QUAD_SHADER", "Assets/Shaders/Quad/Quad_VS.glsl", "Assets/Shaders/Quad/Quad_PS.glsl"); | ||||
| 
 | ||||
| 	m_Shader       = ResourceManager::GetShader("LT_ENGINE_RESOURCES_QUAD_SHADER"); | ||||
| 	m_VertexBuffer = Ref<VertexBuffer>(VertexBuffer::Create(nullptr, sizeof(QuadVertexData), maxVertices, sharedContext)); | ||||
| 	m_IndexBuffer  = Ref<IndexBuffer>(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); | ||||
| 	m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float4 }, { "COLOR", VertexElementType::Float4 } }, sharedContext)); | ||||
| } | ||||
| 
 | ||||
| bool QuadRendererProgram::Advance() | ||||
| { | ||||
| 	m_MapCurrent += 4; | ||||
| 
 | ||||
| 	if (m_MapCurrent >= m_MapEnd) | ||||
| 	{ | ||||
| 		LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_MaxVertices); | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	m_QuadCount++; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| void QuadRendererProgram::Map() | ||||
| { | ||||
| 	m_QuadCount = 0u; | ||||
| 
 | ||||
| 	m_MapCurrent = (QuadRendererProgram::QuadVertexData*)m_VertexBuffer->Map(); | ||||
| 	m_MapEnd     = m_MapCurrent + m_MaxVertices; | ||||
| } | ||||
| 
 | ||||
| void QuadRendererProgram::UnMap() | ||||
| { | ||||
| 	m_VertexBuffer->UnMap(); | ||||
| } | ||||
| 
 | ||||
| void QuadRendererProgram::Bind() | ||||
| { | ||||
| 	m_Shader->Bind(); | ||||
| 	m_VertexLayout->Bind(); | ||||
| 	m_VertexBuffer->Bind(); | ||||
| 	m_IndexBuffer->Bind(); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,57 +0,0 @@ | |||
| #include "TextureRendererProgram.hpp" | ||||
| 
 | ||||
| #include "Camera/Camera.hpp" | ||||
| #include "Graphics/Buffers.hpp" | ||||
| #include "Graphics/Shader.hpp" | ||||
| #include "Graphics/VertexLayout.hpp" | ||||
| #include "Utility/ResourceManager.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| TextureRendererProgram::TextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext) | ||||
|     : m_Shader(nullptr), m_IndexBuffer(nullptr), m_VertexLayout(nullptr), m_MapCurrent(nullptr), m_MapEnd(nullptr), m_QuadCount(0u), m_MaxVertices(maxVertices) | ||||
| { | ||||
| 	// #todo: don't use relative path
 | ||||
| 	ResourceManager::LoadShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER", "Assets/Shaders/Texture/Texture_VS.glsl", "Assets/Shaders/Texture/Texture_PS.glsl"); | ||||
| 
 | ||||
| 	m_Shader       = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TEXTURE_SHADER"); | ||||
| 	m_VertexBuffer = Ref<VertexBuffer>(VertexBuffer::Create(nullptr, sizeof(TextureVertexData), maxVertices, sharedContext)); | ||||
| 	m_IndexBuffer  = Ref<IndexBuffer>(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); | ||||
| 	m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float4 }, { "TEXCOORD", VertexElementType::Float2 } }, sharedContext)); | ||||
| } | ||||
| 
 | ||||
| bool TextureRendererProgram::Advance() | ||||
| { | ||||
| 	if (m_MapCurrent + 4 >= m_MapEnd) | ||||
| 	{ | ||||
| 		LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_MaxVertices); | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	m_MapCurrent += 4; | ||||
| 	m_QuadCount++; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| void TextureRendererProgram::Map() | ||||
| { | ||||
| 	m_QuadCount = 0u; | ||||
| 
 | ||||
| 	m_MapCurrent = (TextureRendererProgram::TextureVertexData*)m_VertexBuffer->Map(); | ||||
| 	m_MapEnd     = m_MapCurrent + m_MaxVertices; | ||||
| } | ||||
| 
 | ||||
| void TextureRendererProgram::UnMap() | ||||
| { | ||||
| 	m_VertexBuffer->UnMap(); | ||||
| } | ||||
| 
 | ||||
| void TextureRendererProgram::Bind() | ||||
| { | ||||
| 	m_Shader->Bind(); | ||||
| 	m_VertexLayout->Bind(); | ||||
| 	m_VertexBuffer->Bind(); | ||||
| 	m_IndexBuffer->Bind(); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,58 +0,0 @@ | |||
| #include "TintedTextureRendererProgram.hpp" | ||||
| 
 | ||||
| #include "Camera/Camera.hpp" | ||||
| #include "Graphics/Buffers.hpp" | ||||
| #include "Graphics/Shader.hpp" | ||||
| #include "Graphics/VertexLayout.hpp" | ||||
| #include "Utility/ResourceManager.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| TintedTextureRendererProgram::TintedTextureRendererProgram(unsigned int maxVertices, Ref<SharedContext> sharedContext) | ||||
|     : m_Shader(nullptr), m_IndexBuffer(nullptr), m_VertexLayout(nullptr), m_MapCurrent(nullptr), m_MapEnd(nullptr), m_QuadCount(0u), m_MaxVertices(maxVertices) | ||||
| { | ||||
| 	// #todo: don't use relative path
 | ||||
| 	ResourceManager::LoadShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER", "Assets/Shaders/TintedTexture/TintedTexture_VS.glsl", "Assets/Shaders/TintedTexture/TintedTexture_PS.glsl"); | ||||
| 
 | ||||
| 	m_Shader       = ResourceManager::GetShader("LT_ENGINE_RESOURCES_TINTED_TEXTURE_SHADER"); | ||||
| 	m_VertexBuffer = Ref<VertexBuffer>(VertexBuffer::Create(nullptr, sizeof(TintedTextureVertexData), maxVertices, sharedContext)); | ||||
| 	m_IndexBuffer  = Ref<IndexBuffer>(IndexBuffer::Create(nullptr, (maxVertices / 4) * 6, sharedContext)); | ||||
| 	m_VertexLayout = Ref<VertexLayout>(VertexLayout::Create(m_VertexBuffer, m_Shader, { { "POSITION", VertexElementType::Float4 }, { "TINT", VertexElementType::Float4 }, { "TEXCOORD", VertexElementType::Float2 } }, sharedContext)); | ||||
| } | ||||
| 
 | ||||
| bool TintedTextureRendererProgram::Advance() | ||||
| { | ||||
| 	m_MapCurrent += 4; | ||||
| 
 | ||||
| 	if (m_MapCurrent >= m_MapEnd) | ||||
| 	{ | ||||
| 		LOG(warn, "'VertexBuffer' map went beyond 'MaxVertices': {}", m_MaxVertices); | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	m_QuadCount++; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| void TintedTextureRendererProgram::Map() | ||||
| { | ||||
| 	m_QuadCount = 0u; | ||||
| 
 | ||||
| 	m_MapCurrent = (TintedTextureRendererProgram::TintedTextureVertexData*)m_VertexBuffer->Map(); | ||||
| 	m_MapEnd     = m_MapCurrent + m_MaxVertices; | ||||
| } | ||||
| 
 | ||||
| void TintedTextureRendererProgram::UnMap() | ||||
| { | ||||
| 	m_VertexBuffer->UnMap(); | ||||
| } | ||||
| 
 | ||||
| void TintedTextureRendererProgram::Bind() | ||||
| { | ||||
| 	m_Shader->Bind(); | ||||
| 	m_VertexLayout->Bind(); | ||||
| 	m_VertexBuffer->Bind(); | ||||
| 	m_IndexBuffer->Bind(); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,31 +0,0 @@ | |||
| #include "Shader.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glShader.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxShader.hpp" | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Ref<Shader> Shader::Create(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	// load shader source
 | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateRef<glShader>(vertexFile, pixelFile); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateRef<dxShader>(vertexFile, pixelFile, std::static_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,35 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Utility/FileManager.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class SharedContext; | ||||
| 
 | ||||
| class Shader | ||||
| { | ||||
| public: | ||||
| 	enum Stage | ||||
| 	{ | ||||
| 		NONE     = 0, | ||||
| 		VERTEX   = 1, | ||||
| 		PIXEL    = 2, | ||||
| 		GEOMETRY = 3 | ||||
| 	}; | ||||
| 
 | ||||
| public: | ||||
| 	static Ref<Shader> Create(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref<SharedContext> sharedContext); | ||||
| 
 | ||||
| 	virtual ~Shader() = default; | ||||
| 
 | ||||
| 	virtual void Bind()   = 0; | ||||
| 	virtual void UnBind() = 0; | ||||
| 
 | ||||
| protected: | ||||
| 	Shader() = default; | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,35 +0,0 @@ | |||
| #include "Texture.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glTexture.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| 	#include "DirectX/dxTexture.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Ref<Texture> Texture::Create(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref<SharedContext> sharedContext, const std::string& filePath) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateRef<glTexture>(width, height, components, pixels, filePath); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateRef<dxTexture>(width, height, components, pixels, std::static_pointer_cast<dxSharedContext>(sharedContext), filePath);) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| Texture::Texture(const std::string& filePath) | ||||
|     : m_FilePath(filePath) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,30 +0,0 @@ | |||
| #include "VertexLayout.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glVertexLayout.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| 	#include "DirectX/dxVertexLayout.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "GraphicsContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Ref<VertexLayout> VertexLayout::Create(Ref<VertexBuffer> vertexBuffer, Ref<Shader> shader, const std::vector<std::pair<std::string, VertexElementType>>& elements, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		return CreateRef<glVertexLayout>(vertexBuffer, elements); | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: LT_WIN( | ||||
| 		return CreateRef<dxVertexLayout>(shader, elements, std::static_pointer_cast<dxSharedContext>(sharedContext));) | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "Invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,53 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <array> | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Event; | ||||
| 
 | ||||
| class Input /* singleton */ | ||||
| { | ||||
| private: | ||||
| 	static Input* s_Context; | ||||
| 
 | ||||
| private: | ||||
| 	std::array<bool, 348> m_KeyboadKeys; | ||||
| 	std::array<bool, 8> m_MouseButtons; | ||||
| 
 | ||||
| 	glm::vec2 m_MousePosition; | ||||
| 	glm::vec2 m_MouseDelta; | ||||
| 	float m_MouseWheelDelta; | ||||
| 
 | ||||
| 	bool m_UserInterfaceEvents; | ||||
| 	bool m_GameEvents; | ||||
| 
 | ||||
| public: | ||||
| 	static Scope<Input> Create(); | ||||
| 
 | ||||
| 	static inline void ReceiveUserInterfaceEvents(bool receive, bool toggle = false) { s_Context->ReceiveUserInterfaceEventsImpl(receive, toggle); } | ||||
| 	static inline void ReceiveGameEvents(bool receive, bool toggle = false) { s_Context->ReceieveGameEventsImpl(receive, toggle); } | ||||
| 
 | ||||
| 	static inline bool GetKeyboardKey(int code) { return s_Context->m_KeyboadKeys[code]; } | ||||
| 	static inline bool GetMouseButton(int code) { return s_Context->m_MouseButtons[code]; } | ||||
| 
 | ||||
| 	static inline const glm::vec2& GetMousePosition(int code) { return s_Context->m_MousePosition; } | ||||
| 
 | ||||
| 	void OnEvent(const Event& inputEvent); | ||||
| 
 | ||||
| 	inline bool IsReceivingInputEvents() const { return m_UserInterfaceEvents; } | ||||
| 	inline bool IsReceivingGameEvents() const { return m_GameEvents; } | ||||
| 
 | ||||
| private: | ||||
| 	Input(); | ||||
| 
 | ||||
| 	void ReceiveUserInterfaceEventsImpl(bool receive, bool toggle = false); | ||||
| 	void ReceieveGameEventsImpl(bool receive, bool toggle = false); | ||||
| 
 | ||||
| 	void RestartInputState(); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,184 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "ltpch.hpp" | ||||
| 
 | ||||
| #include <stdint.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| namespace Key { | ||||
| enum : uint16_t | ||||
| { | ||||
| 	/* digits */ | ||||
| 	D0        = 48, | ||||
| 	D1        = 49, | ||||
| 	D2        = 50, | ||||
| 	D3        = 51, | ||||
| 	D4        = 52, | ||||
| 	D5        = 53, | ||||
| 	D6        = 54, | ||||
| 	D7        = 55, | ||||
| 	D8        = 56, | ||||
| 	D9        = 57, | ||||
| 	Semicolon = 59, // ;
 | ||||
| 	Equal     = 61, // =
 | ||||
| 
 | ||||
| 	/* letters */ | ||||
| 	A = 65, | ||||
| 	B = 66, | ||||
| 	C = 67, | ||||
| 	D = 68, | ||||
| 	E = 69, | ||||
| 	F = 70, | ||||
| 	G = 71, | ||||
| 	H = 72, | ||||
| 	I = 73, | ||||
| 	J = 74, | ||||
| 	K = 75, | ||||
| 	L = 76, | ||||
| 	M = 77, | ||||
| 	N = 78, | ||||
| 	O = 79, | ||||
| 	P = 80, | ||||
| 	Q = 81, | ||||
| 	R = 82, | ||||
| 	S = 83, | ||||
| 	T = 84, | ||||
| 	U = 85, | ||||
| 	V = 86, | ||||
| 	W = 87, | ||||
| 	X = 88, | ||||
| 	Y = 89, | ||||
| 	Z = 90, | ||||
| 
 | ||||
| 	/* brackets */ | ||||
| 	LeftBracket  = 91,           // [
 | ||||
| 	LBracket     = LeftBracket,  // [
 | ||||
| 	RightBracket = 93,           // ]
 | ||||
| 	RBracket     = RightBracket, // ]
 | ||||
| 
 | ||||
| 	/* arrow */ | ||||
| 	Right      = 262, | ||||
| 	RightArrow = Right, | ||||
| 	RArrow     = Right, | ||||
| 	Left       = 263, | ||||
| 	LeftArrow  = Left, | ||||
| 	LArrow     = Left, | ||||
| 	Down       = 264, | ||||
| 	DownArrow  = Down, | ||||
| 	DArrow     = Down, | ||||
| 	Up         = 265, | ||||
| 	UpArrow    = Up, | ||||
| 	UArrow     = Up, | ||||
| 
 | ||||
| 	/* page */ | ||||
| 	PageUp   = 266, | ||||
| 	PageDown = 267, | ||||
| 
 | ||||
| 	/* home/end */ | ||||
| 	Home = 268, | ||||
| 	End  = 269, | ||||
| 
 | ||||
| 	/* toggles */ | ||||
| 	CapsLock   = 280, | ||||
| 	ScrollLock = 281, | ||||
| 	NumLock    = 282, | ||||
| 	NumberLock = NumLock, | ||||
| 
 | ||||
| 	/* function */ | ||||
| 	F1  = 290, | ||||
| 	F2  = 291, | ||||
| 	F3  = 292, | ||||
| 	F4  = 293, | ||||
| 	F5  = 294, | ||||
| 	F6  = 295, | ||||
| 	F7  = 296, | ||||
| 	F8  = 297, | ||||
| 	F9  = 298, | ||||
| 	F10 = 299, | ||||
| 	F11 = 300, | ||||
| 	F12 = 301, | ||||
| 	F13 = 302, | ||||
| 	F14 = 303, | ||||
| 	F15 = 304, | ||||
| 	F16 = 305, | ||||
| 	F17 = 306, | ||||
| 	F18 = 307, | ||||
| 	F19 = 308, | ||||
| 	F20 = 309, | ||||
| 	F21 = 310, | ||||
| 	F22 = 311, | ||||
| 	F23 = 312, | ||||
| 	F24 = 313, | ||||
| 	F25 = 314, | ||||
| 
 | ||||
| 	/* keypad */ | ||||
| 	Kp0         = 320, | ||||
| 	Kp1         = 321, | ||||
| 	Kp2         = 322, | ||||
| 	Kp3         = 323, | ||||
| 	Kp4         = 324, | ||||
| 	Kp5         = 325, | ||||
| 	Kp6         = 326, | ||||
| 	Kp7         = 327, | ||||
| 	Kp8         = 328, | ||||
| 	Kp9         = 329, | ||||
| 	KpDecimal   = 330, | ||||
| 	KpDivide    = 331, | ||||
| 	KpMultiply  = 332, | ||||
| 	KpSubstract = 333, | ||||
| 	KpAdd       = 334, | ||||
| 	KpEnter     = 335, | ||||
| 	KpEqual     = 336, | ||||
| 
 | ||||
| 	/* modifiers */ | ||||
| 	LeftShift    = 340, | ||||
| 	LShift       = LeftShift, | ||||
| 	LeftControl  = 341, | ||||
| 	LControl     = LeftControl, | ||||
| 	LeftAlt      = 342, | ||||
| 	LAlt         = LeftAlt, | ||||
| 	LeftSuper    = 343, | ||||
| 	LSuper       = LeftSuper, | ||||
| 	RightShift   = 344, | ||||
| 	RShift       = 344, | ||||
| 	RightControl = 345, | ||||
| 	RControl     = 345, | ||||
| 	RightAlt     = 346, | ||||
| 	RAlt         = 346, | ||||
| 	RightSuper   = 347, | ||||
| 	RSuper       = 347, | ||||
| 
 | ||||
| 	/* misc */ | ||||
| 	Space      = 32, | ||||
| 	Apostrophe = 39, // '
 | ||||
| 	Quote      = Apostrophe, | ||||
| 
 | ||||
| 	Comma        = 44,    // ,
 | ||||
| 	Minus        = 45,    // -
 | ||||
| 	Period       = 46,    // .
 | ||||
| 	Slash        = 47,    // /
 | ||||
| 	ForwardSlash = Slash, // /
 | ||||
| 	BackSlash    = 92,    // \ | ||||
| 
 | ||||
| 	GraveAccent  = 96,    // `
 | ||||
| 	Console      = GraveAccent, | ||||
| 	World1       = 161, // non-US #1
 | ||||
| 	World2       = 162, // non-US #2
 | ||||
| 	Escape       = 256, | ||||
| 	Esc          = Escape, | ||||
| 	Enter        = 257, | ||||
| 	Tab          = 258, | ||||
| 	BackSpace    = 259, | ||||
| 	Insert       = 260, | ||||
| 	Delete       = 261, | ||||
| 
 | ||||
| 	PrintScreen = 283, | ||||
| 	Pause       = 284, | ||||
| 
 | ||||
| 	Menu = 348, | ||||
| 
 | ||||
| }; | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,62 +0,0 @@ | |||
| #include "Layer.hpp" | ||||
| 
 | ||||
| #include "Events/CharEvent.hpp" | ||||
| #include "Events/Event.hpp" | ||||
| #include "Events/KeyboardEvents.hpp" | ||||
| #include "Events/MouseEvents.hpp" | ||||
| #include "Events/WindowEvents.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Layer::Layer(const std::string& name) | ||||
|     : m_LayerName(name) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| bool Layer::OnEvent(const Event& event) | ||||
| { | ||||
| 	switch (event.GetEventType()) | ||||
| 	{ | ||||
| 	/* mouse */ | ||||
| 	// cursor
 | ||||
| 	case EventType::MouseMoved: | ||||
| 		return OnMouseMoved((MouseMovedEvent&)event); | ||||
| 	// button
 | ||||
| 	case EventType::ButtonPressed: | ||||
| 		return OnButtonPressed((ButtonPressedEvent&)event); | ||||
| 	case EventType::ButtonReleased: | ||||
| 		return OnButtonReleased((ButtonReleasedEvent&)event); | ||||
| 	// wheel
 | ||||
| 	case EventType::WheelScrolled: | ||||
| 		return OnWheelScrolled((WheelScrolledEvent&)event); | ||||
| 
 | ||||
| 	/* keyboard */ | ||||
| 	// key
 | ||||
| 	case EventType::KeyPressed: | ||||
| 		return OnKeyPressed((KeyPressedEvent&)event); | ||||
| 	case EventType::KeyRepeated: | ||||
| 		return OnKeyRepeat((KeyRepeatEvent&)event); | ||||
| 	case EventType::KeyReleased: | ||||
| 		return OnKeyReleased((KeyReleasedEvent&)event); | ||||
| 	// char
 | ||||
| 	case EventType::SetChar: | ||||
| 		return OnSetChar((SetCharEvent&)event); | ||||
| 
 | ||||
| 	/* window */ | ||||
| 	// termination
 | ||||
| 	case EventType::WindowClosed: | ||||
| 		return OnWindowClosed((WindowClosedEvent&)event); | ||||
| 	// size/position
 | ||||
| 	case EventType::WindowResized: | ||||
| 		return OnWindowResized((WindowResizedEvent&)event); | ||||
| 	case EventType::WindowMoved: | ||||
| 		return OnWindowMoved((WindowMovedEvent&)event); | ||||
| 	// focus
 | ||||
| 	case EventType::WindowLostFocus: | ||||
| 		return OnWindowLostFocus((WindowLostFocusEvent&)event); | ||||
| 	case EventType::WindowGainFocus: | ||||
| 		return OnWindowGainFocus((WindowGainFocusEvent&)event); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,78 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Event; | ||||
| 
 | ||||
| // mouse
 | ||||
| class MouseMovedEvent; | ||||
| class ButtonPressedEvent; | ||||
| class ButtonReleasedEvent; | ||||
| class WheelScrolledEvent; | ||||
| 
 | ||||
| // keyboard
 | ||||
| // key
 | ||||
| class KeyPressedEvent; | ||||
| class KeyRepeatEvent; | ||||
| class KeyReleasedEvent; | ||||
| // char
 | ||||
| class SetCharEvent; | ||||
| 
 | ||||
| // window
 | ||||
| class WindowClosedEvent; | ||||
| class WindowResizedEvent; | ||||
| class WindowMovedEvent; | ||||
| class WindowLostFocusEvent; | ||||
| class WindowGainFocusEvent; | ||||
| 
 | ||||
| class Layer | ||||
| { | ||||
| protected: | ||||
| 	std::string m_LayerName; | ||||
| 
 | ||||
| public: | ||||
| 	Layer(const std::string& name); | ||||
| 	virtual ~Layer() = default; | ||||
| 
 | ||||
| 	inline const std::string& GetName() const { return m_LayerName; } | ||||
| 
 | ||||
| 	/* update */ | ||||
| 	virtual void OnUpdate(float deltaTime) {} | ||||
| 	virtual void OnUserInterfaceUpdate() {} | ||||
| 
 | ||||
| 	virtual void OnRender() {} | ||||
| 
 | ||||
| 	bool OnEvent(const Event& event); | ||||
| 
 | ||||
| protected: | ||||
| 	/* mouse */ | ||||
| 	// cursor
 | ||||
| 	virtual bool OnMouseMoved(const MouseMovedEvent& event) { return false; } | ||||
| 	// button
 | ||||
| 	virtual bool OnButtonPressed(const ButtonPressedEvent& event) { return false; } | ||||
| 	virtual bool OnButtonReleased(const ButtonReleasedEvent& event) { return false; } | ||||
| 	// wheel
 | ||||
| 	virtual bool OnWheelScrolled(const WheelScrolledEvent& event) { return false; } | ||||
| 
 | ||||
| 	/* keyboard */ | ||||
| 	// key
 | ||||
| 	virtual bool OnKeyPressed(const KeyPressedEvent& event) { return false; } | ||||
| 	virtual bool OnKeyRepeat(const KeyRepeatEvent& event) { return false; } | ||||
| 	virtual bool OnKeyReleased(const KeyReleasedEvent& event) { return false; } | ||||
| 	// char
 | ||||
| 	virtual bool OnSetChar(const SetCharEvent& event) { return false; } | ||||
| 
 | ||||
| 	/* window */ | ||||
| 	// termination
 | ||||
| 	virtual bool OnWindowClosed(const WindowClosedEvent& event) { return false; } | ||||
| 	// size/position
 | ||||
| 	virtual bool OnWindowResized(const WindowResizedEvent& event) { return false; } | ||||
| 	virtual bool OnWindowMoved(const WindowMovedEvent& event) { return false; } | ||||
| 	// focus
 | ||||
| 	virtual bool OnWindowLostFocus(const WindowLostFocusEvent& event) { return false; } | ||||
| 	virtual bool OnWindowGainFocus(const WindowGainFocusEvent& event) { return false; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,51 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Layer; | ||||
| 
 | ||||
| class Event; | ||||
| 
 | ||||
| class LayerStack /* singleton */ | ||||
| { | ||||
| private: | ||||
| 	static LayerStack* s_Context; | ||||
| 
 | ||||
| private: | ||||
| 	std::vector<Layer*> m_Layers; | ||||
| 
 | ||||
| 	std::vector<Layer*>::iterator m_Begin; | ||||
| 	std::vector<Layer*>::iterator m_End; | ||||
| 
 | ||||
| public: | ||||
| 	static Scope<LayerStack> Create(); | ||||
| 
 | ||||
| 	~LayerStack(); | ||||
| 
 | ||||
| 	// #todo: is this needed?
 | ||||
| 	template<typename T, typename... Args> | ||||
| 	static inline void EmplaceLayer(Args&&... args) | ||||
| 	{ | ||||
| 		s_Context->AttachLayerImpl(new T((args)...)); | ||||
| 	} | ||||
| 
 | ||||
| 	static inline void AttachLayer(Layer* layer) { s_Context->AttachLayerImpl(layer); } | ||||
| 	static inline void DetachLayer(Layer* layer) { s_Context->DetachLayerImpl(layer); } | ||||
| 
 | ||||
| 	inline bool IsEmpty() { return m_Layers.empty(); } | ||||
| 
 | ||||
| 	std::vector<Layer*>::iterator begin() { return m_Layers.begin(); } | ||||
| 	std::vector<Layer*>::iterator end() { return m_Layers.end(); } | ||||
| 	std::vector<Layer*>::reverse_iterator rbegin() { return m_Layers.rbegin(); } | ||||
| 	std::vector<Layer*>::reverse_iterator rend() { return m_Layers.rend(); } | ||||
| 
 | ||||
| private: | ||||
| 	LayerStack(); | ||||
| 
 | ||||
| 	void AttachLayerImpl(Layer* layer); | ||||
| 	void DetachLayerImpl(Layer* layer); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,60 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| // core
 | ||||
| #include "Core/Application.hpp" | ||||
| #include "Core/Window.hpp" | ||||
| 
 | ||||
| // camera
 | ||||
| #include "Camera/Camera.hpp" | ||||
| 
 | ||||
| // debug
 | ||||
| #include "Debug/Logger.hpp" | ||||
| 
 | ||||
| // events
 | ||||
| #include "Events/Event.hpp" | ||||
| #include "Events/KeyboardEvents.hpp" | ||||
| #include "Events/MouseEvents.hpp" | ||||
| #include "Events/WindowEvents.hpp" | ||||
| 
 | ||||
| // graphics
 | ||||
| #include "Graphics/Framebuffer.hpp" | ||||
| #include "Graphics/GraphicsContext.hpp" | ||||
| #include "Graphics/Renderer.hpp" | ||||
| #include "Graphics/Texture.hpp" | ||||
| 
 | ||||
| // input
 | ||||
| #include "Input/Input.hpp" | ||||
| #include "Input/KeyCodes.hpp" | ||||
| #include "Input/MouseCodes.hpp" | ||||
| 
 | ||||
| // layer
 | ||||
| #include "Layer/Layer.hpp" | ||||
| #include "Layer/LayerStack.hpp" | ||||
| 
 | ||||
| // user interface
 | ||||
| #include "UserInterface/UserInterface.hpp" | ||||
| 
 | ||||
| // utility
 | ||||
| #include "Utility/ResourceManager.hpp" | ||||
| 
 | ||||
| // time
 | ||||
| #include "Time/Timer.hpp" | ||||
| 
 | ||||
| // base
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| // third party
 | ||||
| #include <imgui.h> | ||||
| 
 | ||||
| // math
 | ||||
| #include "Math/Random.hpp" | ||||
| 
 | ||||
| // scene
 | ||||
| #include "Scene/Components.hpp" | ||||
| #include "Scene/Entity.hpp" | ||||
| #include "Scene/Scene.hpp" | ||||
| 
 | ||||
| // entry point
 | ||||
| #ifdef LIGHT_ENTRY_POINT | ||||
| 	#include "Base/EntryPoint.hpp" | ||||
| #endif | ||||
|  | @ -1,8 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Components/CameraComponent.hpp" | ||||
| #include "Components/NativeScriptComponent.hpp" | ||||
| #include "Components/SpriteRendererComponent.hpp" | ||||
| #include "Components/TagComponent.hpp" | ||||
| #include "Components/TransformComponent.hpp" | ||||
|  | @ -1,26 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Camera/SceneCamera.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| struct CameraComponent | ||||
| { | ||||
| 	SceneCamera camera; | ||||
| 	bool isPrimary; | ||||
| 
 | ||||
| 	CameraComponent()                       = default; | ||||
| 	CameraComponent(const CameraComponent&) = default; | ||||
| 
 | ||||
| 	CameraComponent(SceneCamera _camera, bool _isPrimary = false) | ||||
| 	    : camera(_camera), isPrimary(_isPrimary) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	operator SceneCamera() { return camera; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,28 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "ScriptableEntity.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| struct NativeScriptComponent | ||||
| { | ||||
| 	NativeScript* instance; | ||||
| 
 | ||||
| 	NativeScript* (*CreateInstance)(); | ||||
| 	void (*DestroyInstance)(NativeScriptComponent*); | ||||
| 
 | ||||
| 	template<typename T> | ||||
| 	void Bind() | ||||
| 	{ | ||||
| 		CreateInstance = []() { | ||||
| 			return static_cast<NativeScript*>(new T()); | ||||
| 		}; | ||||
| 		DestroyInstance = [](NativeScriptComponent* nsc) { | ||||
| 			delete (T*)(nsc->instance); | ||||
| 			nsc->instance = nullptr; | ||||
| 		}; | ||||
| 	} | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,25 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Texture; | ||||
| 
 | ||||
| struct SpriteRendererComponent | ||||
| { | ||||
| 	Ref<Texture> texture; | ||||
| 	glm::vec4 tint; | ||||
| 
 | ||||
| 	SpriteRendererComponent()                               = default; | ||||
| 	SpriteRendererComponent(const SpriteRendererComponent&) = default; | ||||
| 
 | ||||
| 	SpriteRendererComponent(Ref<Texture> _texture, const glm::vec4& _tint = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)) | ||||
| 	    : texture(_texture), tint(_tint) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	operator Ref<Texture>() { return texture; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,23 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| struct TagComponent | ||||
| { | ||||
| 	std::string tag = "Unnamed"; | ||||
| 
 | ||||
| 	TagComponent()                    = default; | ||||
| 	TagComponent(const TagComponent&) = default; | ||||
| 
 | ||||
| 	TagComponent(const std::string& _tag) | ||||
| 	    : tag(_tag) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	operator std::string() { return tag; } | ||||
| 	operator const std::string&() const { return tag; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,34 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #define GLM_ENABLE_EXPERIMENTAL | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| #include <glm/gtc/matrix_transform.hpp> | ||||
| #include <glm/gtx/transform.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| struct TransformComponent | ||||
| { | ||||
| 	glm::vec3 translation; | ||||
| 	glm::vec3 scale; | ||||
| 	glm::vec3 rotation; | ||||
| 
 | ||||
| 	TransformComponent(const TransformComponent&) = default; | ||||
| 
 | ||||
| 	TransformComponent(const glm::vec3& _translation = glm::vec3(0.0f, 0.0f, 0.0f), | ||||
| 	                   const glm::vec3& _scale       = glm::vec3(1.0f, 1.0f, 1.0f), | ||||
| 	                   const glm::vec3& _rotation    = glm::vec3(0.0f, 0.0f, 0.0f)) | ||||
| 
 | ||||
| 	    : translation(_translation), scale(_scale), rotation(_rotation) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	inline glm::mat4 GetTransform() const { return glm::translate(translation) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(scale); } | ||||
| 
 | ||||
| 	operator const glm::mat4() const { return GetTransform(); } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,17 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Core/UUID.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| struct UUIDComponent | ||||
| { | ||||
| 	UUID uuid; | ||||
| 
 | ||||
| 	UUIDComponent(UUID _uuid) | ||||
| 	    : uuid(_uuid) {} | ||||
| 	UUIDComponent(const UUIDComponent&) = default; | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,16 +0,0 @@ | |||
| #include "Entity.hpp" | ||||
| 
 | ||||
| #include "Scene.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Entity::Entity(entt::entity handle, Scene* scene) | ||||
|     : m_Handle(handle), m_Scene(scene) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Entity::~Entity() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,43 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Components/TransformComponent.hpp" | ||||
| #include "Core/UUID.hpp" | ||||
| 
 | ||||
| #include <entt/entt.hpp> | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Entity; | ||||
| 
 | ||||
| class Framebuffer; | ||||
| 
 | ||||
| class Scene | ||||
| { | ||||
| private: | ||||
| 	friend class Entity; | ||||
| 	friend class SceneSerializer; | ||||
| 	friend class SceneHierarchyPanel; | ||||
| 
 | ||||
| private: | ||||
| 	entt::registry m_Registry; | ||||
| 
 | ||||
| public: | ||||
| 	Scene(); | ||||
| 	~Scene(); | ||||
| 
 | ||||
| 	void OnCreate(); | ||||
| 
 | ||||
| 	void OnUpdate(float deltaTime); | ||||
| 	void OnRender(const Ref<Framebuffer>& targetFrameBuffer = nullptr); | ||||
| 
 | ||||
| 	Entity CreateEntity(const std::string& name, const TransformComponent& transform = TransformComponent()); | ||||
| 
 | ||||
| 	Entity GetEntityByTag(const std::string& tag); | ||||
| 
 | ||||
| private: | ||||
| 	Entity CreateEntityWithUUID(const std::string& name, UUID uuid, const TransformComponent& transform = TransformComponent()); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,22 +0,0 @@ | |||
| #include "Timer.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Timer::Timer() | ||||
|     : m_Start(std::chrono::steady_clock::now()) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| DeltaTimer::DeltaTimer() | ||||
|     : m_PreviousFrame(NULL), m_DeltaTime(60.0f / 1000.0f) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void DeltaTimer::Update() | ||||
| { | ||||
| 	float currentFrame = timer.GetElapsedTime(); | ||||
| 	m_DeltaTime        = currentFrame - m_PreviousFrame; | ||||
| 	m_PreviousFrame    = currentFrame; | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,38 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| #include <chrono> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Timer | ||||
| { | ||||
| private: | ||||
| 	std::chrono::time_point<std::chrono::steady_clock> m_Start; | ||||
| 
 | ||||
| public: | ||||
| 	Timer(); | ||||
| 
 | ||||
| 	inline float GetElapsedTime() const { return (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - m_Start).count()) / 1000.; } | ||||
| 
 | ||||
| 	inline void Reset() { m_Start = std::chrono::steady_clock::now(); } | ||||
| }; | ||||
| 
 | ||||
| class DeltaTimer | ||||
| { | ||||
| private: | ||||
| 	Timer timer; | ||||
| 
 | ||||
| 	float m_PreviousFrame; | ||||
| 	float m_DeltaTime; | ||||
| 
 | ||||
| public: | ||||
| 	DeltaTimer(); | ||||
| 
 | ||||
| 	void Update(); | ||||
| 
 | ||||
| 	inline float GetDeltaTime() const { return m_DeltaTime; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,222 +0,0 @@ | |||
| #include "UserInterface.hpp" | ||||
| 
 | ||||
| #include "OpenGL/glUserInterface.hpp" | ||||
| 
 | ||||
| #ifdef LIGHT_PLATFORM_WINDOWS | ||||
| 	#include "DirectX/dxSharedContext.hpp" | ||||
| 	#include "DirectX/dxUserInterface.hpp" | ||||
| #endif | ||||
| 
 | ||||
| #include "Events/CharEvent.hpp" | ||||
| #include "Events/Event.hpp" | ||||
| #include "Events/KeyboardEvents.hpp" | ||||
| #include "Events/MouseEvents.hpp" | ||||
| #include "Graphics/GraphicsContext.hpp" | ||||
| #include "Input/KeyCodes.hpp" | ||||
| 
 | ||||
| #include <imgui.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| UserInterface* UserInterface::s_Context = nullptr; | ||||
| 
 | ||||
| Scope<UserInterface> UserInterface::Create(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	Scope<UserInterface> scopeUserInterface = nullptr; | ||||
| 
 | ||||
| 	switch (GraphicsContext::GetGraphicsAPI()) | ||||
| 	{ | ||||
| 	case GraphicsAPI::OpenGL: | ||||
| 		scopeUserInterface = CreateScope<glUserInterface>(); | ||||
| 		break; | ||||
| 
 | ||||
| 	case GraphicsAPI::DirectX: | ||||
| 		LT_WIN( | ||||
| 		    scopeUserInterface = CreateScope<dxUserInterface>();) | ||||
| 		break; | ||||
| 
 | ||||
| 	default: | ||||
| 		ASSERT(false, "UserInterface::Create: invalid/unsupported 'GraphicsAPI' {}", static_cast<uint32_t>(GraphicsContext::GetGraphicsAPI())); | ||||
| 		return nullptr; | ||||
| 	} | ||||
| 
 | ||||
| 	scopeUserInterface->Init(windowHandle, sharedContext); | ||||
| 	return std::move(scopeUserInterface); | ||||
| } | ||||
| 
 | ||||
| UserInterface::UserInterface() | ||||
|     : m_DockspaceFlags(ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | | ||||
|                        ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | | ||||
|                        ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus) | ||||
| { | ||||
| 	ASSERT(!s_Context, "UserInterface::UserInterface: an instance of 'UserInterface' already exists, do not construct this class!"); | ||||
| 	s_Context = this; | ||||
| } | ||||
| 
 | ||||
| void UserInterface::Init(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext) | ||||
| { | ||||
| 	// create context
 | ||||
| 	IMGUI_CHECKVERSION(); | ||||
| 	ImGui::CreateContext(); | ||||
| 
 | ||||
| 	// configure io
 | ||||
| 	ImGuiIO& io = ImGui::GetIO(); | ||||
| 	io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; | ||||
| 
 | ||||
| 	io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; | ||||
| 	io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; | ||||
| 
 | ||||
| 	io.ConfigFlags |= ImGuiBackendFlags_PlatformHasViewports; | ||||
| 	io.ConfigFlags |= ImGuiBackendFlags_RendererHasViewports; | ||||
| 
 | ||||
| 	// #todo: handle this in a better way
 | ||||
| 	if (std::filesystem::exists("user_gui_layout.ini")) | ||||
| 		io.IniFilename = "user_gui_layout.ini"; | ||||
| 	else | ||||
| 		io.IniFilename = "default_gui_layout.ini"; | ||||
| 
 | ||||
| 	// style
 | ||||
| 	ImGui::StyleColorsDark(); | ||||
| 
 | ||||
| 	PlatformImplementation(windowHandle, sharedContext); | ||||
| 
 | ||||
| 	// keyboard map
 | ||||
| 	io.KeyMap[ImGuiKey_Tab]         = Key::Tab; | ||||
| 	io.KeyMap[ImGuiKey_LeftArrow]   = Key::LeftArrow; | ||||
| 	io.KeyMap[ImGuiKey_RightArrow]  = Key::RightArrow; | ||||
| 	io.KeyMap[ImGuiKey_UpArrow]     = Key::UpArrow; | ||||
| 	io.KeyMap[ImGuiKey_DownArrow]   = Key::DownArrow; | ||||
| 	io.KeyMap[ImGuiKey_PageUp]      = Key::PageUp; | ||||
| 	io.KeyMap[ImGuiKey_PageDown]    = Key::PageDown; | ||||
| 	io.KeyMap[ImGuiKey_Home]        = Key::Home; | ||||
| 	io.KeyMap[ImGuiKey_End]         = Key::End; | ||||
| 	io.KeyMap[ImGuiKey_Insert]      = Key::Insert; | ||||
| 	io.KeyMap[ImGuiKey_Delete]      = Key::Delete; | ||||
| 	io.KeyMap[ImGuiKey_Backspace]   = Key::BackSpace; | ||||
| 	io.KeyMap[ImGuiKey_Space]       = Key::Space; | ||||
| 	io.KeyMap[ImGuiKey_Enter]       = Key::Enter; | ||||
| 	io.KeyMap[ImGuiKey_Escape]      = Key::Escape; | ||||
| 	io.KeyMap[ImGuiKey_KeyPadEnter] = Key::Enter; | ||||
| 	io.KeyMap[ImGuiKey_A]           = Key::A; | ||||
| 	io.KeyMap[ImGuiKey_C]           = Key::C; | ||||
| 	io.KeyMap[ImGuiKey_V]           = Key::V; | ||||
| 	io.KeyMap[ImGuiKey_X]           = Key::X; | ||||
| 	io.KeyMap[ImGuiKey_Y]           = Key::Y; | ||||
| 	io.KeyMap[ImGuiKey_Z]           = Key::Z; | ||||
| 
 | ||||
| 	io.Fonts->AddFontFromFileTTF("Assets//Fonts/OpenSans/OpenSans-Bold.ttf", 18.0f); | ||||
| 	io.FontDefault = io.Fonts->AddFontFromFileTTF("Assets/Fonts/OpenSans/OpenSans-Regular.ttf", 18.0f); | ||||
| 
 | ||||
| 	SetDarkThemeColors(); | ||||
| } | ||||
| 
 | ||||
| void UserInterface::DockspaceBegin() | ||||
| { | ||||
| 	ImGuiViewport* viewport = ImGui::GetMainViewport(); | ||||
| 	ImGui::SetNextWindowPos(viewport->Pos); | ||||
| 	ImGui::SetNextWindowSize(viewport->Size); | ||||
| 	ImGui::SetNextWindowViewport(viewport->ID); | ||||
| 
 | ||||
| 	ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); | ||||
| 	ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); | ||||
| 	ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); | ||||
| 	ImGui::Begin("Dockspace", (bool*)0, s_Context->m_DockspaceFlags); | ||||
| 	ImGui::PopStyleVar(3); | ||||
| 
 | ||||
| 	ImGuiStyle& style     = ImGui::GetStyle(); | ||||
| 	float minWinSizeX     = style.WindowMinSize.x; | ||||
| 	style.WindowMinSize.x = 370.0f; | ||||
| 	ImGui::DockSpace(ImGui::GetID("MyDockSpace"), ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None | ImGuiWindowFlags_NoBackground); | ||||
| 	style.WindowMinSize.x = minWinSizeX; | ||||
| } | ||||
| 
 | ||||
| void UserInterface::DockspaceEnd() | ||||
| { | ||||
| 	ImGui::End(); | ||||
| } | ||||
| 
 | ||||
| void UserInterface::SetDarkThemeColors() | ||||
| { | ||||
| 	ImGuiStyle& style   = ImGui::GetStyle(); | ||||
| 	ImVec4(&colors)[55] = style.Colors; | ||||
| 
 | ||||
| 	style.WindowPadding = ImVec2(0.0f, 0.0f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_Text]         = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); | ||||
| 	colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_WindowBg] = ImVec4(0.10f, 0.10f, 0.11f, 1.00f); | ||||
| 	colors[ImGuiCol_ChildBg]  = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); | ||||
| 	colors[ImGuiCol_PopupBg]  = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_Border]       = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); | ||||
| 	colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_FrameBg]        = ImVec4(0.20f, 0.20f, 0.21f, 1.00f); | ||||
| 	colors[ImGuiCol_FrameBgHovered] = ImVec4(0.30f, 0.31f, 0.31f, 1.00f); | ||||
| 	colors[ImGuiCol_FrameBgActive]  = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_TitleBg]          = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 	colors[ImGuiCol_TitleBgActive]    = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 	colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_ScrollbarBg]          = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); | ||||
| 	colors[ImGuiCol_ScrollbarGrab]        = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); | ||||
| 	colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); | ||||
| 	colors[ImGuiCol_ScrollbarGrabActive]  = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_SliderGrab]       = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); | ||||
| 	colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_Button]        = ImVec4(0.20f, 0.20f, 0.21f, 1.00f); | ||||
| 	colors[ImGuiCol_ButtonHovered] = ImVec4(0.30f, 0.31f, 0.31f, 1.00f); | ||||
| 	colors[ImGuiCol_ButtonActive]  = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_Header]        = ImVec4(0.20f, 0.20f, 0.21f, 1.00f); | ||||
| 	colors[ImGuiCol_HeaderHovered] = ImVec4(0.30f, 0.31f, 0.31f, 1.00f); | ||||
| 	colors[ImGuiCol_HeaderActive]  = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_Separator]        = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); | ||||
| 	colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); | ||||
| 	colors[ImGuiCol_SeparatorActive]  = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_ResizeGrip]        = ImVec4(0.26f, 0.59f, 0.98f, 0.20f); | ||||
| 	colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); | ||||
| 	colors[ImGuiCol_ResizeGripActive]  = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_Tab]                = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 	colors[ImGuiCol_TabHovered]         = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); | ||||
| 	colors[ImGuiCol_TabActive]          = ImVec4(0.28f, 0.28f, 0.28f, 1.00f); | ||||
| 	colors[ImGuiCol_TabUnfocused]       = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); | ||||
| 	colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.20f, 0.20f, 0.21f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_DockingPreview] = ImVec4(0.26f, 0.59f, 0.98f, 0.70f); | ||||
| 	colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_PlotLines]            = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); | ||||
| 	colors[ImGuiCol_PlotLinesHovered]     = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); | ||||
| 	colors[ImGuiCol_PlotHistogram]        = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); | ||||
| 	colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_TableHeaderBg]     = ImVec4(0.19f, 0.19f, 0.20f, 1.00f); | ||||
| 	colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f); | ||||
| 	colors[ImGuiCol_TableBorderLight]  = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); | ||||
| 	colors[ImGuiCol_TableRowBg]        = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); | ||||
| 	colors[ImGuiCol_TableRowBgAlt]     = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_NavHighlight]          = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); | ||||
| 	colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); | ||||
| 	colors[ImGuiCol_NavWindowingDimBg]     = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); | ||||
| 
 | ||||
| 	colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,81 +0,0 @@ | |||
| #define STB_IMAGE_IMPLEMENTATION | ||||
| #include "FileManager.hpp" | ||||
| 
 | ||||
| #include <stb_image.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| BasicFileHandle::BasicFileHandle(uint8_t* data, uint32_t size, const std::string& path, const std::string& name, const std::string& extension) | ||||
|     : m_Data(data), m_Size(size), m_Path(path), m_Name(name), m_Extension(extension) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void BasicFileHandle::Release() | ||||
| { | ||||
| 	delete m_Data; | ||||
| 	m_Data = nullptr; | ||||
| 	m_Size = 0ull; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| BasicFileHandle FileManager::ReadTextFile(const std::string& path) | ||||
| { | ||||
| 	// parse path info
 | ||||
| 	std::string name      = path.substr(0, path.find('.') + -1); | ||||
| 	std::string extension = path.substr(path.find('.') + 1); | ||||
| 
 | ||||
| 	// open file
 | ||||
| 	std::ifstream file(path.c_str(), std::ios_base::in | std::ios_base::binary); | ||||
| 
 | ||||
| 	// check
 | ||||
| 	if (!file) | ||||
| 	{ | ||||
| 		LOG(warn, "Failed to load text file: {}", path); | ||||
| 		file.close(); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	// fetch file size
 | ||||
| 	file.seekg(0, std::ios::end); | ||||
| 	uint32_t size = file.tellg(); | ||||
| 	file.seekg(0, std::ios::beg); | ||||
| 
 | ||||
| 	if (!size) | ||||
| 		LOG(warn, "Empty text file: {}", path); | ||||
| 
 | ||||
| 	// read file
 | ||||
| 	uint8_t* data = new uint8_t[size]; | ||||
| 	file.read(reinterpret_cast<char*>(data), size); | ||||
| 
 | ||||
| 	file.close(); | ||||
| 	return BasicFileHandle(data, size, path, name, extension); | ||||
| } | ||||
| 
 | ||||
| ImageFileHandle FileManager::ReadImageFile(const std::string& path, int32_t desiredComponents) | ||||
| { | ||||
| 	// parse path info
 | ||||
| 	std::string name      = path.substr(0, path.find('.') + -1); | ||||
| 	std::string extension = path.substr(path.find('.') + 1); | ||||
| 
 | ||||
| 	// load image
 | ||||
| 	int32_t width = 0, height = 0, fetchedComponents = 0; | ||||
| 	uint8_t* pixels = stbi_load(path.c_str(), &width, &height, &fetchedComponents, desiredComponents); | ||||
| 
 | ||||
| 	// check
 | ||||
| 	if (!pixels) | ||||
| 		LOG(warn, "Failed to load image file: <{}>", path); | ||||
| 	else if (fetchedComponents != desiredComponents) | ||||
| 		LOG(warn, "Mismatch of fetched/desired components: <{}> ({}/{})", name + '.' + extension, fetchedComponents, desiredComponents); | ||||
| 
 | ||||
| 	return ImageFileHandle(pixels, width * height, path, name, extension, width, height, fetchedComponents, desiredComponents); | ||||
| } | ||||
| 
 | ||||
| void ImageFileHandle::Release() | ||||
| { | ||||
| 	stbi_image_free(reinterpret_cast<void*>(m_Data)); | ||||
| 	m_Data = nullptr; | ||||
| 	m_Size = 0ull; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,66 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class BasicFileHandle | ||||
| { | ||||
| public: | ||||
| 	BasicFileHandle(uint8_t* data = nullptr, uint32_t size = 0ull, const std::string& path = "", const std::string& name = "", const std::string& extension = ""); | ||||
| 
 | ||||
| 	virtual void Release(); | ||||
| 
 | ||||
| 	// getters
 | ||||
| 	inline uint8_t* GetData() { return m_Data; } | ||||
| 	inline uint32_t GetSize() { return m_Size; } | ||||
| 
 | ||||
| 	inline const std::string& GetPath() { return m_Path; } | ||||
| 	inline const std::string& GetName() { return m_Name; } | ||||
| 	inline const std::string& GetExtension() { return m_Extension; } | ||||
| 
 | ||||
| 	inline const std::string& GetNameWithExtension() { return m_Name + '.' + m_Extension; } | ||||
| 
 | ||||
| 	inline bool IsValid() const { return !!m_Data; } | ||||
| 
 | ||||
| 	// operators
 | ||||
| 	inline operator bool() const { return IsValid(); } | ||||
| 
 | ||||
| protected: | ||||
| 	// made protected for custom Free():
 | ||||
| 	uint8_t* m_Data; | ||||
| 	uint32_t m_Size; | ||||
| 
 | ||||
| private: | ||||
| 	const std::string m_Path, m_Name, m_Extension; | ||||
| }; | ||||
| 
 | ||||
| class ImageFileHandle: public BasicFileHandle | ||||
| { | ||||
| public: | ||||
| 	ImageFileHandle(uint8_t* data, uint32_t size, const std::string& path, const std::string& name, const std::string& extension, | ||||
| 	                uint32_t width, uint32_t height, uint32_t components, uint32_t desiredComponents) | ||||
| 	    : BasicFileHandle(data, size, path, name, extension), m_Width(width), m_Height(height), m_Components(components), m_DesiredComponents(desiredComponents) | ||||
| 	{ | ||||
| 	} | ||||
| 
 | ||||
| 	void Release() override; | ||||
| 
 | ||||
| 	// getters
 | ||||
| 	inline uint32_t GetWidth() const { return m_Width; } | ||||
| 	inline uint32_t GetHeight() const { return m_Height; } | ||||
| 	inline uint32_t GetComponents() const { return m_Components; } | ||||
| 	inline uint32_t GetDesiredComponents() const { return m_DesiredComponents; } | ||||
| 
 | ||||
| private: | ||||
| 	uint32_t m_Width, m_Height, m_Components, m_DesiredComponents; | ||||
| }; | ||||
| 
 | ||||
| class FileManager | ||||
| { | ||||
| public: | ||||
| 	static BasicFileHandle ReadTextFile(const std::string& path); | ||||
| 	static ImageFileHandle ReadImageFile(const std::string& path, int32_t desiredComponents); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,72 +0,0 @@ | |||
| #include "ResourceManager.hpp" | ||||
| 
 | ||||
| #include "FileManager.hpp" | ||||
| #include "Graphics/GraphicsContext.hpp" | ||||
| #include "Graphics/Shader.hpp" | ||||
| #include "Graphics/Texture.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| ResourceManager* ResourceManager::s_Context = nullptr; | ||||
| 
 | ||||
| Scope<ResourceManager> ResourceManager::Create() | ||||
| { | ||||
| 	return MakeScope(new ResourceManager()); | ||||
| } | ||||
| 
 | ||||
| ResourceManager::ResourceManager() | ||||
|     : m_Shaders {}, m_Textures {} | ||||
| { | ||||
| 	ASSERT(!s_Context, "Repeated singleton construction"); | ||||
| 	s_Context = this; | ||||
| } | ||||
| 
 | ||||
| void ResourceManager::LoadShaderImpl(const std::string& name, const std::string& vertexPath, const std::string& pixelPath) | ||||
| { | ||||
| 	// check
 | ||||
| 	ASSERT(s_Context, "Uninitliazed singleton"); | ||||
| 	ASSERT(!vertexPath.empty(), "Empty 'vertexPath'"); | ||||
| 	ASSERT(!pixelPath.empty(), "Empty 'pixelPath'"); | ||||
| 
 | ||||
| 	// load files
 | ||||
| 	BasicFileHandle vertexFile = FileManager::ReadTextFile(vertexPath); | ||||
| 	BasicFileHandle pixelFile  = FileManager::ReadTextFile(pixelPath); | ||||
| 
 | ||||
| 	// check
 | ||||
| 	ASSERT(vertexFile.IsValid(), "Failed to read vertex file: {}", vertexPath); | ||||
| 	ASSERT(pixelFile.IsValid(), "Failed to read vertex file: {}", pixelPath); | ||||
| 
 | ||||
| 	// create shader
 | ||||
| 	m_Shaders[name] = Ref<Shader>(Shader::Create(vertexFile, pixelFile, GraphicsContext::GetSharedContext())); | ||||
| 
 | ||||
| 	// free file
 | ||||
| 	vertexFile.Release(); | ||||
| 	pixelFile.Release(); | ||||
| } | ||||
| 
 | ||||
| void ResourceManager::LoadTextureImpl(const std::string& name, const std::string& path, unsigned int desiredComponents /* = 4u */) | ||||
| { | ||||
| 	ASSERT(s_Context, "Uninitliazed singleton"); | ||||
| 
 | ||||
| 	// load file
 | ||||
| 	ImageFileHandle imgFile = FileManager::ReadImageFile(path, desiredComponents); | ||||
| 
 | ||||
| 	// create texture
 | ||||
| 	m_Textures[name] = Ref<Texture>(Texture::Create(imgFile.GetWidth(), imgFile.GetHeight(), imgFile.GetComponents(), imgFile.GetData(), GraphicsContext::GetSharedContext(), path)); | ||||
| 
 | ||||
| 	// free file
 | ||||
| 	imgFile.Release(); | ||||
| } | ||||
| 
 | ||||
| void ResourceManager::ReleaseTextureImpl(const std::string& name) | ||||
| { | ||||
| 	if (!m_Textures[name]) | ||||
| 	{ | ||||
| 		LOG(warn, "Failed to find texture named: {}", name); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	m_Textures[name] = nullptr; | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,44 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Shader; | ||||
| class Texture; | ||||
| 
 | ||||
| class SharedContext; | ||||
| 
 | ||||
| class ResourceManager /* singleton */ | ||||
| { | ||||
| private: | ||||
| 	static ResourceManager* s_Context; | ||||
| 
 | ||||
| private: | ||||
| 	std::unordered_map<std::string, Ref<Shader>> m_Shaders; | ||||
| 	std::unordered_map<std::string, Ref<Texture>> m_Textures; | ||||
| 
 | ||||
| public: | ||||
| 	static Scope<ResourceManager> Create(); | ||||
| 
 | ||||
| 	// #todo: add geometry shader support
 | ||||
| 	static inline void LoadShader(const std::string& name, const std::string& vertexPath, const std::string& pixelPath) { s_Context->LoadShaderImpl(name, vertexPath, pixelPath); } | ||||
| 
 | ||||
| 	static inline void LoadTexture(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u) { s_Context->LoadTextureImpl(name, path, desiredComponents); } | ||||
| 
 | ||||
| 	static inline void ReleaseTexture(const std::string& name) { s_Context->ReleaseTextureImpl(name); } | ||||
| 
 | ||||
| 	static inline Ref<Shader> GetShader(const std::string& name) { return s_Context->m_Shaders[name]; } | ||||
| 	static inline Ref<Texture> GetTexture(const std::string& name) { return s_Context->m_Textures[name]; } | ||||
| 
 | ||||
| private: | ||||
| 	ResourceManager(); | ||||
| 
 | ||||
| 	void LoadShaderImpl(const std::string& name, const std::string& vertexPath, const std::string& pixelPath); | ||||
| 
 | ||||
| 	void LoadTextureImpl(const std::string& name, const std::string& path, unsigned int desiredComponents = 4u); | ||||
| 
 | ||||
| 	void ReleaseTextureImpl(const std::string& name); | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,30 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Scene/Entity.hpp" | ||||
| #include "Scene/Scene.hpp" | ||||
| 
 | ||||
| #include <yaml-cpp/yaml.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class SceneSerializer | ||||
| { | ||||
| public: | ||||
| 	SceneSerializer(const Ref<Scene>& scene); | ||||
| 
 | ||||
| 	void Serialize(const std::string& filePath); | ||||
| 	bool Deserialize(const std::string& filePath); | ||||
| 
 | ||||
| 	void SerializeBinary(const std::string& filePath); | ||||
| 	bool DeserializeBinary(const std::string& filePath); | ||||
| 
 | ||||
| private: | ||||
| 	void SerializeEntity(YAML::Emitter& out, Entity entity); | ||||
| 
 | ||||
| private: | ||||
| 	Ref<Scene> m_Scene; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1 +0,0 @@ | |||
| #include "ltpch.hpp" | ||||
|  | @ -1,94 +0,0 @@ | |||
| #include "dxFramebuffer.hpp" | ||||
| 
 | ||||
| #include "dxSharedContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| dxFramebuffer::dxFramebuffer(const FramebufferSpecification& specification, Ref<dxSharedContext> sharedContext) | ||||
|     : m_Context(sharedContext), m_Specification(specification), m_RenderTargetView(nullptr), m_ColorAttachment(nullptr), m_DepthStencilAttachment(nullptr), m_ShaderResourceView(nullptr), m_DepthStencilView(nullptr) | ||||
| { | ||||
| 	HRESULT hr; | ||||
| 
 | ||||
| 	D3D11_TEXTURE2D_DESC t2dDesc = {}; | ||||
| 	t2dDesc.Width                = specification.width; | ||||
| 	t2dDesc.Height               = specification.height; | ||||
| 	t2dDesc.MipLevels            = 1; | ||||
| 	t2dDesc.ArraySize            = 1; | ||||
| 	t2dDesc.Format               = DXGI_FORMAT_R8G8B8A8_UNORM; | ||||
| 	t2dDesc.SampleDesc.Count     = 1u; | ||||
| 	t2dDesc.SampleDesc.Quality   = 0u; | ||||
| 	t2dDesc.Usage                = D3D11_USAGE_DEFAULT; | ||||
| 	t2dDesc.BindFlags            = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; | ||||
| 	t2dDesc.CPUAccessFlags       = NULL; | ||||
| 	t2dDesc.MiscFlags            = NULL; | ||||
| 	DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_ColorAttachment)); | ||||
| 
 | ||||
| 	D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; | ||||
| 	srvDesc.Format                          = t2dDesc.Format; | ||||
| 	srvDesc.ViewDimension                   = D3D11_SRV_DIMENSION_TEXTURE2D; | ||||
| 	srvDesc.Texture2D.MipLevels             = 1; | ||||
| 	srvDesc.Texture2D.MostDetailedMip       = 0; | ||||
| 	DXC(m_Context->GetDevice()->CreateShaderResourceView(m_ColorAttachment.Get(), &srvDesc, &m_ShaderResourceView)); | ||||
| 
 | ||||
| 	D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {}; | ||||
| 	rtvDesc.Format                        = t2dDesc.Format; | ||||
| 	rtvDesc.ViewDimension                 = D3D11_RTV_DIMENSION_TEXTURE2D; | ||||
| 	rtvDesc.Texture2D.MipSlice            = 0u; | ||||
| 	DXC(m_Context->GetDevice()->CreateRenderTargetView(m_ColorAttachment.Get(), &rtvDesc, &m_RenderTargetView)); | ||||
| } | ||||
| 
 | ||||
| void dxFramebuffer::BindAsTarget(const glm::vec4& clearColor) | ||||
| { | ||||
| 	FLOAT color[] = { | ||||
| 		clearColor.r, | ||||
| 		clearColor.g, | ||||
| 		clearColor.b, | ||||
| 		clearColor.a, | ||||
| 	}; | ||||
| 
 | ||||
| 	m_Context->GetDeviceContext()->OMSetRenderTargets(1u, m_RenderTargetView.GetAddressOf(), nullptr); | ||||
| 	m_Context->GetDeviceContext()->ClearRenderTargetView(m_RenderTargetView.Get(), color); | ||||
| 
 | ||||
| 	D3D11_VIEWPORT viewport; | ||||
| 
 | ||||
| 	viewport.TopLeftX = 0; | ||||
| 	viewport.TopLeftY = 0; | ||||
| 
 | ||||
| 	viewport.Width  = m_Specification.width; | ||||
| 	viewport.Height = m_Specification.height; | ||||
| 
 | ||||
| 	viewport.MinDepth = 0.0f; | ||||
| 	viewport.MaxDepth = 1.0f; | ||||
| 
 | ||||
| 	// set viewport
 | ||||
| 	m_Context->GetDeviceContext()->RSSetViewports(1u, &viewport); | ||||
| } | ||||
| 
 | ||||
| void dxFramebuffer::BindAsResource() | ||||
| { | ||||
| 	LOG(err, "NO_IMPLEMENT"); | ||||
| } | ||||
| 
 | ||||
| void dxFramebuffer::Resize(const glm::uvec2& size) | ||||
| { | ||||
| 	m_Specification.width  = std::clamp(size.x, 1u, 16384u); | ||||
| 	m_Specification.height = std::clamp(size.y, 1u, 16384u); | ||||
| 
 | ||||
| 	D3D11_TEXTURE2D_DESC textureDesc; | ||||
| 	D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; | ||||
| 	D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; | ||||
| 
 | ||||
| 	m_ColorAttachment->GetDesc(&textureDesc); | ||||
| 	m_RenderTargetView->GetDesc(&rtvDesc); | ||||
| 	m_ShaderResourceView->GetDesc(&srvDesc); | ||||
| 
 | ||||
| 	textureDesc.Width  = m_Specification.width; | ||||
| 	textureDesc.Height = m_Specification.height; | ||||
| 
 | ||||
| 	HRESULT hr; | ||||
| 	DXC(m_Context->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &m_ColorAttachment)); | ||||
| 	DXC(m_Context->GetDevice()->CreateRenderTargetView(m_ColorAttachment.Get(), &rtvDesc, &m_RenderTargetView)); | ||||
| 	DXC(m_Context->GetDevice()->CreateShaderResourceView(m_ColorAttachment.Get(), &srvDesc, &m_ShaderResourceView)); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,45 +0,0 @@ | |||
| #include "dxShader.hpp" | ||||
| 
 | ||||
| #include "dxSharedContext.hpp" | ||||
| 
 | ||||
| #include <d3dcompiler.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| dxShader::dxShader(BasicFileHandle vertexFile, BasicFileHandle pixelFile, Ref<dxSharedContext> sharedContext) | ||||
|     : m_Context(sharedContext), m_VertexShader(nullptr), m_PixelShader(nullptr), m_VertexBlob(nullptr) | ||||
| { | ||||
| 	Microsoft::WRL::ComPtr<ID3DBlob> ps = nullptr, vsErr = nullptr, psErr = nullptr; | ||||
| 
 | ||||
| 	// compile shaders (we don't use DXC here because if D3DCompile fails it throws a dxException without logging the vsErr/psErr
 | ||||
| 	D3DCompile(vertexFile.GetData(), vertexFile.GetSize(), NULL, nullptr, nullptr, "main", "vs_4_0", NULL, NULL, &m_VertexBlob, &vsErr); | ||||
| 	D3DCompile(pixelFile.GetData(), pixelFile.GetSize(), NULL, nullptr, nullptr, "main", "ps_4_0", NULL, NULL, &ps, &psErr); | ||||
| 
 | ||||
| 	// check
 | ||||
| 	ASSERT(!vsErr.Get(), "Vertex shader compile error: {}", (char*)vsErr->GetBufferPointer()); | ||||
| 	ASSERT(!psErr.Get(), "Pixels shader compile error: {}", (char*)psErr->GetBufferPointer()); | ||||
| 
 | ||||
| 	// create shaders
 | ||||
| 	HRESULT hr; | ||||
| 	DXC(m_Context->GetDevice()->CreateVertexShader(m_VertexBlob->GetBufferPointer(), m_VertexBlob->GetBufferSize(), NULL, &m_VertexShader)); | ||||
| 	DXC(m_Context->GetDevice()->CreatePixelShader(ps->GetBufferPointer(), ps->GetBufferSize(), NULL, &m_PixelShader)); | ||||
| } | ||||
| 
 | ||||
| dxShader::~dxShader() | ||||
| { | ||||
| 	UnBind(); | ||||
| } | ||||
| 
 | ||||
| void dxShader::Bind() | ||||
| { | ||||
| 	m_Context->GetDeviceContext()->VSSetShader(m_VertexShader.Get(), nullptr, 0u); | ||||
| 	m_Context->GetDeviceContext()->PSSetShader(m_PixelShader.Get(), nullptr, 0u); | ||||
| } | ||||
| 
 | ||||
| void dxShader::UnBind() | ||||
| { | ||||
| 	m_Context->GetDeviceContext()->VSSetShader(nullptr, nullptr, 0u); | ||||
| 	m_Context->GetDeviceContext()->PSSetShader(nullptr, nullptr, 0u); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,31 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Graphics/SharedContext.hpp" | ||||
| 
 | ||||
| #include <d3d11.h> | ||||
| #include <wrl.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class dxSharedContext: public SharedContext | ||||
| { | ||||
| private: | ||||
| 	Microsoft::WRL::ComPtr<ID3D11Device> m_Device                     = nullptr; | ||||
| 	Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_DeviceContext       = nullptr; | ||||
| 	Microsoft::WRL::ComPtr<IDXGISwapChain> m_SwapChain                = nullptr; | ||||
| 	Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView = nullptr; | ||||
| 
 | ||||
| public: | ||||
| 	inline Microsoft::WRL::ComPtr<ID3D11Device> GetDevice() { return m_Device; } | ||||
| 	inline Microsoft::WRL::ComPtr<ID3D11DeviceContext> GetDeviceContext() { return m_DeviceContext; } | ||||
| 	inline Microsoft::WRL::ComPtr<IDXGISwapChain> GetSwapChain() { return m_SwapChain; } | ||||
| 	inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView> GetRenderTargetView() { return m_RenderTargetView; } | ||||
| 
 | ||||
| 	inline Microsoft::WRL::ComPtr<ID3D11Device>& GetDeviceRef() { return m_Device; } | ||||
| 	inline Microsoft::WRL::ComPtr<ID3D11DeviceContext>& GetDeviceContextRef() { return m_DeviceContext; } | ||||
| 	inline Microsoft::WRL::ComPtr<IDXGISwapChain>& GetSwapChainRef() { return m_SwapChain; } | ||||
| 	inline Microsoft::WRL::ComPtr<ID3D11RenderTargetView>& GetRenderTargetViewRef() { return m_RenderTargetView; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,67 +0,0 @@ | |||
| #include "dxTexture.hpp" | ||||
| 
 | ||||
| #include "dxSharedContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| dxTexture::dxTexture(unsigned int width, unsigned int height, unsigned int components, unsigned char* pixels, Ref<dxSharedContext> sharedContext, const std::string& filePath) | ||||
|     : Texture(filePath), m_Context(sharedContext), m_Texture2D(nullptr), m_ShaderResourceView(nullptr), m_SamplerState(nullptr) | ||||
| { | ||||
| 	// texture2d desc
 | ||||
| 	D3D11_TEXTURE2D_DESC t2dDesc = {}; | ||||
| 	t2dDesc.Width                = width; | ||||
| 	t2dDesc.Height               = height; | ||||
| 	t2dDesc.MipLevels            = 0u; | ||||
| 	t2dDesc.ArraySize            = 1u; | ||||
| 	t2dDesc.Format               = components == 4u ? DXGI_FORMAT_R8G8B8A8_UNORM : | ||||
| 	                               components == 3u ? DXGI_FORMAT_R8G8B8A8_UNORM : | ||||
|                                                       // #todo: figure out what to do with this bitch ._.
 | ||||
|                          components == 2u ? DXGI_FORMAT_R8G8_UNORM : | ||||
| 	                               components == 1u     ? DXGI_FORMAT_R8_UNORM : | ||||
|                                                           DXGI_FORMAT_UNKNOWN; | ||||
| 	t2dDesc.SampleDesc.Count     = 1u; | ||||
| 	t2dDesc.SampleDesc.Quality   = 0u; | ||||
| 	t2dDesc.Usage                = D3D11_USAGE_DEFAULT; | ||||
| 	t2dDesc.BindFlags            = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; | ||||
| 	t2dDesc.CPUAccessFlags       = NULL; | ||||
| 	t2dDesc.MiscFlags            = D3D11_RESOURCE_MISC_GENERATE_MIPS; | ||||
| 
 | ||||
| 	// create texture
 | ||||
| 	HRESULT hr; | ||||
| 	DXC(m_Context->GetDevice()->CreateTexture2D(&t2dDesc, nullptr, &m_Texture2D)); | ||||
| 	m_Context->GetDeviceContext()->UpdateSubresource(m_Texture2D.Get(), 0u, nullptr, pixels, width * 4u, 0u); | ||||
| 
 | ||||
| 	m_Texture2D->GetDesc(&t2dDesc); | ||||
| 
 | ||||
| 	// shader resource view desc
 | ||||
| 	D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; | ||||
| 	srvDesc.Format                          = t2dDesc.Format; | ||||
| 	srvDesc.ViewDimension                   = D3D11_SRV_DIMENSION_TEXTURE2D; | ||||
| 	srvDesc.Texture2D.MostDetailedMip       = 0u; | ||||
| 	srvDesc.Texture2D.MipLevels             = -1; | ||||
| 
 | ||||
| 	// create shader resource view
 | ||||
| 	m_Context->GetDevice()->CreateShaderResourceView(m_Texture2D.Get(), &srvDesc, &m_ShaderResourceView); | ||||
| 	m_Context->GetDeviceContext()->GenerateMips(m_ShaderResourceView.Get()); | ||||
| 
 | ||||
| 	// sampler desc
 | ||||
| 	D3D11_SAMPLER_DESC sDesc = {}; | ||||
| 	sDesc.Filter             = D3D11_FILTER_MIN_MAG_MIP_LINEAR; | ||||
| 	sDesc.AddressU           = D3D11_TEXTURE_ADDRESS_WRAP; | ||||
| 	sDesc.AddressV           = D3D11_TEXTURE_ADDRESS_WRAP; | ||||
| 	sDesc.AddressW           = D3D11_TEXTURE_ADDRESS_WRAP; | ||||
| 	sDesc.MinLOD             = 0.0f; | ||||
| 	sDesc.MipLODBias         = 0.0f; | ||||
| 	sDesc.MaxLOD             = D3D11_FLOAT32_MAX; | ||||
| 
 | ||||
| 	// create sampler
 | ||||
| 	m_Context->GetDevice()->CreateSamplerState(&sDesc, &m_SamplerState); | ||||
| } | ||||
| 
 | ||||
| void dxTexture::Bind(unsigned int slot /* = 0u */) | ||||
| { | ||||
| 	m_Context->GetDeviceContext()->PSSetSamplers(slot, 1u, m_SamplerState.GetAddressOf()); | ||||
| 	m_Context->GetDeviceContext()->PSSetShaderResources(slot, 1u, m_ShaderResourceView.GetAddressOf()); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,28 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Graphics/Framebuffer.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class glFramebuffer: public Framebuffer | ||||
| { | ||||
| private: | ||||
| 	FramebufferSpecification m_Specification; | ||||
| 
 | ||||
| 	unsigned int m_BufferID; | ||||
| 	unsigned int m_ColorAttachmentID, m_DepthStencilAttachmentID; | ||||
| 
 | ||||
| public: | ||||
| 	glFramebuffer(const FramebufferSpecification& specification); | ||||
| 	~glFramebuffer(); | ||||
| 
 | ||||
| 	void BindAsTarget(const glm::vec4& clearColor) override; | ||||
| 	void BindAsResource() override; | ||||
| 
 | ||||
| 	void Resize(const glm::uvec2& size) override; | ||||
| 
 | ||||
| 	inline void* GetColorAttachment() override { return (void*)m_ColorAttachmentID; } | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,100 +0,0 @@ | |||
| #include "glGraphicsContext.hpp" | ||||
| 
 | ||||
| #include "Events/WindowEvents.hpp" | ||||
| #include "Graphics/Blender.hpp"            // required for forward declaration
 | ||||
| #include "Graphics/Buffers.hpp"            // required for forward declaration
 | ||||
| #include "Graphics/RenderCommand.hpp"      // required for forward declaration
 | ||||
| #include "Graphics/Renderer.hpp"           // required for forward declaration
 | ||||
| #include "UserInterface/UserInterface.hpp" // required for forward declaration
 | ||||
| #include "Utility/ResourceManager.hpp"     // required for forward declaration
 | ||||
| 
 | ||||
| #include <glad/gl.h> | ||||
| 
 | ||||
| #ifndef STOP_FUCKING_ORDERING_THESE_THE_WRONG_WAY_CLANG_FORMAT____ | ||||
| 	#include <GLFW/glfw3.h> | ||||
| #endif | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| glGraphicsContext::glGraphicsContext(GLFWwindow* windowHandle) | ||||
|     : m_WindowHandle(windowHandle) | ||||
| { | ||||
| 	// set 'GraphicsAPI'
 | ||||
| 	m_GraphicsAPI = GraphicsAPI::OpenGL; | ||||
| 
 | ||||
| 	// make context current
 | ||||
| 	glfwMakeContextCurrent(windowHandle); | ||||
| 
 | ||||
| 	// load opengl (glad)
 | ||||
| 	ASSERT(gladLoadGL(glfwGetProcAddress), "Failed to initialize opengl (glad)"); | ||||
| 
 | ||||
| 	SetDebugMessageCallback(); | ||||
| } | ||||
| 
 | ||||
| void glGraphicsContext::LogDebugData() | ||||
| { | ||||
| 	// #todo: log more information
 | ||||
| 	LOG(info, "________________________________________"); | ||||
| 	LOG(info, "GraphicsContext::"); | ||||
| 	LOG(info, "        API     : OpenGL"); | ||||
| 	// LOG(info, "        Version : {}", glGetString(GL_VERSION));
 | ||||
| 	// LOG(info, "        Renderer: {}", glGetString(GL_RENDERER));
 | ||||
| 	LOG(info, "________________________________________"); | ||||
| } | ||||
| 
 | ||||
| void glGraphicsContext::SetDebugMessageCallback() | ||||
| { | ||||
| 	// determine log level
 | ||||
| 	// #todo: set filters from config.h
 | ||||
| #if defined(LIGHT_DEBUG) | ||||
| 	glEnable(GL_DEBUG_OUTPUT); | ||||
| 	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); | ||||
| 
 | ||||
| 	GLuint ids[] = { | ||||
| 		131185 | ||||
| 	}; | ||||
| 	glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE, _countof(ids), ids, GL_FALSE); | ||||
| #elif defined(LIGHT_RELEASE) | ||||
| 	glEnable(GL_DEBUG_OUTPUT); | ||||
| 	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_FALSE); | ||||
| 	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, GL_TRUE); | ||||
| 	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, GL_TRUE); | ||||
| #else // LIGHT_DIST
 | ||||
| 	return; | ||||
| #endif | ||||
| 
 | ||||
| 	/* setup message callback */ | ||||
| 	glDebugMessageCallback([](unsigned int source, unsigned int type, | ||||
| 	                          unsigned int id, unsigned int severity, | ||||
| 	                          int length, const char* message, | ||||
| 	                          const void* userParam) { | ||||
| 		switch (severity) | ||||
| 		{ | ||||
| 		case GL_DEBUG_SEVERITY_HIGH: | ||||
| 			// throw glException(source, type, id, message);
 | ||||
| 			return; | ||||
| 
 | ||||
| 		case GL_DEBUG_SEVERITY_MEDIUM: | ||||
| 		case GL_DEBUG_SEVERITY_LOW: | ||||
| 			LOG(warn, "glMessageCallback: Severity: {} :: Source: {} :: Type: {} :: ID: {}", | ||||
| 			    Stringifier::glDebugMsgSeverity(severity), | ||||
| 			    Stringifier::glDebugMsgSource(source), | ||||
| 			    Stringifier::glDebugMsgType(type), | ||||
| 			    id); | ||||
| 			LOG(warn, "      {}", message); | ||||
| 			return; | ||||
| 
 | ||||
| 		case GL_DEBUG_SEVERITY_NOTIFICATION: | ||||
| 			LOG(trace, "Severity: {} :: Source: {} :: Type: {} :: ID: {}", | ||||
| 			    Stringifier::glDebugMsgSeverity(severity), | ||||
| 			    Stringifier::glDebugMsgSource(source), | ||||
| 			    Stringifier::glDebugMsgType(type), | ||||
| 			    id); | ||||
| 			LOG(trace, "        {}", message); | ||||
| 			return; | ||||
| 		} | ||||
| 	}, | ||||
| 	                       nullptr); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,12 +0,0 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Base/Base.hpp" | ||||
| #include "Graphics/SharedContext.hpp" | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class glSharedContext: public SharedContext | ||||
| { | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,228 +0,0 @@ | |||
| #include "lWindow.hpp" | ||||
| 
 | ||||
| #include "Events/CharEvent.hpp" | ||||
| #include "Events/Event.hpp" | ||||
| #include "Events/KeyboardEvents.hpp" | ||||
| #include "Events/MouseEvents.hpp" | ||||
| #include "Events/WindowEvents.hpp" | ||||
| #include "Graphics/GraphicsContext.hpp" | ||||
| 
 | ||||
| #include <GLFW/glfw3.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Scope<Window> Window::Create(std::function<void(Event&)> callback) | ||||
| { | ||||
| 	return CreateScope<lWindow>(callback); | ||||
| } | ||||
| 
 | ||||
| lWindow::lWindow(std::function<void(Event&)> callback) | ||||
|     : m_Handle(nullptr), m_EventCallback(callback) | ||||
| { | ||||
| 	// init glfw
 | ||||
| 	ASSERT(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'"); | ||||
| 
 | ||||
| 	// create window
 | ||||
| 	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); | ||||
| 	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); | ||||
| 	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | ||||
| 	glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); | ||||
| 
 | ||||
| 	m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); | ||||
| 	ASSERT(m_Handle, "lWindow::lWindow: failed to create 'GLFWwindow'"); | ||||
| 
 | ||||
| 	// bind event stuff
 | ||||
| 	glfwSetWindowUserPointer(m_Handle, &m_EventCallback); | ||||
| 	BindGlfwEvents(); | ||||
| 
 | ||||
| 	// create graphics context
 | ||||
| 	m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::OpenGL, m_Handle); | ||||
| 	ASSERT(m_GraphicsContext, "lWindow::lWindow: failed to create 'GraphicsContext'"); | ||||
| } | ||||
| 
 | ||||
| lWindow::~lWindow() | ||||
| { | ||||
| 	glfwDestroyWindow(m_Handle); | ||||
| } | ||||
| 
 | ||||
| void lWindow::PollEvents() | ||||
| { | ||||
| 	glfwPollEvents(); | ||||
| } | ||||
| 
 | ||||
| void lWindow::OnEvent(const Event& event) | ||||
| { | ||||
| 	switch (event.GetEventType()) | ||||
| 	{ | ||||
| 	/* closed */ | ||||
| 	case EventType::WindowClosed: | ||||
| 		b_Closed = true; | ||||
| 		break; | ||||
| 
 | ||||
| 	/* resized */ | ||||
| 	case EventType::WindowResized: | ||||
| 		OnWindowResize((const WindowResizedEvent&)event); | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void lWindow::OnWindowResize(const WindowResizedEvent& event) | ||||
| { | ||||
| 	m_Properties.size = event.GetSize(); | ||||
| } | ||||
| 
 | ||||
| void lWindow::SetProperties(const WindowProperties& properties, bool overrideVisibility /* = false */) | ||||
| { | ||||
| 	// save the visibility status and re-assign if 'overrideVisibility' is false
 | ||||
| 	bool visible         = overrideVisibility ? properties.visible : m_Properties.visible; | ||||
| 	m_Properties         = properties; | ||||
| 	m_Properties.visible = visible; | ||||
| 
 | ||||
| 	// set properties
 | ||||
| 	SetTitle(properties.title); | ||||
| 	SetSize(properties.size); | ||||
| 	SetVSync(properties.vsync); | ||||
| 	SetVisibility(visible); | ||||
| } | ||||
| 
 | ||||
| void lWindow::SetTitle(const std::string& title) | ||||
| { | ||||
| 	m_Properties.title = title; | ||||
| 
 | ||||
| 	glfwSetWindowTitle(m_Handle, title.c_str()); | ||||
| } | ||||
| 
 | ||||
| void lWindow::SetSize(const glm::uvec2& size, bool additive /* = false */) | ||||
| { | ||||
| 	m_Properties.size.x = size.x == 0u ? m_Properties.size.x : additive ? m_Properties.size.x + size.x : | ||||
|                                                                           size.x; | ||||
| 	m_Properties.size.y = size.y == 0u ? m_Properties.size.y : additive ? m_Properties.size.y + size.y : | ||||
|                                                                           size.y; | ||||
| 
 | ||||
| 
 | ||||
| 	glfwSetWindowSize(m_Handle, size.x, size.y); | ||||
| } | ||||
| 
 | ||||
| void lWindow::SetVSync(bool vsync, bool toggle /* = false */) | ||||
| { | ||||
| 	m_Properties.vsync = toggle ? !m_Properties.vsync : vsync; | ||||
| 
 | ||||
| 	glfwSwapInterval(m_Properties.vsync); | ||||
| } | ||||
| 
 | ||||
| void lWindow::SetVisibility(bool visible, bool toggle) | ||||
| { | ||||
| 	m_Properties.visible = toggle ? !m_Properties.visible : visible; | ||||
| 
 | ||||
| 	if (m_Properties.visible) | ||||
| 		glfwShowWindow(m_Handle); | ||||
| 	else | ||||
| 		glfwHideWindow(m_Handle); | ||||
| } | ||||
| 
 | ||||
| void lWindow::BindGlfwEvents() | ||||
| { | ||||
| 	//============================== MOUSE_EVENTS ==============================//
 | ||||
| 	/* cursor position */ | ||||
| 	glfwSetCursorPosCallback(m_Handle, [](GLFWwindow* window, double xpos, double ypos) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		MouseMovedEvent event(xpos, ypos); | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* mouse button */ | ||||
| 	glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow* window, int button, int action, int mods) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		if (action == GLFW_PRESS) | ||||
| 		{ | ||||
| 			ButtonPressedEvent event(button); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 		else if (action == GLFW_RELEASE) | ||||
| 		{ | ||||
| 			ButtonReleasedEvent event(button); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 	}); | ||||
| 
 | ||||
| 	/* scroll */ | ||||
| 	glfwSetScrollCallback(m_Handle, [](GLFWwindow* window, double xoffset, double yoffset) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		WheelScrolledEvent event(yoffset); | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 	//============================== MOUSE_EVENTS ==============================//
 | ||||
| 
 | ||||
| 	//============================== KEYBOARD_EVENTS ==============================//
 | ||||
| 	/* key */ | ||||
| 	glfwSetKeyCallback(m_Handle, [](GLFWwindow* window, int key, int scancode, int action, int mods) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		if (action == GLFW_PRESS) | ||||
| 		{ | ||||
| 			KeyPressedEvent event(key); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 		else if (action == GLFW_RELEASE) | ||||
| 		{ | ||||
| 			KeyReleasedEvent event(key); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 	}); | ||||
| 	/* char */ | ||||
| 	glfwSetCharCallback(m_Handle, [](GLFWwindow* window, unsigned int character) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		SetCharEvent event(character); | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	//============================== KEYBOARD_EVENTS ==============================//
 | ||||
| 
 | ||||
| 	//============================== WINDOW_EVENTS ==============================//
 | ||||
| 	/* window position */ | ||||
| 	glfwSetWindowPosCallback(m_Handle, [](GLFWwindow* window, int xpos, int ypos) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 		WindowMovedEvent event(xpos, ypos); | ||||
| 
 | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* window size */ | ||||
| 	glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 		WindowResizedEvent event(width, height); | ||||
| 
 | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* window close */ | ||||
| 	glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow* window) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 		WindowClosedEvent event; | ||||
| 
 | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* window focus */ | ||||
| 	glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow* window, int focus) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		if (focus == GLFW_TRUE) | ||||
| 		{ | ||||
| 			WindowGainFocusEvent event; | ||||
| 			callback(event); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			WindowLostFocusEvent event; | ||||
| 			callback(event); | ||||
| 		} | ||||
| 	}); | ||||
| 	//============================== WINDOW_EVENTS ==============================//
 | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,234 +0,0 @@ | |||
| #include "wWindow.hpp" | ||||
| 
 | ||||
| #include "Events/CharEvent.hpp" | ||||
| #include "Events/Event.hpp" | ||||
| #include "Events/KeyboardEvents.hpp" | ||||
| #include "Events/MouseEvents.hpp" | ||||
| #include "Events/WindowEvents.hpp" | ||||
| #include "Graphics/GraphicsContext.hpp" | ||||
| 
 | ||||
| #include <GLFW/glfw3.h> | ||||
| 
 | ||||
| extern "C" | ||||
| { | ||||
| 	// Force Machine to use Dedicated Graphics
 | ||||
| 	__declspec(dllexport) unsigned long NvOptimusEnablement        = 0x00000001; // NVidia
 | ||||
| 	__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;          // AMD
 | ||||
| } | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| Scope<Window> Window::Create(std::function<void(Event&)> callback) | ||||
| { | ||||
| 	return CreateScope<wWindow>(callback); | ||||
| } | ||||
| 
 | ||||
| wWindow::wWindow(std::function<void(Event&)> callback) | ||||
|     : m_Handle(nullptr), m_EventCallback(callback) | ||||
| { | ||||
| 	// init glfw
 | ||||
| 	ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); | ||||
| 
 | ||||
| 	// create window
 | ||||
| 	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); | ||||
| 	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); | ||||
| 	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | ||||
| 	glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); | ||||
| 
 | ||||
| 	m_Handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); | ||||
| 	ASSERT(m_Handle, "wWindow::wWindow: glfwCreateWindow: failed to create 'GLFWwindow'"); | ||||
| 
 | ||||
| 	// bind event stuff
 | ||||
| 	glfwSetWindowUserPointer(m_Handle, &m_EventCallback); | ||||
| 	BindGlfwEvents(); | ||||
| 
 | ||||
| 	// create graphics context
 | ||||
| 	m_GraphicsContext = GraphicsContext::Create(GraphicsAPI::DirectX, m_Handle); | ||||
| 	ASSERT(m_GraphicsContext, "wWindow::wWindow: failed to create 'GraphicsContext'"); | ||||
| } | ||||
| 
 | ||||
| wWindow::~wWindow() | ||||
| { | ||||
| 	glfwDestroyWindow(m_Handle); | ||||
| } | ||||
| 
 | ||||
| void wWindow::PollEvents() | ||||
| { | ||||
| 	glfwPollEvents(); | ||||
| } | ||||
| 
 | ||||
| void wWindow::OnEvent(const Event& event) | ||||
| { | ||||
| 	switch (event.GetEventType()) | ||||
| 	{ | ||||
| 	/* closed */ | ||||
| 	case EventType::WindowClosed: | ||||
| 		b_Closed = true; | ||||
| 		break; | ||||
| 
 | ||||
| 	/* resized */ | ||||
| 	case EventType::WindowResized: | ||||
| 		OnWindowResize((const WindowResizedEvent&)event); | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void wWindow::OnWindowResize(const WindowResizedEvent& event) | ||||
| { | ||||
| 	m_Properties.size = event.GetSize(); | ||||
| } | ||||
| 
 | ||||
| void wWindow::SetProperties(const WindowProperties& properties, bool overrideVisiblity /* = false */) | ||||
| { | ||||
| 	// save the visibility status and re-assign if 'overrideVisibility' is false
 | ||||
| 	bool visible         = overrideVisiblity ? properties.visible : m_Properties.visible; | ||||
| 	m_Properties         = properties; | ||||
| 	m_Properties.visible = visible; | ||||
| 
 | ||||
| 	// set properties
 | ||||
| 	SetTitle(properties.title); | ||||
| 	SetSize(properties.size); | ||||
| 	SetVSync(properties.vsync); | ||||
| 	SetVisibility(visible); | ||||
| } | ||||
| 
 | ||||
| void wWindow::SetTitle(const std::string& title) | ||||
| { | ||||
| 	m_Properties.title = title; | ||||
| 
 | ||||
| 	glfwSetWindowTitle(m_Handle, m_Properties.title.c_str()); | ||||
| } | ||||
| 
 | ||||
| void wWindow::SetSize(const glm::uvec2& size, bool additive /* = false */) | ||||
| { | ||||
| 	m_Properties.size.x = size.x == 0u ? m_Properties.size.x : additive ? m_Properties.size.x + size.x : | ||||
|                                                                           size.x; | ||||
| 	m_Properties.size.y = size.y == 0u ? m_Properties.size.y : additive ? m_Properties.size.y + size.y : | ||||
|                                                                           size.y; | ||||
| 
 | ||||
| 
 | ||||
| 	glfwSetWindowSize(m_Handle, size.x, size.y); | ||||
| } | ||||
| 
 | ||||
| void wWindow::SetVSync(bool vsync, bool toggle /* = false */) | ||||
| { | ||||
| 	m_Properties.vsync = toggle ? !m_Properties.vsync : vsync; | ||||
| 
 | ||||
| 	glfwSwapInterval(m_Properties.vsync); | ||||
| } | ||||
| 
 | ||||
| void wWindow::SetVisibility(bool visible, bool toggle) | ||||
| { | ||||
| 	m_Properties.visible = toggle ? !m_Properties.visible : visible; | ||||
| 
 | ||||
| 	if (m_Properties.visible) | ||||
| 		glfwShowWindow(m_Handle); | ||||
| 	else | ||||
| 		glfwHideWindow(m_Handle); | ||||
| } | ||||
| 
 | ||||
| void wWindow::BindGlfwEvents() | ||||
| { | ||||
| 	//============================== MOUSE_EVENTS ==============================//
 | ||||
| 	/* cursor position */ | ||||
| 	glfwSetCursorPosCallback(m_Handle, [](GLFWwindow* window, double xpos, double ypos) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		MouseMovedEvent event(xpos, ypos); | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* mouse button */ | ||||
| 	glfwSetMouseButtonCallback(m_Handle, [](GLFWwindow* window, int button, int action, int mods) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		if (action == GLFW_PRESS) | ||||
| 		{ | ||||
| 			ButtonPressedEvent event(button); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 		else if (action == GLFW_RELEASE) | ||||
| 		{ | ||||
| 			ButtonReleasedEvent event(button); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 	}); | ||||
| 
 | ||||
| 	/* scroll */ | ||||
| 	glfwSetScrollCallback(m_Handle, [](GLFWwindow* window, double xoffset, double yoffset) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		WheelScrolledEvent event(yoffset); | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 	//============================== MOUSE_EVENTS ==============================//
 | ||||
| 
 | ||||
| 	//============================== KEYBOARD_EVENTS ==============================//
 | ||||
| 	/* key */ | ||||
| 	glfwSetKeyCallback(m_Handle, [](GLFWwindow* window, int key, int scancode, int action, int mods) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		if (action == GLFW_PRESS) | ||||
| 		{ | ||||
| 			KeyPressedEvent event(key); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 		else if (action == GLFW_RELEASE) | ||||
| 		{ | ||||
| 			KeyReleasedEvent event(key); | ||||
| 			callback(event); | ||||
| 		} | ||||
| 	}); | ||||
| 	/* char */ | ||||
| 	glfwSetCharCallback(m_Handle, [](GLFWwindow* window, unsigned int character) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		SetCharEvent event(character); | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	//============================== KEYBOARD_EVENTS ==============================//
 | ||||
| 
 | ||||
| 	//============================== WINDOW_EVENTS ==============================//
 | ||||
| 	/* window position */ | ||||
| 	glfwSetWindowPosCallback(m_Handle, [](GLFWwindow* window, int xpos, int ypos) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 		WindowMovedEvent event(xpos, ypos); | ||||
| 
 | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* window size */ | ||||
| 	glfwSetWindowSizeCallback(m_Handle, [](GLFWwindow* window, int width, int height) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 		WindowResizedEvent event(width, height); | ||||
| 
 | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* window close */ | ||||
| 	glfwSetWindowCloseCallback(m_Handle, [](GLFWwindow* window) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 		WindowClosedEvent event; | ||||
| 
 | ||||
| 		callback(event); | ||||
| 	}); | ||||
| 
 | ||||
| 	/* window focus */ | ||||
| 	glfwSetWindowFocusCallback(m_Handle, [](GLFWwindow* window, int focus) { | ||||
| 		std::function<void(Event&)> callback = *(std::function<void(Event&)>*)glfwGetWindowUserPointer(window); | ||||
| 
 | ||||
| 		if (focus == GLFW_TRUE) | ||||
| 		{ | ||||
| 			WindowGainFocusEvent event; | ||||
| 			callback(event); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			WindowLostFocusEvent event; | ||||
| 			callback(event); | ||||
| 		} | ||||
| 	}); | ||||
| 	//============================== WINDOW_EVENTS ==============================//	}
 | ||||
| } | ||||
| } // namespace Light
 | ||||
|  | @ -1,5 +0,0 @@ | |||
| #!/bin/bash | ||||
| 
 | ||||
| for f in $(find `pwd` -name "*.cppE"); do | ||||
|     rm "${f}" | ||||
| done | ||||
|  | @ -1,139 +0,0 @@ | |||
| --- | ||||
| # Core | ||||
| Language: Cpp | ||||
| Standard: Cpp11 | ||||
| ColumnLimit: '0' # No limit | ||||
| 
 | ||||
| ### Bin pack ### | ||||
| BinPackArguments: 'true' | ||||
| BinPackParameters: 'true' | ||||
| 
 | ||||
| # Includes | ||||
| SortIncludes: 'true' | ||||
| IncludeBlocks: Regroup | ||||
| IncludeCategories: | ||||
|     # Current Project | ||||
|     - Regex: '"' | ||||
|       Priority: 001 | ||||
|      | ||||
|     # Custom Project Categories... | ||||
| 
 | ||||
|     # Dependecies | ||||
|     - Regex: '<' | ||||
|       Priority: 500 | ||||
|      | ||||
|     # Custom Deependencies Categories... | ||||
| 
 | ||||
|     # C++ includes | ||||
|     - Regex: '[^.h .hpp]>' | ||||
|       Priority: 998 | ||||
| 
 | ||||
|     # C includes | ||||
|     - Regex: '<[^/\n]+[.]h>' | ||||
|       Priority: 999 | ||||
| 
 | ||||
| # Braces | ||||
| BreakBeforeBraces: Custom | ||||
| BraceWrapping: | ||||
|     AfterCaseLabel: true | ||||
|     AfterClass: true | ||||
|     AfterControlStatement: true | ||||
|     AfterEnum: true | ||||
|     AfterFunction: true | ||||
|     AfterNamespace: false | ||||
|     AfterObjCDeclaration: true | ||||
|     AfterStruct: true | ||||
|     AfterUnion: true | ||||
|     AfterExternBlock: true | ||||
|     BeforeCatch: true | ||||
|     BeforeElse: true | ||||
|     IndentBraces: false | ||||
|     SplitEmptyFunction: true | ||||
|     SplitEmptyRecord: true | ||||
|     SplitEmptyNamespace: true | ||||
| 
 | ||||
| # Indentation | ||||
| UseTab: ForIndentation | ||||
| TabWidth: '4' | ||||
| IndentWidth: '4' | ||||
| ContinuationIndentWidth: '4' | ||||
| ConstructorInitializerIndentWidth: '4' | ||||
| IndentCaseLabels: 'false' | ||||
| IndentWrappedFunctionNames: 'true' | ||||
| IndentPPDirectives: BeforeHash | ||||
| NamespaceIndentation: None | ||||
| AccessModifierOffset: '-4' | ||||
| 
 | ||||
| # Space | ||||
| SpaceAfterCStyleCast: 'false' | ||||
| SpaceAfterLogicalNot: 'false' | ||||
| SpaceAfterTemplateKeyword: 'false' | ||||
| SpaceBeforeAssignmentOperators: 'true' | ||||
| SpaceBeforeCpp11BracedList: 'true' | ||||
| SpaceBeforeCtorInitializerColon: 'false' | ||||
| SpaceBeforeInheritanceColon: 'false' | ||||
| SpaceBeforeParens: ControlStatements | ||||
| SpaceBeforeRangeBasedForLoopColon: 'true' | ||||
| SpaceInEmptyParentheses: 'false' | ||||
| SpacesBeforeTrailingComments: '1' | ||||
| SpacesInAngles: 'false' | ||||
| SpacesInCStyleCastParentheses: 'false' | ||||
| SpacesInContainerLiterals: 'false' | ||||
| SpacesInParentheses: 'false' | ||||
| SpacesInSquareBrackets: 'false' | ||||
| 
 | ||||
| ### Alignment ### | ||||
| PointerAlignment: Left | ||||
| DerivePointerAlignment: 'false' | ||||
| AlignAfterOpenBracket: Align | ||||
| AlignEscapedNewlines: Left | ||||
| AlignConsecutiveDeclarations: 'false' | ||||
| AlignConsecutiveAssignments: 'true' | ||||
| AlignConsecutiveMacros: 'true' | ||||
| AlignOperands: 'true' | ||||
| AlignTrailingComments: 'true' | ||||
| 
 | ||||
| ### Single Line ### | ||||
| AllowShortCaseLabelsOnASingleLine: 'true' | ||||
| AllowShortFunctionsOnASingleLine: Inline | ||||
| AllowShortLambdasOnASingleLine: Inline | ||||
| AllowAllArgumentsOnNextLine: 'false' | ||||
| AllowShortLoopsOnASingleLine: 'false' | ||||
| AllowShortBlocksOnASingleLine: 'false' | ||||
| AllowAllParametersOfDeclarationOnNextLine: 'false' | ||||
| AllowShortIfStatementsOnASingleLine: Never | ||||
| 
 | ||||
| ### Break ### | ||||
| AlwaysBreakAfterReturnType: None | ||||
| AlwaysBreakBeforeMultilineStrings: 'false' | ||||
| AlwaysBreakTemplateDeclarations: 'Yes' | ||||
| BreakBeforeBinaryOperators: None | ||||
| BreakBeforeTernaryOperators: 'false' | ||||
| BreakInheritanceList: BeforeComma | ||||
| BreakStringLiterals: 'false' | ||||
| 
 | ||||
| # Penalties | ||||
| PenaltyBreakAssignment: '0' | ||||
| PenaltyBreakBeforeFirstCallParameter: '0' | ||||
| PenaltyBreakComment: '0' | ||||
| PenaltyBreakFirstLessLess: '0' | ||||
| PenaltyBreakString: '0' | ||||
| PenaltyBreakTemplateDeclaration: '0' | ||||
| PenaltyExcessCharacter: '0' | ||||
| PenaltyReturnTypeOnItsOwnLine: '999999999' # Nope | ||||
| 
 | ||||
| # Constructor Initializers | ||||
| ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' | ||||
| AllowAllConstructorInitializersOnNextLine: 'true' | ||||
| BreakConstructorInitializers: BeforeComma | ||||
| 
 | ||||
| # Comments | ||||
| ReflowComments: 'false' | ||||
| CommentPragmas: '^ TODO@:' | ||||
| FixNamespaceComments: 'true' | ||||
| 
 | ||||
| # Misc | ||||
| Cpp11BracedListStyle: 'false' | ||||
| SortUsingDeclarations: 'true' | ||||
| KeepEmptyLinesAtTheStartOfBlocks: 'false' | ||||
| MaxEmptyLinesToKeep: '2' | ||||
|  | @ -1,23 +0,0 @@ | |||
| cmake_minimum_required(VERSION 3.14) | ||||
| 
 | ||||
| add_compile_definitions(LIGHT_PLATFORM_WINDOWS) | ||||
| 
 | ||||
| include_directories( | ||||
|     ${ENGINE_DIR}src/Engine/ | ||||
|     ${MIRROR_DIR}/src/ | ||||
|     ${ENGINE_DIR}src/Platform/GraphicsAPI/ | ||||
|     ${ENGINE_DIR}src/Platform/OS/ | ||||
|     ${DEPENDENCIES_DIR}entt/src/ | ||||
|     ${DEPENDENCIES_DIR}GLAD/include/ | ||||
|     ${DEPENDENCIES_DIR}GLFW/include/ | ||||
|     ${DEPENDENCIES_DIR}glm/ | ||||
|     ${DEPENDENCIES_DIR}imgui/ | ||||
|     ${DEPENDENCIES_DIR}spdlog/include | ||||
|     ${DEPENDENCIES_DIR}stb_image/ | ||||
|     ${DEPENDENCIES_DIR}yaml-cpp/include | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| file(GLOB_RECURSE MIRROR_FILES true ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/src/* ${CMAKE_CURRENT_SOURCE_DIR}/res/*) | ||||
| source_group(TREE ${MIRROR_DIR} FILES ${MIRROR_FILES}) | ||||
| add_executable(Mirror ${MIRROR_FILES}) | ||||
|  | @ -1,32 +0,0 @@ | |||
| #define LIGHT_ENTRY_POINT | ||||
| #include "EditorLayer.hpp" | ||||
| 
 | ||||
| #include <LightEngine.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Mirror: public Light::Application | ||||
| { | ||||
| public: | ||||
| 	Mirror(std::string execName, std::vector<std::string> args) | ||||
| 	    : Application(execName, args) | ||||
| 	{ | ||||
| 		// Set window properties
 | ||||
| 		Light::WindowProperties properties; | ||||
| 		properties.title = "Mirror"; | ||||
| 		properties.size  = glm::uvec2(1280u, 720u); | ||||
| 		properties.vsync = true; | ||||
| 
 | ||||
| 		m_Window->SetProperties(properties); | ||||
| 
 | ||||
| 		// Attach the sandbox layer
 | ||||
| 		LayerStack::EmplaceLayer<EditorLayer>(("MirrorLayer"), args); | ||||
| 	} | ||||
| }; | ||||
| 
 | ||||
| Application* CreateApplication(std::string execName, std::vector<std::string> args) | ||||
| { | ||||
| 	return new Mirror(execName, args); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
|  | @ -1,232 +0,0 @@ | |||
| #include "PropertiesPanel.hpp" | ||||
| 
 | ||||
| #include "Scene/Components.hpp" | ||||
| #include "Utility/ResourceManager.hpp" | ||||
| 
 | ||||
| #include <glm/glm.hpp> | ||||
| #include <glm/gtc/type_ptr.hpp> | ||||
| #include <imgui.h> | ||||
| #include <imgui_internal.h> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| void PropertiesPanel::OnUserInterfaceUpdate() | ||||
| { | ||||
| 	ImGui::Begin("Properties"); | ||||
| 
 | ||||
| 	if (m_EntityContext.IsValid()) | ||||
| 	{ | ||||
| 		if (m_EntityContext.HasComponent<TagComponent>()) | ||||
| 		{ | ||||
| 			auto& tagComponent = m_EntityContext.GetComponent<TagComponent>(); | ||||
| 
 | ||||
| 			char buffer[256]; | ||||
| 			memset(buffer, 0, sizeof(buffer)); | ||||
| 			std::strncpy(buffer, tagComponent.tag.c_str(), sizeof(buffer)); | ||||
| 
 | ||||
| 			if (ImGui::InputText("##Tag", buffer, sizeof(buffer))) | ||||
| 				tagComponent.tag = std::string(buffer); | ||||
| 		} | ||||
| 
 | ||||
| 		ImGui::SameLine(); | ||||
| 		ImGui::PushItemWidth(-1); | ||||
| 
 | ||||
| 		if (ImGui::Button("Add component")) | ||||
| 			ImGui::OpenPopup("Components"); | ||||
| 
 | ||||
| 		if (ImGui::BeginPopup("Components")) | ||||
| 		{ | ||||
| 			if (ImGui::Selectable("SpriteRenderer", false, m_EntityContext.HasComponent<SpriteRendererComponent>() ? ImGuiSelectableFlags_Disabled : NULL)) | ||||
| 				m_EntityContext.AddComponent<SpriteRendererComponent>(Light::ResourceManager::GetTexture("awesomeface")); | ||||
| 
 | ||||
| 			if (ImGui::Selectable("Camera", false, m_EntityContext.HasComponent<CameraComponent>() ? ImGuiSelectableFlags_Disabled : NULL)) | ||||
| 				m_EntityContext.AddComponent<CameraComponent>(); | ||||
| 
 | ||||
| 			ImGui::EndPopup(); | ||||
| 		} | ||||
| 		ImGui::PopItemWidth(); | ||||
| 
 | ||||
| 		DrawComponent<TransformComponent>("Transform Component", m_EntityContext, [&](auto& transformComponent) { | ||||
| 			DrawVec3Control("Translation", transformComponent.translation); | ||||
| 		}); | ||||
| 
 | ||||
| 		DrawComponent<SpriteRendererComponent>("SpriteRenderer Component", m_EntityContext, [&](auto& spriteRendererComponent) { | ||||
| 			ImGui::ColorEdit4("Color", &spriteRendererComponent.tint[0]); | ||||
| 		}); | ||||
| 
 | ||||
| 		DrawComponent<CameraComponent>("Camera Component", m_EntityContext, [&](auto& cameraComponent) { | ||||
| 			auto& camera = cameraComponent.camera; | ||||
| 
 | ||||
| 			SceneCamera::ProjectionType projectionType = camera.GetProjectionType(); | ||||
| 			const char* projectionTypesString[]        = { "Orthographic", "Perspective" }; | ||||
| 
 | ||||
| 			if (ImGui::BeginCombo("ProjectionType", projectionTypesString[(int)projectionType])) | ||||
| 			{ | ||||
| 				for (int i = 0; i < 2; i++) | ||||
| 				{ | ||||
| 					const bool isSelected = (int)projectionType == i; | ||||
| 					if (ImGui::Selectable(projectionTypesString[i], isSelected)) | ||||
| 					{ | ||||
| 						projectionType = (SceneCamera::ProjectionType)i; | ||||
| 						camera.SetProjectionType(projectionType); | ||||
| 					} | ||||
| 
 | ||||
| 					if (isSelected) | ||||
| 						ImGui::SetItemDefaultFocus(); | ||||
| 				} | ||||
| 
 | ||||
| 				ImGui::EndCombo(); | ||||
| 			} | ||||
| 
 | ||||
| 			if (projectionType == SceneCamera::ProjectionType::Orthographic) | ||||
| 			{ | ||||
| 				float orthoSize, nearPlane, farPlane; | ||||
| 
 | ||||
| 				orthoSize = camera.GetOrthographicSize(); | ||||
| 				nearPlane = camera.GetOrthographicNearPlane(); | ||||
| 				farPlane  = camera.GetOrthographicFarPlane(); | ||||
| 
 | ||||
| 				if (ImGui::DragFloat("Orthographic Size", &orthoSize)) | ||||
| 					camera.SetOrthographicSize(orthoSize); | ||||
| 
 | ||||
| 				if (ImGui::DragFloat("Near Plane", &nearPlane)) | ||||
| 					camera.SetOrthographicNearPlane(nearPlane); | ||||
| 
 | ||||
| 				if (ImGui::DragFloat("Far Plane", &farPlane)) | ||||
| 					camera.SetOrthographicFarPlane(farPlane); | ||||
| 			} | ||||
| 
 | ||||
| 			else // perspective
 | ||||
| 			{ | ||||
| 				float verticalFOV, nearPlane, farPlane; | ||||
| 
 | ||||
| 				verticalFOV = glm::degrees(camera.GetPerspectiveVerticalFOV()); | ||||
| 				nearPlane   = camera.GetPerspectiveNearPlane(); | ||||
| 				farPlane    = camera.GetPerspectiveFarPlane(); | ||||
| 
 | ||||
| 				if (ImGui::DragFloat("Vertical FOV", &verticalFOV)) | ||||
| 					camera.SetPerspectiveVerticalFOV(glm::radians(verticalFOV)); | ||||
| 
 | ||||
| 				if (ImGui::DragFloat("Near Plane", &nearPlane)) | ||||
| 					camera.SetPerspectiveNearPlane(nearPlane); | ||||
| 
 | ||||
| 				if (ImGui::DragFloat("Far Plane", &farPlane)) | ||||
| 					camera.SetPerspectiveFarPlane(farPlane); | ||||
| 			} | ||||
| 
 | ||||
| 			ImGui::Separator(); | ||||
| 		}); | ||||
| 	} | ||||
| 
 | ||||
| 	ImGui::End(); | ||||
| } | ||||
| 
 | ||||
| void PropertiesPanel::SetEntityContext(Entity entity) | ||||
| { | ||||
| 	m_EntityContext = entity; | ||||
| } | ||||
| 
 | ||||
| void PropertiesPanel::DrawVec3Control(const std::string& label, glm::vec3& values, float resetValue /*= 0.0f*/, float columnWidth /*= 100.0f*/) | ||||
| { | ||||
| 	ImGuiIO& io = ImGui::GetIO(); | ||||
| 
 | ||||
| 	auto boldFont = io.Fonts->Fonts[0]; | ||||
| 
 | ||||
| 	ImGui::Columns(2); | ||||
| 	ImGui::SetColumnWidth(0, columnWidth); | ||||
| 	ImGui::Text(label.c_str()); | ||||
| 	ImGui::NextColumn(); | ||||
| 
 | ||||
| 	ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth()); | ||||
| 	ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2 { 0, 0 }); | ||||
| 
 | ||||
| 	float lineHeight  = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f; | ||||
| 	ImVec2 buttonSize = { lineHeight + 3.0f, lineHeight }; | ||||
| 
 | ||||
| 	ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.1f, 0.15f, 1.0f)); | ||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.9f, 0.2f, 0.2f, 1.0f)); | ||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.8f, 0.1f, 0.15f, 1.0f)); | ||||
| 	ImGui::PushFont(boldFont); | ||||
| 	if (ImGui::Button("X", buttonSize)) | ||||
| 		values.x = resetValue; | ||||
| 	ImGui::PopFont(); | ||||
| 	ImGui::PopStyleColor(3); | ||||
| 
 | ||||
| 	ImGui::SameLine(); | ||||
| 	ImGui::DragFloat("##X", &values.x, 0.1f); | ||||
| 	ImGui::PopItemWidth(); | ||||
| 	ImGui::SameLine(); | ||||
| 
 | ||||
| 	ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.7f, 0.2f, 1.0f)); | ||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.3f, 0.8f, 0.3f, 1.0f)); | ||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.2f, 0.7f, 0.2f, 1.0f)); | ||||
| 	ImGui::PushFont(boldFont); | ||||
| 	if (ImGui::Button("Y", buttonSize)) | ||||
| 		values.y = resetValue; | ||||
| 	ImGui::PopFont(); | ||||
| 	ImGui::PopStyleColor(3); | ||||
| 
 | ||||
| 	ImGui::SameLine(); | ||||
| 	ImGui::DragFloat("##Y", &values.y, 0.1f); | ||||
| 	ImGui::PopItemWidth(); | ||||
| 	ImGui::SameLine(); | ||||
| 
 | ||||
| 
 | ||||
| 	ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.25f, 0.8f, 1.0f)); | ||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.2f, 0.35f, 0.9f, 1.0f)); | ||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.1f, 0.25f, 0.8f, 1.0f)); | ||||
| 	ImGui::PushFont(boldFont); | ||||
| 	if (ImGui::Button("Z", buttonSize)) | ||||
| 		values.z = resetValue; | ||||
| 	ImGui::PopFont(); | ||||
| 	ImGui::PopStyleColor(3); | ||||
| 
 | ||||
| 	ImGui::SameLine(); | ||||
| 	ImGui::DragFloat("##Z", &values.z, 0.1f); | ||||
| 	ImGui::PopItemWidth(); | ||||
| 
 | ||||
| 	ImGui::PopStyleVar(); | ||||
| 	ImGui::Columns(1); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| template<typename ComponentType, typename UIFunction> | ||||
| void PropertiesPanel::DrawComponent(const std::string& name, Entity entity, UIFunction userInterfaceFunction) | ||||
| { | ||||
| 	if (!entity.HasComponent<ComponentType>()) | ||||
| 		return; | ||||
| 
 | ||||
| 	auto& component = entity.GetComponent<ComponentType>(); | ||||
| 
 | ||||
| 	ImVec2 regionAvail = ImGui::GetContentRegionAvail(); | ||||
| 
 | ||||
| 	ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_FramePadding; | ||||
| 
 | ||||
| 	ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { 4, 4 }); | ||||
| 	float lineHeight = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f; | ||||
| 	ImGui::Separator(); | ||||
| 
 | ||||
| 	if (ImGui::TreeNodeEx((void*)typeid(ComponentType).hash_code(), flags, name.c_str())) | ||||
| 	{ | ||||
| 		ImGui::PopStyleVar(); | ||||
| 
 | ||||
| 		ImGui::SameLine(regionAvail.x - lineHeight * .5f); | ||||
| 		if (ImGui::Button("+", { lineHeight, lineHeight })) | ||||
| 			ImGui::OpenPopup("ComponentSettings"); | ||||
| 
 | ||||
| 		if (ImGui::BeginPopup("ComponentSettings")) | ||||
| 		{ | ||||
| 			if (ImGui::Selectable("Remove component")) | ||||
| 				entity.RemoveComponent<ComponentType>(); | ||||
| 
 | ||||
| 			ImGui::EndPopup(); | ||||
| 		} | ||||
| 
 | ||||
| 		userInterfaceFunction(component); | ||||
| 		ImGui::TreePop(); | ||||
| 	} | ||||
| 	else | ||||
| 		ImGui::PopStyleVar(); | ||||
| } | ||||
| 
 | ||||
| } // namespace Light
 | ||||
| Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB | 
| Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB | 
| Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB | 
| Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB | 
| Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB | 
|  | @ -1,5 +1,13 @@ | |||
| # GLAD # | ||||
| add_subdirectory(./glad) | ||||
| 
 | ||||
| # IMGUI # | ||||
| cmake_minimum_required(VERSION 3.14) | ||||
| 
 | ||||
| set(MIRROR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../modules/mirror/) | ||||
| set(ENGINE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../modules/engine/) | ||||
| set(DEPENDENCIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) | ||||
| 
 | ||||
| if (CMAKE_COMPILER_IS_GNUCC) | ||||
|     add_compile_options(-w) | ||||
| endif() | ||||
|  | @ -18,7 +26,6 @@ file(GLOB IMGUI_FILES true ABSOLUTE | |||
| 
 | ||||
| set(BACKENDS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/) | ||||
| 
 | ||||
| include_directories(${CMAKE_CURRENT_SOURCE_DIR}/imgui) | ||||
| 
 | ||||
| file(GLOB IMGUI_BACKEND_FILES true ABSOLUTE  | ||||
|     ${BACKENDS_DIR}imgui_impl_opengl3.cpp | ||||
|  | @ -38,8 +45,18 @@ endif() | |||
| add_compile_definitions(IMGUI_IMPL_OPENGL_LOADER_GLAD) | ||||
| include_directories(${DEPENDENCIES_DIR}GLFW/include) | ||||
| include_directories(${DEPENDENCIES_DIR}glm/) | ||||
| 
 | ||||
| add_library(imgui STATIC ${IMGUI_FILES} ${IMGUI_BACKEND_FILES}) | ||||
| 
 | ||||
| target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui) | ||||
| target_link_libraries( | ||||
|   imgui | ||||
|   PUBLIC glad | ||||
|   PUBLIC opengl::opengl | ||||
|   PUBLIC glm::glm  | ||||
|   PUBLIC glfw | ||||
| ) | ||||
| 
 | ||||
| # Copy imconfig.h over | ||||
| file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Configurations/imgui/imconfig.h | ||||
| file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/configurations/imgui/imconfig.h | ||||
|     DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/imgui/) | ||||
							
								
								
									
										0
									
								
								Dependencies/imgui → external/imgui
									
										
									
									
										vendored
									
									
								
							
							
						
						
							
								
								
									
										2
									
								
								modules/CMakeLists.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,2 @@ | |||
| add_subdirectory(./engine) | ||||
| add_subdirectory(./mirror) | ||||
							
								
								
									
										116
									
								
								modules/engine/CMakeLists.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,116 @@ | |||
| cmake_minimum_required(VERSION 3.16) | ||||
| 
 | ||||
| if(NOT WIN32) | ||||
|     add_library_module(engine  | ||||
|         camera/camera.cpp | ||||
|         camera/ortho.cpp | ||||
|         camera/scene.cpp | ||||
|         core/application.cpp | ||||
|         core/uuid.cpp | ||||
|         debug/exceptions.cpp | ||||
|         debug/instrumentor.cpp | ||||
|         debug/logger.cpp | ||||
|         graphics/blender.cpp | ||||
|         graphics/buffers.cpp | ||||
|         graphics/framebuffer.cpp | ||||
|         graphics/graphics_context.cpp | ||||
|         graphics/render_command.cpp | ||||
|         graphics/renderer.cpp | ||||
|         graphics/renderer_programs/quad.cpp | ||||
|         graphics/renderer_programs/texture.cpp | ||||
|         graphics/renderer_programs/tinted_texture.cpp | ||||
|         graphics/shader.cpp | ||||
|         graphics/texture.cpp | ||||
|         graphics/vertex_layout.cpp | ||||
|         input/input.cpp | ||||
|         layer/layer.cpp | ||||
|         layer/layer_stack.cpp | ||||
|         math/random.cpp | ||||
|         platform/graphics/opengl/blender.cpp | ||||
|         platform/graphics/opengl/buffers.cpp | ||||
|         platform/graphics/opengl/framebuffers.cpp | ||||
|         platform/graphics/opengl/graphics_context.cpp | ||||
|         platform/graphics/opengl/render_command.cpp | ||||
|         platform/graphics/opengl/shader.cpp | ||||
|         platform/graphics/opengl/texture.cpp | ||||
|         platform/graphics/opengl/user_interface.cpp | ||||
|         platform/graphics/opengl/vertex_layout.cpp | ||||
|         platform/os/linux/l_window.cpp | ||||
|         scene/entity.cpp | ||||
|         scene/scene.cpp | ||||
|         time/timer.cpp | ||||
|         user_interface/user_interface.cpp | ||||
|         utils/file_manager.cpp | ||||
|         utils/resource_manager.cpp | ||||
|         utils/serializer.cpp | ||||
|         utils/stringifier.cpp | ||||
|     ) | ||||
| else() | ||||
|     add_library_module(engine  | ||||
|         camera/camera.cpp | ||||
|         camera/ortho.cpp | ||||
|         camera/scene.cpp | ||||
|         core/application.cpp | ||||
|         core/uuid.cpp | ||||
|         debug/exceptions.cpp | ||||
|         debug/instrumentor.cpp | ||||
|         debug/logger.cpp | ||||
|         graphics/blender.cpp | ||||
|         graphics/buffers.cpp | ||||
|         graphics/framebuffer.cpp | ||||
|         graphics/graphics_context.cpp | ||||
|         graphics/render_command.cpp | ||||
|         graphics/renderer.cpp | ||||
|         graphics/renderer_programs/quad.cpp | ||||
|         graphics/renderer_programs/texture.cpp | ||||
|         graphics/renderer_programs/tinted_texture.cpp | ||||
|         graphics/shader.cpp | ||||
|         graphics/texture.cpp | ||||
|         graphics/vertex_layout.cpp | ||||
|         input/input.cpp | ||||
|         layer/layer.cpp | ||||
|         layer/layer_stack.cpp | ||||
|         math/random.cpp | ||||
|         platform/graphics/directx/blender.cpp | ||||
|         platform/graphics/directx/buffers.cpp | ||||
|         platform/graphics/directx/framebuffers.cpp | ||||
|         platform/graphics/directx/graphics_context.cpp | ||||
|         platform/graphics/directx/render_command.cpp | ||||
|         platform/graphics/directx/shader.cpp | ||||
|         platform/graphics/directx/texture.cpp | ||||
|         platform/graphics/directx/user_interface.cpp | ||||
|         platform/graphics/directx/vertex_layout.cpp | ||||
|         platform/graphics/opengl/blender.cpp | ||||
|         platform/graphics/opengl/buffers.cpp | ||||
|         platform/graphics/opengl/framebuffers.cpp | ||||
|         platform/graphics/opengl/graphics_context.cpp | ||||
|         platform/graphics/opengl/render_command.cpp | ||||
|         platform/graphics/opengl/shader.cpp | ||||
|         platform/graphics/opengl/texture.cpp | ||||
|         platform/graphics/opengl/user_interface.cpp | ||||
|         platform/graphics/opengl/vertex_layout.cpp | ||||
|         platform/os/windows/w_window.cpp | ||||
|         scene/entity.cpp | ||||
|         scene/scene.cpp | ||||
|         time/timer.cpp | ||||
|         user_interface/user_interface.cpp | ||||
|         utils/file_manager.cpp | ||||
|         utils/resource_manager.cpp | ||||
|         utils/serializer.cpp | ||||
|         utils/stringifier.cpp | ||||
|     ) | ||||
| endif() | ||||
| 
 | ||||
| target_link_libraries( | ||||
|   engine | ||||
|   PUBLIC glad | ||||
|   PUBLIC opengl::opengl | ||||
|   PUBLIC glfw | ||||
|   PUBLIC spdlog::spdlog | ||||
|   PUBLIC imgui | ||||
|   PUBLIC stb::stb | ||||
|   PUBLIC yaml-cpp::yaml-cpp | ||||
|   PUBLIC EnTT::EnTT | ||||
| ) | ||||
| 
 | ||||
| target_precompile_headers(engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/ltpch.hpp) | ||||
|  | @ -9,13 +9,13 @@ template<typename T> | |||
| using Ref = std::shared_ptr<T>; | ||||
| 
 | ||||
| template<typename T, typename... Args> | ||||
| constexpr Ref<T> CreateRef(Args&&... args) | ||||
| constexpr Ref<T> CreateRef(Args &&...args) | ||||
| { | ||||
| 	return std::make_shared<T>(std::forward<Args>(args)...); | ||||
| } | ||||
| 
 | ||||
| template<typename T> | ||||
| constexpr Ref<T> MakeRef(T* rawPointer) | ||||
| constexpr Ref<T> MakeRef(T *rawPointer) | ||||
| { | ||||
| 	return std::shared_ptr<T>(rawPointer); | ||||
| } | ||||
|  | @ -25,13 +25,13 @@ template<typename T> | |||
| using Scope = std::unique_ptr<T>; | ||||
| 
 | ||||
| template<typename T, typename... Args> | ||||
| constexpr std::unique_ptr<T> CreateScope(Args&&... args) | ||||
| constexpr std::unique_ptr<T> CreateScope(Args &&...args) | ||||
| { | ||||
| 	return std::make_unique<T>(std::forward<Args>(args)...); | ||||
| } | ||||
| 
 | ||||
| template<typename T> | ||||
| constexpr std::unique_ptr<T> MakeScope(T* rawPointer) | ||||
| constexpr std::unique_ptr<T> MakeScope(T *rawPointer) | ||||
| { | ||||
| 	return std::unique_ptr<T>(rawPointer); | ||||
| } | ||||
|  | @ -60,7 +60,8 @@ constexpr std::unique_ptr<T> MakeScope(T* rawPointer) | |||
| #endif | ||||
| //========== PLATFORM ==========//
 | ||||
| 
 | ||||
| //====================================================================== OPERATIONS ======================================================================//
 | ||||
| //====================================================================== OPERATIONS
 | ||||
| //======================================================================//
 | ||||
| /* assertions */ | ||||
| #define ASSERT(x, ...)                                          \ | ||||
| 	{                                                           \ | ||||
|  | @ -76,36 +77,31 @@ constexpr std::unique_ptr<T> MakeScope(T* rawPointer) | |||
| #define BIT(x) 1 << x | ||||
| 
 | ||||
| /* token */ | ||||
| #define LT_PAIR_TOKEN_VALUE_TO_NAME(token) \ | ||||
| 	{                                      \ | ||||
| 		token, #token                      \ | ||||
| 	} | ||||
| #define LT_PAIR_TOKEN_NAME_TO_VALUE(token) \ | ||||
| 	{                                      \ | ||||
| 		#token, token                      \ | ||||
| 	} | ||||
| #define LT_TOKEN_NAME(token) #token | ||||
| //====================================================================== OPERATIONS ======================================================================//
 | ||||
| #define LT_PAIR_TOKEN_VALUE_TO_NAME(token) { token, #token } | ||||
| #define LT_PAIR_TOKEN_NAME_TO_VALUE(token) { #token, token } | ||||
| #define LT_TOKEN_NAME(token)               #token | ||||
| //====================================================================== OPERATIONS
 | ||||
| //======================================================================//
 | ||||
| 
 | ||||
| //========== ESSENTIAL_HEADERS ==========//
 | ||||
| /* config */ | ||||
| #ifndef LIGHT_CONFIG_H | ||||
| 	#include "Base/Config.hpp" | ||||
| 	#include <engine/base/config.hpp> | ||||
| #endif | ||||
| 
 | ||||
| /* debug */ | ||||
| #ifndef LIGHT_LOGGER_H | ||||
| 	#include "Debug/Logger.hpp" | ||||
| 	#include <engine/debug/logger.hpp> | ||||
| #endif | ||||
| #include "Debug/Exceptions.hpp" | ||||
| #include <engine/debug/exceptions.hpp> | ||||
| 
 | ||||
| /* portables */ | ||||
| #ifndef LIGHT_DEBUG_TRAP_H | ||||
| 	#include "Base/Portables/DebugTrap.hpp" | ||||
| 	#include <engine/base/portables/debug_trap.hpp> | ||||
| #endif | ||||
| 
 | ||||
| /* utility */ | ||||
| #ifndef LIGHT_STRINGIFIER_H | ||||
| 	#include "Utility/Stringifier.hpp" | ||||
| 	#include <engine/utils/stringifier.hpp> | ||||
| #endif | ||||
| //========== ESSENTIAL_HEADERS ==========//
 | ||||
|  | @ -5,13 +5,13 @@ | |||
| 	#include <LightEngine.hpp> | ||||
| 
 | ||||
| // to be defined in client project
 | ||||
| extern Light::Application* Light::CreateApplication(std::string execName, std::vector<std::string> args); | ||||
| extern Light::Application *Light::CreateApplication(); | ||||
| 
 | ||||
| // #todo: use windows specific stuff
 | ||||
| int main(int argc, char* argv[]) | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
| 	Light::Application* application = nullptr; | ||||
| 	int exitCode                    = 0; | ||||
| 	Light::Application *application = nullptr; | ||||
| 	int exitCode = 0; | ||||
| 
 | ||||
| 	std::vector<std::string> args; | ||||
| 
 | ||||
|  | @ -20,7 +20,7 @@ int main(int argc, char* argv[]) | |||
| 
 | ||||
| 	try | ||||
| 	{ | ||||
| 		application = Light::CreateApplication(argv[0], args); | ||||
| 		application = Light::CreateApplication(); | ||||
| 		ASSERT(application, "Light::Application is not intialized"); | ||||
| 
 | ||||
| 		for (int i = 0; i < argc; i++) | ||||
|  | @ -53,16 +53,16 @@ int main(int argc, char* argv[]) | |||
| 
 | ||||
| #elif defined(LIGHT_PLATFORM_LINUX) | ||||
| 
 | ||||
| 	#include <LightEngine.hpp> | ||||
| 	#include <engine/engine.hpp> | ||||
| 
 | ||||
| // to be defined in client project
 | ||||
| extern Light::Application* Light::CreateApplication(); | ||||
| extern Light::Application *Light::CreateApplication(); | ||||
| 
 | ||||
| // #todo: use linux specific stuff
 | ||||
| int main(int argc, char* argv[]) | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
| 	Light::Application* application = nullptr; | ||||
| 	int exitCode                    = 0; | ||||
| 	Light::Application *application = nullptr; | ||||
| 	int exitCode = 0; | ||||
| 
 | ||||
| 	try | ||||
| 	{ | ||||
|  | @ -2,15 +2,19 @@ | |||
| #ifndef LIGHT_DEBUG_TRAP_H | ||||
| 	#define LIGHT_DEBUG_TRAP_H | ||||
| 
 | ||||
| 	#include "Base/Base.hpp" | ||||
| 	#include <engine/base/base.hpp> | ||||
| 
 | ||||
| // https://github.com/nemequ/portable-snippets/tree/master/debug-trap
 | ||||
| 
 | ||||
| 	#ifdef LIGHT_DIST | ||||
| 		#ifdef _MSC_VER | ||||
| 			#define LT_DEBUG_TRAP()                                                 \ | ||||
| 				LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ | ||||
| 				                 __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | ||||
| 			#define LT_DEBUG_TRAP()                                    \ | ||||
| 				LT_FILE_CRITICAL(                                      \ | ||||
| 				    "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ | ||||
| 				    __FUNCSIG__,                                       \ | ||||
| 				    __FILE__,                                          \ | ||||
| 				    __LINE__                                           \ | ||||
| 				) // or __FUNCSIG__
 | ||||
| 
 | ||||
| 		#else | ||||
| 			#define LT_DEBUG_TRAP() \ | ||||
|  | @ -85,8 +89,7 @@ static inline void LT_DEBUG_TRAP(void) | |||
| 		#elif defined(_55_) | ||||
| static inline void LT_DEBUG_TRAP(void) | ||||
| { | ||||
| 	__asm__ __volatile__( | ||||
| 	    ";\n .if (.MNEMONIC)\n ESTOP_1\n .else\n ESTOP_1()\n .endif\n NOP"); | ||||
| 	__asm__ __volatile__(";\n .if (.MNEMONIC)\n ESTOP_1\n .else\n ESTOP_1()\n .endif\n NOP"); | ||||
| } | ||||
| 
 | ||||
| 		#elif defined(_64P_) | ||||
|  | @ -119,14 +122,16 @@ static inline void LT_DEBUG_TRAP(void) | |||
| 
 | ||||
| 	#if !defined(LT_DEBUG_TRAP) | ||||
| 		#if !defined(LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP) | ||||
| 			#error \ | ||||
| 			    "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP in Config.h to disable this error" | ||||
| 			#error "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP in Config.h to disable this error" | ||||
| 
 | ||||
| 		#elif defined(LIGHT_DIST) | ||||
| 			#ifdef _MSC_VER | ||||
| 				#define LT_DEBUG_TRAP()                                              \ | ||||
| 					LOG(critical, "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ | ||||
| 					    __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | ||||
| 				#define LT_DEBUG_TRAP()                                    \ | ||||
| 					LOG(critical,                                          \ | ||||
| 					    "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ | ||||
| 					    __FUNCSIG__,                                       \ | ||||
| 					    __FILE__,                                          \ | ||||
| 					    __LINE__) // or __FUNCSIG__
 | ||||
| 
 | ||||
| 			#else | ||||
| 				#define LT_DEBUG_TRAP() \ | ||||
|  | @ -135,9 +140,12 @@ static inline void LT_DEBUG_TRAP(void) | |||
| 			#endif | ||||
| 		#else /* !defined(LIGHT_DIST) */ | ||||
| 			#ifdef _MSC_VER | ||||
| 				#define LT_DEBUG_TRAP()                                              \ | ||||
| 					LOG(critical, "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ | ||||
| 					    __FUNCSIG__, __FILE__, __LINE__) // or __FUNCSIG__
 | ||||
| 				#define LT_DEBUG_TRAP()                                    \ | ||||
| 					LOG(critical,                                          \ | ||||
| 					    "DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \ | ||||
| 					    __FUNCSIG__,                                       \ | ||||
| 					    __FILE__,                                          \ | ||||
| 					    __LINE__) // or __FUNCSIG__
 | ||||
| 
 | ||||
| 			#else | ||||
| 				#define LT_DEBUG_TRAP() \ | ||||
							
								
								
									
										35
									
								
								modules/engine/include/engine/camera/camera.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,35 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <engine/base/base.hpp> | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace Light { | ||||
| 
 | ||||
| class Camera | ||||
| { | ||||
| private: | ||||
| 	glm::vec4 m_BackgroundColor = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); | ||||
| 
 | ||||
| protected: | ||||
| 	glm::mat4 m_Projection; | ||||
| 
 | ||||
| public: | ||||
| 	Camera() = default; | ||||
| 
 | ||||
| 	inline const glm::mat4 &GetProjection() const | ||||
| 	{ | ||||
| 		return m_Projection; | ||||
| 	} | ||||
| 
 | ||||
| 	inline const glm::vec4 &GetBackgroundColor() const | ||||
| 	{ | ||||
| 		return m_BackgroundColor; | ||||
| 	} | ||||
| 
 | ||||
| 	inline void SetBackgroundColor(const glm::vec4 &color) | ||||
| 	{ | ||||
| 		m_BackgroundColor = color; | ||||
| 	} | ||||
| }; | ||||
| 
 | ||||
| } // namespace Light
 | ||||