Capture

In order to show my curator some progress, I wanted to make a video of Sloganeer's output. Of course I could have just recorded it with my phone but that doesn't do justice to the app's nice smooth transitions. Yeah there are various freewares around that could work but they all have their downsides. So much better and more interesting to just roll my own capture. OK there went two days. It's actually pretty challenging to capture frames in Direct2D without stalling the GPU pipeline. And 1080p frames are big enough (8 MB) that it's a bad idea to write them to disk in the render thread. So that necessitates a thread-safe queue, and a thread pool of writer threads, each with their own WIC instance. OK better pack a lunch. But it all works now, and it's neatly wrapped in a class CD2DCapture.

This test helps verify that each frame contains what it should:

	m_pD2DDeviceContext->Clear(m_clrBkgnd);//@@@
	CString s;
	static int iFrame;
	s.Format(_T("%d"), iFrame);
	iFrame++;
	CD2DSizeF	szRT(m_pD2DDeviceContext->GetSize());
	m_pD2DDeviceContext->DrawText(s, s.GetLength(), m_pTextFormat, CD2DRectF(0, 0, szRT.width, szRT.height), m_pDrawBrush);

And for benchmarking OnDraw:

	CArrayEx	m_aBenchmark;//@@@

	m_aBenchmark.SetSize(5000);
	m_aBenchmark.FastRemoveAll();

	double	t = b.Elapsed();//@@@
	m_aBenchmark.Add(float(t));

in Destroy:

	CStdioFile	fBench(_T("bench.txt"), CFile::modeCreate | CFile::modeWrite);
	for (int i = 0; i < m_aBenchmark.GetSize(); i++) {
		CString	s;
		s.Format(_T("%f"), m_aBenchmark[i]);
		fBench.WriteString(s + '\n');

Comments

Popular posts from this blog

Elevator Door

Orthogonality of transitions

Hollow transition