|
@@ -23,15 +23,15 @@
|
|
|
#include "../../Precompiled.h"
|
|
#include "../../Precompiled.h"
|
|
|
|
|
|
|
|
#include "../../Core/Context.h"
|
|
#include "../../Core/Context.h"
|
|
|
-#include "../../IO/FileSystem.h"
|
|
|
|
|
|
|
+#include "../../Core/Profiler.h"
|
|
|
#include "../../Graphics/Graphics.h"
|
|
#include "../../Graphics/Graphics.h"
|
|
|
#include "../../Graphics/GraphicsEvents.h"
|
|
#include "../../Graphics/GraphicsEvents.h"
|
|
|
#include "../../Graphics/GraphicsImpl.h"
|
|
#include "../../Graphics/GraphicsImpl.h"
|
|
|
-#include "../../IO/Log.h"
|
|
|
|
|
-#include "../../Core/Profiler.h"
|
|
|
|
|
#include "../../Graphics/Renderer.h"
|
|
#include "../../Graphics/Renderer.h"
|
|
|
-#include "../../Resource/ResourceCache.h"
|
|
|
|
|
#include "../../Graphics/TextureCube.h"
|
|
#include "../../Graphics/TextureCube.h"
|
|
|
|
|
+#include "../../IO/FileSystem.h"
|
|
|
|
|
+#include "../../IO/Log.h"
|
|
|
|
|
+#include "../../Resource/ResourceCache.h"
|
|
|
#include "../../Resource/XMLFile.h"
|
|
#include "../../Resource/XMLFile.h"
|
|
|
|
|
|
|
|
#include "../../DebugNew.h"
|
|
#include "../../DebugNew.h"
|
|
@@ -54,7 +54,8 @@ static const char* cubeMapLayoutNames[] = {
|
|
|
|
|
|
|
|
static SharedPtr<Image> GetTileImage(Image* src, int tileX, int tileY, int tileWidth, int tileHeight)
|
|
static SharedPtr<Image> GetTileImage(Image* src, int tileX, int tileY, int tileWidth, int tileHeight)
|
|
|
{
|
|
{
|
|
|
- return SharedPtr<Image>(src->GetSubimage(IntRect(tileX * tileWidth, tileY * tileHeight, (tileX + 1) * tileWidth, (tileY + 1) * tileHeight)));
|
|
|
|
|
|
|
+ return SharedPtr<Image>(
|
|
|
|
|
+ src->GetSubimage(IntRect(tileX * tileWidth, tileY * tileHeight, (tileX + 1) * tileWidth, (tileY + 1) * tileHeight)));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
TextureCube::TextureCube(Context* context) :
|
|
TextureCube::TextureCube(Context* context) :
|
|
@@ -65,7 +66,7 @@ TextureCube::TextureCube(Context* context) :
|
|
|
addressMode_[COORD_U] = ADDRESS_CLAMP;
|
|
addressMode_[COORD_U] = ADDRESS_CLAMP;
|
|
|
addressMode_[COORD_V] = ADDRESS_CLAMP;
|
|
addressMode_[COORD_V] = ADDRESS_CLAMP;
|
|
|
addressMode_[COORD_W] = ADDRESS_CLAMP;
|
|
addressMode_[COORD_W] = ADDRESS_CLAMP;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
|
faceMemoryUse_[i] = 0;
|
|
faceMemoryUse_[i] = 0;
|
|
|
}
|
|
}
|
|
@@ -83,11 +84,11 @@ void TextureCube::RegisterObject(Context* context)
|
|
|
bool TextureCube::BeginLoad(Deserializer& source)
|
|
bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
{
|
|
{
|
|
|
ResourceCache* cache = GetSubsystem<ResourceCache>();
|
|
ResourceCache* cache = GetSubsystem<ResourceCache>();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// In headless mode, do not actually load the texture, just return success
|
|
// In headless mode, do not actually load the texture, just return success
|
|
|
if (!graphics_)
|
|
if (!graphics_)
|
|
|
return true;
|
|
return true;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// If device is lost, retry later
|
|
// If device is lost, retry later
|
|
|
if (graphics_->IsDeviceLost())
|
|
if (graphics_->IsDeviceLost())
|
|
|
{
|
|
{
|
|
@@ -95,19 +96,19 @@ bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
dataPending_ = true;
|
|
dataPending_ = true;
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
cache->ResetDependencies(this);
|
|
cache->ResetDependencies(this);
|
|
|
|
|
|
|
|
String texPath, texName, texExt;
|
|
String texPath, texName, texExt;
|
|
|
SplitPath(GetName(), texPath, texName, texExt);
|
|
SplitPath(GetName(), texPath, texName, texExt);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
loadParameters_ = (new XMLFile(context_));
|
|
loadParameters_ = (new XMLFile(context_));
|
|
|
if (!loadParameters_->Load(source))
|
|
if (!loadParameters_->Load(source))
|
|
|
{
|
|
{
|
|
|
loadParameters_.Reset();
|
|
loadParameters_.Reset();
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
loadImages_.Clear();
|
|
loadImages_.Clear();
|
|
|
|
|
|
|
|
XMLElement textureElem = loadParameters_->GetRoot();
|
|
XMLElement textureElem = loadParameters_->GetRoot();
|
|
@@ -119,15 +120,16 @@ bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
// If path is empty, add the XML file path
|
|
// If path is empty, add the XML file path
|
|
|
if (GetPath(name).Empty())
|
|
if (GetPath(name).Empty())
|
|
|
name = texPath + name;
|
|
name = texPath + name;
|
|
|
-
|
|
|
|
|
- CubeMapLayout layout = (CubeMapLayout)GetStringListIndex(imageElem.GetAttribute("layout").CString(), cubeMapLayoutNames, CML_HORIZONTAL);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ CubeMapLayout layout =
|
|
|
|
|
+ (CubeMapLayout)GetStringListIndex(imageElem.GetAttribute("layout").CString(), cubeMapLayoutNames, CML_HORIZONTAL);
|
|
|
SharedPtr<Image> image = cache->GetTempResource<Image>(name);
|
|
SharedPtr<Image> image = cache->GetTempResource<Image>(name);
|
|
|
if (!image)
|
|
if (!image)
|
|
|
return false;
|
|
return false;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int faceWidth, faceHeight;
|
|
int faceWidth, faceHeight;
|
|
|
loadImages_.Resize(MAX_CUBEMAP_FACES);
|
|
loadImages_.Resize(MAX_CUBEMAP_FACES);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
switch (layout)
|
|
switch (layout)
|
|
|
{
|
|
{
|
|
|
case CML_HORIZONTAL:
|
|
case CML_HORIZONTAL:
|
|
@@ -140,14 +142,14 @@ bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
loadImages_[FACE_POSITIVE_Y] = GetTileImage(image, 4, 0, faceWidth, faceHeight);
|
|
loadImages_[FACE_POSITIVE_Y] = GetTileImage(image, 4, 0, faceWidth, faceHeight);
|
|
|
loadImages_[FACE_NEGATIVE_Y] = GetTileImage(image, 5, 0, faceWidth, faceHeight);
|
|
loadImages_[FACE_NEGATIVE_Y] = GetTileImage(image, 5, 0, faceWidth, faceHeight);
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case CML_HORIZONTALNVIDIA:
|
|
case CML_HORIZONTALNVIDIA:
|
|
|
faceWidth = image->GetWidth() / MAX_CUBEMAP_FACES;
|
|
faceWidth = image->GetWidth() / MAX_CUBEMAP_FACES;
|
|
|
faceHeight = image->GetHeight();
|
|
faceHeight = image->GetHeight();
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
|
loadImages_[i] = GetTileImage(image, i, 0, faceWidth, faceHeight);
|
|
loadImages_[i] = GetTileImage(image, i, 0, faceWidth, faceHeight);
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case CML_HORIZONTALCROSS:
|
|
case CML_HORIZONTALCROSS:
|
|
|
faceWidth = image->GetWidth() / 4;
|
|
faceWidth = image->GetWidth() / 4;
|
|
|
faceHeight = image->GetHeight() / 3;
|
|
faceHeight = image->GetHeight() / 3;
|
|
@@ -158,7 +160,7 @@ bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
loadImages_[FACE_NEGATIVE_Z] = GetTileImage(image, 3, 1, faceWidth, faceHeight);
|
|
loadImages_[FACE_NEGATIVE_Z] = GetTileImage(image, 3, 1, faceWidth, faceHeight);
|
|
|
loadImages_[FACE_NEGATIVE_Y] = GetTileImage(image, 1, 2, faceWidth, faceHeight);
|
|
loadImages_[FACE_NEGATIVE_Y] = GetTileImage(image, 1, 2, faceWidth, faceHeight);
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case CML_VERTICALCROSS:
|
|
case CML_VERTICALCROSS:
|
|
|
faceWidth = image->GetWidth() / 3;
|
|
faceWidth = image->GetWidth() / 3;
|
|
|
faceHeight = image->GetHeight() / 4;
|
|
faceHeight = image->GetHeight() / 4;
|
|
@@ -174,7 +176,7 @@ bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
loadImages_[FACE_NEGATIVE_Z]->FlipHorizontal();
|
|
loadImages_[FACE_NEGATIVE_Z]->FlipHorizontal();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case CML_BLENDER:
|
|
case CML_BLENDER:
|
|
|
faceWidth = image->GetWidth() / 3;
|
|
faceWidth = image->GetWidth() / 3;
|
|
|
faceHeight = image->GetHeight() / 2;
|
|
faceHeight = image->GetHeight() / 2;
|
|
@@ -194,14 +196,14 @@ bool TextureCube::BeginLoad(Deserializer& source)
|
|
|
while (faceElem)
|
|
while (faceElem)
|
|
|
{
|
|
{
|
|
|
String name = faceElem.GetAttribute("name");
|
|
String name = faceElem.GetAttribute("name");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// If path is empty, add the XML file path
|
|
// If path is empty, add the XML file path
|
|
|
if (GetPath(name).Empty())
|
|
if (GetPath(name).Empty())
|
|
|
name = texPath + name;
|
|
name = texPath + name;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
loadImages_.Push(cache->GetTempResource<Image>(name));
|
|
loadImages_.Push(cache->GetTempResource<Image>(name));
|
|
|
cache->StoreResourceDependency(this, name);
|
|
cache->StoreResourceDependency(this, name);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
faceElem = faceElem.GetNext("face");
|
|
faceElem = faceElem.GetNext("face");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -224,18 +226,18 @@ bool TextureCube::EndLoad()
|
|
|
// In headless mode, do not actually load the texture, just return success
|
|
// In headless mode, do not actually load the texture, just return success
|
|
|
if (!graphics_ || graphics_->IsDeviceLost())
|
|
if (!graphics_ || graphics_->IsDeviceLost())
|
|
|
return true;
|
|
return true;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// If over the texture budget, see if materials can be freed to allow textures to be freed
|
|
// If over the texture budget, see if materials can be freed to allow textures to be freed
|
|
|
CheckTextureBudget(GetTypeStatic());
|
|
CheckTextureBudget(GetTypeStatic());
|
|
|
|
|
|
|
|
SetParameters(loadParameters_);
|
|
SetParameters(loadParameters_);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned i = 0; i < loadImages_.Size() && i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < loadImages_.Size() && i < MAX_CUBEMAP_FACES; ++i)
|
|
|
SetData((CubeMapFace)i, loadImages_[i]);
|
|
SetData((CubeMapFace)i, loadImages_[i]);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
loadImages_.Clear();
|
|
loadImages_.Clear();
|
|
|
loadParameters_.Reset();
|
|
loadParameters_.Reset();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -260,7 +262,7 @@ void TextureCube::OnDeviceReset()
|
|
|
dataLost_ = true;
|
|
dataLost_ = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
dataPending_ = false;
|
|
dataPending_ = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -270,19 +272,19 @@ void TextureCube::Release()
|
|
|
{
|
|
{
|
|
|
if (!graphics_)
|
|
if (!graphics_)
|
|
|
return;
|
|
return;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
|
|
for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
|
|
|
{
|
|
{
|
|
|
if (graphics_->GetTexture(i) == this)
|
|
if (graphics_->GetTexture(i) == this)
|
|
|
graphics_->SetTexture(i, 0);
|
|
graphics_->SetTexture(i, 0);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
|
{
|
|
{
|
|
|
if (renderSurfaces_[i])
|
|
if (renderSurfaces_[i])
|
|
|
renderSurfaces_[i]->Release();
|
|
renderSurfaces_[i]->Release();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
((IDirect3DCubeTexture9*)object_)->Release();
|
|
((IDirect3DCubeTexture9*)object_)->Release();
|
|
|
object_ = 0;
|
|
object_ = 0;
|
|
|
}
|
|
}
|
|
@@ -300,25 +302,25 @@ bool TextureCube::SetSize(int size, unsigned format, TextureUsage usage)
|
|
|
LOGERROR("Depth-stencil usage not supported for cube maps");
|
|
LOGERROR("Depth-stencil usage not supported for cube maps");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Delete the old rendersurfaces if any
|
|
// Delete the old rendersurfaces if any
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
|
{
|
|
{
|
|
|
renderSurfaces_[i].Reset();
|
|
renderSurfaces_[i].Reset();
|
|
|
faceMemoryUse_[i] = 0;
|
|
faceMemoryUse_[i] = 0;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
pool_ = D3DPOOL_MANAGED;
|
|
pool_ = D3DPOOL_MANAGED;
|
|
|
usage_ = 0;
|
|
usage_ = 0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (usage == TEXTURE_RENDERTARGET)
|
|
if (usage == TEXTURE_RENDERTARGET)
|
|
|
{
|
|
{
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
|
renderSurfaces_[i] = new RenderSurface(this);
|
|
renderSurfaces_[i] = new RenderSurface(this);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
usage_ |= D3DUSAGE_RENDERTARGET;
|
|
usage_ |= D3DUSAGE_RENDERTARGET;
|
|
|
pool_ = D3DPOOL_DEFAULT;
|
|
pool_ = D3DPOOL_DEFAULT;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Nearest filtering and mipmaps disabled by default
|
|
// Nearest filtering and mipmaps disabled by default
|
|
|
filterMode_ = FILTER_NEAREST;
|
|
filterMode_ = FILTER_NEAREST;
|
|
|
requestedLevels_ = 1;
|
|
requestedLevels_ = 1;
|
|
@@ -328,54 +330,54 @@ bool TextureCube::SetSize(int size, unsigned format, TextureUsage usage)
|
|
|
usage_ |= D3DUSAGE_DYNAMIC;
|
|
usage_ |= D3DUSAGE_DYNAMIC;
|
|
|
pool_ = D3DPOOL_DEFAULT;
|
|
pool_ = D3DPOOL_DEFAULT;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (usage == TEXTURE_RENDERTARGET)
|
|
if (usage == TEXTURE_RENDERTARGET)
|
|
|
SubscribeToEvent(E_RENDERSURFACEUPDATE, HANDLER(TextureCube, HandleRenderSurfaceUpdate));
|
|
SubscribeToEvent(E_RENDERSURFACEUPDATE, HANDLER(TextureCube, HandleRenderSurfaceUpdate));
|
|
|
else
|
|
else
|
|
|
UnsubscribeFromEvent(E_RENDERSURFACEUPDATE);
|
|
UnsubscribeFromEvent(E_RENDERSURFACEUPDATE);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
width_ = size;
|
|
width_ = size;
|
|
|
height_ = size;
|
|
height_ = size;
|
|
|
format_ = format;
|
|
format_ = format;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return Create();
|
|
return Create();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int width, int height, const void* data)
|
|
bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int width, int height, const void* data)
|
|
|
{
|
|
{
|
|
|
PROFILE(SetTextureData);
|
|
PROFILE(SetTextureData);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!object_)
|
|
if (!object_)
|
|
|
{
|
|
{
|
|
|
LOGERROR("No texture created, can not set data");
|
|
LOGERROR("No texture created, can not set data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!data)
|
|
if (!data)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Null source for setting data");
|
|
LOGERROR("Null source for setting data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (level >= levels_)
|
|
if (level >= levels_)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Illegal mip level for setting data");
|
|
LOGERROR("Illegal mip level for setting data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (graphics_->IsDeviceLost())
|
|
if (graphics_->IsDeviceLost())
|
|
|
{
|
|
{
|
|
|
LOGWARNING("Texture data assignment while device is lost");
|
|
LOGWARNING("Texture data assignment while device is lost");
|
|
|
dataPending_ = true;
|
|
dataPending_ = true;
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (IsCompressed())
|
|
if (IsCompressed())
|
|
|
{
|
|
{
|
|
|
x &= ~3;
|
|
x &= ~3;
|
|
|
y &= ~3;
|
|
y &= ~3;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int levelWidth = GetLevelWidth(level);
|
|
int levelWidth = GetLevelWidth(level);
|
|
|
int levelHeight = GetLevelHeight(level);
|
|
int levelHeight = GetLevelHeight(level);
|
|
|
if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || width <= 0 || height <= 0)
|
|
if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || width <= 0 || height <= 0)
|
|
@@ -383,38 +385,38 @@ bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int wi
|
|
|
LOGERROR("Illegal dimensions for setting data");
|
|
LOGERROR("Illegal dimensions for setting data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
D3DLOCKED_RECT d3dLockedRect;
|
|
D3DLOCKED_RECT d3dLockedRect;
|
|
|
RECT d3dRect;
|
|
RECT d3dRect;
|
|
|
d3dRect.left = x;
|
|
d3dRect.left = x;
|
|
|
d3dRect.top = y;
|
|
d3dRect.top = y;
|
|
|
d3dRect.right = x + width;
|
|
d3dRect.right = x + width;
|
|
|
d3dRect.bottom = y + height;
|
|
d3dRect.bottom = y + height;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
DWORD flags = 0;
|
|
DWORD flags = 0;
|
|
|
if (level == 0 && x == 0 && y == 0 && width == levelWidth && height == levelHeight && pool_ == D3DPOOL_DEFAULT)
|
|
if (level == 0 && x == 0 && y == 0 && width == levelWidth && height == levelHeight && pool_ == D3DPOOL_DEFAULT)
|
|
|
flags |= D3DLOCK_DISCARD;
|
|
flags |= D3DLOCK_DISCARD;
|
|
|
-
|
|
|
|
|
- if (FAILED(((IDirect3DCubeTexture9*)object_)->LockRect((D3DCUBEMAP_FACES)face, level, &d3dLockedRect, (flags &
|
|
|
|
|
- D3DLOCK_DISCARD) ? 0 : &d3dRect, flags)))
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (FAILED(((IDirect3DCubeTexture9*)object_)->LockRect((D3DCUBEMAP_FACES)face, level, &d3dLockedRect,
|
|
|
|
|
+ (flags & D3DLOCK_DISCARD) ? 0 : &d3dRect, flags)))
|
|
|
{
|
|
{
|
|
|
LOGERROR("Could not lock texture");
|
|
LOGERROR("Could not lock texture");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (IsCompressed())
|
|
if (IsCompressed())
|
|
|
{
|
|
{
|
|
|
height = (height + 3) >> 2;
|
|
height = (height + 3) >> 2;
|
|
|
y >>= 2;
|
|
y >>= 2;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
unsigned char* src = (unsigned char*)data;
|
|
unsigned char* src = (unsigned char*)data;
|
|
|
unsigned rowSize = GetRowDataSize(width);
|
|
unsigned rowSize = GetRowDataSize(width);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// GetRowDataSize() returns CPU-side (source) data size, so need to convert for X8R8G8B8
|
|
// GetRowDataSize() returns CPU-side (source) data size, so need to convert for X8R8G8B8
|
|
|
if (format_ == D3DFMT_X8R8G8B8)
|
|
if (format_ == D3DFMT_X8R8G8B8)
|
|
|
rowSize = rowSize / 3 * 4;
|
|
rowSize = rowSize / 3 * 4;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Perform conversion from RGB / RGBA as necessary
|
|
// Perform conversion from RGB / RGBA as necessary
|
|
|
switch (format_)
|
|
switch (format_)
|
|
|
{
|
|
{
|
|
@@ -426,32 +428,38 @@ bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int wi
|
|
|
src += rowSize;
|
|
src += rowSize;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case D3DFMT_X8R8G8B8:
|
|
case D3DFMT_X8R8G8B8:
|
|
|
for (int i = 0; i < height; ++i)
|
|
for (int i = 0; i < height; ++i)
|
|
|
{
|
|
{
|
|
|
unsigned char* dest = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
unsigned char* dest = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
|
for (int j = 0; j < width; ++j)
|
|
for (int j = 0; j < width; ++j)
|
|
|
{
|
|
{
|
|
|
- *dest++ = src[2]; *dest++ = src[1]; *dest++ = src[0]; *dest++ = 255;
|
|
|
|
|
|
|
+ *dest++ = src[2];
|
|
|
|
|
+ *dest++ = src[1];
|
|
|
|
|
+ *dest++ = src[0];
|
|
|
|
|
+ *dest++ = 255;
|
|
|
src += 3;
|
|
src += 3;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case D3DFMT_A8R8G8B8:
|
|
case D3DFMT_A8R8G8B8:
|
|
|
for (int i = 0; i < height; ++i)
|
|
for (int i = 0; i < height; ++i)
|
|
|
{
|
|
{
|
|
|
unsigned char* dest = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
unsigned char* dest = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
|
for (int j = 0; j < width; ++j)
|
|
for (int j = 0; j < width; ++j)
|
|
|
{
|
|
{
|
|
|
- *dest++ = src[2]; *dest++ = src[1]; *dest++ = src[0]; *dest++ = src[3];
|
|
|
|
|
|
|
+ *dest++ = src[2];
|
|
|
|
|
+ *dest++ = src[1];
|
|
|
|
|
+ *dest++ = src[0];
|
|
|
|
|
+ *dest++ = src[3];
|
|
|
src += 4;
|
|
src += 4;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
((IDirect3DCubeTexture9*)object_)->UnlockRect((D3DCUBEMAP_FACES)face, level);
|
|
((IDirect3DCubeTexture9*)object_)->UnlockRect((D3DCUBEMAP_FACES)face, level);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -461,7 +469,7 @@ bool TextureCube::SetData(CubeMapFace face, Deserializer& source)
|
|
|
SharedPtr<Image> image(new Image(context_));
|
|
SharedPtr<Image> image(new Image(context_));
|
|
|
if (!image->Load(source))
|
|
if (!image->Load(source))
|
|
|
return false;
|
|
return false;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return SetData(face, image);
|
|
return SetData(face, image);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -472,14 +480,14 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
LOGERROR("Null image, can not load texture");
|
|
LOGERROR("Null image, can not load texture");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
unsigned memoryUse = 0;
|
|
unsigned memoryUse = 0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int quality = QUALITY_HIGH;
|
|
int quality = QUALITY_HIGH;
|
|
|
Renderer* renderer = GetSubsystem<Renderer>();
|
|
Renderer* renderer = GetSubsystem<Renderer>();
|
|
|
if (renderer)
|
|
if (renderer)
|
|
|
quality = renderer->GetTextureQuality();
|
|
quality = renderer->GetTextureQuality();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!image->IsCompressed())
|
|
if (!image->IsCompressed())
|
|
|
{
|
|
{
|
|
|
unsigned char* levelData = image->GetData();
|
|
unsigned char* levelData = image->GetData();
|
|
@@ -487,13 +495,13 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
int levelHeight = image->GetHeight();
|
|
int levelHeight = image->GetHeight();
|
|
|
unsigned components = image->GetComponents();
|
|
unsigned components = image->GetComponents();
|
|
|
unsigned format = 0;
|
|
unsigned format = 0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (levelWidth != levelHeight)
|
|
if (levelWidth != levelHeight)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Cube texture width not equal to height");
|
|
LOGERROR("Cube texture width not equal to height");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Discard unnecessary mip levels
|
|
// Discard unnecessary mip levels
|
|
|
for (unsigned i = 0; i < mipsToSkip_[quality]; ++i)
|
|
for (unsigned i = 0; i < mipsToSkip_[quality]; ++i)
|
|
|
{
|
|
{
|
|
@@ -502,26 +510,30 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
levelWidth = image->GetWidth();
|
|
levelWidth = image->GetWidth();
|
|
|
levelHeight = image->GetHeight();
|
|
levelHeight = image->GetHeight();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
switch (components)
|
|
switch (components)
|
|
|
{
|
|
{
|
|
|
case 1:
|
|
case 1:
|
|
|
format = useAlpha ? Graphics::GetAlphaFormat() : Graphics::GetLuminanceFormat();
|
|
format = useAlpha ? Graphics::GetAlphaFormat() : Graphics::GetLuminanceFormat();
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case 2:
|
|
case 2:
|
|
|
format = Graphics::GetLuminanceAlphaFormat();
|
|
format = Graphics::GetLuminanceAlphaFormat();
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case 3:
|
|
case 3:
|
|
|
format = Graphics::GetRGBFormat();
|
|
format = Graphics::GetRGBFormat();
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case 4:
|
|
case 4:
|
|
|
format = Graphics::GetRGBAFormat();
|
|
format = Graphics::GetRGBAFormat();
|
|
|
break;
|
|
break;
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ assert(false); // Should never reach here
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Create the texture when face 0 is being loaded, check that rest of the faces are same size & format
|
|
// Create the texture when face 0 is being loaded, check that rest of the faces are same size & format
|
|
|
if (!face)
|
|
if (!face)
|
|
|
{
|
|
{
|
|
@@ -543,12 +555,12 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned i = 0; i < levels_; ++i)
|
|
for (unsigned i = 0; i < levels_; ++i)
|
|
|
{
|
|
{
|
|
|
SetData(face, i, 0, 0, levelWidth, levelHeight, levelData);
|
|
SetData(face, i, 0, 0, levelWidth, levelHeight, levelData);
|
|
|
memoryUse += levelWidth * levelHeight * components;
|
|
memoryUse += levelWidth * levelHeight * components;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (i < levels_ - 1)
|
|
if (i < levels_ - 1)
|
|
|
{
|
|
{
|
|
|
image = image->GetNextLevel();
|
|
image = image->GetNextLevel();
|
|
@@ -565,19 +577,19 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
unsigned levels = image->GetNumCompressedLevels();
|
|
unsigned levels = image->GetNumCompressedLevels();
|
|
|
unsigned format = graphics_->GetFormat(image->GetCompressedFormat());
|
|
unsigned format = graphics_->GetFormat(image->GetCompressedFormat());
|
|
|
bool needDecompress = false;
|
|
bool needDecompress = false;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (width != height)
|
|
if (width != height)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Cube texture width not equal to height");
|
|
LOGERROR("Cube texture width not equal to height");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!format)
|
|
if (!format)
|
|
|
{
|
|
{
|
|
|
format = Graphics::GetRGBAFormat();
|
|
format = Graphics::GetRGBAFormat();
|
|
|
needDecompress = true;
|
|
needDecompress = true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
unsigned mipsToSkip = mipsToSkip_[quality];
|
|
unsigned mipsToSkip = mipsToSkip_[quality];
|
|
|
if (mipsToSkip >= levels)
|
|
if (mipsToSkip >= levels)
|
|
|
mipsToSkip = levels - 1;
|
|
mipsToSkip = levels - 1;
|
|
@@ -585,11 +597,11 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
--mipsToSkip;
|
|
--mipsToSkip;
|
|
|
width /= (1 << mipsToSkip);
|
|
width /= (1 << mipsToSkip);
|
|
|
height /= (1 << mipsToSkip);
|
|
height /= (1 << mipsToSkip);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
|
|
// Create the texture when face 0 is being loaded, assume rest of the faces are same size & format
|
|
|
if (!face)
|
|
if (!face)
|
|
|
{
|
|
{
|
|
|
- SetNumLevels(Max((int)(levels - mipsToSkip), 1));
|
|
|
|
|
|
|
+ SetNumLevels((unsigned)Max((int)(levels - mipsToSkip), 1));
|
|
|
SetSize(width, format);
|
|
SetSize(width, format);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -605,7 +617,7 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
|
|
for (unsigned i = 0; i < levels_ && i < levels - mipsToSkip; ++i)
|
|
|
{
|
|
{
|
|
|
CompressedLevel level = image->GetCompressedLevel(i + mipsToSkip);
|
|
CompressedLevel level = image->GetCompressedLevel(i + mipsToSkip);
|
|
@@ -624,13 +636,13 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
faceMemoryUse_[face] = memoryUse;
|
|
faceMemoryUse_[face] = memoryUse;
|
|
|
unsigned totalMemoryUse = sizeof(TextureCube);
|
|
unsigned totalMemoryUse = sizeof(TextureCube);
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
|
totalMemoryUse += faceMemoryUse_[i];
|
|
totalMemoryUse += faceMemoryUse_[i];
|
|
|
SetMemoryUse(totalMemoryUse);
|
|
SetMemoryUse(totalMemoryUse);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -641,35 +653,35 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
LOGERROR("No texture created, can not get data");
|
|
LOGERROR("No texture created, can not get data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!dest)
|
|
if (!dest)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Null destination for getting data");
|
|
LOGERROR("Null destination for getting data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (level >= levels_)
|
|
if (level >= levels_)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Illegal mip level for getting data");
|
|
LOGERROR("Illegal mip level for getting data");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (graphics_->IsDeviceLost())
|
|
if (graphics_->IsDeviceLost())
|
|
|
{
|
|
{
|
|
|
LOGWARNING("Getting texture data while device is lost");
|
|
LOGWARNING("Getting texture data while device is lost");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int levelWidth = GetLevelWidth(level);
|
|
int levelWidth = GetLevelWidth(level);
|
|
|
int levelHeight = GetLevelHeight(level);
|
|
int levelHeight = GetLevelHeight(level);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
D3DLOCKED_RECT d3dLockedRect;
|
|
D3DLOCKED_RECT d3dLockedRect;
|
|
|
RECT d3dRect;
|
|
RECT d3dRect;
|
|
|
d3dRect.left = 0;
|
|
d3dRect.left = 0;
|
|
|
d3dRect.top = 0;
|
|
d3dRect.top = 0;
|
|
|
d3dRect.right = levelWidth;
|
|
d3dRect.right = levelWidth;
|
|
|
d3dRect.bottom = levelHeight;
|
|
d3dRect.bottom = levelHeight;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
IDirect3DSurface9* offscreenSurface = 0;
|
|
IDirect3DSurface9* offscreenSurface = 0;
|
|
|
// Need to use a offscreen surface & GetRenderTargetData() for rendertargets
|
|
// Need to use a offscreen surface & GetRenderTargetData() for rendertargets
|
|
|
if (renderSurfaces_[face])
|
|
if (renderSurfaces_[face])
|
|
@@ -681,7 +693,7 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
|
|
IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
|
|
|
- device->CreateOffscreenPlainSurface(width_, height_, (D3DFORMAT)format_, D3DPOOL_SYSTEMMEM, &offscreenSurface, 0);
|
|
|
|
|
|
|
+ device->CreateOffscreenPlainSurface((UINT)width_, (UINT)height_, (D3DFORMAT)format_, D3DPOOL_SYSTEMMEM, &offscreenSurface, 0);
|
|
|
if (!offscreenSurface)
|
|
if (!offscreenSurface)
|
|
|
{
|
|
{
|
|
|
LOGERROR("Could not create surface for getting rendertarget data");
|
|
LOGERROR("Could not create surface for getting rendertarget data");
|
|
@@ -697,23 +709,24 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- if (FAILED(((IDirect3DCubeTexture9*)object_)->LockRect((D3DCUBEMAP_FACES)face, level, &d3dLockedRect, &d3dRect, D3DLOCK_READONLY)))
|
|
|
|
|
|
|
+ if (FAILED(
|
|
|
|
|
+ ((IDirect3DCubeTexture9*)object_)->LockRect((D3DCUBEMAP_FACES)face, level, &d3dLockedRect, &d3dRect, D3DLOCK_READONLY)))
|
|
|
{
|
|
{
|
|
|
LOGERROR("Could not lock texture");
|
|
LOGERROR("Could not lock texture");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int height = levelHeight;
|
|
int height = levelHeight;
|
|
|
if (IsCompressed())
|
|
if (IsCompressed())
|
|
|
height = (height + 3) >> 2;
|
|
height = (height + 3) >> 2;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
unsigned char* destPtr = (unsigned char*)dest;
|
|
unsigned char* destPtr = (unsigned char*)dest;
|
|
|
unsigned rowSize = GetRowDataSize(levelWidth);
|
|
unsigned rowSize = GetRowDataSize(levelWidth);
|
|
|
// GetRowDataSize() returns CPU-side (destination) data size, so need to convert for X8R8G8B8
|
|
// GetRowDataSize() returns CPU-side (destination) data size, so need to convert for X8R8G8B8
|
|
|
if (format_ == D3DFMT_X8R8G8B8)
|
|
if (format_ == D3DFMT_X8R8G8B8)
|
|
|
rowSize = rowSize / 3 * 4;
|
|
rowSize = rowSize / 3 * 4;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Perform conversion to RGB / RGBA as necessary
|
|
// Perform conversion to RGB / RGBA as necessary
|
|
|
switch (format_)
|
|
switch (format_)
|
|
|
{
|
|
{
|
|
@@ -725,32 +738,38 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
destPtr += rowSize;
|
|
destPtr += rowSize;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case D3DFMT_X8R8G8B8:
|
|
case D3DFMT_X8R8G8B8:
|
|
|
for (int i = 0; i < height; ++i)
|
|
for (int i = 0; i < height; ++i)
|
|
|
{
|
|
{
|
|
|
unsigned char* src = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
unsigned char* src = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
|
for (int j = 0; j < levelWidth; ++j)
|
|
for (int j = 0; j < levelWidth; ++j)
|
|
|
{
|
|
{
|
|
|
- destPtr[2] = *src++; destPtr[1] = *src++; destPtr[0] = *src++; ++src;
|
|
|
|
|
|
|
+ destPtr[2] = *src++;
|
|
|
|
|
+ destPtr[1] = *src++;
|
|
|
|
|
+ destPtr[0] = *src++;
|
|
|
|
|
+ ++src;
|
|
|
destPtr += 3;
|
|
destPtr += 3;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case D3DFMT_A8R8G8B8:
|
|
case D3DFMT_A8R8G8B8:
|
|
|
for (int i = 0; i < height; ++i)
|
|
for (int i = 0; i < height; ++i)
|
|
|
{
|
|
{
|
|
|
unsigned char* src = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
unsigned char* src = (unsigned char*)d3dLockedRect.pBits + i * d3dLockedRect.Pitch;
|
|
|
for (int j = 0; j < levelWidth; ++j)
|
|
for (int j = 0; j < levelWidth; ++j)
|
|
|
{
|
|
{
|
|
|
- destPtr[2] = *src++; destPtr[1] = *src++; destPtr[0] = *src++; destPtr[3] = *src++;
|
|
|
|
|
|
|
+ destPtr[2] = *src++;
|
|
|
|
|
+ destPtr[1] = *src++;
|
|
|
|
|
+ destPtr[0] = *src++;
|
|
|
|
|
+ destPtr[3] = *src++;
|
|
|
destPtr += 4;
|
|
destPtr += 4;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (offscreenSurface)
|
|
if (offscreenSurface)
|
|
|
{
|
|
{
|
|
|
offscreenSurface->UnlockRect();
|
|
offscreenSurface->UnlockRect();
|
|
@@ -758,26 +777,26 @@ bool TextureCube::GetData(CubeMapFace face, unsigned level, void* dest) const
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
((IDirect3DCubeTexture9*)object_)->UnlockRect((D3DCUBEMAP_FACES)face, level);
|
|
((IDirect3DCubeTexture9*)object_)->UnlockRect((D3DCUBEMAP_FACES)face, level);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool TextureCube::Create()
|
|
bool TextureCube::Create()
|
|
|
{
|
|
{
|
|
|
Release();
|
|
Release();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!graphics_ || !width_ || !height_)
|
|
if (!graphics_ || !width_ || !height_)
|
|
|
return false;
|
|
return false;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (graphics_->IsDeviceLost())
|
|
if (graphics_->IsDeviceLost())
|
|
|
{
|
|
{
|
|
|
LOGWARNING("Texture creation while device is lost");
|
|
LOGWARNING("Texture creation while device is lost");
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
|
|
IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
|
|
|
if (!device || FAILED(device->CreateCubeTexture(
|
|
if (!device || FAILED(device->CreateCubeTexture(
|
|
|
- width_,
|
|
|
|
|
|
|
+ (UINT)width_,
|
|
|
requestedLevels_,
|
|
requestedLevels_,
|
|
|
usage_,
|
|
usage_,
|
|
|
(D3DFORMAT)format_,
|
|
(D3DFORMAT)format_,
|
|
@@ -788,9 +807,9 @@ bool TextureCube::Create()
|
|
|
LOGERROR("Could not create cube texture");
|
|
LOGERROR("Could not create cube texture");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
levels_ = ((IDirect3DCubeTexture9*)object_)->GetLevelCount();
|
|
levels_ = ((IDirect3DCubeTexture9*)object_)->GetLevelCount();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (usage_ & D3DUSAGE_RENDERTARGET)
|
|
if (usage_ & D3DUSAGE_RENDERTARGET)
|
|
|
{
|
|
{
|
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
|
|
@@ -799,7 +818,7 @@ bool TextureCube::Create()
|
|
|
(IDirect3DSurface9**)&renderSurfaces_[i]->surface_);
|
|
(IDirect3DSurface9**)&renderSurfaces_[i]->surface_);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|