mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-05-31 07:04:40 +00:00
Fix Vsync
This commit is contained in:
@@ -47,7 +47,6 @@ extern "C"
|
||||
}
|
||||
|
||||
HINSTANCE hMyInst;
|
||||
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
char chGlobalText[256];
|
||||
uint16_t ui16GlobalText[256];
|
||||
|
||||
@@ -56,15 +55,7 @@ uint16_t ui16GlobalText[256];
|
||||
#define NUM_PROFILE_SETTINGS 4
|
||||
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
{
|
||||
#ifdef _XBOX
|
||||
XPROFILE_OPTION_CONTROLLER_VIBRATION,
|
||||
XPROFILE_GAMER_YAXIS_INVERSION,
|
||||
XPROFILE_GAMER_CONTROL_SENSITIVITY,
|
||||
XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL,
|
||||
XPROFILE_TITLE_SPECIFIC1,
|
||||
#else
|
||||
0,0,0,0,0
|
||||
#endif
|
||||
};
|
||||
|
||||
// Screen resolution — auto-detected from the monitor at startup.
|
||||
@@ -74,13 +65,8 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
|
||||
int g_iScreenWidth = 1920;
|
||||
int g_iScreenHeight = 1080;
|
||||
|
||||
// Real window dimensions — updated on every WM_SIZE so the 3D perspective
|
||||
// always matches the current window, even after a resize.
|
||||
int g_rScreenWidth = 1920;
|
||||
int g_rScreenHeight = 1080;
|
||||
static bool f3ComboUsed = false;
|
||||
|
||||
float g_iAspectRatio = static_cast<float>(g_iScreenWidth) / g_iScreenHeight;
|
||||
static bool g_bResizeReady = false;
|
||||
|
||||
char g_Win64Username[17] = { 0 };
|
||||
@@ -90,12 +76,6 @@ wchar_t g_Win64UsernameW[17] = { 0 };
|
||||
static bool g_isFullscreen = false;
|
||||
static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
|
||||
|
||||
struct Win64LaunchOptions
|
||||
{
|
||||
int screenMode;
|
||||
bool fullscreen;
|
||||
};
|
||||
|
||||
// ---------- Persistent options (options.txt next to exe) ----------
|
||||
static void GetOptionsFilePath(char *out, size_t outSize)
|
||||
{
|
||||
@@ -294,59 +274,12 @@ void DefineActions(void)
|
||||
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN);
|
||||
}
|
||||
|
||||
#if 0
|
||||
HRESULT InitD3D( IDirect3DDevice9 **ppDevice,
|
||||
D3DPRESENT_PARAMETERS *pd3dPP )
|
||||
{
|
||||
IDirect3D9 *pD3D;
|
||||
|
||||
pD3D = Direct3DCreate9( D3D_SDK_VERSION );
|
||||
|
||||
// Set up the structure used to create the D3DDevice
|
||||
// Using a permanent 1280x720 backbuffer now no matter what the actual video resolution.right Have also disabled letterboxing,
|
||||
// which would letterbox a 1280x720 output if it detected a 4:3 video source - we're doing an anamorphic squash in this
|
||||
// mode so don't need this functionality.
|
||||
|
||||
ZeroMemory( pd3dPP, sizeof(D3DPRESENT_PARAMETERS) );
|
||||
XVIDEO_MODE VideoMode;
|
||||
XGetVideoMode( &VideoMode );
|
||||
g_bWidescreen = VideoMode.fIsWideScreen;
|
||||
pd3dPP->BackBufferWidth = 1280;
|
||||
pd3dPP->BackBufferHeight = 720;
|
||||
pd3dPP->BackBufferFormat = D3DFMT_A8R8G8B8;
|
||||
pd3dPP->BackBufferCount = 1;
|
||||
pd3dPP->EnableAutoDepthStencil = TRUE;
|
||||
pd3dPP->AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
pd3dPP->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
pd3dPP->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
//pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX;
|
||||
//ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled
|
||||
// in the launcher/dashboard.
|
||||
if(g_bWidescreen)
|
||||
pd3dPP->Flags=0;
|
||||
else
|
||||
pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX;
|
||||
|
||||
// Create the device.
|
||||
return pD3D->CreateDevice(
|
||||
0,
|
||||
D3DDEVTYPE_HAL,
|
||||
nullptr,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES,
|
||||
pd3dPP,
|
||||
ppDevice );
|
||||
}
|
||||
#endif
|
||||
//#define MEMORY_TRACKING
|
||||
|
||||
#ifdef MEMORY_TRACKING
|
||||
void ResetMem();
|
||||
void DumpMem();
|
||||
void MemPixStuff();
|
||||
#else
|
||||
void MemSect(int sect)
|
||||
{
|
||||
}
|
||||
void MemSect(int sect) {}
|
||||
#endif
|
||||
|
||||
HINSTANCE g_hInst = nullptr;
|
||||
@@ -408,7 +341,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
@@ -443,21 +376,30 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
int vk = static_cast<int>(wParam);
|
||||
if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK)
|
||||
break;
|
||||
#ifdef _WINDOWS64
|
||||
|
||||
const Minecraft* pm = Minecraft::GetInstance();
|
||||
ChatScreen* chat = pm && pm->screen ? dynamic_cast<ChatScreen*>(pm->screen) : nullptr;
|
||||
if (chat)
|
||||
{
|
||||
if (vk == 'V' && (GetKeyState(VK_CONTROL) & 0x8000))
|
||||
{ chat->handlePasteRequest(); break; }
|
||||
if ((vk == VK_UP || vk == VK_DOWN) && !(lParam & 0x40000000))
|
||||
{ if (vk == VK_UP) chat->handleHistoryUp(); else chat->handleHistoryDown(); break; }
|
||||
if (vk >= '1' && vk <= '9') // Prevent hotkey conflicts
|
||||
{
|
||||
chat->handlePasteRequest();
|
||||
break;
|
||||
}
|
||||
|
||||
if ((vk == VK_UP || vk == VK_DOWN) && !(lParam & 0x40000000))
|
||||
{
|
||||
if (vk == VK_UP)
|
||||
chat->handleHistoryUp();
|
||||
else
|
||||
chat->handleHistoryDown();
|
||||
break;
|
||||
}
|
||||
|
||||
if (vk == VK_SHIFT)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vk == VK_SHIFT)
|
||||
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
|
||||
else if (vk == VK_CONTROL)
|
||||
@@ -465,7 +407,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
else if (vk == VK_MENU)
|
||||
vk = (lParam & (1 << 24)) ? VK_RMENU : VK_LMENU;
|
||||
g_KBMInput.OnKeyDown(vk);
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
@@ -565,7 +507,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -577,23 +519,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
//
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEXW wcex;
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEXW);
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIconW(hInstance, L"Minecraft");
|
||||
wcex.hIcon = LoadIcon(hInstance, "Minecraft");
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = L"Minecraft";
|
||||
wcex.lpszClassName = L"MinecraftClass";
|
||||
wcex.hIconSm = LoadIconW(wcex.hInstance, MAKEINTRESOURCEW(IDI_MINECRAFTWINDOWS));
|
||||
wcex.lpszMenuName = "Minecraft";
|
||||
wcex.lpszClassName = "MinecraftClass";
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_MINECRAFTWINDOWS));
|
||||
|
||||
return RegisterClassExW(&wcex);
|
||||
return RegisterClassEx(&wcex);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -610,11 +552,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
g_hInst = hInstance; // Store instance handle in our global variable
|
||||
|
||||
RECT wr = {0, 0, g_rScreenWidth, g_rScreenHeight}; // set the size, but not the position
|
||||
RECT wr = {0, 0, g_iScreenWidth, g_iScreenHeight}; // set the size, but not the position
|
||||
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); // adjust the size
|
||||
|
||||
g_hWnd = CreateWindowW( L"MinecraftClass",
|
||||
L"Minecraft",
|
||||
g_hWnd = CreateWindow( "MinecraftClass",
|
||||
"Minecraft",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT,
|
||||
0,
|
||||
@@ -654,34 +596,6 @@ uint16_t *GetGlobalText()
|
||||
}
|
||||
return ui16GlobalText;
|
||||
}
|
||||
void SeedEditBox()
|
||||
{
|
||||
DialogBox(hMyInst, MAKEINTRESOURCE(IDD_SEED),
|
||||
g_hWnd, reinterpret_cast<DLGPROC>(DlgProc));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(Msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(wParam)
|
||||
{
|
||||
case IDOK:
|
||||
// Set the text
|
||||
GetDlgItemText(hWndDlg,IDC_EDIT,chGlobalText,256);
|
||||
EndDialog(hWndDlg, 0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Create Direct3D device and swap chain
|
||||
@@ -690,9 +604,9 @@ HRESULT InitDevice()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
UINT width = g_rScreenWidth;
|
||||
UINT height = g_rScreenHeight;
|
||||
//app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
UINT width = g_iScreenWidth;
|
||||
UINT height = g_iScreenHeight;
|
||||
app.DebugPrintf("width: %d, height: %d\n", width, height);
|
||||
|
||||
UINT createDeviceFlags = 0;
|
||||
#ifdef _DEBUG
|
||||
@@ -803,7 +717,6 @@ HRESULT InitDevice()
|
||||
vp.TopLeftY = 0;
|
||||
g_pImmediateContext->RSSetViewports( 1, &vp );
|
||||
|
||||
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||
PostProcesser::GetInstance().Init();
|
||||
|
||||
return S_OK;
|
||||
@@ -879,8 +792,8 @@ static bool ResizeD3D(int newW, int newH)
|
||||
*pRM_BBWidth, *pRM_BBHeight, oldScDesc.BufferDesc.Width, oldScDesc.BufferDesc.Height);
|
||||
}
|
||||
|
||||
RenderManager.Suspend();
|
||||
TrimMem();
|
||||
RenderManager.Suspend();
|
||||
while (!RenderManager.Suspended())
|
||||
Sleep(1);
|
||||
|
||||
@@ -1025,8 +938,8 @@ static bool ResizeD3D(int newW, int newH)
|
||||
ui.updateScreenSize(bbW, bbH);
|
||||
|
||||
// Track actual backbuffer dimensions for the rest of the engine
|
||||
g_rScreenWidth = bbW;
|
||||
g_rScreenHeight = bbH;
|
||||
g_iScreenWidth = bbW;
|
||||
g_iScreenHeight = bbH;
|
||||
|
||||
success = true;
|
||||
|
||||
@@ -1075,17 +988,17 @@ postReset:
|
||||
// If it's the NEW one (partial failure after swap), update to new dims.
|
||||
if (g_pSwapChain != pOldSwapChain)
|
||||
{
|
||||
g_rScreenWidth = recW;
|
||||
g_rScreenHeight = recH;
|
||||
g_iScreenWidth = recW;
|
||||
g_iScreenHeight = recH;
|
||||
ui.updateScreenSize(recW, recH);
|
||||
}
|
||||
|
||||
app.DebugPrintf("[RESIZE] FAILED but recovered views at %dx%d\n", g_rScreenWidth, g_rScreenHeight);
|
||||
app.DebugPrintf("[RESIZE] FAILED but recovered views at %dx%d\n", g_iScreenWidth, g_iScreenHeight);
|
||||
}
|
||||
g_pImmediateContext->Flush();
|
||||
|
||||
gdraw_D3D11_PostReset();
|
||||
gdraw_D3D11_SetRendertargetSize(g_rScreenWidth, g_rScreenHeight);
|
||||
gdraw_D3D11_SetRendertargetSize(g_iScreenWidth, g_iScreenHeight);
|
||||
if (success)
|
||||
IggyFlushInstalledFonts();
|
||||
|
||||
@@ -1175,10 +1088,10 @@ static Minecraft* InitialiseMinecraftRuntime()
|
||||
{
|
||||
app.loadMediaArchive();
|
||||
|
||||
// RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||
|
||||
app.loadStringTable();
|
||||
ui.init(g_pd3dDevice, g_pImmediateContext, g_pRenderTargetView, g_pDepthStencilView, g_rScreenWidth, g_rScreenHeight);
|
||||
ui.init(g_pd3dDevice, g_pImmediateContext, g_pRenderTargetView, g_pDepthStencilView, g_iScreenWidth, g_iScreenHeight);
|
||||
|
||||
InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU);
|
||||
g_KBMInput.Init();
|
||||
@@ -1238,8 +1151,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_ LPTSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
// Init our exception handler
|
||||
//SetUnhandledExceptionFilter(CConsoleMinecraftApp::UnhandledExceptionFilter);
|
||||
|
||||
// 4J-Win64: set CWD to exe dir so asset paths resolve correctly
|
||||
{
|
||||
@@ -1251,12 +1164,9 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
|
||||
// Declare DPI awareness so GetSystemMetrics returns physical pixels
|
||||
SetProcessDPIAware();
|
||||
// Use the native monitor resolution for the window and swap chain,
|
||||
// but keep g_iScreenWidth/Height at 1920x1080 for logical resolution
|
||||
// (SWF selection, ortho projection, game logic). The real window
|
||||
// dimensions are tracked by g_rScreenWidth/g_rScreenHeight.
|
||||
g_rScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
g_rScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
// Use the native monitor resolution for the window and swap chain
|
||||
g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
// Load username from username.txt
|
||||
char exePath[MAX_PATH] = {};
|
||||
|
||||
Reference in New Issue
Block a user