Skip to content

Commit 464fdfc

Browse files
committed
Update SDL2 header usage
1 parent c1c660c commit 464fdfc

File tree

12 files changed

+45
-16
lines changed

12 files changed

+45
-16
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ CheckOptions:
4949
- { key: readability-identifier-length.MinimumVariableNameLength, value: 2 }
5050
- { key: readability-identifier-length.MinimumParameterNameLength, value: 2 }
5151
- { key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors, value: '1' }
52+
- { key: misc-include-cleaner.IgnoreHeaders, value: "SDL2/SDL\.h" }

src/core/Core/Application.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#include "Application.hpp"
22

3-
#include <SDL.h>
4-
#include <SDL_error.h>
5-
#include <SDL_events.h>
6-
#include <SDL_filesystem.h>
7-
#include <SDL_video.h>
3+
#include <SDL2/SDL.h>
84
#include <backends/imgui_impl_opengl3.h>
95
#include <backends/imgui_impl_sdl2.h>
106
#include <glad/glad.h>
@@ -180,10 +176,14 @@ ExitStatus App::Application::run() {
180176
}
181177

182178
void App::Application::stop() {
179+
APP_PROFILE_FUNCTION();
180+
183181
m_running = false;
184182
}
185183

186184
void Application::on_event(const SDL_WindowEvent& event) {
185+
APP_PROFILE_FUNCTION();
186+
187187
switch (event.event) {
188188
case SDL_WINDOWEVENT_CLOSE:
189189
return on_close();
@@ -198,14 +198,20 @@ void Application::on_event(const SDL_WindowEvent& event) {
198198
}
199199

200200
void Application::on_minimize() {
201+
APP_PROFILE_FUNCTION();
202+
201203
m_minimized = true;
202204
}
203205

204206
void Application::on_shown() {
207+
APP_PROFILE_FUNCTION();
208+
205209
m_minimized = false;
206210
}
207211

208212
void Application::on_close() {
213+
APP_PROFILE_FUNCTION();
214+
209215
stop();
210216
}
211217

src/core/Core/Application.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <SDL.h>
3+
#include <SDL2/SDL.h>
44

55
#include <memory>
66
#include <string>
@@ -10,7 +10,7 @@
1010

1111
namespace App {
1212

13-
enum class ExitStatus : int { SUCCESS = 0, FAILURE = 1 };
13+
enum class ExitStatus : std::uint8_t { SUCCESS = 0, FAILURE = 1 };
1414

1515
class Application {
1616
public:

src/core/Core/DPIHandler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <SDL.h>
3+
#include <SDL2/SDL.h>
44
#include <imgui.h>
55

66
#include "Core/Window.hpp"

src/core/Core/Window.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Window.hpp"
22

3-
#include <SDL_video.h>
3+
#include <SDL2/SDL.h>
44
#include <glad/glad.h>
55

66
#include "Core/DPIHandler.hpp"
@@ -49,10 +49,14 @@ Window::~Window() {
4949
}
5050

5151
SDL_Window* Window::get_native_window() const {
52+
APP_PROFILE_FUNCTION();
53+
5254
return m_window;
5355
}
5456

5557
SDL_GLContext Window::get_native_context() const {
58+
APP_PROFILE_FUNCTION();
59+
5660
return m_gl_context;
5761
}
5862

src/core/Core/Window.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <SDL.h>
3+
#include <SDL2/SDL.h>
44

55
#include <string>
66

src/core/Platform/Linux/DPIHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Core/DPIHandler.hpp"
22

3-
#include <SDL_video.h>
3+
#include <SDL2/SDL.h>
44
#include <imgui.h>
55

66
#include "Core/Debug/Instrumentor.hpp"

src/core/Platform/Linux/Resources.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
#include "Core/Resources.hpp"
22

3-
#include <SDL_filesystem.h>
3+
#include <SDL2/SDL.h>
44

55
#include <filesystem>
66
#include <string>
77
#include <string_view>
88

9+
#include "Core/Debug/Instrumentor.hpp"
10+
911
namespace App {
1012

1113
static const std::string BASE_PATH{SDL_GetBasePath()};
1214

1315
std::filesystem::path Resources::resource_path(const std::filesystem::path& file_path) {
16+
APP_PROFILE_FUNCTION();
17+
1418
std::filesystem::path font_path{BASE_PATH};
1519
font_path /= "../share";
1620
font_path /= "fonts" / file_path;
1721
return font_path;
1822
}
1923

2024
std::filesystem::path Resources::font_path(const std::string_view& font_file) {
25+
APP_PROFILE_FUNCTION();
26+
2127
return resource_path(font_file);
2228
}
2329

src/core/Platform/Mac/DPIHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Core/DPIHandler.hpp"
22

3-
#include <SDL_video.h>
3+
#include <SDL2/SDL.h>
44
#include <imgui.h>
55

66
#include <cmath>

src/core/Platform/Mac/Resources.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
#include "Core/Resources.hpp"
22

3-
#include <SDL_filesystem.h>
3+
#include <SDL2/SDL.h>
44

55
#include <filesystem>
66
#include <string>
77
#include <string_view>
88

9+
#include "Core/Debug/Instrumentor.hpp"
10+
911
namespace App {
1012

1113
static const std::string BASE_PATH{SDL_GetBasePath()};
1214

1315
std::filesystem::path Resources::resource_path(const std::filesystem::path& file_path) {
16+
APP_PROFILE_FUNCTION();
17+
1418
std::filesystem::path font_path{BASE_PATH};
1519
font_path /= file_path;
1620
return font_path;
1721
}
1822

1923
std::filesystem::path Resources::font_path(const std::string_view& font_file) {
24+
APP_PROFILE_FUNCTION();
25+
2026
return resource_path(font_file);
2127
}
2228

0 commit comments

Comments
 (0)