forked from Ports/goldeneye-pc-port
Quit (quit event, window close, Alt+F4, from either SDL pump) used to exit(0) immediately while the render thread could be mid-frame in the driver: the likely trigger of the host's 0x119 bugchecks. Now quits are requested; the render thread glFinish()es, unbinds the context and parks at a frame boundary, and the host exits after (max 2 s). GE_QUITFRAME=<n> gives the harness a clean self-quit; golden_gate.sh uses it.
85 lines
3.0 KiB
C
85 lines
3.0 KiB
C
#ifndef PORT_VIDEO_H
|
|
#define PORT_VIDEO_H
|
|
|
|
/*
|
|
* Video: SDL2 window + OpenGL context + frame pacing, on top of fast3d's
|
|
* window-manager / rendering APIs (port/fast3d).
|
|
*
|
|
* The game's VI (osViSetMode / osViSwapBuffer / ...) is mapped onto this
|
|
* layer by the libultra shims; the software RSP (fast3d) renders into the GL
|
|
* context owned here.
|
|
*/
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <PR/ultratypes.h>
|
|
#include <PR/gbi.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Initialize the window + GL context. Returns 0 on success. */
|
|
/* Steam Deck first-run preset; must run after the config constructor and
|
|
* before configLoad() (see video.c). No-op effect once an ini exists. */
|
|
void videoApplySteamOSDefaults(void);
|
|
int videoInit(void);
|
|
void videoDestroy(void);
|
|
|
|
/* Frame boundary hooks, driven by the SP task shim (libultra.c). These run
|
|
* on the game's scheduler thread. */
|
|
void videoStartFrame(void);
|
|
void videoSubmitCommands(Gfx *cmds); /* runs the software RSP on the list */
|
|
void videoEndFrame(void);
|
|
|
|
/* Host-thread SDL event pump: keeps the window responsive (Windows only
|
|
* dispatches messages to the creating thread) and handles quit. Called in a
|
|
* loop from main(). Exits the process on QUIT/ESC/close. */
|
|
void videoPumpEvents(void);
|
|
|
|
/* D344: orderly quit. Any thread may request it; the render thread parks at
|
|
* the next frame boundary (glFinish + context released) and the host thread
|
|
* then exits. Never call exit() directly for a normal quit: the render thread
|
|
* could be inside the GL driver (the 0x119 bugchecks). */
|
|
void videoRequestQuit(const char *why);
|
|
int videoQuitRequested(void);
|
|
|
|
/* The game's native video mode (NTSC 640x480, PAL 640x400). fast3d scales
|
|
* N64 screen coordinates into window pixels using this. */
|
|
void videoUpdateNativeResolution(s32 w, s32 h);
|
|
u32 videoGetFrameCount(void);
|
|
s32 videoGetNativeWidth(void);
|
|
s32 videoGetNativeHeight(void);
|
|
|
|
/* Offscreen framebuffers (fast3d GL FBOs) + texture cache control. */
|
|
s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize);
|
|
void videoCopyFramebuffer(s32 dst, s32 src, s32 left, s32 top);
|
|
void videoResetTextureCache(void);
|
|
|
|
/* Current FPS (measured). */
|
|
float videoGetFPS(void);
|
|
|
|
/* Re-apply the live-tunable [Video] knobs (VSync / FpsCap / TextureFilter) on
|
|
* the next frame start. Called by the F10 options overlay after an edit. */
|
|
void videoRequestLiveConfig(void);
|
|
|
|
/* F10 options overlay -> window/fullscreen changes. The overlay input handler
|
|
* runs on the scheduler thread; SDL window ops must run on the thread that
|
|
* created the window, so these only post a request that videoPumpEvents()
|
|
* (host thread) applies. The Get* helpers are read-only and thread-safe. */
|
|
void videoRequestWindowSize(int w, int h);
|
|
void videoRequestFullscreen(int on);
|
|
void videoGetWindowSize(int *w, int *h);
|
|
void videoGetDesktopSize(int *w, int *h);
|
|
int videoIsFullscreen(void);
|
|
|
|
/* Snapshot live window geometry into the config vars (call before configSave
|
|
* on a clean exit). No-op if the window isn't up. */
|
|
void videoSaveWindowState(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PORT_VIDEO_H */
|