-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
105 lines (70 loc) · 6.15 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*********************************************************************************************************************************************************************************************************************************/
/*
* * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
********************************************************************************************************************************
AuralEngine is 3D first person game engine designed with Sound Designers in mind to test their ideas in a virtual playground.
Overview
The gateway point for our application is in the main function. First we initialize the Wwise audio engine with the Setup and AudioLoop functions. We then split our application along two threads: in one direction the FLTK GUI
is initialized through the designerGui function; This thread allows users to build their levels, place dialogue events and sprites. In the other direction, we unroll a thread which opens an OpenGl window and uses a raycast
algorithm to draw a 3D image to the screen based upon ray intersections on a 2D grid.
The Designer GUI
The designerGui is our initialization function. It creates all the initial FLTK widgets and links their callback functions. The sessionData structure is the master data structure which is used to communicate between both
threads in the application. Beneath it in hierarchy is the MapData structure which holds all the information relating to particular Maps; subservient to that is the Sprite structure which holds data particular to specific
sprites on specific maps.
worldMaps is a vector of MapData structs, we navigate through it with the currentMap variable. Member function deleteWorldMaps, performs our heap cleanup. mapNames is a vector of Strings which contains the name of each Map:
it is passed to the mapLabel FL_Box.
MapData contains three arrays, which are the Wall, Ceiling and Floor map layouts. Default maps are empty besides boundary walls. Default Maps are copied from the initial array into each new Map. The three sub data structures
are the positions Vector, which manages Portals and dialogue Events, the spriteData vector, which is a vector of Sprite objects and by default we have a sky.ppm array which draws our sky but we can have the user load in
their own sky as well and store it in the ppmData vector.
The Designer Gui is refreshed with the drawWorldMaps function and should be called whenever something is updated or loaded from disk.
Aural Display
The Init function is the gateway into the OpenGL side of the application. We establish the main character's perspective, load game Dialogue and draw any initial sprites or events. The main loop is functionally the display
function and its controlled by an ENUM called GameStates; it outlines all the modes the graphics engine can control or if the engine is active or frozen. Its default state is threeDimensionalDisplay. The game clock is
collected from the GLUT_ELAPSED_TIME, swapping between two buffers; this mainly controls how fast the dialogue is written, but also how fast the character turns. Two Dimensional Display reveals the map from the 2D grid
perspective. DialogueEvent triggers the game engine's dialogue system, which is modeled after classic RPGs. LoadScreen triggers a Black Screen.
***********************************************************************************************************************************************************************************************************************************/
#include "Directory.h"
#include "Aural_Audio.h"
#include "Aural_Display.h"
#include "Aural_Maps.h"
#include "Aural_Textures.h"
#include "DesignerGUI.h"
void cleanup()
{
std::cout << "cleanup called" << std::endl;
thisSession.deleteWorldMaps();
}
int main(int argc, char* argv[])
{
//audio intialize
Setup();
AK::SoundEngine::PostEvent(AK::EVENTS::AMBIENCE, GAME_OBJECT_ID_THEME);
AudioLoop();
std::thread fltkThread(designerGui);
//graphic intialize
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(screenWidth, screenHeight) ;
glutInitWindowPosition(0, 0);
glutCreateWindow("AuralEngine");
init();
glutDisplayFunc(display);
glutKeyboardFunc(ButtonDown);
glutKeyboardUpFunc(ButtonUp);
//guiInit();
glutMainLoop();
Fl::lock(); // Ensure that FLTK resources are locked before termination
fltkThread.join();
Fl::unlock();
atexit(cleanup);
AK::SoundEngine::Term();
g_lowLevelIO.Term();
if (AK::IAkStreamMgr::Get())
AK::IAkStreamMgr::Get()->Destroy();
AK::MemoryMgr::Term();
return 0;
}