platform agnostic argument handling
This commit is contained in:
parent
ddaf4943e3
commit
db66e81721
2 changed files with 14 additions and 11 deletions
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include "vulkanexamplebase.h"
|
#include "vulkanexamplebase.h"
|
||||||
|
|
||||||
|
std::vector<char*> VulkanExampleBase::args;
|
||||||
|
|
||||||
VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
||||||
{
|
{
|
||||||
this->enableValidation = enableValidation;
|
this->enableValidation = enableValidation;
|
||||||
|
|
@ -676,20 +678,19 @@ void VulkanExampleBase::submitFrame()
|
||||||
|
|
||||||
VulkanExampleBase::VulkanExampleBase(bool enableValidation, PFN_GetEnabledFeatures enabledFeaturesFn)
|
VulkanExampleBase::VulkanExampleBase(bool enableValidation, PFN_GetEnabledFeatures enabledFeaturesFn)
|
||||||
{
|
{
|
||||||
// Check for validation command line flag
|
// Parse command line arguments
|
||||||
#if defined(_WIN32)
|
for (auto arg : args)
|
||||||
for (int32_t i = 0; i < __argc; i++)
|
|
||||||
{
|
{
|
||||||
if (__argv[i] == std::string("-validation"))
|
if (arg == std::string("-validation"))
|
||||||
{
|
{
|
||||||
enableValidation = true;
|
enableValidation = true;
|
||||||
}
|
}
|
||||||
if (__argv[i] == std::string("-vsync"))
|
if (arg == std::string("-vsync"))
|
||||||
{
|
{
|
||||||
enableVSync = true;
|
enableVSync = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
// Vulkan library is loaded dynamically on Android
|
// Vulkan library is loaded dynamically on Android
|
||||||
bool libLoaded = loadVulkanLibrary();
|
bool libLoaded = loadVulkanLibrary();
|
||||||
assert(libLoaded);
|
assert(libLoaded);
|
||||||
|
|
@ -894,11 +895,9 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
|
||||||
this->windowInstance = hinstance;
|
this->windowInstance = hinstance;
|
||||||
|
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
|
for (auto arg : args)
|
||||||
// Check command line arguments
|
|
||||||
for (int32_t i = 0; i < __argc; i++)
|
|
||||||
{
|
{
|
||||||
if (__argv[i] == std::string("-fullscreen"))
|
if (arg == std::string("-fullscreen"))
|
||||||
{
|
{
|
||||||
fullscreen = true;
|
fullscreen = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,8 @@ public:
|
||||||
|
|
||||||
float zoom = 0;
|
float zoom = 0;
|
||||||
|
|
||||||
|
static std::vector<char*> args;
|
||||||
|
|
||||||
// Defines a frame rate independent timer value clamped from -1.0...1.0
|
// Defines a frame rate independent timer value clamped from -1.0...1.0
|
||||||
// For use in animations, rotations, etc.
|
// For use in animations, rotations, etc.
|
||||||
float timer = 0.0f;
|
float timer = 0.0f;
|
||||||
|
|
@ -368,6 +370,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
} \
|
} \
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) \
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) \
|
||||||
{ \
|
{ \
|
||||||
|
for (size_t i = 0; i < __argc; i++) { VulkanExample::args.push_back(__argv[i]); }; \
|
||||||
vulkanExample = new VulkanExample(); \
|
vulkanExample = new VulkanExample(); \
|
||||||
vulkanExample->setupWindow(hInstance, WndProc); \
|
vulkanExample->setupWindow(hInstance, WndProc); \
|
||||||
vulkanExample->initSwapchain(); \
|
vulkanExample->initSwapchain(); \
|
||||||
|
|
@ -423,6 +426,7 @@ static void handleEvent(const xcb_generic_event_t *event) \
|
||||||
} \
|
} \
|
||||||
int main(const int argc, const char *argv[]) \
|
int main(const int argc, const char *argv[]) \
|
||||||
{ \
|
{ \
|
||||||
|
for (size_t i = 0; i < argc; i++) { VulkanExample::args.push_back(argv[i]); }; \
|
||||||
vulkanExample = new VulkanExample(); \
|
vulkanExample = new VulkanExample(); \
|
||||||
vulkanExample->setupWindow(); \
|
vulkanExample->setupWindow(); \
|
||||||
vulkanExample->initSwapchain(); \
|
vulkanExample->initSwapchain(); \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue