Hr = pDXGIFactory2->CreateSwapChainForComposition(m_pD3D11Device, &swapChainDesc, nullptr, &m_pDXGISwapChain1) Hr = pDXGIFactory2->CreateSwapChainForHwnd(m_pD3D11Device, hWnd, &swapChainDesc, nullptr, nullptr, &m_pDXGISwapChain1) Hr = pDXGIAdapter->GetParent(IID_PPV_ARGS(&pDXGIFactory2)) Hr = m_pDXGIDevice->GetAdapter(&pDXGIAdapter) SwapChainDesc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT::DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL SwapChainDesc.Scaling = (hWnd != NULL) ? DXGI_SCALING::DXGI_SCALING_NONE : DXGI_SCALING::DXGI_SCALING_STRETCH SwapChainDesc.BufferCount = 2 // use double buffering to enable flip SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT SwapChainDesc.Format = DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM bugLevel = D2D1_DEBUG_LEVEL::D2D1_DEBUG_LEVEL_INFORMATION ĭ2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, _uuidof(ID2D1Factory1), &options, (void**)&m_pD2DFactory1) ĭXGI_SWAP_CHAIN_DESC1 swapChainDesc = ZeroMemory(&options, sizeof(D2D1_FACTORY_OPTIONS)) Return DefWindowProc(hWnd, message, wParam, lParam) M_pD2DDeviceContext3->FillRectangle(D2D1::RectF(size.width - size.width / 6, size.height - size.height / 3, size.width, size.height), m_pD2DBrushGreen) M_pD2DDeviceContext3->FillRectangle(D2D1::RectF(0.f, 0.f, size.width / 6, size.height/3), m_pD2DBrushBlue) M_pD2DDeviceContext3->FillRectangle(D2D1::RectF(size.width / 2, 0.f, size.width, size.height), m_pD2DBrushWhite) M_pD2DDeviceContext3->FillRectangle(D2D1::RectF(0.f, 0.f, size.width/2, size.height), m_pD2DBrushBlack) If (m_pD2DDeviceContext3 & m_pDXGISwapChain1)ĭ2D1_SIZE_F size = m_pD2DDeviceContext3->GetSize() LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) Return MessageBox(NULL, TEXT("Cannot create window !"), TEXT("Error"), MB_ICONERROR | MB_OK) HWND hWnd = CreateWindowEx(WS_EX_NOREDIRECTIONBITMAP, wcex.lpszClassName, TEXT("Test"), WS_OVERLAPPEDWINDOW, nX, nY, nWidth, nHeight, NULL, NULL, hInst, NULL) Int nX = (GetSystemMetrics(SM_CXSCREEN) - nWidth) / 2, nY = (GetSystemMetrics(SM_CYSCREEN) - nHeight) / 2 Return MessageBox(NULL, TEXT("Cannot register class !"), TEXT("Error"), MB_ICONERROR | MB_OK) LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_WINDOW + 1), NULL, TEXT("WindowClass"), NULL, Sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, WndProc, 0, 0, hInst, LoadIcon(NULL, IDI_APPLICATION), Int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) Void OnResize(HWND hWnd, UINT nWidth, UINT nHeight) HRESULT CreateDirectComposition(HWND hWnd) IDCompositionTarget* m_pDCompositionTarget = NULL IDCompositionDevice* m_pDCompositionDevice = NULL ID2D1SolidColorBrush* m_pD2DBrushGreen = NULL ID2D1SolidColorBrush* m_pD2DBrushBlue = NULL ID2D1SolidColorBrush* m_pD2DBrushWhite = NULL ID2D1SolidColorBrush* m_pD2DBrushBlack = NULL IDXGISwapChain1* m_pDXGISwapChain1 = NULL ID2D1DeviceContext3* m_pD2DDeviceContext3 = NULL ID3D11DeviceContext* m_pD3D11DeviceContext = NULL LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) #pragma comment(linker,"\"/manifestdependency:type='win32' \ Is it possible for me to use all possible RGB color? Because I don't want the white color to became invisible in my window.įor the test, I left the caption and the drawing is done on Right-Click (I set opacity 0.5 for black and white) : That is, I wanted to draw a semi-transparent white rectangle.Īlso, I see that both SetLayeredWindowAttributes and UpdateLayeredWindow accepts COLORREF, that this color will be transparent. But here is the simpler example: // Inside WM_PAINT The above image is what I want to achieve. Someone also told me that I can't ignore WM_PAINT completely, which makes me more confused. Because both post that I read doesn't handle WM_PAINT at all. However, I am confused, whether I should draw on the WM_PAINT as usual or just use UpdateLayeredWindow() and left WM_PAINT unhandled. I have read some other posts about this ( post1, post2). Here is the expected window that I am trying to build (the water and the boat is my desktop wallpaper, not the window itself): I am currently trying to build a semi-transparent window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |