mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
104a9cbffd
## Link to GitHub Issue, if one exists Fixes #276 ## Description of change Note: this change is not compatible with previous screen resize config; i.e., if you had the zoom setting dialed into a certain view, after this change it won't be the same area, so you'll have to set up a scene again. I think this is a worthwhile cost since the old logic is just broken in weird ways, and preserving old settings is really tedious math (for a feature that not many people use). Besides, this change will only use the new Scenes values from the JSON. Rewrite the DX9 image scaler logic. * Previously, the rendering surface was fixed at `4096*4096 px`. Now, this is relative to the backbuffer dimensions, which depends on the game & respects user provided `-forceres`. * Remove "center" option, make it the default. Above two changes fix the aspect ratio issue (scaling in portrait games not respecting screen ratio) and things breaking at higher res (1080p when zoomed out far enough, or when forced to run at 4k resolution for example) * Use `scenes` leaf of screen resize JSON config for Scene 1 as well, completely removing ourselves from being compatible with older spice2x versions for these values. * Add additional bounds check before calling `StretchRect` to avoid users getting stuck with a bad layout, which can kill performance. ## Compiling 🦾 ## Testing Tested 32 bit (popn / ddr), 64 bit (ldj), portrait and landscape modes (kfc)
101 lines
3.4 KiB
C++
101 lines
3.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <cstdint>
|
|
|
|
#include <windows.h>
|
|
#include <d3d9.h>
|
|
|
|
#include "external/toojpeg/toojpeg.h"
|
|
|
|
// order must match spice2x_AutoOrientation UI enum order
|
|
enum graphics_orientation {
|
|
ORIENTATION_CW = 0,
|
|
ORIENTATION_CCW = 1,
|
|
ORIENTATION_NORMAL = 2,
|
|
};
|
|
|
|
enum graphics_dx9on12_state {
|
|
DX9ON12_AUTO,
|
|
DX9ON12_FORCE_OFF,
|
|
DX9ON12_FORCE_ON,
|
|
};
|
|
|
|
// flag settings
|
|
extern bool GRAPHICS_CAPTURE_CURSOR;
|
|
extern bool GRAPHICS_LOG_HRESULT;
|
|
extern bool GRAPHICS_SDVX_FORCE_720;
|
|
extern bool GRAPHICS_SHOW_CURSOR;
|
|
extern bool GRAPHICS_WINDOWED;
|
|
extern graphics_orientation GRAPHICS_ADJUST_ORIENTATION;
|
|
extern std::vector<HWND> GRAPHICS_WINDOWS;
|
|
extern UINT GRAPHICS_FORCE_REFRESH;
|
|
extern std::optional<int> GRAPHICS_FORCE_VSYNC_BUFFER;
|
|
extern bool GRAPHICS_FORCE_SINGLE_ADAPTER;
|
|
extern bool GRAPHICS_PREVENT_SECONDARY_WINDOW;
|
|
extern std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_FS_CUSTOM_RESOLUTION;
|
|
extern bool GRAPHICS_FS_ORIENTATION_SWAP;
|
|
extern uint32_t GRAPHICS_FS_ORIGINAL_WIDTH;
|
|
extern uint32_t GRAPHICS_FS_ORIGINAL_HEIGHT;
|
|
|
|
extern graphics_dx9on12_state GRAPHICS_9_ON_12_STATE;
|
|
extern bool GRAPHICS_9_ON_12_REQUESTED_BY_GAME;
|
|
|
|
extern std::optional<int> GRAPHICS_WINDOW_STYLE;
|
|
extern std::optional<std::pair<uint32_t, uint32_t>> GRAPHICS_WINDOW_SIZE;
|
|
extern std::optional<std::string> GRAPHICS_WINDOW_POS;
|
|
extern bool GRAPHICS_WINDOW_ALWAYS_ON_TOP;
|
|
extern bool GRAPHICS_WINDOW_BACKBUFFER_SCALE;
|
|
|
|
extern bool GRAPHICS_IIDX_WSUB;
|
|
extern std::optional<std::string> GRAPHICS_IIDX_WSUB_SIZE;
|
|
extern std::optional<std::string> GRAPHICS_IIDX_WSUB_POS;
|
|
extern int GRAPHICS_IIDX_WSUB_WIDTH;
|
|
extern int GRAPHICS_IIDX_WSUB_HEIGHT;
|
|
extern int GRAPHICS_IIDX_WSUB_X;
|
|
extern int GRAPHICS_IIDX_WSUB_Y;
|
|
extern HWND TDJ_SUBSCREEN_WINDOW;
|
|
extern HWND SDVX_SUBSCREEN_WINDOW;
|
|
|
|
extern bool SUBSCREEN_FORCE_REDRAW;
|
|
|
|
// settings
|
|
extern std::string GRAPHICS_DEVICEID;
|
|
extern std::string GRAPHICS_SCREENSHOT_DIR;
|
|
|
|
// Direct3D 9 settings
|
|
extern std::optional<UINT> D3D9_ADAPTER;
|
|
extern DWORD D3D9_BEHAVIOR_DISABLE;
|
|
extern bool D3D9_DEVICE_HOOK_DISABLE;
|
|
|
|
void graphics_init();
|
|
void graphics_hook_window(HWND hWnd, D3DPRESENT_PARAMETERS *pPresentationParameters);
|
|
void graphics_add_wnd_proc(WNDPROC wndProc);
|
|
void graphics_remove_wnd_proc(WNDPROC wndProc);
|
|
void graphics_hook_subscreen_window(HWND hWnd);
|
|
void graphics_screens_register(int screen);
|
|
void graphics_screens_unregister(int screen);
|
|
void graphics_screens_get(std::vector<int> &screens);
|
|
void graphics_screenshot_trigger();
|
|
bool graphics_screenshot_consume();
|
|
void graphics_capture_trigger(int screen);
|
|
bool graphics_capture_consume(int *screen);
|
|
void graphics_capture_enqueue(int screen, uint8_t *data, size_t width, size_t height);
|
|
void graphics_capture_skip(int screen);
|
|
bool graphics_capture_receive_jpeg(int screen, TooJpeg::WRITE_ONE_BYTE receiver,
|
|
bool rgb = true, int quality = 80, bool downsample = true, int divide = 0,
|
|
uint64_t *timestamp = nullptr,
|
|
int *width = nullptr, int *height = nullptr);
|
|
std::string graphics_screenshot_genpath();
|
|
|
|
// graphics_windowed.cpp
|
|
void graphics_windowed_wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
void graphics_capture_initial_window(HWND hWnd);
|
|
void graphics_update_window_style(HWND hWnd);
|
|
void graphics_update_z_order(HWND hWnd);
|
|
void graphics_move_resize_window(HWND hWnd);
|
|
bool graphics_window_change_crashes_game();
|
|
void graphics_load_windowed_subscreen_parameters();
|