Jump to content
  • Advertisement
Sign in to follow this  
jeremie009

DX11 Painting Texture

This topic is 895 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

Hi, 

 

I'm working on a tool to do basic edit of texture using dx11. I need to edit texture while rendering them using dx11.

 

So what I'm doing so far is that I'm updating a array on the cpu and just before the draw call I'm update my resource using map/ unmap. 

 

the problem is the difference between the final texture and the color array I keep in the cpu.  I manage to get the pixel to be paint but there is some offset issue. 

 

this is my code 

 var data = _device.Context.MapSubresource(Rgb.Resource, 0, MapMode.WriteDiscard, MapFlags.None);
            var buffer = (Color*)data.DataPointer;

            for (var i = 0; i < Texture.Length; i++)
            {
                var x = (int) (i % Rectangle.Width);
                var y = (int) (i / Rectangle.Width);

                buffer[y * data.RowPitch / 4 + x] = Texture[i];
            }

            _device.Context.UnmapSubresource(Rgb.Resource, 0);

texture is the color array store on the cpu and rgb is the shaderresourceView. 

 

Color is Sharpdx Color Struct

 

 

I'm using sharpdx and c#  by the way. 

 

So basically I'm having a problem with the offset. the dataraw pitch doesn't match the cpu texture pitch and even with my code I can't get them to match the mouse position. The more I move further from the left upper corner the more the offset is apparent. 

 

So anybody with input about how to deal with it? Should I write another struct and use a buffer to compensate for the offset ? How updating the texture is not the way to do it ?

 

 

 

Share this post


Link to post
Share on other sites
Advertisement


the dataraw pitch doesn't match the cpu texture pitch and even with my code I can't get them to match the mouse position.

the gpu texture will likely be a mipmapped texture.

Share this post


Link to post
Share on other sites
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!