bool COpenGL::ChangeDrawSurfaceSize(unsigned int width, unsigned int height) { DestroyDrawSurface(); CreateDrawSurface(width, height); SetupVertices(); return true; }
bool COpenGL::ChangeDrawSurfaceSize(unsigned int scale) { filterScale = scale; DestroyDrawSurface(); CreateDrawSurface(); SetupVertices(); return true; }
/* CDirect3D::ResetDevice resets the device called if surface was lost or the settings/display size require a device reset ----- returns true if successful, false otherwise */ bool CDirect3D::ResetDevice() { if(!init_done) return false; HRESULT hr; //release prior to reset DestroyDrawSurface(); if(cgAvailable) { cgShader->OnLostDevice(); cgD3D9SetDevice(NULL); } //zero or unknown values result in the current window size/display settings dPresentParams.BackBufferWidth = 0; dPresentParams.BackBufferHeight = 0; dPresentParams.BackBufferCount = GUI.DoubleBuffered?2:1; dPresentParams.BackBufferFormat = D3DFMT_UNKNOWN; dPresentParams.FullScreen_RefreshRateInHz = 0; dPresentParams.Windowed = true; dPresentParams.PresentationInterval = GUI.Vsync?D3DPRESENT_INTERVAL_ONE:D3DPRESENT_INTERVAL_IMMEDIATE; dPresentParams.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; if(fullscreen) { dPresentParams.BackBufferWidth = GUI.FullscreenMode.width; dPresentParams.BackBufferHeight = GUI.FullscreenMode.height; dPresentParams.BackBufferCount = GUI.DoubleBuffered?2:1; dPresentParams.Windowed = false; if(GUI.FullscreenMode.depth == 32) dPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8; else dPresentParams.BackBufferFormat = D3DFMT_R5G6B5; dPresentParams.FullScreen_RefreshRateInHz = GUI.FullscreenMode.rate; } if(FAILED(hr = pDevice->Reset(&dPresentParams))) { DXTRACE_ERR(TEXT("Unable to reset device"), hr); return false; } if(cgAvailable) { cgD3D9SetDevice(pDevice); cgShader->OnResetDevice(); } pDevice->SetRenderState(D3DRS_LIGHTING, FALSE); pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); //recreate the surface CreateDrawSurface(); SetViewport(); return true; }
/* CDirect3D::ChangeDrawSurfaceSize changes the draw surface size: deletes the old textures, creates a new texture and calculate new vertices IN: scale - the scale that has to fit into the textures ----- returns true if successful, false otherwise */ bool CDirect3D::ChangeDrawSurfaceSize(unsigned int scale) { filterScale = scale; if(pDevice) { DestroyDrawSurface(); CreateDrawSurface(); SetupVertices(); return true; } return false; }