ゲームグラフィックス特論
main.cpp
[詳解]
1 //
2 // メインプログラム
3 //
4 
5 // MessageBox の準備
6 #if defined(_MSC_VER)
7 # define NOMINMAX
8 # include <Windows.h>
9 # include <atlstr.h>
10 #elif defined(__APPLE__)
11 # include <CoreFoundation/CoreFoundation.h>
12 #else
13 # include <iostream>
14 #endif
15 #define HEADER_STR "ゲームグラフィックス特論"
16 
17 // ウィンドウ関連の処理
18 #define USE_IMGUI
19 #include "Window.h"
20 
21 // アプリケーション本体
22 extern void app();
23 
24 //
25 // メインプログラム
26 //
27 int main() try
28 {
29  // ウィンドウ関連の初期設定
30  Window::init(4, 1);
31 
32  // アプリケーションの実行
33  app();
34 }
35 catch (const std::runtime_error &e)
36 {
37  // エラーメッセージを表示する
38 #if defined(_MSC_VER)
39  MessageBox(NULL, CString(e.what()), TEXT(HEADER_STR), MB_ICONERROR);
40 #elif defined(__APPLE__)
41  // the following code is copied from http://blog.jorgearimany.com/2010/05/messagebox-from-windows-to-mac.html
42  // convert the strings from char* to CFStringRef
43  CFStringRef msg_ref = CFStringCreateWithCString(NULL, e.what(), kCFStringEncodingUTF8);
44 
45  // result code from the message box
46  CFOptionFlags result;
47 
48  //launch the message box
49  CFUserNotificationDisplayAlert(
50  0, // no timeout
51  kCFUserNotificationNoteAlertLevel, // change it depending message_type flags ( MB_ICONASTERISK.... etc.)
52  NULL, // icon url, use default, you can change it depending message_type flags
53  NULL, // not used
54  NULL, // localization of strings
55  CFSTR(HEADER_STR), // header text
56  msg_ref, // message text
57  NULL, // default "ok" text in button
58  NULL, // alternate button title
59  NULL, // other button title, null--> no other button
60  &result // response flags
61  );
62 
63  // Clean up the strings
64  CFRelease(msg_ref);
65 #else
66  std::cerr << HEADER_STR << ": " << e.what() << '\n';
67 #endif
68 
69  // ブログラムを終了する
70  return EXIT_FAILURE;
71 }
ゲームグラフィックス特論の宿題用補助プログラムのウィンドウ関連の処理.
static void init(int major=0, int minor=1)
初期化, 最初に一度だけ実行する.
Definition: Window.h:561
#define HEADER_STR
Definition: main.cpp:15
void app()
Definition: ggsample01.cpp:19
int main()
Definition: main.cpp:27