2012/5/9 Józef Kucia <joseph.ku...@gmail.com>: > + mip_levels = min(src_info->MipLevels, > IDirect3DCubeTexture9_GetLevelCount(cube_texture)); > + for (face = D3DCUBEMAP_FACE_POSITIVE_X; face <= > D3DCUBEMAP_FACE_NEGATIVE_Z; face++) > + { > + size = src_info->Width; > + for (mip_level = 0; mip_level < mip_levels; mip_level++) > + { > + hr = calculate_dds_surface_size(src_info, size, size, > &src_pitch, &mip_level_size); > + if (FAILED(hr)) return hr; > + > + SetRect(&src_rect, 0, 0, size, size); > + > + IDirect3DCubeTexture9_GetCubeMapSurface(cube_texture, face, > mip_level, &surface); > + hr = D3DXLoadSurfaceFromMemory(surface, palette, NULL, pixels, > src_info->Format, src_pitch, > + NULL, &src_rect, filter, color_key); > + IDirect3DSurface9_Release(surface); > + if (FAILED(hr)) return hr; > + > + pixels += mip_level_size; > + size = max(1, size / 2); > + } > + > + /* if texture has fewer mip levels than DDS file, skip excessive mip > levels */ > + while (mip_level < src_info->MipLevels) > + { > + calculate_dds_surface_size(src_info, size, size, &src_pitch, > &mip_level_size); > + pixels += mip_level_size; > + size = max(1, size / 2); > + mip_level++; > + } > + }
Really a nitpick, you could merge the "while" into the "for" loop above. > + if ((caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) && (pool != D3DPOOL_DEFAULT) > && (usage != D3DUSAGE_DYNAMIC)) > + { > + hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, > pool, &tex); > + buftex = NULL; > + } > + else > + { > + hr = D3DXCreateCubeTexture(device, size, mip_levels, usage, format, > D3DPOOL_SYSTEMMEM, &buftex); > + tex = buftex; > + } The "if" condition doesn't look correct to me, since e.g. you don't need a temporary texture if pool == D3DPOOL_DEFAULT and usage == D3DUSAGE_DYNAMIC.