Skip to content

Commit

Permalink
Add basic window
Browse files Browse the repository at this point in the history
  • Loading branch information
kissholic committed Aug 18, 2024
1 parent 095e042 commit 677fa57
Show file tree
Hide file tree
Showing 11 changed files with 550 additions and 0 deletions.
131 changes: 131 additions & 0 deletions .clang-format
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
*.exe
*.out
*.app

# Immediate
.vscode
.xmake
build

40 changes: 40 additions & 0 deletions Include/Graphics/GraphicsContext.h
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
23 changes: 23 additions & 0 deletions Include/Graphics/ShaderLoader.h
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
14 changes: 14 additions & 0 deletions Include/Misc.h
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
115 changes: 115 additions & 0 deletions Include/Object.h
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

Loading

0 comments on commit 677fa57

Please sign in to comment.