Archived

This topic is now archived and is closed to further replies.

Ikland

Dx8 - Creating a mip map from a file

Recommended Posts

Hi there, I am just looking for a little assistance here please, in regards to DirectX 8. What I am trying to do is create a mip map from a file. The problem I have though is that when I call the D3DXCreateTextureFromFile function, with what I think are the required details, it says that this function does not take XX parameters. I have tried everything I can think of, according to the way that the Dx8 SDK says it should be given parameters, but its all just a bit too much for this little Dx8 n00b. Presently I am loading the base texture at present like this - if( FAILED( D3DXCreateTextureFromFile( g_d3d_device, d3dxMaterials[i] .pTextureFilename, &g_pMeshTextures[i] ) ) ) Which works well, but I can't get the mip mapped version to work. I have looked at the MS example in the SDK, but they only show it using the straight CreateTexture function. Is anyone able to demostrate for me, how a mip map is created using the D3DXCreateTextureFromFile function? Thanks heaps, Ikland Edited by - Ikland on January 30, 2001 7:38:09 PM

Share this post


Link to post
Share on other sites
The function will automatically generate all the mip-map surfaces and shrink the image onto the smaller surfaces for you, but you have to have mip-mapping filtering turned on, ie-

g_pD3DDevice->SetTextureStageState ( 0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR );


Share this post


Link to post
Share on other sites
So how many mip map levels does it make? If it creates all the mip map levels of powers of 2, isn''t that kind of a waste of video mem?

Share this post


Link to post
Share on other sites
That line doesnt create a mipmap chain, it only sets the filtering method to use to get the pixel color between mipmap levels. You can create a mipmap chain when you load in the mipmap with these functions:
    
TCHAR strPath1[MAX_PATH];
DXUtil_FindMediaFile(strPath1, "grass.bmp");
D3DXCreateTextureFromFileExA(g_pGameApp->m_pd3dDevice,
strPath1,
D3DX_DEFAULT, //width is taken from the image, or can put in a number here

D3DX_DEFAULT, //height is taken from the image

D3DX_DEFAULT, //default or 0 creates a complete mipmap chain down to 1x1 pixels

0, //should be 0

D3DFMT_R8G8B8, //24 bit image

D3DPOOL_MANAGED,
D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER, //filter

D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER, //mip filter

0, //color key

NULL,
NULL,
&m_Texture_Grass);


Possibility

Edited by - Possibility on June 21, 2001 1:51:24 AM

Share this post


Link to post
Share on other sites