BOOL gldResizeDrawable_DX( DGL_ctx *ctx, BOOL bDefaultDriver, BOOL bPersistantInterface, BOOL bPersistantBuffers) { GLD_driver_dx8 *gld = NULL; D3DDEVTYPE d3dDevType; D3DPRESENT_PARAMETERS d3dpp; D3DDISPLAYMODE d3ddm; HRESULT hResult; // Error if context is NULL. if (ctx == NULL) return FALSE; gld = ctx->glPriv; if (gld == NULL) return FALSE; if (ctx->bSceneStarted) { IDirect3DDevice8_EndScene(gld->pDev); ctx->bSceneStarted = FALSE; } d3dDevType = (glb.dwDriver == GLDS_DRIVER_HAL) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; if (!bDefaultDriver) d3dDevType = D3DDEVTYPE_REF; // Force Direct3D Reference Rasterise (software) // Get the display mode so we can make a compatible backbuffer hResult = IDirect3D8_GetAdapterDisplayMode(gld->pD3D, glb.dwAdapter, &d3ddm); if (FAILED(hResult)) { nContextError = GLDERR_D3D; // goto return_with_error; return FALSE; } // Destroy DX8 Vertex Shaders before Reset() // _gldDestroyVertexShaders(gld); // Release POOL_DEFAULT objects before Reset() if (gld->PB2d.dwPool == D3DPOOL_DEFAULT) _gldDestroyPrimitiveBuffer(&gld->PB2d); if (gld->PB3d.dwPool == D3DPOOL_DEFAULT) _gldDestroyPrimitiveBuffer(&gld->PB3d); // if (gld->PBtwosidelight.dwPool == D3DPOOL_DEFAULT) // _gldDestroyPrimitiveBuffer(&gld->PBtwosidelight); // Clear the presentation parameters (sets all members to zero) ZeroMemory(&d3dpp, sizeof(d3dpp)); // Recommended by MS; needed for MultiSample. // Be careful if altering this for FullScreenBlit d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.BackBufferCount = 1; d3dpp.MultiSampleType = _gldGetDeviceMultiSampleType(gld->pD3D, d3ddm.Format, d3dDevType, !ctx->bFullscreen); d3dpp.AutoDepthStencilFormat = ctx->lpPF->dwDriverData; d3dpp.EnableAutoDepthStencil = (d3dpp.AutoDepthStencilFormat == D3DFMT_UNKNOWN) ? FALSE : TRUE; // TODO: Sync to refresh if (ctx->bFullscreen) { ddlogWarnOption(FALSE); // Don't popup any messages in fullscreen d3dpp.Windowed = FALSE; d3dpp.BackBufferWidth = d3ddm.Width; d3dpp.BackBufferHeight = d3ddm.Height; d3dpp.hDeviceWindow = ctx->hWnd; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; // Get better benchmark results? KeithH // d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_UNLIMITED; } else { ddlogWarnOption(glb.bMessageBoxWarnings); // OK to popup messages d3dpp.Windowed = TRUE; d3dpp.BackBufferWidth = ctx->dwWidth; d3dpp.BackBufferHeight = ctx->dwHeight; d3dpp.hDeviceWindow = ctx->hWnd; d3dpp.FullScreen_RefreshRateInHz = 0; d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; } hResult = IDirect3DDevice8_Reset(gld->pDev, &d3dpp); if (FAILED(hResult)) { ddlogError(DDLOG_CRITICAL_OR_WARN, "dglResize: Reset failed", hResult); return FALSE; //goto cleanup_and_return_with_error; } // Explicitly Clear resized surfaces (DaveM) { D3DVIEWPORT8 d3dvp1, d3dvp2; IDirect3DDevice8_GetViewport(gld->pDev, &d3dvp1); IDirect3DDevice8_GetViewport(gld->pDev, &d3dvp2); d3dvp1.X = 0; d3dvp1.Y = 0; d3dvp1.Width = ctx->dwWidth; d3dvp1.Height = ctx->dwHeight; IDirect3DDevice8_SetViewport(gld->pDev, &d3dvp1); IDirect3DDevice8_Clear(gld->pDev,0,NULL,D3DCLEAR_TARGET,0,0,0); IDirect3DDevice8_SetViewport(gld->pDev, &d3dvp2); } // // Recreate POOL_DEFAULT objects // if (gld->PB2d.dwPool == D3DPOOL_DEFAULT) { _gldCreatePrimitiveBuffer(ctx->glCtx, gld, &gld->PB2d); } if (gld->PB3d.dwPool == D3DPOOL_DEFAULT) { _gldCreatePrimitiveBuffer(ctx->glCtx, gld, &gld->PB3d); } // if (gld->PBtwosidelight.dwPool == D3DPOOL_DEFAULT) { // _gldCreatePrimitiveBuffer(ctx->glCtx, gld, &gld->PB2d); // } // Recreate DX8 Vertex Shaders // _gldCreateVertexShaders(gld); // Signal a complete state update ctx->glCtx->Driver.UpdateState(ctx->glCtx, _NEW_ALL); // Begin a new scene IDirect3DDevice8_BeginScene(gld->pDev); ctx->bSceneStarted = TRUE; return TRUE; }
static HRESULT d3d_device_clear(d3d_device *dev, DWORD count, const D3DRECT *rects, DWORD flags, D3DCOLOR color, float z, DWORD stencil) { IDirect3DDevice8 *device = (IDirect3DDevice8 *)dev; return IDirect3DDevice8_Clear(device, count, rects, flags, color, z, stencil); }