Created
April 2, 2019 10:56
-
-
Save Dzejkop/9ff7564ee755f538a7ec07219720a77b to your computer and use it in GitHub Desktop.
winapi.rs texture issues
This file contains 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
// Texture creation | |
let mut texture: *mut ID3D11Texture2D = null_mut(); | |
let mut texture_desc: D3D11_TEXTURE2D_DESC = std::mem::zeroed(); | |
texture_desc.Width = width; // usually 1280 | |
texture_desc.Height = height; // usually 720 | |
texture_desc.MipLevels = 1; | |
texture_desc.ArraySize = 1; | |
texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | |
texture_desc.SampleDesc.Count = 1; | |
texture_desc.Usage = D3D11_USAGE_DYNAMIC; | |
texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; | |
texture_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; | |
// device is ID3D11Device | |
device.CreateTexture2D(&texture_desc, null_mut(), &mut texture); | |
// Texture update | |
let mut texture_mapped_res: D3D11_MAPPED_SUBRESOURCE = std::mem::zeroed(); | |
let res = device_context.Map(self.texture as *mut _, 0, D3D11_MAP_WRITE, 0, &mut texture_mapped_res); | |
if texture_mapped_res.pData.is_null() { | |
error!("Mapping unsuccesfful pData is null"); | |
} | |
// copy src -> pData | |
device_context.Unmap(self.texture as *mut _, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment