-
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
Showing
11 changed files
with
550 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,131 @@ | ||
# https://github.com/microsoft/ccf-app-template/blob/main/.clang-format | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AlignConsecutiveMacros: false | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: DontAlign | ||
AlignOperands: false | ||
AlignTrailingComments: false | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: false | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BraceWrapping: | ||
AfterCaseLabel: true | ||
AfterClass: true | ||
AfterControlStatement: true | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterObjCDeclaration: true | ||
AfterStruct: true | ||
AfterUnion: true | ||
AfterExternBlock: true | ||
BeforeCatch: true | ||
BeforeElse: true | ||
IndentBraces: false | ||
SplitEmptyFunction: false | ||
SplitEmptyRecord: false | ||
SplitEmptyNamespace: false | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Custom | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializers: AfterColon | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 2 | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: true | ||
DeriveLineEnding: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
ForEachMacros: | ||
- FOREACH | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
SortPriority: 0 | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
SortPriority: 0 | ||
- Regex: '.*' | ||
Priority: 1 | ||
SortPriority: 0 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentCaseLabels: true | ||
IndentGotoLabels: true | ||
IndentPPDirectives: AfterHash | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: All | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 600 | ||
PointerAlignment: Left | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpaceBeforeSquareBrackets: false | ||
Standard: c++20 | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 2 | ||
UseCRLF: false | ||
UseTab: Never |
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 |
---|---|---|
|
@@ -30,3 +30,9 @@ | |
*.exe | ||
*.out | ||
*.app | ||
|
||
# Immediate | ||
.vscode | ||
.xmake | ||
build | ||
|
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,40 @@ | ||
/* | ||
* File: GraphicsContext.h | ||
* Author: kissholic | ||
* Copyright (c) 2024 kissholic. All wrongs reserved. | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
#include <string> | ||
|
||
namespace be { | ||
|
||
|
||
class GraphicsContext { | ||
public: | ||
GraphicsContext(int Width, int Height, const std::string& Title); | ||
~GraphicsContext(); | ||
|
||
bool Init() noexcept; | ||
void Step(double DeltaTime) noexcept; | ||
bool ShouldExit() noexcept; | ||
void HandleResizeWindow() noexcept; | ||
|
||
private: | ||
bool GLFWInit() noexcept; | ||
void GLFWTerminate() noexcept; | ||
|
||
bool BGFXInit() noexcept; | ||
void BGFXTerminate() noexcept; | ||
|
||
private: | ||
std::string mTitle; | ||
class GLFWwindow* mWindow; | ||
int mWidth; | ||
int mHeight; | ||
}; | ||
|
||
|
||
} // namespace be |
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 @@ | ||
/* | ||
* File: ShaderLoader.h | ||
* Author: kissholic | ||
* Copyright (c) 2024 kissholic. All wrongs reserved. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace be { | ||
|
||
|
||
class ShaderLoader { | ||
public: | ||
|
||
|
||
private: | ||
|
||
}; | ||
|
||
|
||
} // namespace be |
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 @@ | ||
/* | ||
* File: Misc.h | ||
* Author: kissholic | ||
* Copyright (c) 2024 kissholic. All wrongs reserved. | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
namespace be { | ||
|
||
|
||
|
||
} // namespace be |
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,115 @@ | ||
/* | ||
* File: Object.h | ||
* Author: kissholic | ||
* Copyright (c) 2024 kissholic. All wrongs reserved. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <type_traits> | ||
|
||
|
||
namespace be { | ||
|
||
class Object { | ||
public: | ||
Object() {} | ||
virtual ~Object() {} | ||
|
||
virtual void Step([[maybe_unused]] double DeltaTime) noexcept {} | ||
|
||
uint32_t GetRefCount() const noexcept { return mRefCount; } | ||
|
||
private: | ||
friend class ObjectRef; | ||
|
||
void IncRefCount() noexcept { ++mRefCount;} | ||
void DecRefCount() noexcept { --mRefCount; } | ||
|
||
private: | ||
uint32_t mRefCount; | ||
}; | ||
|
||
|
||
template<typename T> | ||
concept IsObject = std::is_base_of<Object, T>::value; | ||
|
||
|
||
class ObjectRef { | ||
public: | ||
ObjectRef(std::nullptr_t) noexcept : mObj(nullptr) {} | ||
|
||
ObjectRef(Object* Obj) noexcept : mObj(Obj) { | ||
if (mObj) { | ||
mObj->IncRefCount(); | ||
} | ||
} | ||
|
||
ObjectRef(const ObjectRef& Ref) noexcept : mObj(Ref.mObj) { | ||
if (mObj) { | ||
mObj->IncRefCount(); | ||
} | ||
} | ||
|
||
~ObjectRef() noexcept { | ||
if (mObj) { | ||
mObj->DecRefCount(); | ||
} | ||
} | ||
|
||
ObjectRef& operator=(const ObjectRef& Ref) noexcept { | ||
if (this!= &Ref) { | ||
if (mObj) { | ||
mObj->DecRefCount(); | ||
} | ||
mObj = Ref.mObj; | ||
if (mObj) { | ||
mObj->IncRefCount(); | ||
} | ||
} | ||
return *this; | ||
} | ||
|
||
ObjectRef& opeartor(Object* Obj) noexcept { | ||
if (mObj) { | ||
mObj->DecRefCount(); | ||
} | ||
mObj = Obj; | ||
if (mObj) { | ||
mObj->IncRefCount(); | ||
} | ||
return *this; | ||
} | ||
|
||
ObjectRef& operator=(ObjectRef&& Ref) noexcept { | ||
if (this!= &Ref) { | ||
if (mObj) { | ||
mObj->DecRefCount(); | ||
} | ||
mObj = Ref.mObj; | ||
Ref.mObj = nullptr; | ||
} | ||
return *this; | ||
} | ||
|
||
Object* Get() const noexcept { return mObj; } | ||
|
||
Object* operator->() const noexcept { return mObj; } | ||
Object* operator->() noexcept { return mObj; } | ||
|
||
Object& operator*() const noexcept { return *mObj; } | ||
Object& operator*() noexcept { return *mObj; } | ||
|
||
private: | ||
Object* mObj; | ||
}; | ||
|
||
|
||
template<IsObject T> | ||
ObjectRef MakeObjectRef(auto&&... Args) noexcept { | ||
return ObjectRef(new T(std::forward<decltype(Args)>(Args)...)); | ||
} | ||
|
||
} // namespace be | ||
|
Oops, something went wrong.