Screen flicker problem

Started by
7 comments, last by monkeyography 21 years, 2 months ago
I've get a weird kind of screen flicker going on. The flicker is in the form of a blacked out screen (or a section of the screen by some accounts), for one frame. The flicker apparently happens every time the character starts moving and also on occasion if you jut let the game sit. My 'Frames per Second' text, rendered via "d3dfont.h" does not flicker though, just the 3d stuff. a flicker will be composed of a black screen with a lonely 'Frames per Second' in the upper left corner. SwapEffect is currently set to D3DSWAPEFFECT_DISCARD though I have tried every other kind and none of them affect the flicker. Strangely, the flicker does not affect my computer (athlon750, geforce2pro, win2k, directX8.1 developer), but does affect every single other computer I've ever run my game on (amd/pIII/pIV, geforce2/geforce4, win2k/winXP, directX8.? runtime) here's a recent compile if you want to see the flicker for yourself (arrow keys to move player) thanks for any help [edited by - monkeyography on February 9, 2003 10:56:49 AM]
Advertisement
Could this have anything to do with my having the developer version of DirectX and everyone else just having the runtime?
It is not the developer version of directx.

Here is what MIGHT be happening, but I am not sure as I have not seen your code. Some graphic cards do not like the near clip plane of the Perspective Fov to be set to 0. If your code looks like this(or similar) simply change the near clip plane to 1.0f.

D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4,1.0f, 0,//Near Clip Plane
5000.0f );

chang to
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 5000.0f );
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Changed the near clipping plane from .1 to 1.0 but to no effect. Also tried the game out on a (2ghz, RIVA TNT2 Model 64, winXP) machine and the 3d stuff would only appear during a screen refresh event, like when the window got or lost focus.

here''s the source, along with all the art required to run the game, if you want to check it out. On my computer the folder lies in DXINSTALL\samples\Multimedia\Direct3D\. (I cut out a bunch of files (photoshop, old code) to keep down the size of the zip file... hope i didn''t leave out any thing essential)

Most of the directX settings are set in WindowManager::InitD3D. the majority of scene drawing calls are made in GameManager::updateOrRender() and PlayState::draw()

thanks a bunch everyone. this has been a real pain
Yeah, for some reason this is happening in one of my programs as well. It only seems to happen in my MFC windowed application (editor) and not my fullscreen Win32 game.
I just got the flicker to appear on my computer (geforce2gts) by creating a device with D3DCREATE_HARDWARE_VERTEXPROCESSING rather than D3DCREATE_SOFTWARE_VERTEXPROCESSING. This is interesting. The geforce2 is supposed to support hardware vertex processing, and my framerate does go up 150%, but there''s obviously something weird happening because with hardware vertex processing the flicker appears on my computer, same as everyone else''s.

Of course, I''d been specifying software vertex processing at all times before this, so why have other people''s machines always gotten the flicker?

Here''s the code where I set up my Direct3D settings:

  HRESULT WindowManager::initD3D( HWND hWnd ){    // Create the D3D object.    if( NULL == ( pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) ){        std::cerr << "Your system needs DirectX 8 or higher, please visit\n"                  << "http://microsoft.com/directx "                  << "and download the latest runtime\n";        return E_FAIL;    }    // Get the current desktop display mode, so we can set up a back    // buffer of the same format    D3DDISPLAYMODE d3ddm;    if( FAILED( pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )    {        std::cerr << "FATAL_ERROR: failed to get current desktop display mode";        return E_FAIL;    }    // Set up the structure used to create the D3DDevice. Since we are now    // using more complex geometry, we will create a device with a zbuffer.    D3DPRESENT_PARAMETERS d3dpp;     ZeroMemory( &d3dpp, sizeof(d3dpp) );    d3dpp.Windowed = TRUE;    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    d3dpp.BackBufferFormat = d3ddm.Format;    d3dpp.EnableAutoDepthStencil = TRUE;    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;    // Create the D3DDevice    if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,                                    D3DCREATE_SOFTWARE_VERTEXPROCESSING,                                    &d3dpp, &pd3dDevice ) ) )    {        std::cerr << "FATAL_ERROR: failed to create Direct3D Device";        return E_FAIL;    }    // Turn on the zbuffer    pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );    // Turn on backface culling     pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );    // use mip-maps on textures    pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR  );    pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR  );    // alpha blending settings    pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );    pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );    // normalize normals    pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );    // Turn on lighting     D3DXVECTOR3 vecDir1;    D3DLIGHT8 light1;    ZeroMemory( &light1, sizeof(D3DLIGHT8) );    light1.Type       = D3DLIGHT_DIRECTIONAL;    light1.Diffuse.r  = 0.8f;    light1.Diffuse.g  = 0.8f;    light1.Diffuse.b  = 0.8f;    vecDir1 = D3DXVECTOR3( -0.5f, 0.6f, 1.0f );    D3DXVec3Normalize( (D3DXVECTOR3*)&light1.Direction, &vecDir1 );    light1.Range       = 1000.0f;    pd3dDevice->SetLight( 0, &light1 );    pd3dDevice->LightEnable( 0, TRUE);    pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );    pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00252525 );    return S_OK;}  
this happened to me on a game I am making. It was because the timer I set was too low. It was set to update every 3 milliseconds. When I moved it up to 30 it stopped. This might not be the problem tho.
extended waranty, how can I lose!
I could be wrong here, but are you limitting your frame rate to some value, say 60? I havent really looked at your code as I have no time. If you ''lock'' the frame rate, I suggest to remove that and use vsync instead, or use time based movement.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
By default, the game will update what''s going on 30 times per second, between updates it will draw the scene as many times as possible (linearly interpolating any animation). On my machine it gets 100fps, I''ve seen it get between 3fps and 350 fps on other machines. I''ve toyed with vsync and it doesn''t affect anything but framerate, the flicker will persist.

I went and toyed with framerate just now though, tying it to the update rate and then bringing that rate down to once per second for some *real* careful examination. Anything 3d will not render for one frame each time a player makes a move. Also, anything 3d will not render for one frame whenever there''s a screen refresh event, like when i move another window on top of the game. Also, the less complex I make the scene(by not drawing certain elements) the less often the flicker occurs

Of course, everything works 100%perfectAOKhunkydory on my machine if I use software vertex processing. Any configuration whatsoever on machines other than my own, however, will always suffer from the flicker.

This is so damned bizarre! Flames are shooting out of my ass! Big angry flames!

This topic is closed to new replies.

Advertisement