Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualSolid_Spy

Posted 29 November 2012 - 02:12 PM

Ok, well now i have another problem.

I know how to create surfaces and render to them, but the depth doesn't seem to transfer.

I have depth buffer enabled, but i have 3d objects being drawn on top of each other. what i do?

Here's my code:

shaderbuff->GetSurfaceLevel(0, &blur_surface1);

// Is there something i should be doing here?

d3ddev->SetRenderTarget(0, blur_surface1);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1, 0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
	d3ddev->SetFVF(CUSTOMFVF);
if(playing == 1)
{
	D3DXMATRIX matView;
	D3DXMatrixLookAtLH(&matView,
					   &D3DXVECTOR3 (x, y + 1, z + 10),
					   &D3DXVECTOR3 (cos(yaw) + x, y + 1, sin(yaw) + z + 10),
					   &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));
	d3ddev->SetTransform(D3DTS_VIEW, &matView);
	D3DXMATRIX matProjection;
	D3DXMatrixPerspectiveFovLH(&matProjection,
							   D3DXToRadian(45),
							   (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT,
							   0.0f,
							   100.0f);
d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);
  D3DXMATRIX mattranslate;
	 for(int i = 0; i < 16; i++)
  {
   for(int j = 0; j < 16; j++)
   {
	D3DXMatrixTranslation(&mattranslate, i * 3.0f, 0.0f, j * 3.0f);
d3ddev->SetTransform(D3DTS_WORLD, &mattranslate);
	d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
d3ddev->SetIndices(i_buffer);
	d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
   }
}
}
d3ddev->EndScene();
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
d3ddev->SetRenderTarget(0, backbuffer);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, 0, NULL, NULL);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
//d3ddev->SetPixelShader(blur_shader);
d3ddev->SetTexture(0, texture1);
d3ddev->StretchRect(blur_surface1, &rect, backbuffer, &rect2, D3DTEXF_NONE);
if(playing == 0)
{
for(UINT i = 0; i < objectlist.size(); i++)
{
  objectlist[i].Render();
}
}
d3ddev->EndScene();
	d3ddev->Present(NULL, NULL, NULL, NULL);
d3ddev->SetTexture(0, NULL);

Credit goes to DirectXTutorial.com for helping me out.

#3Solid_Spy

Posted 29 November 2012 - 02:12 PM

Ok, well now i have another problem.

I know how to create surfaces and render to them, but the depth doesn't seem to transfer.

I have depth buffer enabled, but i have 3d objects being drawn on top of each other. what i do?

Here's my code:

shaderbuff->GetSurfaceLevel(0, &blur_surface1);

// Is there something i should be doing here?

d3ddev->SetRenderTarget(0, depth_buffer1);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1, 0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
	d3ddev->SetFVF(CUSTOMFVF);
if(playing == 1)
{
	D3DXMATRIX matView;
	D3DXMatrixLookAtLH(&matView,
					   &D3DXVECTOR3 (x, y + 1, z + 10),
					   &D3DXVECTOR3 (cos(yaw) + x, y + 1, sin(yaw) + z + 10),
					   &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));
	d3ddev->SetTransform(D3DTS_VIEW, &matView);
	D3DXMATRIX matProjection;
	D3DXMatrixPerspectiveFovLH(&matProjection,
							   D3DXToRadian(45),
							   (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT,
							   0.0f,
							   100.0f);
d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);
  D3DXMATRIX mattranslate;
	 for(int i = 0; i < 16; i++)
  {
   for(int j = 0; j < 16; j++)
   {
	D3DXMatrixTranslation(&mattranslate, i * 3.0f, 0.0f, j * 3.0f);
d3ddev->SetTransform(D3DTS_WORLD, &mattranslate);
	d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
d3ddev->SetIndices(i_buffer);
	d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
   }
}
}
d3ddev->EndScene();
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
d3ddev->SetRenderTarget(0, backbuffer);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, 0, NULL, NULL);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
//d3ddev->SetPixelShader(blur_shader);
d3ddev->SetTexture(0, texture1);
d3ddev->StretchRect(blur_surface1, &rect, backbuffer, &rect2, D3DTEXF_NONE);
if(playing == 0)
{
for(UINT i = 0; i < objectlist.size(); i++)
{
  objectlist[i].Render();
}
}
d3ddev->EndScene();
	d3ddev->Present(NULL, NULL, NULL, NULL);
d3ddev->SetTexture(0, NULL);

Credit goes to DirectXTutorial.com for helping me out.

#2Solid_Spy

Posted 29 November 2012 - 02:10 PM

Ok, well now i have another problem.

I know how to create surfaces and render to them, but the depth doesn't seem to transfer.

I have depth buffer enabled, but i have 3d objects being drawn on top of each other. what i do?

Here's my code:

shaderbuff->GetSurfaceLevel(0, &blur_surface1);
d3ddev->SetRenderTarget(0, depth_buffer1);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1, 0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
    d3ddev->SetFVF(CUSTOMFVF);
if(playing == 1)
{
    D3DXMATRIX matView;
    D3DXMatrixLookAtLH(&matView,
					   &D3DXVECTOR3 (x, y + 1, z + 10),
					   &D3DXVECTOR3 (cos(yaw) + x, y + 1, sin(yaw) + z + 10),
					   &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));
    d3ddev->SetTransform(D3DTS_VIEW, &matView);
    D3DXMATRIX matProjection;
    D3DXMatrixPerspectiveFovLH(&matProjection,
							   D3DXToRadian(45),
							   (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT,
							   0.0f,
							   100.0f);
d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);
  D3DXMATRIX mattranslate;
	 for(int i = 0; i < 16; i++)
  {
   for(int j = 0; j < 16; j++)
   {
    D3DXMatrixTranslation(&mattranslate, i * 3.0f, 0.0f, j * 3.0f);
d3ddev->SetTransform(D3DTS_WORLD, &mattranslate);
    d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
d3ddev->SetIndices(i_buffer);
    d3ddev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
   }
}
}
d3ddev->EndScene();
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
d3ddev->SetRenderTarget(0, backbuffer);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, 0, NULL, NULL);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();
//d3ddev->SetPixelShader(blur_shader);
d3ddev->SetTexture(0, texture1);
d3ddev->StretchRect(blur_surface1, &rect, backbuffer, &rect2, D3DTEXF_NONE);
if(playing == 0)
{
for(UINT i = 0; i < objectlist.size(); i++)
{
  objectlist[i].Render();
}
}
d3ddev->EndScene();
    d3ddev->Present(NULL, NULL, NULL, NULL);
d3ddev->SetTexture(0, NULL);

Credit goes to DirectXTutorial.com for helping me out.

#1Solid_Spy

Posted 29 November 2012 - 02:04 PM

Ok, well now i have another problem.

I know how to create surfaces and render to them, but the depth doesn't seem to transfer.

I have depth buffer enabled, but i have 3d objects being drawn on top of each other. what i do?

PARTNERS