Problem rendering full screen quad

Started by
1 comment, last by cyberlorddan 13 years, 7 months ago
I'm trying to render a full screen quad, but when I reset my device nothing shows up on screen.

Let me explain. I first render some terrain in 3D, which shows up after I reset my device. Before implementing HDR lights I've started to build the screen quad. Everything goes fine until I reset my device. Nothing shows on screen.

I've debugged it with PIX and after I reset my device, the mesh shows up in the "Mesh" tab, but not on the "Render tab". Everything seems to be ok in the "Mesh" tab. Before I reset my device, when I debug a pixel it shows up all the events such as "clear" and the pixel shader stuff. After I reset my device just the "clear" and "final color" events appear.

This is the shader code:

struct VertexToPixel
{
float4 Position : POSITION;
float2 TexCoords : TEXCOORD0;
};

struct PixelToFrame
{
float4 Color : COLOR0;
};

VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float2 inTexCoords : TEXCOORD0)
{
VertexToPixel Output = (VertexToPixel)0;

Output.Position =inPos;
Output.Position.z = 1.0f;
Output.Position.w = 1.0f;
Output.Position.xy=Output.Position.xy/2.0f;
Output.TexCoords = inTexCoords;

return Output;
}

PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;

Output.Color = 0.9f;
Output.Color.a = 1.0f;

return Output;
}

technique Simplest
{
pass Pass0
{
VertexShader = compile vs_3_0 SimplestVertexShader();
PixelShader = compile ps_3_0 OurFirstPixelShader();
}
}


This is the render code:
direct3Ddevice->SetVertexDeclaration(g_pVertexDeclHardware2);
direct3Ddevice->SetIndices(LE_TERRAIN_QuadIndexBuffer);
direct3Ddevice->SetStreamSource(0, LE_TERRAIN_ScreenQuadVertexBuffer, 0, sizeof(le_screenQuadVertexFormat));
direct3Ddevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );

LE_ENGINE_screenQuadEffect->SetTechnique("Simplest");
LE_ENGINE_screenQuadEffect->CommitChanges();
UINT numPasses;
LE_ENGINE_screenQuadEffect->Begin(&numPasses, 0);
LE_ENGINE_screenQuadEffect->BeginPass(0);

direct3Ddevice->Clear(0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 0, 0);
direct3Ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
direct3Ddevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );

LE_ENGINE_screenQuadEffect->EndPass();
LE_ENGINE_screenQuadEffect->End();
direct3Ddevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );

I can't figure out what's wrong... I call effect.onLostDevice, effect.onResetDevice. The vertex buffer is reinitialized after the device resets. What's wrong???
Advertisement
Compare the render states before and after the reset, PIX can do a full dump of them. I remember a thread where someone suddenly had fog enabled after a reset. Obviously a reset can have such nasty effects.

And I'd set states and clear before calling effect->Begin(), maybe this is problematic, too.
Culling got re-enabled after reset. Thx for suggesting to check the render states!!!

This topic is closed to new replies.

Advertisement