0

Hello guys,

I've been playing with Direct2D lately, and found out (from a presentation) that converting geometries into meshes makes rendering a lot faster
So, how do I do this?

I tried this:

hr = RenderEngine.D2DFactory->CreateRectangleGeometry(D2D1::RectF(0,0,10,10), &pGem);
	hr = RenderEngine.RenderTarget->CreateMesh(&pMesh);
	hr = pMesh->Open(&pSink);
	hr = pGem->Tessellate(D2D1::Matrix3x2F::Identity(), pSink);
	hr = pSink->Close();
	SafeReplace(&pFillMesh, pMesh);
	pSink->Release();
	pMesh->Release();
	pGem->Release();

Where pGem is of the ID2D1RectangleGeometry type
pMesh is of the ID2D1Mesh type
pSink is of the ID2D1TesselationSink type

And then in the render function I called

RenderTarget->BeginDraw();
for(int i=0;i<total;i++)
{
RenderTarget->SetTransform(D2D1::Matrix3x2F::Translation(p[i].x, p[i].y));
RenderTarget->FillMesh(NULL, pFillMesh)
}
RenderTarget->EndDraw();

But nothing draws.
I ran debug and tested if all the HRESULTs of the mesh creation were allright, and they were all on S_OK
When i replace the draw code with FillGeometry it draws fine.
I also tried commenting out the pMesh->Release() line.

BTW, the compiler doesn't give errors

Please help me fix this code or give me a (link to a) simple example where meshes are used, because the example on msdn has almost 90kb of code.

Thanks in advance,
Tigran

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Tigran
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.