Jump to content
  • Advertisement
Sign in to follow this  
CraigLonsdale_184900

DX11 [SlimDX]Streaming Kinect Output to DX11 Texture2D

This topic is 2605 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,

I have been learning HLSL for DX11 and i am trying to stream the output of my kinect in to a texture, but i can't quite get it, i keep getting a bunch of errors.
I am using SlimDX and here is how i set up my texture.



uint[] rgb = new uint[depthMD.XRes * depthMD.YRes * 4];
ushort* pDepth = (ushort*)m_kinectServer.DepthMapGenerator.DepthMapPtr.ToPointer();

// set pixels
for (int y = 0; y < depthMD.YRes; ++y)
{
//byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride;
for (int x = 0; x < depthMD.XRes; x+=4, ++pDepth)
{
uint pixel = (uint)m_histogram[*pDepth];
rgb[(y * x) + x + 0] = pixel;
rgb[(y * x) + x + 1] = pixel;
rgb[(y * x) + x + 2] = pixel;
rgb[(y * x) + x + 3] = pixel;
}
}

SlimDX.Direct3D11.Texture2DDescription texDesc = new Texture2DDescription();
texDesc.Width = depthMD.XRes;
texDesc.Height = depthMD.YRes;
texDesc.MipLevels = 0;
texDesc.Format = Format.R32G32B32A32_UInt;
texDesc.Usage = ResourceUsage.Default;
texDesc.BindFlags = BindFlags.ShaderResource;
texDesc.CpuAccessFlags = CpuAccessFlags.None;
texDesc.OptionFlags = ResourceOptionFlags.None;
texDesc.ArraySize = 1;
texDesc.SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0);

DataRectangle dataRect = new DataRectangle(32 * depthMD.XRes * 4, new DataStream(rgb, true, false));

m_kinectTexture = new Texture2D(DX11Context.Device, texDesc, dataRect);



I'm not sure if the format is right, i would have rather have used a direct pointer to the data (m_kinectServer.DepthMapGenerator.DepthMapPtr.ToPointer();) but it return a void *
and ShaderResourceView.FromPointer() takes an IntPtr (not sure what this means i'm also pretty new at C#).

Any advice you can give me would be great, i'm getting the errors.


D3D11: ERROR: ID3D11Device::CreateTexture2D: pInitialData[1].pSysMem cannot be NULL. [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA ]
D3D11: ERROR: ID3D11Device::CreateTexture2D: pInitialData[1].SysMemPitch cannot be 0 [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA ]
D3D11: ERROR: ID3D11Device::CreateTexture2D: pInitialData[5].SysMemPitch cannot be 0 [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA ]
D3D11: ERROR: ID3D11Device::CreateTexture2D: pInitialData[7].pSysMem cannot be NULL. [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA ]
D3D11: ERROR: ID3D11Device::CreateTexture2D: pInitialData[8].pSysMem cannot be NULL. [ STATE_CREATION ERROR #100: CREATETEXTURE2D_INVALIDINITIALDATA ]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!