-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleWindow.cpp
More file actions
103 lines (82 loc) · 1.71 KB
/
ModuleWindow.cpp
File metadata and controls
103 lines (82 loc) · 1.71 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
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
#include "Globals.h"
#include "Application.h"
#include "ModuleWindow.h"
#include "ModuleCamera.h"
#include "GL/glew.h"
#include "Imgui/imgui.h"
#include "Imgui/imgui_impl_sdl.h"
#include "Imgui/imgui_impl_opengl3.h"
ModuleWindow::ModuleWindow()
{
}
// Destructor
ModuleWindow::~ModuleWindow()
{
}
// Called before render is available
bool ModuleWindow::Init()
{
LOG("Init SDL window & surface");
bool ret = true;
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
LOG("SDL_VIDEO could not initialize! SDL_Error: %s\n", SDL_GetError());
ret = false;
}
else
{
//Create window
Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
if(FULLSCREEN == true)
{
flags |= SDL_WINDOW_FULLSCREEN;
}
if (RESIZABLE)
{
flags |= SDL_WINDOW_RESIZABLE;
}
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
width = (int)(DM.w);
height = (int)(DM.h * 0.925);
window = SDL_CreateWindow(TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
if(window == NULL)
{
LOG("Window could not be created! SDL_Error: %s\n", SDL_GetError());
ret = false;
}
else
{
//Get window surface
screen_surface = SDL_GetWindowSurface(window);
}
}
return ret;
}
// Called before quitting
bool ModuleWindow::CleanUp()
{
LOG("Destroying SDL window and quitting all SDL systems");
//Destroy window
if(window != NULL)
{
SDL_DestroyWindow(window);
}
if(glcontext != NULL)
{
SDL_GL_DeleteContext(glcontext);
}
//Quit SDL subsystems
SDL_Quit();
return true;
}
update_status ModuleWindow::Update()
{
return UPDATE_CONTINUE;
}
void ModuleWindow::Resize(unsigned int newWidth, unsigned int newHeight)
{
width = newWidth;
height = newHeight;
App->camera->SetAspectRatio();
}