Archived

This topic is now archived and is closed to further replies.

Yoshi

D3D8 render to surface

Recommended Posts

Hi, I have the following problem. I don''t get the render to surface functions to work. I set up a texture as render surface and have a device that was created by D3DXRendertoSurface(or something similar). The devices are all valid and return S_OK. But now my problem occurs. I call RenderSurface->BeginScene(TargetSurface,ViewPort) and the function returns an E_FAIL. Code is below. I don''t know where the error is located. I want to use DrawText to render to a texture. Maybe there is another solution I haven''t noticed yet?
  

// Tagpos is an Rect that contains the texure size

// TextTex is an LPDIRECT3DTEXURE8

// FontSurface is an LPDIRECT3DSURFACE8

// Vp is an Viewport

// I have a 32Bit main-rendertarget

HRESULT err=D3DXCreateTexture(lpD3DDevice8,TagPos.right-TagPos.left,TagPos.bottom-TagPos.top,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&TextTex);
	TextTex->GetSurfaceLevel(0,&FontSurface);
	err=D3DXCreateRenderToSurface(lpD3DDevice8,TagPos.right-TagPos.left,TagPos.bottom-TagPos.top,D3DFMT_A8R8G8B8,FALSE,D3DFMT_D16,&RenderSurface);
	D3DXRTS_DESC Desc;
	RenderSurface->GetDesc(&Desc);
	lpD3DDevice8->EndScene();
	Vp.X=0;
	Vp.Y=0;
	Vp.Width=TagPos.right-TagPos.left;
	Vp.Height=TagPos.bottom-TagPos.top;
// Here does the failure occur

	err=RenderSurface->BeginScene(FontSurface,&Vp);

[/code]
Yoshi  

Share this post


Link to post
Share on other sites