Jump to content
  • Advertisement
Sign in to follow this  
ucfchuck

shader resource view from texture

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

im running in c++ but i think its pretty similar and maybe someone can help. ID3D10Texture2D* pTexture = NULL; D3D10_TEXTURE2D_DESC tdesc; using namespace std; int cnt; int *mBlock=new int[49152*4]; for (cnt=0; cnt<49152;cnt++) { mBlock[cnt*4]=128; mBlock[cnt*4+1]=128; mBlock[cnt*4+2]=128; mBlock[cnt*4+3]=128; } tdesc.Width = 512; tdesc.Height = 96; tdesc.MipLevels = tdesc.ArraySize = 1; tdesc.Format = DXGI_FORMAT_R32G32B32A32_UINT; tdesc.SampleDesc.Count = 1; tdesc.Usage = D3D10_USAGE_DYNAMIC; tdesc.BindFlags = D3D10_BIND_SHADER_RESOURCE; tdesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; D3D10_SUBRESOURCE_DATA Rdata; Rdata.pSysMem= mBlock; Rdata.SysMemPitch=8192; Rdata.SysMemSlicePitch=0; g_pd3dDevice->CreateTexture2D( &tdesc, NULL, &pTexture ); ID3D10ShaderResourceView* pShaderResView = NULL; g_pd3dDevice->CreateShaderResourceView( pTexture, NULL, &pShaderResView ); this gives me an all black 'texture' no matter what color values i load into mBlock. ive tried changing the format to R8 and A8, UINT and UNORM changing the size of memblock accordingly and still never any color. im trying to load any data into a texture and load it into a shader resource view so that i can map the texture later with a new image.

Share this post


Link to post
Share on other sites
Advertisement
why do you have NULL in

g_pd3dDevice->CreateTexture2D( &tdesc, NULL, &pTexture ); ?
you should put &Rdata in:
g_pd3dDevice->CreateTexture2D( &tdesc, &Rdata, &pTexture );

Share this post


Link to post
Share on other sites
well, since I'm also quite new to DX10 I'm afraid I can't help you much more.

have you checked out the "Creating Texture Resources" topic (Creating Empty Textures->Filling Textures Manually) in directX sdk documentation?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!