diff --git a/GDP/D3D9/Direct3D.cpp b/GDP/D3D9/Direct3D.cpp index dfaec76..479281c 100644 --- a/GDP/D3D9/Direct3D.cpp +++ b/GDP/D3D9/Direct3D.cpp @@ -1,5 +1,6 @@ #include "Direct3D.h" #include "Utilities.h" +#include INT Direct3D::init(HWND hWnd, UINT width, UINT height, BOOL isFullscreen) { @@ -50,10 +51,28 @@ INT Direct3D::init(HWND hWnd, UINT width, UINT height, BOOL isFullscreen) void Direct3D::beginScene() { + _pD3DDevice->BeginScene(); // init a frame, after this call we are allowed to do draw calls + + // change background color + static std::default_random_engine e; + static std::uniform_int_distribution d(0, 255); + + _pD3DDevice->Clear( + 0, nullptr, // areas to clear, null -> everything + D3DCLEAR_TARGET, // what to clear, bitmask + + // how to clean + //D3DCOLOR_XRGB(d(e), d(e), d(e)), //random color + //D3DCOLOR_XRGB(255, 0, 0), // red color + D3DCOLOR_XRGB(0, 0, 0), // black color + 1.0f, 0xFFFFFFFF + ); } void Direct3D::endScene() { + _pD3DDevice->EndScene(); // close a frame, after this call we are not allowed to do draw calls + _pD3DDevice->Present(nullptr, nullptr, nullptr, nullptr); // swap back- with frontbuffer } void Direct3D::deInit() diff --git a/GDP/D3D9/Window.cpp b/GDP/D3D9/Window.cpp index dd38e7c..05c95d1 100644 --- a/GDP/D3D9/Window.cpp +++ b/GDP/D3D9/Window.cpp @@ -16,12 +16,15 @@ INT Window::init(HINSTANCE hInstance, UINT width, UINT height) if (!RegisterClass(&wc)) return 100; // 3. adjust window size (optional) + DWORD style; + style = WS_OVERLAPPEDWINDOW; // window with border & title + //style = WS_POPUP; // borderless window // 4. create window instance _hWnd = CreateWindow( wc.lpszClassName, // class name for window instance wc.lpszClassName, // window title - WS_OVERLAPPEDWINDOW, // visual window style + style, // visual window style 100, 100, // window position (left-top corner) width, height, // window size nullptr, // handle to parent window @@ -75,7 +78,7 @@ LRESULT WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) PostQuitMessage(0); return 0; case WM_KEYDOWN: - if (wParam == VK_ESCAPE) + if (wParam == VK_ESCAPE) { DestroyWindow(hWnd); return 0;