////////////////////////////////////////////////////////////////
//
// CPixelsManager::SetVolumeTexturePixels
//
// Copy pixels into texture
//
////////////////////////////////////////////////////////////////
bool CPixelsManager::SetVolumeTexturePixels ( IDirect3DVolumeTexture9* pD3DVolumeTexture, const CPixels& pixels, const RECT* pRect, uint uiSlice )
{
    if ( !pD3DVolumeTexture )
        return false;

    IDirect3DVolume9* pVolume = NULL;
    CAutoReleaseMe < IDirect3DVolume9 > Thanks( pVolume );

    UINT Level = 0;
    pD3DVolumeTexture->GetVolumeLevel ( Level, &pVolume );
    if ( !pVolume )
        return false;

    bool bResult = false;
    D3DVOLUME_DESC Desc;
    pVolume->GetDesc ( &Desc );

    if ( Desc.Usage == 0 )
    {
        if ( Desc.Format == D3DFMT_A8R8G8B8 || Desc.Format == D3DFMT_X8R8G8B8 || Desc.Format == D3DFMT_R5G6B5 )
        {
            // Direct reading will work here
            bResult = SetVolumePixels ( pVolume, pixels, pRect, uiSlice );
        }
        else
        {
            return false;
        }
    }

    return bResult;
}
	void D3D9PixelBuffer::bind( uint32 mip, IDirect3DVolumeTexture9* texTarget )
	{
		unbind();
		mMipIndex = mip;
		m3DTarget = texTarget;
		IDirect3DVolume9* vol = NULL;
		if (FAILED(texTarget->GetVolumeLevel(mip, &vol)))
		{
			unbind();
			return;
		}
		D3DVOLUME_DESC desc;
		vol->GetDesc(&desc);
		mWidth	= desc.Width;
		mHeight	= desc.Height;
		mDepth	= desc.Depth;
		mFormat	= D3D9Translator::getPixelFormat(desc.Format);
		mRowPitch = mWidth * DPixelFormatTool::getFormatBytes(mFormat);
		mSlicePitch = mHeight * mRowPitch;
		mByteSize	= mSlicePitch * mDepth;
		ReleaseCOM(vol);
	}
Exemplo n.º 3
0
void
sge::d3d9::volumefuncs::unlock_box(
	IDirect3DVolume9 &_volume
)
{
	if(
		_volume.UnlockBox()
		!= D3D_OK
	)
		throw sge::renderer::exception(
			FCPPT_TEXT("Vurface::UnlockBox() failed!")
		);
}
Exemplo n.º 4
0
D3DVOLUME_DESC const
sge::d3d9::volumefuncs::get_desc(
	IDirect3DVolume9 &_volume
)
{
	D3DVOLUME_DESC ret;

	if(
		_volume.GetDesc(
			&ret
		)
		!= D3D_OK
	)
		throw sge::renderer::exception(
			FCPPT_TEXT("Volume::GetDesc() failed!")
		);

	return ret;
}