JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
main.hpp
Go to the documentation of this file.
1// Copyright 2015-2026 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include "Finally.hpp"
8#include "other.hpp"
9#include "window.hpp"
10#ifdef NDEBUG
11#include "message.hpp"
12#endif
13
14#ifdef __APPLE__
15#include "TargetConditionals.h"
16#endif
17
18#if !defined(JNGL_MAIN_BEGIN)
19 #if defined(ANDROID)
20 #include <android_native_app_glue.h>
21
22 namespace jngl {
23 extern android_app* androidApp;
24 }
25 #define JNGL_MAIN_RETURN (void)
26 #define JNGL_MAIN_BEGIN void android_main(android_app* __androidApp) { \
27 jngl::androidApp = __androidApp;
28 #define JNGL_MAIN_END }
29 #elif defined(__APPLE__) && TARGET_OS_IPHONE // iOS
30 #define JNGL_MAIN_RETURN
31 #define JNGL_MAIN_BEGIN void shouldNotBeCalled() {
32 #define JNGL_MAIN_END }
33 #else
34 #ifdef NDEBUG
35 #define JNGL_CATCH_EXCEPTION_TO_ERROR_MESSAGE try {
36 #else
37 #define JNGL_CATCH_EXCEPTION_TO_ERROR_MESSAGE
38 #endif
39 #define JNGL_MAIN_RETURN return
40 #define JNGL_MAIN_BEGIN /* NOLINT */ int main(int argc, char** argv) { \
41 JNGL_CATCH_EXCEPTION_TO_ERROR_MESSAGE \
42 { \
43 std::vector<std::string> tmp(argc - 1); \
44 for (int i = 1; i < argc; ++i) { \
45 tmp[i - 1] = argv[i]; \
46 } \
47 jngl::internal::setArgs(tmp); \
48 } \
49 jngl::Finally _ZtzNg47T5XSjogv(jngl::hideWindow);
50 #ifdef NDEBUG
51 #define JNGL_MAIN_END /* NOLINT */ } catch (std::exception& e) { \
52 jngl::errorMessage(e.what()); \
53 return EXIT_FAILURE; \
54 } \
55 }
56 #else
57 #define JNGL_MAIN_END }
58 #endif
59 #endif
60#endif
Contains jngl::Finally class.
JNGL's main namespace.
Miscellaneous functions.
Functions related to the main window.