-
Notifications
You must be signed in to change notification settings - Fork 45
/
main.cpp
67 lines (60 loc) · 2.13 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// ゲームグラフィックス特論宿題アプリケーション
//
#include "GgApp.h"
// MessageBox の準備
#if defined(_MSC_VER)
# include <atlstr.h>
#elif defined(__APPLE__)
# include <CoreFoundation/CoreFoundation.h>
#else
# include <iostream>
#endif
#define HEADER_STR "ゲームグラフィックス特論"
//
// メインプログラム
//
int main(int argc, const char* const* argv) try
{
// アプリケーションのオブジェクトを生成する
#if defined(GL_GLES_PROTOTYPES)
GgApp app(3, 1);
#else
GgApp app(4, 1);
#endif
// アプリケーションを実行する
return app.main(argc, argv);
}
catch (const std::runtime_error &e)
{
// エラーメッセージを表示する
#if defined(_MSC_VER)
MessageBox(NULL, CString(e.what()), TEXT(HEADER_STR), MB_ICONERROR);
#elif defined(__APPLE__)
// the following code is copied from http://blog.jorgearimany.com/2010/05/messagebox-from-windows-to-mac.html
// convert the strings from char* to CFStringRef
CFStringRef msg_ref = CFStringCreateWithCString(NULL, e.what(), kCFStringEncodingUTF8);
// result code from the message box
CFOptionFlags result;
//launch the message box
CFUserNotificationDisplayAlert(
0, // no timeout
kCFUserNotificationNoteAlertLevel, // change it depending message_type flags ( MB_ICONASTERISK.... etc.)
NULL, // icon url, use default, you can change it depending message_type flags
NULL, // not used
NULL, // localization of strings
CFSTR(HEADER_STR), // header text
msg_ref, // message text
NULL, // default "ok" text in button
NULL, // alternate button title
NULL, // other button title, null--> no other button
&result // response flags
);
// Clean up the strings
CFRelease(msg_ref);
#else
std::cerr << HEADER_STR << ": " << e.what() << '\n';
#endif
// ブログラムを終了する
return EXIT_FAILURE;
}