Sign in to follow this  
lomateron

initializing texture question

Recommended Posts

lomateron    491

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
MJP    19753

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this