コード例 #1
0
ファイル: DirectX11Texture.cpp プロジェクト: shadercoder/scge
bool DirectX11Texture::finaliseLoad()
{
	if(FAILED(D3DX11CreateShaderResourceViewFromMemory(mResourceData->mD3D11Device, mLoadingData.data(), mLoadingData.size(), nullptr, nullptr, mTextureSRV.getModifiablePointer(), nullptr)))
		return true;
	mLoadingData.clear();

	return false;
}
コード例 #2
0
HRESULT TextureLoader::LoadFromCompiledContentFile(ID3D11Device* device, std::istream* input,
                                                   TextureOptions* options, WCHAR* errorMsg, UINT errorLen, TextureContent** contentOut)
{
    HRESULT hr;

    UINT size;
    BYTE* data;
    hr = ReadFileFromStream(*input, &data, size);
    if (FAILED(hr))
    {
        return hr;
    }

    TextureContent* content = new TextureContent();

    hr = D3DX11GetImageInfoFromMemory(data, size, NULL, &content->Info, NULL);
    if (FAILED(hr))
    {
        FormatDXErrorMessageW(hr, errorMsg, errorLen);
        delete[] data;
        return hr;
    }

    if (options && options->Generate3DFrom2D)
    {
        hr = CreateDDSTexture3DFromMemory(device, data, size, &content->ShaderResourceView);
    }
    else
    {
        hr = D3DX11CreateShaderResourceViewFromMemory(device, data, size, NULL, NULL,
            &content->ShaderResourceView, NULL);
    }
    delete[] data;
    if (FAILED(hr))
    {
        FormatDXErrorMessageW(hr, errorMsg, errorLen);
        return hr;
    }

    if (options && options->DebugName)
    {
        CHAR debugName[256];

        sprintf_s(debugName, "%s %s", options->DebugName, "SRV");
        V_RETURN(SetDXDebugName(content->ShaderResourceView, debugName));
    }
    *contentOut = content;
    return S_OK;
}
コード例 #3
0
		D3D11Texture *D3D11Texture::load(ID3D11Device *device, ResourceStream &stream)
		{
			void *data = (void *)new char[stream.getSize()];
			stream.read(data, 0, stream.getSize());

			ID3D11ShaderResourceView *texture;

			HRESULT hr = D3DX11CreateShaderResourceViewFromMemory(device, data, stream.getSize(), NULL, NULL, &texture, NULL);

			delete [] data;

			if (FAILED(hr))
			{
				Log::getPtr()->error("Could not create D3D11Texture from Resource [" + stream.getResourceID() + "]");
				return 0;
			}

			return new D3D11Texture(texture);
		}