refactor: migració a l'arquitectura SDL3 Callback API
Substitueix el bucle blocant main() → Director::run() → escena::run() per SDL_AppInit/Iterate/Event/Quit. Cada escena implementa ara iterate() (un frame) i handleEvent() (un event) sota una interfície base Scene. - Director gestiona l'escena activa i les transicions via switchToActiveScene() - Setup/cleanup que estava al voltant del while de run() mogut a ctor/dtor (música de Game/Ending/Ending2, volum de LoadingScreen) - GlobalEvents ja no processa SDL_EVENT_QUIT (ho fa Director::handleEvent) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,14 +5,24 @@ Empezado en Castalla el 01/07/2022.
|
||||
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
#include "core/system/director.hpp"
|
||||
|
||||
auto main() -> int {
|
||||
// Crea el objeto Director
|
||||
auto director = std::make_unique<Director>();
|
||||
|
||||
// Bucle principal
|
||||
return Director::run();
|
||||
SDL_AppResult SDL_AppInit(void** appstate, int /*argc*/, char* /*argv*/[]) {
|
||||
*appstate = new Director();
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_AppIterate(void* appstate) {
|
||||
return static_cast<Director*>(appstate)->iterate();
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) {
|
||||
return static_cast<Director*>(appstate)->handleEvent(*event);
|
||||
}
|
||||
|
||||
void SDL_AppQuit(void* appstate, SDL_AppResult /*result*/) {
|
||||
delete static_cast<Director*>(appstate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user