Exemplo n.º 1
0
void ProgressCallback( void* context, int percent )
{
	if ( context )
	{
		Window *w = ( Window* ) context;
		PostMessage( w->GetHwnd( ), WM_D2_SET_PROGRESS, percent, 0 );
	}
}
Exemplo n.º 2
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	Window* pWindow = MemoryManager::New<Window>();
	RenderInterface* pRenderInterface = MemoryManager::New<DX11RenderInterface>();
	//test
	RenderTarget render_target(ViewPort(0, 0, pWindow->GetWindowWidth(), pWindow->GetWindowHeight()));
	Observer<Window> WindowObserver(pWindow);
	Observer<RenderInterface> RenderInterfaceObserver(pRenderInterface);
	WindowObserver.m_RespondStart = [&](Window&) {
		pRenderInterface->Init();
	};
	WindowObserver.m_RespondRun = [&](Window&) {
		pRenderInterface->BeginRender(render_target);
		pRenderInterface->EndRender(render_target);
	};
	WindowObserver.m_RespondResize = [&](Window&) {
		if (render_target.m_IfInitialized)
		{
			pRenderInterface->ResizeRenderTarget(render_target, ViewPort(0, 0, pWindow->GetWindowWidth(), pWindow->GetWindowHeight()));
			pRenderInterface->BeginRender(render_target);
			pRenderInterface->EndRender(render_target);
		}
	};
	WindowObserver.m_RespondRelease = [&](Window&) {

	};
	RenderInterfaceObserver.m_RespondStart = [&](RenderInterface&) {
		pRenderInterface->InitRenderTarget(render_target, pWindow->GetHwnd());
	};
	RenderInterfaceObserver.m_RespondRelease = [&](RenderInterface&) {
		pRenderInterface->ReleaseRenderTarget(render_target);
	};
	//----
	pWindow->StartRun(hInstance);
	MemoryManager::Delete(pWindow);
	MemoryManager::Delete(pRenderInterface);
	return 0;
}