Advertisement

Mipmaps in DirectX7...

Started by January 10, 2000 09:04 AM
3 comments, last by Ake 25 years, 1 month ago
Hi, I just converted my D3D engine to DX7, and almost everything worked, except for mipmapping. I create a mipmap texture like this:

   ZeroMemory( &ddsd2, sizeof(ddsd2) );
   ddsd2.dwSize               = sizeof(ddsd2);
   ddsd2.dwFlags              = DDSD_CAPS / DDSD_WIDTH / DDSD_HEIGHT / DDSD_MIPMAPCOUNT  / DDSD_PIXELFORMAT;
   ddsd2.ddsCaps.dwCaps       = DDSCAPS_TEXTURE / DDSCAPS_MIPMAP / DDSCAPS_COMPLEX;
   ddsd2.dwWidth              = m_iWidth;
   ddsd2.dwHeight             = m_iHeight;
   ddsd2.dwMipMapCount        = m_iMipCount;;
   ddsd2.ddsCaps.dwCaps2      = DDSCAPS2_TEXTUREMANAGE;
   memcpy(&ddsd2.ddpfPixelFormat, &ddpfTextureFormats[ iTextureFormatToUse ], sizeof(DDPIXELFORMAT));

   	if (lpDDraw->CreateSurface(&ddsd2, &lpTextureSurface, NULL) != DD_OK)
		return FALSE;
Looks OK, right? Then I load a bitmap into the surface and scale/filter it to put in the mipmap chain. I access my mipmap like this:

   ddsCaps.dwCaps = DDSCAPS_TEXTURE / DDSCAPS_MIPMAP;
   hr = lpTextureSurface->GetAttachedSurface( &ddsCaps, &lpMipMap );
But GetAttachedSurface just returns DDERR_NOTFOUND... What am I doing wrong? Greets Tobias
Are you initializing the other members of ddsCaps to 0?
Advertisement
Now I am...
But it still doesn''t work, but at least it doesn''t return
DDERR_NOTFOUND anymore. It crashes the second time I call
GetAttachsurface instead...

Greets Tobias
What are the dimensions of the original surface? What''s your card''s Min texture width and height?

Where exactly does it crash? It would probably help alot to have the rest of the code posted (down to the line after the crash)

As a test, you might take your original surface and call GetSurfaceDesc on it and check the dwMipMapCount member to see how many mip map levels were actually made.




-ns-
-ns-
I''ve fixed it now, I forgot to call AddRef in the beginning
so something weird probably happened when I Released it...
Thanks anyway.

Greets Tobias

This topic is closed to new replies.

Advertisement