RenderTargetPtr D3D9VideoBufferManager::CreateRenderTarget(TexturePtr rtTex)
{
	int rWidth = rtTex->GetWidth(), rHeight = rtTex->GetHeight(); 

	if (rWidth == -1 || rHeight == -1)
	{
		rWidth = Engine::Instance()->GetDeviceProperty()->Width;
		rHeight = Engine::Instance()->GetDeviceProperty()->Height;
	}

	IDirect3DSurface9 * pD3D9RenderTarget = NULL;

	D3D9RenderTarget * pTexture = new D3D9RenderTarget(mD3D9Device);

	pTexture->mName = rtTex->GetName();
	pTexture->mWidth = rWidth;
	pTexture->mHeight = rHeight;
	pTexture->mFormat = rtTex->GetFormat();
	pTexture->mMSAA = MSAA_NONE;
	pTexture->mTexture = rtTex;

	D3D9Texture * d3dTex = (D3D9Texture *)rtTex.c_ptr();

	d3dTex->GetD3DTexture()->GetSurfaceLevel(0, &pTexture->mRenderTarget);

	mRenderTargets.Insert(pTexture->GetName(), pTexture);

	return RenderTargetPtr(pTexture);
}
void D3D9VideoBufferManager::BitBlt(TexturePtr texDest, ImagePtr imageSrc, const Rect * pDest, const Rect * pSrc)
{
    IDirect3DTexture9 * pD3DDestTexture = NULL;
    IDirect3DTexture9 * pD3DSrcTexture = NULL;

    if (texDest->GetTextureType() == TEXTYPE_2D)
    {
        pD3DDestTexture = static_cast<D3D9Texture*>(texDest.c_ptr())->mD3D9Texture;
    }

    D3D9Image * img = (D3D9Image*)imageSrc.c_ptr();
    pD3DSrcTexture = img->_MyTexture();
    
    assert(pD3DDestTexture && pD3DSrcTexture);

    IDirect3DSurface9 * pDestSurface;
    IDirect3DSurface9 * pSrcSurface;
    const RECT * pDestRect = reinterpret_cast<const RECT *>(pDest);
    const RECT * pSrcRect = reinterpret_cast<const RECT *>(pSrc);

    pD3DDestTexture->GetSurfaceLevel(0, &pDestSurface);
    pD3DSrcTexture->GetSurfaceLevel(0, &pSrcSurface);

    D3DXLoadSurfaceFromSurface(pDestSurface, 
                               NULL,
                               pDestRect,
                               pSrcSurface,
                               NULL,
                               pSrcRect,
                               D3DX_DEFAULT,
                               0);
}
示例#3
0
	TexturePtr NullHWBufferManager::LoadTexture(const String & filename, float priority, int mipmaps, eUsage usage)
	{
		Hash2 hash(filename.c_str());

		TexturePtr p = _find(hash, filename);
		if (p == NULL)
		{
			NullTexture * pTexture = new NullTexture(filename, filename);
			pTexture->mWidth = 0;
			pTexture->mHeight = 0;
			pTexture->mMipmaps = 1;
			pTexture->mUsage = usage;
			pTexture->mFormat = ePixelFormat::UNKNOWN;
			pTexture->mPriority = priority;

			p = pTexture;

			mTextureMap.Insert(hash, p.c_ptr());
		}

		if (priority < 0)
		{
			p->EnsureLoad();
		}
		else
		{
			p->Load();
		}

		return p;
	}