dl
dl_main.h
浏览该文件的文档.
1
11#include <cassert>
12#include <cstdio>
13#include <system/dl_platform.h>
14
15
16extern int Main();
17
18#if DL_PLATFORM != DL_PLATFORM_ANDROID
19
20#if defined(NDEBUG) && DL_PLATFORM == DL_PLATFORM_WIN32
21#define DL_USE_CRASH_RPT
22#endif
23
24#ifdef DL_USE_CRASH_RPT
25#include "CrashRpt.h"
26#endif
27
28inline void dl_main_init()
29{
30#ifdef DL_USE_CRASH_RPT
31 CR_INSTALL_INFOW info;
32 memset(&info, 0, sizeof(CR_INSTALL_INFOW));
33 info.cb = sizeof(CR_INSTALL_INFOW); // Size of the structure
34 info.pszAppName = L"dl_engine"; // App name
35 info.pszAppVersion = L"1.0.0"; // App version
36 info.pszEmailSubject = L"CrashRpt Console Test 1.0.0 Error Report"; // Email subject
37 info.pszEmailTo = L"test@hotmail.com"; // Email recipient address
38
39 // Install crash handlers
40 int nInstResult = crInstallW(&info);
41 assert(nInstResult == 0);
42
43 // Check result
44 if (nInstResult != 0)
45 {
46 WCHAR buff[256];
47 crGetLastErrorMsgW(buff, 256); // Get last error
48 printf("%ws\n", buff); // and output it to the screen
49 }
50#endif
51}
52
53inline void dl_main_release()
54{
55#ifdef DL_USE_CRASH_RPT
56 int nUninstRes = crUninstall(); // Uninstall exception handlers
57 assert(nUninstRes == 0);
58#endif
59}
60
61#if DL_USE_CONSOLE
62int main()
63{
65 int ret = Main();
67 return ret;
68}
69#else
70#include <wtypes.h>
71int CALLBACK WinMain(
72 __in HINSTANCE hInstance,
73 __in HINSTANCE hPrevInstance,
74 __in LPSTR lpCmdLine,
75 __in int nCmdShow
76)
77{
79 int ret = Main();
81 return ret;
82}
83#endif
84
85#else
86#include <game-activity/native_app_glue/android_native_app_glue.h>
87#include <system/dl_android.h>
88// 主函数
89void android_main(android_app* app)
90{
92 dl::g_android->Init();
93 Main();
94 delete dl::g_android;
95}
96
97#endif
安卓相关
void dl_main_init()
int Main()
void dl_main_release()
int CALLBACK WinMain(__in HINSTANCE hInstance, __in HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nCmdShow)
平台宏
AndroidData * g_android
安卓平台特有句柄