Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality. If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers. And always feel free to hit us up on Twitter @MxdRealityDev.

Updating texture via a buffer in separate file

I am trying my hands on Direct X 11 template in VS 2015 in VC++. I am using: D3D11_MAPPED_SUBRESOURCE Resource and MAP and UNMAP to update texture in the Spinning Cube template. Now i have a separate file in my project where i am reading pixels from a buffer and need to upload it to this texture in spinning cube file.

I am using a struct to hold the texture data :
struct Frames{
int text_Width;
int text_height;
unsigned int text_Sz;
unsigned char* text_Data; };

Want to know how can i use this struct from a separate file to upload the texture data in my Direct X based Spinning Cube file.

or do i need to release the texture and re-create it and map it to my 3D object. Can anyone please help me out in this ?

Answers

  • If the pixel format and the dimensions are the same I don't think you would need to "rebuild" it, so the texture object and its views probably can be reused. On the other hand, you might need (not sure now) to release the shader view from the pixel shader texture slot by calling PSSetShaderResources with null view if any texture slot is set to that texture's view. After the update it can be set again.

    To update the pixels did you try the UpdateSubresource call? It needs to be iterated for all the arrays and mip levels.

    In my case I have code as follow. ColorARGB is my custom struct with ARGB uint8 values. Just replace it with the size of the matching pixel format.

    Context->UpdateSubresource(pD3DTexture, D3D11CalcSubresource(nMipLevel, 0, nMipLevels), nullptr, pMipBitmap->GetData<ColorARGB*>(), nWidth * sizeof(ColorARGB), nWidth * nHeight * sizeof(ColorARGB));

  • Here's an example using SharpDX and C#. I'm sure you can convert it over to C++ & DirectX.
    https://github.com/dngoins/HololensDXTutorials

    Dwight Goins
    CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
    MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
    http://dgoins.wordpress.com

Sign In or Register to comment.