102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
graphics.c File Reference
#include "graphics_private.h"
#include "hooks_private.h"
#include <dttr_config.h>
#include <dttr_errors.h>
#include <dttr_log.h>
#include <dttr_sdl.h>
#include <stddef.h>
#include <windows.h>
#include "sds.h"
#include "sidecar_private.h"

Go to the source code of this file.

Data Structures

struct  backend_candidate
struct  backend_range

Macros

#define DTTR_MIN_WINDOW_DIM   64
#define BACKEND_COUNT   SDL_arraysize(backend_candidates)
#define IDX_SDL_GPU   0
#define IDX_OPENGL   1

Functions

static void update_window_title (const DTTR_BackendState *state)
static int clamp_dim (int value, int fallback)
static void select_render_resolution (const DTTR_BackendState *state, int *out_width, int *out_height)
static void refresh_render_resolution (DTTR_BackendState *state)
static void init_common_state (DTTR_BackendState *state)
static HWND get_hwnd (SDL_Window *window)
void dttr_graphics_mod_present_rect_before (DTTR_BackendState *state, const DTTR_PresentRect *present)
void dttr_graphics_mod_present_rect_after (DTTR_BackendState *state, const DTTR_PresentRect *present, bool overlay_rendered)
static void destroy_window (DTTR_BackendState *state)
static backend_range select_backend_range (DTTR_GraphicsApi api)
HWND dttr_graphics_init ()
void dttr_graphics_set_logical_resolution (int width, int height)
SDL_Windowdttr_graphics_get_window ()
SDL_GPUDevice * dttr_graphics_get_device ()
void dttr_graphics_handle_window_resize (int width, int height)
void dttr_graphics_begin_frame ()
void dttr_graphics_end_frame ()
bool dttr_graphics_present_video_frame_bgra (const uint8_t *pixels, int width, int height, int stride)
void dttr_graphics_cleanup ()

Variables

static const backend_candidate backend_candidates []
static sds window_title = NULL

Macro Definition Documentation

◆ BACKEND_COUNT

#define BACKEND_COUNT   SDL_arraysize(backend_candidates)

Definition at line 19 of file graphics.c.

Referenced by select_backend_range().

◆ DTTR_MIN_WINDOW_DIM

#define DTTR_MIN_WINDOW_DIM   64

Definition at line 18 of file graphics.c.

Referenced by clamp_dim(), and dttr_graphics_handle_window_resize().

◆ IDX_OPENGL

#define IDX_OPENGL   1

Definition at line 32 of file graphics.c.

Referenced by select_backend_range().

◆ IDX_SDL_GPU

#define IDX_SDL_GPU   0

Definition at line 31 of file graphics.c.

Referenced by select_backend_range().

Function Documentation

◆ clamp_dim()

int clamp_dim ( int value,
int fallback )
static

◆ destroy_window()

void destroy_window ( DTTR_BackendState * state)
static

Definition at line 457 of file graphics.c.

References dttr_graphics_mod_window_destroying(), NULL, and state.

Referenced by dttr_graphics_cleanup(), and dttr_graphics_init().

◆ dttr_graphics_begin_frame()

void dttr_graphics_begin_frame ( )

Definition at line 599 of file graphics.c.

References dttr_backend, and state.

Referenced by d3d_device7_record_clear(), and tick_main_loop().

◆ dttr_graphics_cleanup()

◆ dttr_graphics_end_frame()

void dttr_graphics_end_frame ( )

Definition at line 610 of file graphics.c.

References dttr_backend, and state.

Referenced by surface_present(), and tick_main_loop().

◆ dttr_graphics_get_device()

SDL_GPUDevice * dttr_graphics_get_device ( )

Definition at line 583 of file graphics.c.

References dttr_backend.

Referenced by DTTR_Hook_WinMainCallback().

◆ dttr_graphics_get_window()

SDL_Window * dttr_graphics_get_window ( )

Definition at line 578 of file graphics.c.

References dttr_backend.

Referenced by DTTR_Hook_WinMainCallback(), and kvec_t().

◆ dttr_graphics_handle_window_resize()

void dttr_graphics_handle_window_resize ( int width,
int height )

◆ dttr_graphics_init()

◆ dttr_graphics_mod_present_rect_after()

void dttr_graphics_mod_present_rect_after ( DTTR_BackendState * state,
const DTTR_PresentRect * present,
bool overlay_rendered )

◆ dttr_graphics_mod_present_rect_before()

void dttr_graphics_mod_present_rect_before ( DTTR_BackendState * state,
const DTTR_PresentRect * present )

◆ dttr_graphics_present_video_frame_bgra()

bool dttr_graphics_present_video_frame_bgra ( const uint8_t * pixels,
int width,
int height,
int stride )

Definition at line 621 of file graphics.c.

References dttr_backend, state, and stride.

Referenced by dttr_movies_tick().

◆ dttr_graphics_set_logical_resolution()

void dttr_graphics_set_logical_resolution ( int width,
int height )

◆ get_hwnd()

HWND get_hwnd ( SDL_Window * window)
static

Definition at line 177 of file graphics.c.

References NULL.

Referenced by dttr_graphics_init().

◆ init_common_state()

◆ refresh_render_resolution()

void refresh_render_resolution ( DTTR_BackendState * state)
static

◆ select_backend_range()

backend_range select_backend_range ( DTTR_GraphicsApi api)
static

◆ select_render_resolution()

void select_render_resolution ( const DTTR_BackendState * state,
int * out_width,
int * out_height )
static

◆ update_window_title()

void update_window_title ( const DTTR_BackendState * state)
static

Definition at line 42 of file graphics.c.

References DTTR_VERSION, h, state, w, and window_title.

Referenced by dttr_graphics_handle_window_resize(), and dttr_graphics_init().

Variable Documentation

◆ backend_candidates

const backend_candidate backend_candidates[]
static
Initial value:
= {
{SDL_WINDOW_OPENGL, dttr_graphics_opengl_init},
}
bool dttr_graphics_opengl_init(DTTR_BackendState *state)
bool dttr_graphics_sdl3gpu_init(DTTR_BackendState *state)

Definition at line 26 of file graphics.c.

Referenced by dttr_graphics_init().

◆ window_title

sds window_title = NULL
static

Definition at line 34 of file graphics.c.

Referenced by DTTR_ImGui_ErrorShow(), DTTR_LoaderUI_ShowError(), and update_window_title().