diff options
-rw-r--r-- | o3d/core/win/d3d9/texture_d3d9.cc | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/o3d/core/win/d3d9/texture_d3d9.cc b/o3d/core/win/d3d9/texture_d3d9.cc index b2e309f..68ca0bc 100644 --- a/o3d/core/win/d3d9/texture_d3d9.cc +++ b/o3d/core/win/d3d9/texture_d3d9.cc @@ -400,30 +400,30 @@ Texture2DD3D9* Texture2DD3D9::Create(ServiceLocator* service_locator, resize_to_pot, enable_render_surfaces); + if (resize_to_pot) { + texture->backing_bitmap_->Allocate(format, width, height, levels, + Bitmap::IMAGE); + } + // Clear the texture. // This is platform specific because some platforms, (command-buffers), // will guarantee the textures are cleared so we don't have to. { - size_t row_size = image::ComputeMipChainSize(mip_width, 1, format, 1); + size_t row_size = image::ComputeMipChainSize(width, 1, format, 1); scoped_array<uint8> zero(new uint8[row_size]); memset(zero.get(), 0, row_size); for (int level = 0; level < levels; ++level) { if (enable_render_surfaces) { texture->GetRenderSurface(level); - } else { + } else if (!texture->IsCompressed()) { texture->SetRect(level, 0, 0, - image::ComputeMipDimension(level, mip_width), - image::ComputeMipDimension(level, mip_height), + image::ComputeMipDimension(level, width), + image::ComputeMipDimension(level, height), zero.get(), 0); } } } - if (resize_to_pot) { - texture->backing_bitmap_->Allocate(format, width, height, levels, - Bitmap::IMAGE); - } - return texture; } @@ -739,32 +739,33 @@ TextureCUBED3D9* TextureCUBED3D9::Create(ServiceLocator* service_locator, resize_to_pot, enable_render_surfaces); + if (resize_to_pot) { + for (int ii = 0; ii < static_cast<int>(NUMBER_OF_FACES); ++ii) { + texture->backing_bitmaps_[ii]->Allocate( + format, edge_length, edge_length, levels, Bitmap::IMAGE); + } + } + // Clear the texture. // This is platform specific because some platforms, (command-buffers), will // guarantee the textures are cleared so we don't have to. { - size_t row_size = image::ComputeMipChainSize(edge, 1, format, 1); + size_t row_size = image::ComputeMipChainSize(edge_length, 1, format, 1); scoped_array<uint8> zero(new uint8[row_size]); memset(zero.get(), 0, row_size); for (int level = 0; level < levels; ++level) { for (int face = 0; face < static_cast<int>(NUMBER_OF_FACES); ++face) { if (enable_render_surfaces) { texture->GetRenderSurface(static_cast<CubeFace>(face), level); - } else { + } else if (!texture->IsCompressed()) { texture->SetRect(static_cast<CubeFace>(face),level , 0, 0, - image::ComputeMipDimension(level, edge), - image::ComputeMipDimension(level, edge), + image::ComputeMipDimension(level, edge_length), + image::ComputeMipDimension(level, edge_length), zero.get(), 0); } } } } - if (resize_to_pot) { - for (int ii = 0; ii < static_cast<int>(NUMBER_OF_FACES); ++ii) { - texture->backing_bitmaps_[ii]->Allocate( - format, edge_length, edge_length, levels, Bitmap::IMAGE); - } - } return texture; } |