Mip mapping

Started by
12 comments, last by webjeff 19 years, 11 months ago
Well, I''m using DirectX 9. Hmm, this could get harry. Well, I will look into increasing the size of the textures and reapplying them. Thanks guys. Does anyone know if mip mapping happens automatically. I put the correct samplestates to do mip mapping but it didn''t look like anything changed. However, I looked online and I saw a tutorial that shows you resizing the textures itself. Do I really need to do that or will DX do it for you?

Thanks again

Jeff
Advertisement
Use D3DXCreateTextureFromFileEx and keep miplevels as zero for a complete mipmap chain to be built for you.

Also remember not every graphics card can support non-power of two textures, and if they do it will be slower than if you where.
Actually, it is recomented that the dimentions of textures that you use should have dimentions in power of 2 (128, 256, 512...).
That's sure for Direct3D.
In Direct3D you can create a mipmap chain by specifing the DDSCAPS_MIPMAP | DDSCAPS_COMPLEX flags in DDSURFACEDESC2 structure passed to the IDirectDraw::CreateSurface. For example, to create a chain of 4 mipmap levels (256x256), (128x128), (64x64), (32x32) write:


DDSURFACEDESC2 ddsd2;
LPDIRECTDRAWSURFACE lpDDMipMap;
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_MIPMAPCOUNT;
ddsd2.dwMipMapCount = 4; // 4 mipmap levels
ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
//DDSCAPS_TEXTURE flag must be set also
ddsd2.dwWidth = 256; // First mipmap
ddsd2.dwHeight = 256; // First mipmap

ddres = lpDD->CreateSurface(&ddsd2, &lpDDMipMap);

where lpDD is a valid pointer to a DirectDraw interface.

This sould work with non-power of two textures dimentions, also it is not recommented for speed optimization.

Jim Valavanis



[edited by - Jimmy Valavanis on May 20, 2004 2:37:39 PM]
Coorect me if im mistaken but arent non-power of 2 textures scaled anyway. In other words by doing it yourself you save processing speed.
-CProgrammer

This topic is closed to new replies.

Advertisement