JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
init.hpp
Go to the documentation of this file.
1// Copyright 2020-2025 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
11#if defined(__has_include) && __has_include("filesystem")
12#include <filesystem>
13#endif
14
15namespace jngl::internal {
16
17[[nodiscard]] uint8_t mainLoop(AppParameters);
18
19} // namespace jngl::internal
20
41
42#if !defined(__APPLE__) || !TARGET_OS_IPHONE // iOS
43JNGL_MAIN_BEGIN { // NOLINT
44#if !defined(ANDROID) && defined(__has_include) && __has_include(<filesystem>) && \
45 (!defined(TARGET_OS_IOS) || TARGET_OS_IOS == 0)
48 if (err) {
49 std::filesystem::current_path("../data", err); // move out of build/bin folder
50 if (err) {
51 std::filesystem::current_path("../../data", err); // move out of build/Debug folder
52 if (err) {
53 std::filesystem::current_path("../../../data",
54 err); // move out of out\build\x64-Debug
55 if (err) {
57 }
58 }
59 }
60 }
61#endif
62 JNGL_MAIN_RETURN jngl::internal::mainLoop(jnglInit());
63}
64JNGL_MAIN_END
65#endif
66
67#if defined(_MSC_VER) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
68#ifndef NOMINMAX
69#define NOMINMAX
70#endif
71#include <windows.h>
72
73INT WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int) {
74 return main(__argc, __argv);
75}
76#endif
Contains jngl::AppParameters struct.
T current_path(T... args)
jngl::AppParameters jnglInit()
Implement this function and set AppParameters::start.
Defines macros for the main entry point.
std::string getBinaryPath()
Returns the directory of the currently running binary.
Parameters used to initialize the main window.