Created
November 6, 2014 13:32
-
-
Save smakhtin/5bac3742fbb0b864b96c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static DX11Texture3D FromRawFile(DX11RenderContext context, string path, ImageLoadInformation loadinfo) | |
| { | |
| DX11Texture3D res = new DX11Texture3D(context); | |
| try | |
| { | |
| var data = File.ReadAllBytes(path); | |
| //var arr = new byte[1024]; | |
| var dataStream = new DataStream(data, true, false); | |
| var description = new Texture3DDescription | |
| { | |
| BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, | |
| //CpuAccessFlags = CpuAccessFlags.None, | |
| MipLevels = 1, | |
| //Usage = ResourceUsage.Default, | |
| //OptionFlags = ResourceOptionFlags.None, | |
| Width = loadinfo.Width, | |
| Height = loadinfo.Height, | |
| Depth = loadinfo.Depth, | |
| Format = loadinfo.Format | |
| }; | |
| var dataBox = new DataBox(description.Height, description.Width*description.Height, dataStream); | |
| var texture = new Texture3D(context.Device, description, dataBox); | |
| res.Resource = texture; | |
| res.SRV = new ShaderResourceView(context.Device, res.Resource); | |
| Texture3DDescription desc = res.Resource.Description; | |
| res.Width = desc.Width; | |
| res.Height = desc.Height; | |
| res.Format = desc.Format; | |
| res.Depth = desc.Depth; | |
| } | |
| catch | |
| { | |
| } | |
| return res; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment