GFXPC refactor

This commit is contained in:
louist103 2025-01-26 21:21:29 -05:00
parent 83000e2f6a
commit b8814ef00f
3 changed files with 18 additions and 19 deletions

View File

@ -60,6 +60,7 @@ void AdvancedResolutionSettingsWindow::InitElement() {
}
void AdvancedResolutionSettingsWindow::DrawElement() {
GfxPc* gfxPc = GfxPc::GetInstance();
// Initialise update flags.
bool update[3];
for (uint8_t i = 0; i < sizeof(update); i++)
@ -71,13 +72,13 @@ void AdvancedResolutionSettingsWindow::DrawElement() {
short integerScale_maximumBounds = 1; // can change when window is resized
// This is mostly just for UX purposes, as Fit Automatically logic is part of LUS.
if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) >
((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) {
if (((float)gfxPc->mGameWindowViewport.width / gfxPc->mGameWindowViewport.height) >
((float)gfxPc->mCurDimensions.width / gfxPc->mCurDimensions.height)) {
// Scale to window height
integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height;
integerScale_maximumBounds = gfxPc->mGameWindowViewport.height / gfxPc->mCurDimensions.height;
} else {
// Scale to window width
integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width;
integerScale_maximumBounds = gfxPc->mGameWindowViewport.width / gfxPc->mCurDimensions.width;
}
// Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS.
// Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded.
@ -161,9 +162,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() {
}
}
// Resolution visualiser
ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width,
gfx_current_game_window_viewport.height);
ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height);
ImGui::Text("Viewport dimensions: %d x %d", gfxPc->mGameWindowViewport.width,
gfxPc->mGameWindowViewport.height);
ImGui::Text("Internal resolution: %d x %d", gfxPc->mCurDimensions.width, gfxPc->mCurDimensions.height);
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
if (disabled_everything) { // Hide aspect ratio controls.
@ -203,7 +204,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() {
} else if (showHorizontalResField) { // Show calculated aspect ratio
if (item_aspectRatio) {
UIWidgets::Spacer(2);
const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height;
const float resolvedAspectRatio = (float)gfxPc->mCurDimensions.width / gfxPc->mCurDimensions.height;
ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio);
} else {
UIWidgets::Spacer(enhancementSpacerHeight);

View File

@ -1439,7 +1439,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
if (prevAltAssets != curAltAssets) {
prevAltAssets = curAltAssets;
Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);
gfx_texture_cache_clear();
GfxPc::GetInstance()->TextureCacheClear();
SOH::SkeletonPatcher::UpdateSkeletons();
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
}
@ -1790,7 +1790,7 @@ extern "C" void OTRControllerCallback(uint8_t rumble) {
}
extern "C" float OTRGetAspectRatio() {
return gfx_current_dimensions.aspect_ratio;
return GfxPc::GetInstance()->mCurDimensions.aspect_ratio;
}
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
@ -1803,12 +1803,12 @@ extern "C" float OTRGetDimensionFromRightEdge(float v) {
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
return gfx_current_dimensions.width;
return GfxPc::GetInstance()->mCurDimensions.width;
}
// Gets the height of the current render target area
extern "C" uint32_t OTRGetGameRenderHeight() {
return gfx_current_dimensions.height;
return GfxPc::GetInstance()->mCurDimensions.height;
}
f32 floorf(f32 x);// RANDOTODO False positive error "allowing all exceptions is incompatible with previous function"
@ -2373,11 +2373,11 @@ extern "C" void EntranceTracker_SetLastEntranceOverride(s16 entranceIndex) {
}
extern "C" void Gfx_RegisterBlendedTexture(const char* name, u8* mask, u8* replacement) {
gfx_register_blended_texture(name, mask, replacement);
GfxPc::GetInstance()->RegisterBlendedTexture(name, mask, replacement);
}
extern "C" void Gfx_UnregisterBlendedTexture(const char* name) {
gfx_unregister_blended_texture(name);
GfxPc::GetInstance()->UnregisterBlendedTexture(name);
}
extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) {
@ -2390,8 +2390,7 @@ extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) {
if (ResourceMgr_OTRSigCheck(imgName)) {
texAddr = (const uint8_t*)ResourceMgr_GetResourceDataByNameHandlingMQ(imgName);
}
gfx_texture_cache_delete(texAddr);
GfxPc::GetInstance()->TextureCacheDelete(texAddr);
}
void SoH_ProcessDroppedFiles(std::string filePath) {

View File

@ -2,8 +2,7 @@
#include "global.h"
#include "OTRGlobals.h"
int gfx_create_framebuffer(uint32_t width, uint32_t height, uint32_t native_width, uint32_t native_height,
uint8_t resize);
int gfx_create_framebuffer(uint32_t width, uint32_t height, uint32_t native_width, uint32_t native_height,uint8_t resize);
s32 gPauseFrameBuffer = -1;
s32 gBlurFrameBuffer = -1;