-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIWindow.cpp
More file actions
226 lines (174 loc) · 6.19 KB
/
GUIWindow.cpp
File metadata and controls
226 lines (174 loc) · 6.19 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include "GUIWindow.h"
#include "Globals.h"
#include "ModuleTexture.h"
#include "ModuleCamera.h"
#include "ModuleRender.h"
#include "ModuleWindow.h"
#include "ModuleTimeManager.h"
#include "ModuleInput.h"
#include "Application.h"
#include "DevIL/ilu.h"
void GUIWindow::Draw(const char * title)
{
if(isEnabled)
{
SDL_Window* window = App->window->window;
assert(window != nullptr);
ImGui::Begin(title, &isEnabled);
if (ImGui::Checkbox("FullScreen", &App->window->fullscreen))
{
if (App->window->fullscreen)
{
SDL_DisplayMode displayMode;
SDL_GetDesktopDisplayMode(0, &displayMode);
SDL_SetWindowSize(window, displayMode.w, displayMode.h);
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
App->camera->SetAspectRatio();
}
else
{
SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowSize(window, SCREEN_WIDTH, SCREEN_WIDTH);
App->camera->SetAspectRatio();
}
}
ImGui::SameLine();
ImGui::Checkbox("Resizable", &App->window->resizable);
int currentColorStyle = -1;
if (ImGui::Combo("Color Style", ¤tColorStyle, "Classic\0Dark\0Light\0"))
{
switch (currentColorStyle)
{
case 0: ImGui::StyleColorsClassic(); break;
case 1: ImGui::StyleColorsDark(); break;
case 2: ImGui::StyleColorsLight(); break;
default: break;
}
}
ImGui::SliderFloat("Brightness", &actualBright, 0.000f, 1.000f, "%.3f");
ImGui::SliderInt("Width", &App->window->width, 1, 2500, "%d");
ImGui::SliderInt("Height", &App->window->height, 1, 2500, "%d");
ImGui::Checkbox("See Scene and Game together", &App->renderer->showBothSceneGame);
if (App->window->resizable)
{
SDL_SetWindowSize(window, App->window->width, App->window->height);
App->camera->SetAspectRatio();
}
else
{
SDL_GetWindowSize(window, &App->window->width, &App->window->height);
App->camera->SetAspectRatio();
}
SDL_SetWindowBrightness(window, actualBright);
if (ImGui::CollapsingHeader("Hardware"))
{
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "CPUs: "); ImGui::SameLine();
ImGui::Text("%d(Cache: %dkb)", SDL_GetCPUCount(), SDL_GetCPUCacheLineSize());
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "System RAM: "); ImGui::SameLine();
ImGui::Text("%dGb", SDL_GetSystemRAM() / 1000);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Caps: "); ImGui::SameLine();
if(SDL_Has3DNow())
{
ImGui::Text("3DNow,"); ImGui::SameLine();
}
if(SDL_HasAVX())
{
ImGui::Text("AVX,"); ImGui::SameLine();
}
if (SDL_HasAVX2())
{
ImGui::Text("AVX2,"); ImGui::SameLine();
}
if(SDL_HasAltiVec())
{
ImGui::Text("AltiVec,"); ImGui::SameLine();
}
if(SDL_HasMMX())
{
ImGui::Text("MMX,"); ImGui::SameLine();
}
if(SDL_HasRDTSC())
{
ImGui::Text("RDTSC,"); ImGui::SameLine();
}
if(SDL_HasSSE())
{
ImGui::Text("SSE,"); ImGui::SameLine();
}
if (SDL_HasSSE2())
{
ImGui::Text("SSE2,"); ImGui::SameLine();
}
if (SDL_HasSSE3())
{
ImGui::Text("SSE3,"); ImGui::SameLine();
}
if (SDL_HasSSE41())
{
ImGui::Text("SSE41,"); ImGui::SameLine();
}
if (SDL_HasSSE42())
{
ImGui::Text("SSE42,"); ImGui::SameLine();
}
ImGui::Text("");
ImGui::Separator();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "GPU: "); ImGui::SameLine();
ImGui::Text("%s", glGetString(GL_VENDOR));
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Brand: "); ImGui::SameLine();
ImGui::Text("%s", glGetString(GL_RENDERER));
#define GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX 0x9048
#define GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX 0x9049
GLint total_mem_kb = 0;
glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX,
&total_mem_kb);
GLint cur_avail_mem_kb = 0;
glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX,
&cur_avail_mem_kb);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VRAM Total: "); ImGui::SameLine();
ImGui::Text("%d(Mb)", total_mem_kb / 1000);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VRAM Available: "); ImGui::SameLine();
ImGui::Text("%d(Mb)", cur_avail_mem_kb / 1000);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "VRAM Usage: "); ImGui::SameLine();
ImGui::Text("%d(Mb)", (total_mem_kb / 1000) - (cur_avail_mem_kb / 1000));
}
if (ImGui::CollapsingHeader("Variables"))
{
if (ImGui::CollapsingHeader("Renderer"))
{
//Face Culling
ImGui::Checkbox("Face Culling", &App->renderer->faceCullingIsActive);
App->renderer->EnableFaceCulling();
//GL_DEPTH_TEST
ImGui::Checkbox("Depth Test", &App->renderer->dephtTestIsActive);
App->renderer->EnableDepthTest();
//Changing front face
ImGui::Checkbox("Front Face: CWW/CW", &App->renderer->changingFrontFace);
App->renderer->ChangeFrontFace();
//Texture2D
ImGui::Checkbox("Texture2D", &App->renderer->texture2DIsActive);
App->renderer->EnableTexture2D();
//Fill triangles
ImGui::Checkbox("Fill Triangles", &App->renderer->fillTrianglesIsActive);
App->renderer->FillTriangles();
//Alpha test
ImGui::Checkbox("Alpha test", &App->renderer->alphaTestIsActive);
App->renderer->EnableAlphaTest();
}
if (ImGui::CollapsingHeader("Input"))
{
ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Mouse");
ImGui::Text("Mouse Position: (%f , %f)", App->input->GetMousePosition().x, App->input->GetMousePosition().y);
ImGui::Text("Mouse delta motion: (%f, %f)", App->input->GetMouseMotion().x, App->input->GetMouseMotion().y);
ImGui::Text("Mouse Wheel: %d", App->input->GetMouseWheel());
ImGui::Text("Mouse Right Click: %d", App->input->GetMouseButtonDown(SDL_BUTTON_RIGHT) == KEY_REPEAT ? 1 : 0);
ImGui::Text("Mouse Left Click: %d", App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_REPEAT ? 1 : 0);
ImGui::Separator();
ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "KeyBoard");
ImGui::Text("Keys down:"); for (int i = 0; i < 300; i++) if (App->input->GetKey(i) == KEY_DOWN) { ImGui::SameLine(); ImGui::Text("%d ", i); }
ImGui::Text("Keys repeat:"); for (int i = 0; i < 300; i++) if (App->input->GetKey(i) == KEY_REPEAT) { ImGui::SameLine(); ImGui::Text("%d ", i); }
}
}
ImGui::End();
}
}