Files
vanilla/gui/main.c
T
MattKC b0bbc31002 Various optimizations and refactoring (#259)
* optimizations

* Update menu_game.h

* try new code

* use cached EGLImages

* try drm cache on pi

* nani?

* huh?

* require opengl egl

* find EGL

* find EGL separately

* logging

* add support for versions of ffmpeg less than 6.0

* disable drm cache for now

* Update ui_sdl.c

* use old code for now

* disable avcc hdr for now

* restore error message

* try disabling format modifiers?

* tell me what the layer is

* pi decoder actually produces frames in yuv420p

* print more debug info

* try this

* switch to faster decode path

* switch to old code

* Update ui_sdl.c

* add more timing profiling

* more printing

* enable some optimizations

* draw menus when not in game mode

* call render present

* Update ui_sdl.c

* Update ui_sdl.c

* remove unused code

* Update CMakeLists.txt

* incorporate direct DRM code

* Update CMakeLists.txt

* free drm context and test old decoding code

* move SDL event loop to separate thread so controls are not limited by display rate

* add a wait to reduce CPU thrashing

* fix double free

* separate video into recv and consume threads

* Update ui_sdl_drm.c

* Update ui_sdl_drm.c

* Update gamepad.c

* further optimizations

* anti-alias buttons more

* fix some compiler errors

* only include DRM on linux

* fix windows compile issues

* fix includes

* Update CMakeLists.txt

* add htobe32 define for macOS

* Update video.c

* Update gamepad.c
2025-11-30 20:56:52 -08:00

84 lines
1.6 KiB
C

#include <stdio.h>
#include <string.h>
#include <vanilla.h>
#include "config.h"
#include "menu/menu.h"
#include "platform.h"
#include "ui/ui.h"
#include "ui/ui_sdl.h"
#define SCREEN_WIDTH 854
#define SCREEN_HEIGHT 480
#if !defined(ANDROID) && !defined(_WIN32)
#define SDL_main main
#endif
#include "pipemgmt.h"
void display_cli_help(const char **argv);
int SDL_main(int argc, const char **argv)
{
// Default to full screen unless "-w" is specified
int fs = 1;
for (int i = 1, consumed; i < argc; i += consumed) {
consumed = -1;
if (!strcmp(argv[i], "-w") || !strcmp(argv[i], "--window")) {
fs = 0;
consumed = 1;
}
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
display_cli_help(argv);
return 0;
}
if (consumed <= 0) {
vpilog("Invalid argument(s): %s\n\n", argv[i]);
display_cli_help(argv);
return 1;
}
}
vanilla_install_logger(vpilog_va);
// Load config
vpi_config_init();
// Initialize UI system
vui_context_t *vui = vui_alloc(SCREEN_WIDTH, SCREEN_HEIGHT);
// Initialize SDL2
int ret = 1;
if (vui_init_sdl(vui, fs)) {
vpilog("Failed to initialize VUI\n");
goto exit;
}
vpi_menu_init(vui);
while (vui_update_sdl(vui)) {
vpi_update_pipe();
}
ret = 0;
vpi_stop_pipe();
exit:
vui_close_sdl(vui);
vui_free(vui);
vpi_config_free();
return ret;
}
void display_cli_help(const char **argv) {
vpilog("Usage: %s [options]\n\n", argv[0]);
vpilog("Options:\n");
vpilog(" -w, --window Run Vanilla in a window\n");
vpilog(" -h, --help Show this help message\n");
}