-
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.
Merge pull request #6 from wowvain-dev/application-layer
Application layer
- Loading branch information
Showing
15 changed files
with
527 additions
and
647 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
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
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,57 @@ | ||
#include "Application.h" | ||
|
||
using namespace Vane; | ||
|
||
bool Application::create(ApplicationConfig* config) { | ||
if (Application::initialised) { | ||
VFATAL("Application::create called more than once."); | ||
return false; | ||
} | ||
|
||
Logger::initializeLogging(); | ||
|
||
// TODO(wowvain-dev): Remove later, used for testing | ||
VFATAL("A test message: %f", 3.14f); | ||
VERROR("A test message: %f", 3.14f); | ||
VWARN("A test message: %f", 3.14f); | ||
VINFO("A test message: %f", 3.14f); | ||
VDEBUG("A test message: %f", 3.14f); | ||
VTRACE("A test message: %f", 3.14f); | ||
|
||
isRunning = true; | ||
isSuspended = false; | ||
|
||
#ifdef VPLATFORM_WINDOWS | ||
platform = new WindowsPlatform(); | ||
#elif VPLATFORM_LINUX | ||
platform = new LinuxPlatform(); | ||
#endif | ||
|
||
if(!platform->startup( | ||
config->name.c_str(), | ||
config->startPosX, | ||
config->startPosY, | ||
config->startWidth, | ||
config->startHeight)) { | ||
VFATAL("Couldn't startup platform properly!"); | ||
return false; | ||
} | ||
|
||
Application::initialised = true; | ||
|
||
return true; | ||
} | ||
|
||
bool Application::run() { | ||
while(isRunning) { | ||
if(!platform->pumpMessages()) { | ||
isRunning = false; | ||
} | ||
} | ||
|
||
isRunning = false; | ||
|
||
platform->shutdown(); | ||
|
||
return true; | ||
} |
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,58 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////// | ||
// Copyright wowvain-dev | Bogdan Stanciu (c) 2024. | ||
// | ||
// MIT License | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
////////////////////////////////////////////////////////////////////////////////////////// | ||
#pragma once | ||
|
||
#include "../Platform/Platform.h" | ||
#include "Logger.h" | ||
#include "Defines.h" | ||
#include <string> | ||
|
||
#ifdef VPLATFORM_WINDOWS | ||
#include "../Platform/Platform_Win32.h" | ||
#elif VPLATFORM_LINUX | ||
#include "../Platform/Platform_Linux.h" | ||
#endif | ||
|
||
using std::string; | ||
|
||
namespace Vane { | ||
|
||
struct VAPI ApplicationConfig { | ||
i16 startPosX; | ||
i16 startPosY; | ||
i16 startWidth; | ||
i16 startHeight; | ||
|
||
string name; | ||
}; | ||
|
||
class VAPI Application { | ||
private: | ||
VAPI static bool initialised; | ||
ApplicationConfig startConfig; | ||
|
||
bool isRunning; | ||
bool isSuspended; | ||
Platform* platform; | ||
i16 width; | ||
i16 height; | ||
f64 lastTime; | ||
|
||
|
||
public: | ||
bool create(ApplicationConfig* config); | ||
bool run(); | ||
|
||
}; | ||
|
||
bool Application::initialised = false; | ||
|
||
}; |
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 |
---|---|---|
|
@@ -36,7 +36,7 @@ namespace Vane { | |
V_TRACE = 5 | ||
}; | ||
|
||
class VAPI Logger { | ||
class Logger { | ||
public: | ||
|
||
private: | ||
|
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
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
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
Binary file not shown.
Oops, something went wrong.