-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitAppState.cpp
77 lines (56 loc) · 1.69 KB
/
InitAppState.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
#include "InitAppState.h"
InitAppState::InitAppState()
{
stateName = "InitApp";
}
void InitAppState::Enter()
{
}
void InitAppState::Exit()
{
stateManager = nullptr;
resManager = nullptr;
settings = nullptr;
screen = nullptr;
}
GotoState InitAppState::Update()
{
stateManager = this->GetStateManager();
// Read the settings file and keep it in state manager
stateManager->ReadSettings();
settings = stateManager->GetSettings();
// Tell us whenever something bad happens
#ifdef _DEBUG
GPU_SetDebugLevel(GPU_DEBUG_LEVEL_MAX);
#else
GPU_SetDebugLevel(GPU_DEBUG_LEVEL_0);
#endif
// Get a 1920x1080 window to render to
screen = GPU_Init(settings->GetWindowWidth(), settings->GetWindowHeight(), GPU_DEFAULT_INIT_FLAGS);
// Did initialization fail?
if (screen == NULL)
return 1;
// Set VSync On/Off
SDL_GL_SetSwapInterval(settings->GetVSync()); // 0:VSync off, 1:VSync on (default)
// Go fullscreen
if (settings->GetFullscreen())
GPU_SetFullscreen(true, false);
// Get windowID. A direct ID to our window.
SDL_Window* window = SDL_GetWindowFromID(screen->context->windowID);
SDL_SetWindowTitle(window, "Draxia");
// Clear the screen
//GPU_Clear(screen);
// Show the result in the window
//GPU_Flip(screen);
// Give the state manager the GPU_Target
stateManager->SetGpuTarget(screen);
// Give the state manager the resource manager
stateManager->SetResourceManager(new ResourceManager(screen));
resManager = stateManager->GetResourceManager();
//
// Load resources
//
// Font
fontSharedBig = resManager->AddSharedFontResource("Data\\Fonts\\OpenSans-Regular-64.fnt");
return ToState::Run;
}