forked from Yao-class-cpp-studio/GameX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0b4b5ea
Showing
18 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: Google | ||
AccessModifierOffset: -1 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlinesLeft: true | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: true | ||
BinPackParameters: false | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | ||
IncludeCategories: | ||
- Regex: '^<.*\.h>' | ||
Priority: 1 | ||
- Regex: '^<.*' | ||
Priority: 2 | ||
- Regex: '.*' | ||
Priority: 3 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IndentCaseLabels: true | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Right | ||
ReflowComments: true | ||
SortIncludes: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
TabWidth: 8 | ||
UseTab: Never | ||
--- | ||
Language: Proto | ||
BasedOnStyle: Google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build | ||
cmake-build-* | ||
.idea | ||
.vscode | ||
.vs | ||
vcpkg_installed | ||
imgui.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "external/grassland"] | ||
path = external/grassland | ||
url = https://github.com/LazyJazz/grassland.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v13.0.1 | ||
hooks: | ||
- id: clang-format | ||
files: '\.(glsl|frag|vert|cu|cuh|cc|cpp|hpp|h|c|cxx|hxx|rchit|rgen|rmiss|comp|proto)$' | ||
types_or: ['text'] | ||
|
||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/external/grassland/external/vcpkg/scripts/buildsystems/vcpkg.cmake) | ||
|
||
project(GameX) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
add_subdirectory(external/grassland) | ||
|
||
add_subdirectory(src/GameX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
set(COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/.. ${GRASSLAND_INCLUDE_DIRS}) | ||
|
||
message(STATUS "COMMON_INCLUDE_DIRS: ${COMMON_INCLUDE_DIRS}") | ||
|
||
add_executable(GameX main.cpp) | ||
|
||
add_subdirectory(utils) | ||
add_subdirectory(shaders) | ||
add_subdirectory(application) | ||
|
||
target_include_directories(GameX PUBLIC ${COMMON_INCLUDE_DIRS}) | ||
target_link_libraries(GameX PUBLIC ${GAMEX_LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(LIB_NAME GameXApplication) | ||
|
||
file(GLOB_RECURSE SOURCES *.cpp *.h) | ||
|
||
add_library(${LIB_NAME} ${SOURCES}) | ||
|
||
target_include_directories(${LIB_NAME} PUBLIC ${COMMON_INCLUDE_DIRS}) | ||
target_link_libraries(${LIB_NAME} PUBLIC grassland) | ||
|
||
list(APPEND GAMEX_LIBS ${LIB_NAME}) | ||
set(GAMEX_LIBS ${GAMEX_LIBS} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "GameX/application/application.h" | ||
|
||
namespace GameX { | ||
Application::Application(const GameX::ApplicationSettings &settings) | ||
: settings_(settings) { | ||
glfwInit(); | ||
|
||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); | ||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); | ||
window_ = glfwCreateWindow(settings_.width, settings_.height, "GameX", | ||
nullptr, nullptr); | ||
|
||
grassland::vulkan::CoreSettings core_settings; | ||
core_settings.window = window_; | ||
|
||
core_ = std::make_unique<grassland::vulkan::Core>(core_settings); | ||
} | ||
|
||
void Application::Run() { | ||
Init(); | ||
|
||
while (!glfwWindowShouldClose(window_)) { | ||
glfwPollEvents(); | ||
Update(); | ||
Render(); | ||
} | ||
|
||
core_->Device()->WaitIdle(); | ||
Cleanup(); | ||
} | ||
|
||
void Application::Init() { | ||
} | ||
|
||
void Application::Update() { | ||
} | ||
|
||
void Application::Render() { | ||
} | ||
|
||
void Application::Cleanup() { | ||
} | ||
} // namespace GameX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <GameX/utils/utils.h> | ||
|
||
namespace GameX { | ||
|
||
struct ApplicationSettings { | ||
bool fullscreen{false}; | ||
int width{1280}; | ||
int height{720}; | ||
}; | ||
|
||
class Application { | ||
public: | ||
Application(const ApplicationSettings &settings); | ||
|
||
GLFWwindow *Window() const { | ||
return window_; | ||
} | ||
grassland::vulkan::Core *Core() const { | ||
return core_.get(); | ||
} | ||
|
||
void Run(); | ||
|
||
private: | ||
void Init(); | ||
|
||
void Update(); | ||
void Render(); | ||
|
||
void Cleanup(); | ||
|
||
ApplicationSettings settings_; | ||
GLFWwindow *window_; | ||
std::unique_ptr<grassland::vulkan::Core> core_; | ||
}; | ||
} // namespace GameX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "GameX/application/application.h" | ||
|
||
int main() { | ||
GameX::ApplicationSettings settings; | ||
GameX::Application app(settings); | ||
app.Run(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set(LIB_NAME GameXShaders) | ||
|
||
file(GLOB_RECURSE SOURCES *.cpp *.h) | ||
|
||
add_library(${LIB_NAME} ${SOURCES}) | ||
|
||
target_include_directories(${LIB_NAME} PUBLIC ${COMMON_INCLUDE_DIRS}) | ||
target_link_libraries(${LIB_NAME} PUBLIC grassland) | ||
|
||
PACK_SHADER_CODE(${LIB_NAME}) | ||
|
||
list(APPEND GAMEX_LIBS ${LIB_NAME}) | ||
set(GAMEX_LIBS ${GAMEX_LIBS} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "GameX/shaders/shaders.h" | ||
|
||
namespace GameX {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include "GameX/utils/utils.h" | ||
|
||
namespace GameX { | ||
namespace { | ||
|
||
#include "built_in_shaders.inl" | ||
|
||
} | ||
|
||
std::vector<uint32_t> BuiltInShaderSpv(const std::string &code_path) { | ||
auto code = GetShaderCode(code_path); | ||
return grassland::vulkan::CompileGLSLToSPIRV( | ||
code, grassland::vulkan::FileNameSuffixToShaderStage(code_path)); | ||
} | ||
} // namespace GameX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(LIB_NAME GameXUtils) | ||
|
||
file(GLOB_RECURSE SOURCES *.cpp *.h) | ||
|
||
add_library(${LIB_NAME} ${SOURCES}) | ||
|
||
target_include_directories(${LIB_NAME} PUBLIC ${COMMON_INCLUDE_DIRS}) | ||
target_link_libraries(${LIB_NAME} PUBLIC grassland) | ||
|
||
list(APPEND GAMEX_LIBS ${LIB_NAME}) | ||
set(GAMEX_LIBS ${GAMEX_LIBS} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "GameX/utils/utils.h" | ||
|
||
namespace GameX {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
#include <grassland/grassland.h> | ||
|
||
namespace GameX {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "grassland", | ||
"version-string": "0.1.0", | ||
"description": "Grassland", | ||
"dependencies": [ | ||
"glfw3", | ||
"freetype", | ||
"glm", | ||
"stb", | ||
"spdlog", | ||
"imgui", | ||
"abseil", | ||
"gtest", | ||
"sfml", | ||
"vulkan-memory-allocator", | ||
"glslang", | ||
{ | ||
"name": "d3dx12", | ||
"platform": "windows" | ||
}, | ||
"eigen3" | ||
] | ||
} |