Sign in to follow this  

Rendering to texture, weird problem [DX9]

This topic is 3320 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

Hello :) I'm having strange problems with my engine, I'm rendering different scenes on textures and combining them into a scene manager. Everything works fine on my workstation (NVIDIA 8600GT), but I get weird picture on every other machine I tried. Also, rendering to texture doesn't work on the workstation with reference driver mode, which leads me to conclusion I'm not doing it properly. I get no warnings or errors with D3D debug runtime, except few warning about locking vertex buffers more than once per frame, which I think is not causing that problem. This is an example picture that I see on other machines running with HAL driver: That gray stuff all over it is changing on device reset, it does look different on every machine. In fact, the render target is cleared with that same color:
m_pd3dDevice->Clear(
  0,
  NULL,
  D3DCLEAR_TARGET,
  D3DCOLOR_XRGB( 100,100,100),
  1.0f,
  0);


Here's a part of the code that does the rendering to texture:
		LPDIRECT3DSURFACE9 oldDepthStencil;
		m_pd3dDevice->GetDepthStencilSurface(&oldDepthStencil);

		//render-to-texture
		LPDIRECT3DSURFACE9	pSurface;
		m_RenderTarget->GetSurfaceLevel(0, &pSurface);
		//set new render target
		m_pd3dDevice->SetRenderTarget(0, pSurface);

		m_pd3dDevice->SetDepthStencilSurface(m_pDepthStencilSurface);
		//clear texture
		m_pd3dDevice->Clear(0,
							NULL,
							D3DCLEAR_TARGET,
							D3DCOLOR_XRGB( 100,100,100),
							1.0f,
							0);

		m_pd3dDevice->BeginScene();

                // rendering the scene

		m_pd3dDevice->EndScene();

		// restore back buffer as render target
		LPDIRECT3DSURFACE9 pBackBuffer;
		m_pd3dDevice->GetBackBuffer(NULL, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
		m_pd3dDevice->SetRenderTarget(0, pBackBuffer);

		m_pd3dDevice->SetDepthStencilSurface(oldDepthStencil);
		oldDepthStencil->Release();

		SAFE_RELEASE(pBackBuffer);

		SAFE_RELEASE(pSurface);



Any ideas what I'm doing wrong ?

Share this post


Link to post
Share on other sites

This topic is 3320 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this