Jump to content
  • Advertisement
Sign in to follow this  

RenderToSurface problem. BeginScene returning invalid call

This topic is 4608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have a problem on RenderToSurface. lpRenderToSurface->BeginScene(lpSurface, NULL ); Row always return INVALID CALL. I can't find where is the problem.

//Some codes from device creation 

       d3dpp.BackBufferWidth =nContentWidth;
	d3dpp.BackBufferHeight =nContentHeight;
	d3dpp.BackBufferFormat =d3ddm.Format;
	d3dpp.BackBufferCount = 1;
	d3dpp.MultiSampleType =D3DMULTISAMPLE_NONE;	
	d3dpp.SwapEffect = //D3DSWAPEFFECT_COPY;
	d3dpp.hDeviceWindow = hWnd;
	d3dpp.Windowed =bWindowed; 
	d3dpp.EnableAutoDepthStencil = true;
	d3dpp.AutoDepthStencilFormat =D3DFMT_D16;
	d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
	//Ekran tazeleme hızını bekleme
	d3dpp.PresentationInterval= D3DPRESENT_INTERVAL_IMMEDIATE;

		&d3dpp, &g_pd3dDevice ))){
			BTLog.WriteLog("X Direct3D error");
			return E_FAIL;
	}else BTLog.WriteLog("V Direct3D ok");

//RenderToSurface Init fonction
void CBT_RENDERTOSURFACE::InitRenderToSurface(LPDIRECT3DDEVICE9 lpD3DDevice,int nWidth,int nHeight){
	if (lpD3DDevice!=NULL) {
	}else {
		MessageBox(NULL,"Render To Surface init hatası","",MB_OK);
    static D3DDISPLAYMODE mode;
    lpDevice->GetDisplayMode( 0, &mode );
    D3DXCreateTexture( lpDevice, nWidth, nHeight, 1, D3DUSAGE_RENDERTARGET,mode.Format, D3DPOOL_DEFAULT, &lpTexture );

    lpTexture->GetSurfaceLevel(0, &lpSurface);
    D3DXCreateRenderToSurface( lpDevice, desc.Width, desc.Height, desc.Format,TRUE, D3DFMT_D16, &lpRenderToSurface );


void CBT_RENDERTOSURFACE::BeginRender(){
	lpRenderToSurface->BeginScene(lpSurface, NULL ); //return INVALID CALL
	lpDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 200, 200, 200 ), 1.0f, 0);	


Share this post

Link to post
Share on other sites
D3DERR_INVALIDCALL usually indicates a problem with one of the parameters you passed to the function that returned the error or a previous function which forms part of the same operation.

Try linking your code against D3DX9D.LIB (note the D on the end of the library name). That will give you extra debug output from D3DX calls (output to the active debugger/debug stream as with D3D calls).

That said, from a quick look, I can't see anything immediately wrong with the code you've posted so I think seeing if D3DX9D.LIB has anything to say in your output window is definately the first thing to try.

Share this post

Link to post
Share on other sites
Just a guess, but are you perhaps calling that CBT_RENDERTOSURFACE::BeginRender() after you've already called BeginScene() on your 'default' rendertarget? I had the same error (though that might not say much) a while back and it proved to be caused by this issue. AFAIK, you should do any rendering to additional render targets outside of any other BeginScene() ... EndScene() blocks.

Hope this helps & please correct me if I'm wrong :)

Share this post

Link to post
Share on other sites
Thanks for help frends. When I increase DX Debug Output level, in output windows show follow erros. And remigius your are correct problem is gone. Thank you very much.

Direct3D9: (ERROR) :BeginScene, already in scene. BeginScene failed.
D3D9 Helper: IDirect3DDevice9::BeginScene failed: D3DERR_INVALIDCALL
D3DX: BeginScene failed
D3DX: EndScene called outside a scene

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!