Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyJazz committed Dec 21, 2023
0 parents commit 0b4b5ea
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .clang-format
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build
cmake-build-*
.idea
.vscode
.vs
vcpkg_installed
imgui.ini
3 changes: 3 additions & 0 deletions .gitmodules
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
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
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
11 changes: 11 additions & 0 deletions CMakeLists.txt
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)
1 change: 1 addition & 0 deletions external/grassland
Submodule grassland added at 645288
13 changes: 13 additions & 0 deletions src/GameX/CMakeLists.txt
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})
11 changes: 11 additions & 0 deletions src/GameX/application/CMakeLists.txt
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)
43 changes: 43 additions & 0 deletions src/GameX/application/application.cpp
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
38 changes: 38 additions & 0 deletions src/GameX/application/application.h
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
8 changes: 8 additions & 0 deletions src/GameX/main.cpp
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;
}
13 changes: 13 additions & 0 deletions src/GameX/shaders/CMakeLists.txt
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)
3 changes: 3 additions & 0 deletions src/GameX/shaders/shaders.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "GameX/shaders/shaders.h"

namespace GameX {}
17 changes: 17 additions & 0 deletions src/GameX/shaders/shaders.h
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
11 changes: 11 additions & 0 deletions src/GameX/utils/CMakeLists.txt
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)
3 changes: 3 additions & 0 deletions src/GameX/utils/utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "GameX/utils/utils.h"

namespace GameX {}
4 changes: 4 additions & 0 deletions src/GameX/utils/utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include <grassland/grassland.h>

namespace GameX {}
23 changes: 23 additions & 0 deletions vcpkg.json
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"
]
}

0 comments on commit 0b4b5ea

Please sign in to comment.