-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCS261_Replication_Tester.cpp
More file actions
65 lines (54 loc) · 1.76 KB
/
CS261_Replication_Tester.cpp
File metadata and controls
65 lines (54 loc) · 1.76 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
//---------------------------------------------------------
// file: CS261_Replication_Tester.cpp
// author: Matthew Picioccio
// email: matthew.picioccio@digipen.edu
//
// brief: Entry point
//
// C-Processing documentation link:
// https://inside.digipen.edu/main/GSDP:GAM100/CProcessing
//
// Copyright © 2021 DigiPen, All rights reserved.
//---------------------------------------------------------
#include "framework.h"
#include "GameStateManager.h"
#include "MainMenuState.h"
/// <summary>
/// Enable the console, so we can see useful cout and cerr output.
/// For reference, see one of the newer answers in https://stackoverflow.com/questions/311955/redirecting-cout-to-a-console-in-windows.
/// </summary>
/// <remarks>In modern Windows SDKs, the old freopen method is not sufficient to capture cout/cerr. This method does work.</remarks>
void ShowConsole()
{
AllocConsole();
static std::ofstream conout("CONOUT$", std::ios::out);
std::cout.rdbuf(conout.rdbuf());
std::cerr.rdbuf(conout.rdbuf());
// NOTE: CP_Engine_Run will call FreeConsole() for us when the program is exiting.
}
/// <summary>
/// Entry point for the process
/// </summary>
/// <returns>0 if successful, non-zero for process errors</returns>
int main(void)
{
ShowConsole();
// initialize WinSock
WSADATA wsa_data;
const auto res = WSAStartup(MAKEWORD(2, 2), &wsa_data);
if (res != 0)
{
std::cerr << "Error in WSAStartup: " << WSAGetLastError() << std::endl;
return 1;
}
// establish the initial window settings
CP_System_SetWindowTitle("CS 261 Replication Tester");
CP_System_SetWindowSize(1024, 768);
// start the simulation
auto* main_menu_state = new MainMenuState();
GameStateManager::EstablishBaseState(main_menu_state);
CP_Engine_Run();
// clean up WinSock
WSACleanup();
return 0;
}