954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to create Direct2D Mesh (ID2D1Mesh)

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

Tigran
Junior Poster in Training
92 posts since Jun 2008
Reputation Points: 24
Solved Threads: 8
 

*bump*

Tigran
Junior Poster in Training
92 posts since Jun 2008
Reputation Points: 24
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: