#### Archived

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

# Dx8 - Creating a mip map from a file

This topic is 6241 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
OMG! 1 line??? Woot! Thanks heaps Simon! I tried it and it works brilliantly.

Thanks for the hint!

Ikland

No problem

##### 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 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 on other sites
I figured something was fishy there. Thanks for clearing that up.

##### Share on other sites
Also, a full mip map chain will only use up exactly 33.333% more memory then the original image.

Possibility

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631781
• Total Posts
3002316
×