add frame rendering
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "Direct3D.h"
|
#include "Direct3D.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
#include <random>
|
||||||
|
|
||||||
INT Direct3D::init(HWND hWnd, UINT width, UINT height, BOOL isFullscreen)
|
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()
|
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<int> 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()
|
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()
|
void Direct3D::deInit()
|
||||||
|
|||||||
+4
-1
@@ -16,12 +16,15 @@ INT Window::init(HINSTANCE hInstance, UINT width, UINT height)
|
|||||||
if (!RegisterClass(&wc)) return 100;
|
if (!RegisterClass(&wc)) return 100;
|
||||||
|
|
||||||
// 3. adjust window size (optional)
|
// 3. adjust window size (optional)
|
||||||
|
DWORD style;
|
||||||
|
style = WS_OVERLAPPEDWINDOW; // window with border & title
|
||||||
|
//style = WS_POPUP; // borderless window
|
||||||
|
|
||||||
// 4. create window instance
|
// 4. create window instance
|
||||||
_hWnd = CreateWindow(
|
_hWnd = CreateWindow(
|
||||||
wc.lpszClassName, // class name for window instance
|
wc.lpszClassName, // class name for window instance
|
||||||
wc.lpszClassName, // window title
|
wc.lpszClassName, // window title
|
||||||
WS_OVERLAPPEDWINDOW, // visual window style
|
style, // visual window style
|
||||||
100, 100, // window position (left-top corner)
|
100, 100, // window position (left-top corner)
|
||||||
width, height, // window size
|
width, height, // window size
|
||||||
nullptr, // handle to parent window
|
nullptr, // handle to parent window
|
||||||
|
|||||||
Reference in New Issue
Block a user