void ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat, const IntRect& aRect, uint32_t aFlags) { // If we hit this assertion, then it might be due to an empty transaction // followed by a real transaction. Our buffers should be created (but not // painted in the empty transaction) and then painted (but not created) in the // real transaction. That is kind of fragile, and this assert will catch // circumstances where we screw that up, e.g., by unnecessarily recreating our // buffers. MOZ_ASSERT(!mIsNewBuffer, "Bad! Did we create a buffer twice without painting?"); mIsNewBuffer = true; DestroyBuffers(); mSurfaceFormat = aFormat; mSize = IntSize(aRect.width, aRect.height); mTextureFlags = TextureFlagsForRotatedContentBufferFlags(aFlags); if (aFlags & BUFFER_COMPONENT_ALPHA) { mTextureFlags |= TextureFlags::COMPONENT_ALPHA; } CreateBackBuffer(mBufferRect); }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hinst = hInstance; nShowCmd = nCmdShow; MainWindowRect.left = 0; MainWindowRect.top = 0; MainWindowRect.right = _WINWIDTH; MainWindowRect.bottom = _WINHEIGHT; hMainWindow = CreateWindow( APPNAME, APPNAME, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, _WINWIDTH, _WINHEIGHT, NULL, NULL, hinst, NULL); CreateBackBuffer(); ShowWindow(hMainWindow, nCmdShow); UpdateWindow(hMainWindow); Initialized = Initialize(); return (TRUE); }
clsDXDevice::clsDXDevice(HWND wndHandle) { CreateDirect9(); CreateD3D_Para(); CreateDXDevice(wndHandle); CreateBackBuffer(d3ddev); }
void ContentClientDoubleBuffered::EnsureBackBufferIfFrontBuffer() { if (!mTextureClient && mFrontClient) { CreateBackBuffer(mFrontBufferRect); mBufferRect = mFrontBufferRect; mBufferRotation = mFrontBufferRotation; } }
void CWinSystemWin32DX::OnResize(int width, int height) { if (!m_IsAlteringWindow) ReleaseBackBuffer(); m_deviceResources->SetLogicalSize(width, height); if (!m_IsAlteringWindow) CreateBackBuffer(); }
void CContextManager::Resize(HWND hWnd, unsigned int Width, unsigned int Height) { if (m_D3DDevice != nullptr) { CHECKED_RELEASE(m_RenderTargetView); CHECKED_RELEASE(m_DepthStencil); CHECKED_RELEASE(m_DepthStencilView); m_SwapChain->ResizeBuffers(0, Width, Height, DXGI_FORMAT_UNKNOWN, 0); HRESULT hr = CreateBackBuffer(hWnd, Width, Height); assert(hr == S_OK); } }
void UGraphicsDevice::OnScreenSizeChanged() { HRESULT hr = mD3dSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0); if (FAILED(hr)) { assert(false); } if (!CreateBackBuffer()) { assert(false); } }
static M4Err DD_Resize(VideoOutput *dr, u32 width, u32 height) { DDCONTEXT; if (dd->is_3D_out) { dd->width = width; dd->height = height; return DD_SetupOpenGL(dr); } if (!dd->ddraw_init) return InitDirectDraw(dr, width, height); else return CreateBackBuffer(dr, width, height); }
void DirectDrawWrapper::CreateDevice() { HRESULT hResult; DDSURFACEDESC2 ddsd; DDRAW_INIT_STRUCT( ddsd ); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hResult = lpDirectDraw->CreateSurface( &ddsd, &lpDDSPrimary, NULL ); if( hResult != DD_OK ) { DisplayError( hResult, TEXT( "Error Creating Primary Surface" ) ); return; } hResult = lpDirectDraw->CreateClipper( 0, &lpDDClipper, NULL ); if( hResult != DD_OK ) { DisplayError( hResult, TEXT( "Error Creating Primary Surface Clipper" ) ); return; } hResult = lpDDClipper->SetHWnd( 0, hWnd ); if( hResult != DD_OK ) { DisplayError( hResult, TEXT( "Error Setting Primary Surface Clipper Window" ) ); return; } hResult = lpDDSPrimary->SetClipper( lpDDClipper ); if( hResult != DD_OK ) { DisplayError( hResult, TEXT( "Error Attaching Primary Surface" ) ); return; } CreateBackBuffer(); }
// Procesar todos los mensajes que han llegado al hilo DWORD CViewGame::TProcessMessage() { S_MESSAGE Msg; if (!Message.PeekMessage(&Msg)) return true; switch (Msg.Msg) { case WM_MOUSEMOVE: { float m_MouseX=LOWORD(Msg.lParam); float m_MouseY=HIWORD(Msg.lParam); float m_GrafMaxY=480; float m_GrafMaxX=640; // Corregir posicion m_MouseY=1-m_MouseY*2; m_MouseX=m_MouseX*2-1; // Desnormalizar m_MouseY=m_MouseY*m_GrafMaxY; m_MouseX=m_MouseX*m_GrafMaxX; // calcular posicion del lente Game_ColY=m_MouseY*Game_ColZ/1; Game_ColX=m_MouseX*Game_ColZ/1; break; } case WM_DESTROY: { DestroyFrontDC(); break; } case UM_INIT_OPENGL: { if (CreateBackBuffer()!=0) break; if (CreateFrontDC()!=0) break; QueryPerformanceCounter(&TimerStart); OnPlay=true; WTime=0; break; } case UM_GAME_START: { OnPlay=true; WTime=0; break; } case UM_GAME_STOP: { OnPlay=false; WTime=INFINITE; break; } case UM_THREAD_CLOSE: { OnPlay=false; WTime=INFINITE; DestroyBackBuffer(); Message.ReplyMessage(); return false; } case WM_KEYDOWN: { MessageBeep(-1); GameNewFire(); break; } } Message.ReplyMessage(); return true; }
void DirectDrawWrapper::ResetDevice() { SafeRelease( lpDDSBack ); CreateBackBuffer(); }
bool UGraphicsDevice::Init(int inClientHeight, int inClientWidth) { LOG(LogGraphicsDevice, Log, "Graphics Device initialization begin...\n"); if (!XMVerifyCPUSupport()) { LOG(LogGraphicsDevice, Error, "Init() Failed to verify DirectX Math library support\n"); return false; } DXGI_SWAP_CHAIN_DESC swapChainDesc; ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC)); swapChainDesc.BufferCount = 1; swapChainDesc.BufferDesc.Width = inClientWidth; swapChainDesc.BufferDesc.Height = inClientHeight; swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.OutputWindow = UGameWindow::GetHWnd(); swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; swapChainDesc.Windowed = true; UINT createDeviceFlags = 0; #ifdef _DEBUG createDeviceFlags = D3D11_CREATE_DEVICE_DEBUG; #endif D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, }; D3D_FEATURE_LEVEL featureLevel; HRESULT hr = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, featureLevels, _countof(featureLevels), D3D11_SDK_VERSION, &swapChainDesc, &mD3dSwapChain, &mD3dDevice, &featureLevel, &mD3dDeviceCtx); if (hr == E_INVALIDARG) { hr = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, &featureLevels[1], _countof(featureLevels) - 1, D3D11_SDK_VERSION, &swapChainDesc, &mD3dSwapChain, &mD3dDevice, &featureLevel, &mD3dDeviceCtx); } if (FAILED(hr)) { LOG(LogGraphicsDevice, Error, "Init() Failed to create graphics device and swap chain\n"); return false; } if (!CreateBackBuffer()) { LOG(LogGraphicsDevice, Error, "Init() Failed to create the application back buffer render target view\n"); return false; } SetViewport(inClientHeight, inClientWidth); LOG(LogGraphicsDevice, Log, "Graphics Device initialization successful\n"); return true; }
void CQueueView::OnSize(UINT nType, int cx, int cy) { CreateBackBuffer(cx, cy); // order matters, else bars are erratic UpdateView(); CScrollView::OnSize(nType, cx, cy); }