MipMapping in Direct3D IM
Help! Little question.
How can I create & use mipmap?
I''ve tried to make MipMap sample with using directx7 SDK help file but it dosn''t working.
That''s my code (rip from DX7 SDK help file)
It''s only load the main texture without any mipmaps.
Where I mistake?
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE7 lpDDMipMap;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_MIPMAPCOUNT;
ddsd.dwMipMapCount = 5;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE |
DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
ddsd.dwWidth = TextureWidth;
ddsd.dwHeight = TextureHeight;
ddres = lpDD->CreateSurface(&ddsd, &lpDDMipMap);
if (FAILED(ddres))
LPDIRECTDRAWSURFACE7 lpDDLevel, lpDDNextLevel;
DDSCAPS2 ddsCaps;
HRESULT ddres;
lpDDLevel = lpDDMipMap;
lpDDLevel->AddRef();
ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
ddres = DD_OK;
while (ddres == DD_OK)
{
In this place I use StretchBlt to blit downscaled texture to the lpDDLevel surface
ddres = lpDDLevel->GetAttachedSurface(
&ddsCaps, &lpDDNextLevel);
lpDDLevel->Release();
lpDDLevel = lpDDNextLevel;
}
if ((ddres != DD_OK) && (ddres != DDERR_NOTFOUND))
{
// Code to handle the error goes here
}
It''s only load the main texture without any mipmaps.
Where I mistake?
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE7 lpDDMipMap;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_MIPMAPCOUNT;
ddsd.dwMipMapCount = 5;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE |
DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
ddsd.dwWidth = TextureWidth;
ddsd.dwHeight = TextureHeight;
ddres = lpDD->CreateSurface(&ddsd, &lpDDMipMap);
if (FAILED(ddres))
LPDIRECTDRAWSURFACE7 lpDDLevel, lpDDNextLevel;
DDSCAPS2 ddsCaps;
HRESULT ddres;
lpDDLevel = lpDDMipMap;
lpDDLevel->AddRef();
ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
ddres = DD_OK;
while (ddres == DD_OK)
{
In this place I use StretchBlt to blit downscaled texture to the lpDDLevel surface
ddres = lpDDLevel->GetAttachedSurface(
&ddsCaps, &lpDDNextLevel);
lpDDLevel->Release();
lpDDLevel = lpDDNextLevel;
}
if ((ddres != DD_OK) && (ddres != DDERR_NOTFOUND))
{
// Code to handle the error goes here
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement