Dx8 - Creating a mip map from a file

Started by
6 comments, last by Ikland 22 years, 10 months ago
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> </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
Ikland
Advertisement
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 );


OMG! 1 line??? Woot! Thanks heaps Simon! I tried it and it works brilliantly.

Thanks for the hint!

Ikland
Ikland
No problem
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?
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
I figured something was fishy there. Thanks for clearing that up.
Also, a full mip map chain will only use up exactly 33.333% more memory then the original image.

Possibility

This topic is closed to new replies.

Advertisement