Reputation: 3520
I am new to DirectX.
Where can I get tutorials and sample codes for multi threading using directx and C++?
I need to findout the distance transform of an image using multi threading.
Or could you please give me an example of finding the average of 100 numbers using directx?
Upvotes: 1
Views: 2283
Reputation: 48337
The best source for DirectX samples tends to be the DirectX SDK, which you can find here. There are quite a few tutorials around, some in the SDK, some here and here.
Multithreading with DirectX (I assume you mean D3D in specific) just requires being careful with your objects and using the multithread hint when creating the D3D object. Some tips on that here and a discussion on how to over here.
The code will look something like:
HRESULT hr = pD3DObject->CreateDevice
(
D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_MULTITHREADED, &presentParams, &pD3DDevice
);
After that, finding the distance transform depends on how you're handling that. I'm not entirely sure what you want to do (if you comment with details I'll see if I can edit something more in).
To generate the average of numbers, I wouldn't actually recommend using DirectX. Regular code should be able to handle that, and the work and overhead of using D3D to average 100 numbers seems rather inefficient.
Upvotes: 2