JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
jngl
init.hpp
Go to the documentation of this file.
1
// Copyright 2020-2023 Jan Niklas Hasse <jhasse@bixense.com>
2
// For conditions of distribution and use, see copyright notice in LICENSE.txt
5
6
#pragma once
7
8
#include "
AppParameters.hpp
"
9
#include "
main.hpp
"
10
#include "
message.hpp
"
11
12
#include <
cmath
>
13
14
#if defined(__has_include) && __has_include("filesystem")
15
#include <
filesystem
>
16
#endif
17
18
namespace
jngl::internal {
19
20
void
mainLoop(AppParameters);
21
22
}
// namespace jngl::internal
23
43
jngl::AppParameters
jnglInit
();
44
45
#if !defined(__APPLE__) || !TARGET_OS_IPHONE
// iOS
46
JNGL_MAIN_BEGIN {
// NOLINT
47
#if !defined(ANDROID) && defined(__has_include) && __has_include(<filesystem>) && \
48
(!defined(TARGET_OS_IOS) || TARGET_OS_IOS == 0)
49
std::error_code
err;
50
std::filesystem::current_path
(
"data"
, err);
51
if
(err) {
52
std::filesystem::current_path
(
"../data"
, err);
// move out of build/bin folder
53
if
(err) {
54
std::filesystem::current_path
(
"../../data"
, err);
// move out of build/Debug folder
55
if
(err) {
56
std::filesystem::current_path
(
"../../../data"
,
57
err);
// move out of out\build\x64-Debug
58
if
(err) {
59
std::filesystem::current_path
(
jngl::getBinaryPath
() +
"data"
, err);
60
}
61
}
62
}
63
}
64
#endif
65
jngl::internal::mainLoop(
jnglInit
());
66
}
67
JNGL_MAIN_END
68
#endif
69
70
#if defined(_MSC_VER) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
71
#include <windows.h>
72
73
INT WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_
int
) {
74
return
main(1,
nullptr
);
75
}
76
#endif
AppParameters.hpp
Contains jngl::AppParameters struct.
cmath
std::filesystem::current_path
T current_path(T... args)
std::error_code
filesystem
jnglInit
jngl::AppParameters jnglInit()
Implement this function and set AppParameters::start.
main.hpp
Defines macros for the main entry point.
message.hpp
jngl::getBinaryPath
std::string getBinaryPath()
Returns the directory of the currently running binary.
jngl::AppParameters
Parameters used to initialize the main window.
Definition
AppParameters.hpp:19