Fix last commit

This commit is contained in:
UnknownShadow200 2024-04-25 09:10:42 +10:00
parent cf7b353572
commit 1b6bbbe6cf
5 changed files with 14 additions and 9 deletions

View File

@ -281,6 +281,9 @@ cc_bool Game_ValidateBitmapPow2(const cc_string* file, struct Bitmap* bmp) {
void Game_UpdateDimensions(void) {
Game.Width = max(Window_Main.Width, 1);
Game.Height = max(Window_Main.Height, 1);
Gfx.ViewportWidth = Game.Width;
Gfx.ViewportHeight = Game.Height;
}
static void Game_OnResize(void* obj) {
@ -402,6 +405,7 @@ static void Game_Load(void) {
Game_UpdateDimensions();
Game_SetFpsLimit(Options_GetEnum(OPT_FPS_LIMIT, 0, FpsLimit_Names, FPS_LIMIT_COUNT));
Gfx_Create();
Logger_WarnFunc = Game_WarnFunc;
LoadOptions();
GameVersion_Load();

View File

@ -66,6 +66,7 @@ CC_VAR extern struct _GfxData {
int MinTexWidth, MinTexHeight;
cc_bool ReducedPerfMode;
cc_uint8 ReducedPerfModeCooldown;
int ViewportX, ViewportY, ViewportWidth, ViewportHeight;
} Gfx;
extern GfxResourceID Gfx_defaultIb;

View File

@ -648,10 +648,10 @@ static void RS_CreateRasterState(void) {
static void RS_UpdateViewport(void) {
D3D11_VIEWPORT viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = Window_Main.Width;
viewport.Height = Window_Main.Height;
viewport.TopLeftX = Gfx.ViewportX;
viewport.TopLeftY = Gfx.ViewportY;
viewport.Width = Gfx.ViewportWidth;
viewport.Height = Gfx.ViewportHeight;
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
ID3D11DeviceContext_RSSetViewports(context, 1, &viewport);

View File

@ -2231,10 +2231,10 @@ static struct Widget* touch_widgets[ONSCREEN_MAX_BTNS + TOUCH_EXTRA_BTNS + 2] =
#define TOUCH_MAX_VERTICES (THUMBSTICKWIDGET_MAX + TOUCH_MAX_BTNS * BUTTONWIDGET_MAX)
static void TouchScreen_ChatClick(void* s, void* w) { ChatScreen_OpenInput(&String_Empty); }
static void TouchScreen_RespawnClick(void* s, void* w) { LocalPlayer_HandleRespawn(); }
static void TouchScreen_SetSpawnClick(void* s, void* w) { LocalPlayer_HandleSetSpawn(); }
static void TouchScreen_FlyClick(void* s, void* w) { LocalPlayer_HandleFly(); }
static void TouchScreen_NoclipClick(void* s, void* w) { LocalPlayer_HandleNoclip(); }
static void TouchScreen_RespawnClick(void* s, void* w) { LocalPlayer_HandleRespawn(&LocalPlayer_Instance); }
static void TouchScreen_SetSpawnClick(void* s, void* w) { LocalPlayer_HandleSetSpawn(&LocalPlayer_Instance); }
static void TouchScreen_FlyClick(void* s, void* w) { LocalPlayer_HandleFly(&LocalPlayer_Instance); }
static void TouchScreen_NoclipClick(void* s, void* w) { LocalPlayer_HandleNoclip(&LocalPlayer_Instance); }
static void TouchScreen_CameraClick(void* s, void* w) { Camera_CycleActive(); }
static void TouchScreen_MoreClick(void* s, void* w) { TouchMoreScreen_Show(); }
static void TouchScreen_SwitchClick(void* s, void* w) { Inventory_SwitchHotbar(); }

View File

@ -325,7 +325,7 @@ void Gfx_EndFrame(void) {
}
void Gfx_OnWindowResize(void) {
glViewport(0, 0, Game.Width, Game.Height);
glViewport(Gfx.ViewportX, Gfx.ViewportY, Gfx.ViewportWidth, Gfx.ViewportHeight);
/* With cocoa backend, in some cases [NSOpenGLContext update] will actually */
/* call glViewport with the size of the window framebuffer */
/* https://github.com/glfw/glfw/issues/80 */