SDL3 port - code cleanup

This commit is contained in:
Matteo De Carlo
2024-10-12 13:04:08 +02:00
parent c9e1d19dd3
commit 0824ae2198
6 changed files with 35 additions and 41 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
wi::arguments::Parse(argc, argv);
sdl3::sdlsystem_ptr_t system = sdl3::make_sdlsystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD | SDL_INIT_EVENTS);
sdl3::sdlsystem_ptr_t system = sdl3::make_sdlsystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD);
if (!system) {
throw sdl3::SDLError("Error creating SDL3 system");
}
+1 -1
View File
@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
application.infoDisplay.resolution = true;
application.infoDisplay.fpsinfo = true;
sdl3::sdlsystem_ptr_t system = sdl3::make_sdlsystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
sdl3::sdlsystem_ptr_t system = sdl3::make_sdlsystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD);
sdl3::window_ptr_t window = sdl3::make_window(
"Template",
2560, 1440,
+30 -35
View File
@@ -18,41 +18,36 @@ int sdl_loop(Tests &tests)
case SDL_EVENT_QUIT:
quit = true;
break;
// case SDL_WINDOWEVENT:
// switch (event.window.event) {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED: // exit tests
quit = true;
break;
case SDL_EVENT_WINDOW_RESIZED:
// Tells the engine to reload window configuration (size and dpi)
tests.SetWindow(tests.window);
break;
case SDL_EVENT_WINDOW_FOCUS_LOST:
tests.is_window_active = false;
break;
case SDL_EVENT_WINDOW_FOCUS_GAINED:
tests.is_window_active = true;
if (wi::shadercompiler::GetRegisteredShaderCount() > 0)
{
std::thread([] {
wi::backlog::post("[Shader check] Started checking " + std::to_string(wi::shadercompiler::GetRegisteredShaderCount()) + " registered shaders for changes...");
if (wi::shadercompiler::CheckRegisteredShadersOutdated())
{
wi::backlog::post("[Shader check] Changes detected, initiating reload...");
wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [](uint64_t userdata) {
wi::renderer::ReloadShaders();
});
}
else
{
wi::backlog::post("[Shader check] All up to date");
}
}).detach();
}
break;
// default:
// break;
// }
case SDL_EVENT_WINDOW_CLOSE_REQUESTED: // exit tests
quit = true;
break;
case SDL_EVENT_WINDOW_RESIZED:
// Tells the engine to reload window configuration (size and dpi)
tests.SetWindow(tests.window);
break;
case SDL_EVENT_WINDOW_FOCUS_LOST:
tests.is_window_active = false;
break;
case SDL_EVENT_WINDOW_FOCUS_GAINED:
tests.is_window_active = true;
if (wi::shadercompiler::GetRegisteredShaderCount() > 0)
{
std::thread([] {
wi::backlog::post("[Shader check] Started checking " + std::to_string(wi::shadercompiler::GetRegisteredShaderCount()) + " registered shaders for changes...");
if (wi::shadercompiler::CheckRegisteredShadersOutdated())
{
wi::backlog::post("[Shader check] Changes detected, initiating reload...");
wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [](uint64_t userdata) {
wi::renderer::ReloadShaders();
});
}
else
{
wi::backlog::post("[Shader check] All up to date");
}
}).detach();
}
break;
default:
break;
}
-1
View File
@@ -4,7 +4,6 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL3/SDL_oldnames.h>
#include <memory>
#include <sstream>
+1 -1
View File
@@ -1,7 +1,6 @@
#pragma once
// This file includes platform, os specific libraries and supplies common platform specific resources
#include <SDL3/SDL_video.h>
#ifdef _WIN32
#ifndef NOMINMAX
@@ -33,6 +32,7 @@ typedef void* HMODULE;
#ifdef SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_vulkan.h>
#include "sdl3.h"
#endif
+2 -2
View File
@@ -1,9 +1,9 @@
#include "wiSDLInput.h"
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_gamepad.h>
#ifdef SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_gamepad.h>
#include "wiUnorderedMap.h"
#include "wiBacklog.h"