Jump to content
  • Advertisement
Sign in to follow this  
lomateron

initializing texture question

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

I want to create texture and fill it when created with some values, the texture has this:

 

 

texD.Width = res;
texD.Height = res;
texD.MipLevels = 1;
texD.ArraySize = 1;
texD.Format = DXGI_FORMAT_R16_FLOAT;  //yeah this format
texD.SampleDesc.Count = 1;
texD.SampleDesc.Quality = 0;
texD.Usage = D3D10_USAGE_DEFAULT;
texD.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
texD.CPUAccessFlags = 0;
texD.MiscFlags = 0;
 
So when i create it i do this:
 
D3D10_SUBRESOURCE_DATA rDSt;
rDSt.pSysMem=&fPixJN[0];
rDSt.SysMemPitch=2*res;
hr = g_pd3dDevice->CreateTexture2D(&texD, &rDSt, &TexJNMEMORY);
 
And fPixJN is this:
vector<float16> fPixJN(res*res);
 
float16 doesnt exist in c++ visual studio 2012, how can i create that vector so i can fill it with floats
 

 

Share this post


Link to post
Share on other sites
Advertisement

If you're using DirectXMath it provides a HALF type (which is just a typedef for uint16_t, so you can use that as well). It also has conversion functions that can convert from 32-bit floats to 16-bit floats.

If you're using the older D3DX stuff, then you can use D3DXFLOAT16 which has constructors and casting operators that can convert to and from 16-bit floats. There's also D3DXFloat32To16Array for converting an entire array in one call.

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!