-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
48 changed files
with
13,369 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,126 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: DontAlign | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Left | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: InlineOnly | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Allman | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeComma | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 140 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: true | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- for | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
- Regex: '.*\.generated\.h' | ||
Priority: 100 | ||
- Regex: '.*(PCH).*' | ||
Priority: -1 | ||
- Regex: '".*"' | ||
Priority: 1 | ||
- Regex: '^<.*\.(h)>' | ||
Priority: 3 | ||
- Regex: '^<.*>' | ||
Priority: 4 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IndentCaseLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Never | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Left | ||
RawStringFormats: | ||
- Language: Cpp | ||
Delimiters: | ||
- cc | ||
- CC | ||
- cpp | ||
- Cpp | ||
- CPP | ||
- 'c++' | ||
- 'C++' | ||
CanonicalDelimiter: '' | ||
BasedOnStyle: google | ||
- Language: TextProto | ||
Delimiters: | ||
- pb | ||
- PB | ||
- proto | ||
- PROTO | ||
EnclosingFunctions: | ||
- EqualsProto | ||
- EquivToProto | ||
- PARSE_PARTIAL_TEXT_PROTO | ||
- PARSE_TEST_PROTO | ||
- PARSE_TEXT_PROTO | ||
- ParseTextOrDie | ||
- ParseTextProtoOrDie | ||
CanonicalDelimiter: '' | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 4 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
TabWidth: 4 | ||
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Directories | ||
.vs/ | ||
bin/ | ||
bin-int/ | ||
x64/ | ||
|
||
|
||
DXSDK11 | ||
.idea | ||
x64/ | ||
Debug/ | ||
|
||
# Exclude | ||
!vendor/bin |
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,95 @@ | ||
#include "Camera.h" | ||
#include "Input.h" | ||
#include "NativeWindow.h" | ||
#include "Renderer.h" | ||
|
||
#include <chrono> | ||
#include <iostream> | ||
#include <queue> | ||
#include <string> | ||
|
||
using namespace std::chrono; | ||
|
||
float getTimeDeltaMs(const time_point<system_clock>& begin, const time_point<system_clock>& end) | ||
{ | ||
return std::chrono::duration_cast<duration<float, std::milli>>(end - begin).count(); | ||
} | ||
|
||
float getTimeDeltaSecs(const time_point<system_clock>& begin, const time_point<system_clock>& end) | ||
{ | ||
return std::chrono::duration_cast<duration<float>>(end - begin).count(); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std::shared_ptr<NativeWindow> window = std::make_shared<NativeWindow>(L"ATLAS", 720, 480); | ||
// Input::InputWindow = window; | ||
DX11Renderer* renderer = new DX11Renderer(); | ||
Camera* camera = new Camera(90.0f, 0.1f, 1000.0f, window->GetAspectRatio()); | ||
HRESULT hr = renderer->InitialiseGeneral(window); | ||
if (FAILED(hr)) | ||
{ | ||
printf("Failed to initialise renderer: 0x%llx", hr); | ||
return 1; | ||
} | ||
hr = renderer->Initialise(); | ||
if (FAILED(hr)) | ||
{ | ||
printf("Failed to initialise renderer: 0x%llx", hr); | ||
return 1; | ||
} | ||
printf("Renderer initialised\n"); | ||
|
||
time_point<system_clock> tickTimeBefore; | ||
time_point<system_clock> tickTimeAfter = system_clock::now(); | ||
float tickDelta = 0.0f; // in seconds | ||
|
||
// Main message loop | ||
MSG msg = {0}; | ||
std::queue<float> frametimes = std::queue<float>(); | ||
int frameCount = 0; | ||
|
||
float targetFrameTime = static_cast<float>(1) / 144; | ||
|
||
while (WM_QUIT != msg.message) | ||
{ | ||
if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) | ||
{ | ||
TranslateMessage(&msg); | ||
DispatchMessage(&msg); | ||
} | ||
else | ||
{ | ||
// if (tickDelta < targetFrameTime) | ||
// Sleep((targetFrameTime - tickDelta) * 1000); | ||
tickTimeBefore = tickTimeAfter; | ||
camera->Update(tickDelta); | ||
Input::UpdatePrevious(window); | ||
renderer->Render(camera, tickDelta); | ||
tickTimeAfter = system_clock::now(); | ||
tickDelta = getTimeDeltaSecs(tickTimeBefore, tickTimeAfter); | ||
if (frameCount % 10 == 0) | ||
{ | ||
frametimes.push(tickDelta); | ||
} | ||
frameCount++; | ||
if (frameCount > 1000) | ||
{ | ||
float total = 0.0f; | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
total += frametimes.front(); | ||
frametimes.pop(); | ||
} | ||
float averageFrametimeMs = 1000.0f * total / 100.0f; | ||
std::cout << "Average frametime: " << std::to_string(averageFrametimeMs) | ||
<< ", Average FPS: " << std::to_string(1000 / averageFrametimeMs) << std::endl; | ||
frameCount = 0; | ||
} | ||
} | ||
} | ||
|
||
renderer = nullptr; | ||
|
||
return 0; | ||
} |
Oops, something went wrong.