• 9
• 9
• 10
• 10
• 9

# Graphics bug with direct x

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

## Recommended Posts

So I'm having an issue where items in my game seem to blur and parts of the screen don't update each frame. When I change the line md3dPP.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; to md3dPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; to this line it all but gets rid of the problem but the problem still persists rarely. Here are some pictures of it happening.

##### Share on other sites
Do you clear your screen before each frame? Simply drawing over and over will give this result. You should call Clear() on your IDirect3DDevice9 object with flags to clear both the target and the zbuffer.

##### Share on other sites
I'm using a skybox which I call before every beginScene() call and that should replace all the needed clear calls. But if i do make the clear call it fixes the problem but my skybox flashes the clear color.

Maybe it has something to do with the shader I'm using.

uniform extern float4x4 gWVP;uniform extern texture  gEnvMap;sampler EnvMapS = sampler_state{    Texture   = <gEnvMap>;    MinFilter = LINEAR;     MagFilter = LINEAR;    MipFilter = LINEAR;    AddressU  = WRAP;    AddressV  = WRAP;};void SkyVS(float3 posL : POSITION0,            out float4 oPosH : POSITION0,            out float3 oEnvTex : TEXCOORD0){	oPosH = mul(float4(posL, 1.0f), gWVP).xyww;         oEnvTex = posL;}float4 SkyPS(float3 envTex : TEXCOORD0) : COLOR{    return texCUBE(EnvMapS, envTex);}technique SkyTech{    pass P0    {        vertexShader = compile vs_2_0 SkyVS();        pixelShader  = compile ps_2_0 SkyPS();		CullMode = None;		ZFunc = Always; // Always write sky to depth buffer		StencilEnable = true;		StencilFunc   = Always;		StencilPass   = Replace;		StencilRef    = 0; // clear to zero    }}

##### Share on other sites
Quote:
 Original post by ScreamerI'm using a skybox which I call before every beginScene() call and that should replace all the needed clear calls. But if i do make the clear call it fixes the problem but my skybox flashes the clear color.
That indicates to me that you're only clearing on every other frame. Your skybox should completely cover the backbuffer, so you won't see the clear colour.

Also, any output from the Debug Runtimes?

##### Share on other sites
Nah I was just saying that if I cleared and called the draw of the skybox the background flashes because both are being called. That isn't the issue.

My debug output looks like this

Miss rate before optimization: 1.000000
Miss rate after optimization: 1.000000
First-chance exception at 0x7590f35f in Bird.exe: Microsoft C++ exception: long at memory location 0x0017fab8..
D3DX: Warning ID3DXEffect::EndPass. Changes have been made but not commited. CommitChange must be called before each DrawPrimitive call
Miss rate before optimization: 1.000000
Miss rate after optimization: 1.000000

With a lot more miss rate messages before and after. Then some memory leaks being dumped.

Oh and for the debug runtimes It wont let me click on it because the option is greyed out. I suppose I can update the DX version and post the output.

Thanks for the help,
Screamer

##### Share on other sites
Draw your skybox AFTER beginscene, not before.

##### Share on other sites
Quote:
 Original post by ScreamerNah I was just saying that if I cleared and called the draw of the skybox the background flashes because both are being called. That isn't the issue.
It sounds to me like it is - you shouldn't see any flash because you're overwriting the clear colour with the skybox, and then presenting, right? If you get flashing, then there's a fairly major problem.

Quote:
 Original post by ScreamerSo I got the new version of the directx to run the debug runtime with and here is the output i got.
The error is right there:
Quote:
 Direct3D9: (ERROR) :Need to call BeginScene before rendering.
Somewhere in your code you're rendering before calling BeginScene(), which is illegal.

Also, it looks to me like you're not checking your return values, because you call DrawIndexedPrimitive() (Or render a mesh, which calls DrawIndexedPrimitive internally), which could cause all manner of bugs on other hardware - you MUST check the return value (With the FAILED() or SUCCEEDED() macro, not testing against D3D_OK) of every function that returns data you rely on (Any Create*() calls, and functions like GetDeviceCaps()), and some other functions - in this case, if BeginScene() fails, you can't do any rendering.

##### Share on other sites
Ok so I fixed the first issue by putting the skybox call in the proper place. Don't know why i put it out there. But an issue persists. Right now im getting randomly colored holes in the draw. It looks like this but everywhere randomly.

gd3dDevice->BeginScene();//gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0087CEEB, 1.0f, 0);mSky->draw();

If I uncomment the line above then the flashing holes are just the clear color.

Thanks,
Screamer