Mercurial > mm7
diff Render.cpp @ 1802:633f81bb3ae7
HWND -> class OSWindow
author | Nomad |
---|---|
date | Mon, 07 Oct 2013 11:52:33 +0200 |
parents | 4da5644df18f |
children | 9f93b5700e2d |
line wrap: on
line diff
--- a/Render.cpp Tue Oct 01 06:19:58 2013 +0200 +++ b/Render.cpp Mon Oct 07 11:52:33 2013 +0200 @@ -2094,16 +2094,16 @@ hd_water_current_frame = 0; } -bool Render::Initialize(bool bWindowed, int windowed_width, int windowed_height, uint32_t uDefaultDevice, - bool bColoredLights, uint32_t uDetailLevel, bool bTinting) +bool Render::Initialize(bool bWindowed, OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) { - bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); - + //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); + + this->window = window; bStartInWindow = bWindowed; - windowed_mode_width = windowed_width; - windowed_mode_height = windowed_height; - - uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); + //windowed_mode_width = windowed_width; + //windowed_mode_height = windowed_height; + + uDesiredDirect3DDevice = 0;//ReadWindowsRegistryInt("D3D Device", 1); bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); @@ -2186,7 +2186,7 @@ RECT x; // [sp+68h] [bp-10h]@3 memset(&v3, 0, sizeof(DDBLTFX)); - GetWindowRect(hWnd, &x); + GetWindowRect(window->GetApiHandle(), &x); if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5) { @@ -2909,8 +2909,8 @@ pRenderD3D->Present(false); } } - else - { + else __debugbreak(); // no sr + /*{ if ( v1->bWindowMode ) { RestoreFrontBuffer(); @@ -2934,7 +2934,7 @@ a4.right = 640; BltBackToFontFast(0, 0, &a4); } - } + }*/ } } @@ -2979,9 +2979,9 @@ void Render::Release() { Render *v1; // esi@1 - RenderD3D *v2; // ecx@1 - char v3; // zf@4 - void *v4; // ebx@6 + //RenderD3D *v2; // ecx@1 + //char v3; // zf@4 + //void *v4; // ebx@6 IDirectDraw *v5; // eax@10 IDirectDrawSurface2 *v6; // eax@11 IDirectDrawSurface2 *v7; // eax@13 @@ -2996,36 +2996,34 @@ void **v16; // esi@29 v1 = this; - v2 = this->pRenderD3D; - if ( v2 ) + if (pRenderD3D) { if ( v1->field_40110 ) { - pRenderD3D->ClearTarget(1u, 0, 0, 1.0); + pRenderD3D->ClearTarget(true, 0, false, 1.0); pRenderD3D->Present(0); - pRenderD3D->ClearTarget(1u, 0, 0, 1.0); + pRenderD3D->ClearTarget(true, 0, false, 1.0); } v1->pColorKeySurface4 = 0; v1->pBackBuffer4 = 0; - v3 = v1->pTargetSurface == 0; v1->pFrontBuffer4 = 0; v1->pDirectDraw4 = 0; - if ( !v3 ) + if (v1->pTargetSurface) { free(v1->ptr_400E8); v1->pTargetSurface = 0; v1->ptr_400E8 = 0; } - v4 = v1->pRenderD3D; - if ( v4 ) + if (pRenderD3D) { pRenderD3D->Release(); - free(v4); - } - v1->pRenderD3D = 0; + delete pRenderD3D; + } + pRenderD3D = 0; } else - { + ;//__debugbreak(); // no sr + /*{ if ( bWinNT4_0 == 1 ) { v5 = (IDirectDraw *)v1->pDirectDraw2; @@ -3098,7 +3096,7 @@ *v15 = 0; *v16 = 0; } - } + }*/ } //----- (0049FFD7) -------------------------------------------------------- @@ -3108,7 +3106,7 @@ } //----- (0049FFFB) -------------------------------------------------------- -bool Render::InitializeFullscreen(HWND hWnd) +bool Render::InitializeFullscreen() { //Render *v2; // esi@1 //HWND v3; // ebx@1 @@ -3147,10 +3145,19 @@ this->bColorKeySupported = 0; Release(); //v3 = hWnd; - this->hWnd = hWnd; + this->window = window; CreateZBuffer(); - if ( bUserDirect3D ) - { + + /*if (!bUserDirect3D) + { + CreateDirectDraw(); + SetDirectDrawCooperationMode(hWnd, 1); + SetDirectDrawDisplayMode(640u, 480u, 16u); + CreateDirectDrawPrimarySurface(); + v15 = 1; + } + else + {*/ pRenderD3D = new RenderD3D; v28 = pRenderD3D; v6 = uDesiredDirect3DDevice; @@ -3158,14 +3165,14 @@ v7 = pRenderD3D->pAvailableDevices; if ( v7[v6].bIsDeviceCompatible ) { - v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); + v8 = pRenderD3D->CreateDevice(v6, 0, window->GetApiHandle()); uAcquiredDirect3DDevice = uDesiredDirect3DDevice; } else { if ( v7[1].bIsDeviceCompatible ) { - v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); + v8 = pRenderD3D->CreateDevice(1u, 0, window->GetApiHandle()); uAcquiredDirect3DDevice = 1; } else @@ -3173,7 +3180,7 @@ if ( !v7->bIsDeviceCompatible ) Error("There aren't any D3D devices to create."); - v8 = pRenderD3D->CreateDevice(0, 0, hWnd); + v8 = pRenderD3D->CreateDevice(0, 0, window->GetApiHandle()); uAcquiredDirect3DDevice = 0; } } @@ -3261,15 +3268,7 @@ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); - } - else - { - CreateDirectDraw(); - SetDirectDrawCooperationMode(hWnd, 1); - SetDirectDrawDisplayMode(640u, 480u, 16u); - CreateDirectDrawPrimarySurface(); - v15 = 1; - } + //} ddpfPrimareSuface.dwSize = 32; GetTargetPixelFormat(&ddpfPrimareSuface); ParseTargetPixelFormat(); @@ -3329,7 +3328,7 @@ } //----- (004A05F3) -------------------------------------------------------- -bool Render::SwitchToWindow(HWND hWnd) +bool Render::SwitchToWindow() { //Render *v2; // esi@1 //void *v3; // eax@2 @@ -3371,8 +3370,19 @@ pDirectDraw4 = 0; bColorKeySupported = 0; CreateZBuffer(); - if ( bUserDirect3D ) - { + /*if (!bUserDirect3D) + { + CreateDirectDraw(); + SetDirectDrawCooperationMode(hWnd, 0); + field_4004C = 1; + CreateFrontBuffer(); + CreateClipper(hWnd); + CreateBackBuffer(); + field_40030 = 0; + field_18_locked_pitch = 0; + } + else + {*/ /*v3 = malloc(0x148u); thisa = (RenderD3D *)v3; v29 = 0; @@ -3388,7 +3398,7 @@ if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && uDesiredDirect3DDevice != 1 ) { - v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); + v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, window->GetApiHandle()); uAcquiredDirect3DDevice = uDesiredDirect3DDevice; } else @@ -3396,7 +3406,7 @@ if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) Error("There aren't any D3D devices to init."); - v7 = pRenderD3D->CreateDevice(0, 1, hWnd); + v7 = pRenderD3D->CreateDevice(0, 1, window->GetApiHandle()); uAcquiredDirect3DDevice = 0; } if ( !v7 ) @@ -3480,18 +3490,8 @@ ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); - } - else - { - CreateDirectDraw(); - SetDirectDrawCooperationMode(hWnd, 0); - field_4004C = 1; - CreateFrontBuffer(); - CreateClipper(hWnd); - CreateBackBuffer(); - field_40030 = 0; - field_18_locked_pitch = 0; - } + //} + ddpfPrimareSuface.dwSize = 32; GetTargetPixelFormat(&ddpfPrimareSuface); ParseTargetPixelFormat(); @@ -3523,7 +3523,7 @@ field_40110 = 1; LABEL_47: bWindowMode = 1; - hWnd = hWnd; + //hWnd = hWnd; return 0; } pTargetSurface = 0; @@ -3997,7 +3997,8 @@ pDirectDraw2 = nullptr; pDirectDraw4 = nullptr; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); else ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); @@ -4018,7 +4019,8 @@ flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); else ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); @@ -4027,7 +4029,8 @@ //----- (004A11C6) -------------------------------------------------------- void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) { - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); else ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); @@ -4046,7 +4049,8 @@ DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 v1 = this; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) { memset(&a2, 0, 0x7Cu); pDD = (IDirectDraw *)v1->pDirectDraw4; @@ -4086,7 +4090,8 @@ DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 v1 = this; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) { memset(&a2, 0, 0x7Cu); v2 = (IDirectDraw *)v1->pDirectDraw4; @@ -4140,7 +4145,8 @@ int a4; // [sp+98h] [bp-8h]@3 v1 = this; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) { v2 = 0; this->field_4004C = 1; @@ -4191,7 +4197,8 @@ //----- (004A14F4) -------------------------------------------------------- void Render::CreateClipper(HWND a2) { - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) { ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); ErrD3D(pDDrawClipper->SetHWnd(0, a2)); @@ -4209,7 +4216,8 @@ { IDirectDrawSurface *v2; // eax@3 - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) v2 = (IDirectDrawSurface *)this->pFrontBuffer4; else v2 = (IDirectDrawSurface *)this->pFrontBuffer2; @@ -4223,7 +4231,8 @@ signed int v4; // eax@3 v3 = this; - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) { DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc, 0, 0x7Cu); @@ -4244,16 +4253,11 @@ *pOutPixelsPerRow = v4 >> 1; } -//----- (004A169E) -------------------------------------------------------- -bool Render::UsingDirect3D() -{ - return bUserDirect3D == 0; -} - //----- (004A16E1) -------------------------------------------------------- void Render::UnlockBackBuffer() { - if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) + if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + pVersion->pVersionInfo.dwMajorVersion != 4 ) ErrD3D(pBackBuffer4->Unlock(0)); else ErrD3D(pBackBuffer2->Unlock(0)); @@ -8316,17 +8320,19 @@ } if ( pRenderer->bWindowMode ) { - SetMenu(hWnd, 0); - SetWindowLongA(hWnd, -20, 0); - SetWindowLongA(hWnd, -16, 0x10000000u); - pRenderer->InitializeFullscreen(hWnd); + //SetMenu(hWnd, 0); + //SetWindowLongA(hWnd, -20, 0); + //SetWindowLongA(hWnd, -16, 0x10000000u); + window->SetFullscreenMode(); + pRenderer->InitializeFullscreen(); v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; pGame->pGammaController->Initialize(v0); } else { - ClipCursor(0); - pRenderer->SwitchToWindow(hWnd); + //ClipCursor(0); + window->SetWindowedMode(window->GetWidth(), window->GetHeight()); + pRenderer->SwitchToWindow(); } if ( pRenderer->pRenderD3D ) { @@ -8379,13 +8385,13 @@ viewparams->bRedrawGameUI = 1; viewparams->InitGrayPalette(); pMouse->SetCurrentCursorBitmap(); - if ( pRenderer->bWindowMode ) + /*if ( pRenderer->bWindowMode ) { //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); ShowWindow(hWnd, SW_SHOWNORMAL); - } - pMouse->bActive = 1; + }*/ + pMouse->bActive = true; if ( pVideoPlayer->AnyMovieLoaded() ) pVideoPlayer->SelectMovieType(); if (dword_6BE364_game_settings_1 & 0x0800 )