[DirectX11] Create ID3D11Texture
ID3D11Texture2D * CreateTexture(ID3D11Device *myDevice, int w, int h, DWORD colorABGR)
{
ID3D11Texture2D *tex;
D3D11_TEXTURE2D_DESC tdesc;
D3D11_SUBRESOURCE_DATA tbsd;
DWORD *buf = (DWORD*)malloc(sizeof(DWORD)*(w*h);
//ABGR
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
buf[i*w + j] = colorABGR;
}
}
tbsd.pSysMem = (void *)buf;
tbsd.SysMemPitch = w * 4;
tbsd.SysMemSlicePitch = w*h * 4;
tdesc.Width = w;
tdesc.Height = h;
tdesc.MipLevels = 1;
tdesc.ArraySize = 1;
tdesc.SampleDesc.Count = 1;
tdesc.SampleDesc.Quality = 0;
tdesc.Usage = D3D11_USAGE_DEFAULT;
tdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
tdesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
tdesc.CPUAccessFlags = 0;
tdesc.MiscFlags = 0;
if (FAILED(myDevice->CreateTexture2D(&tdesc, &tbsd, &tex)))
return(0);
free(buf);
return(tex);
}