-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (54 loc) · 2.02 KB
/
main.cpp
File metadata and controls
73 lines (54 loc) · 2.02 KB
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
68
69
70
71
72
73
// ---------------------------------------------------------------------
// INCLUDE STATEMENTS
// ---------------------------------------------------------------------
#include <CGApp\CGApp.h>
#include <GL\CGOpenGL.h>
#include <iostream>
// Debug window
#include "PDebug.h"
using namespace std;
// ---------------------------------------------------------------------
// WIN MAIN
// ---------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE h_instance, HINSTANCE h_prev_instance, LPSTR lp_cmd_line, int show_cmd)
{
// Debug window instance
PDebug debugWnd;
// Tell Windows to terminate app if heap becomes corrupted
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
// Initialise COM (for Windows Imaging Component (WIC), Media Foundation and other COM features)
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
// Redirect console output to the file "runlog.txt"
FILE *consoleFile = NULL;
freopen_s(&consoleFile, "runlog.txt", "w", stdout);
// Initial memory report
gu_memory_report();
// Create main CGApp (singleton) object
CGApp *app = new CGApp();
if (app)
{
// Create main app delegate (contains OpenGL functionality)
CGAppDelegate *appDelegate = new CGOpenGL(app);
if (appDelegate)
{
// Init the debug window
debugWnd.Initialise();
// Initialise application with relevant delegate object. Ownership of appDelegate passed implicitly to app object so don't need to explicitly release here
hr = app->initApp(TEXT("CGApplication"), TEXT("Jak Boulton - 10026037 - Genetic Programming"), 1000, 768, WS_OVERLAPPEDWINDOW, appDelegate);
if (SUCCEEDED(hr))
// Start app runloop if successfully initialised
hr = app->startRunloop();
}
app->release();
}
// Final memory report
gu_memory_report();
// Redirect output back to the console
freopen_s(&consoleFile, "CON", "w", stdout);
// Notify COM we're done
CoUninitialize();
}
}
// ---------------------------------------------------------------------