directx 9 fullscreen flicker

Started by
11 comments, last by staticVoid2 15 years, 1 month ago
hi there, I'm having this problem when I set my directx app to fullscreen... basically I have a textured cube stored as one vertex buffer and one index buffer, when I render this cube twice in the same frame some (random) parts of the screen flicker between the blue backbuffer color and the texture, I can't print a screen shot because everytime I try the blue flicker stops just for a split second, this only happens in fullscreen mode, any ideas what's wrong? this problem just started after I installed a new copy of windows, its the exact same operating system, I also had to download a more recent version of the directx sdk(november) and fix all the library paths. thanks for any help
Advertisement
Could be a driver issue, if it worked previous to your re-install of windows.

What's your device clear line look like?

ie:
pdev->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DXCOLOR( 0.1f, 0.1f, 0.1f, 1.0f), 1.0f, 0 );
Are you sure its not alternating green/pink? That's the debug runtime's way of telling you you're rendering to an uninitialized/uncleared buffer...

Try running a PIX capture as that should allow you to see each frame without you trying to grab a screenshot.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by PSS
Could be a driver issue, if it worked previous to your re-install of windows.

What's your device clear line look like?

ie:
*** Source Snippet Removed ***


	DWORD flags = 0;	if(backBuffer)		flags |= D3DCLEAR_TARGET;	if(zBuffer)		flags |= D3DCLEAR_ZBUFFER;	pDevice->Clear(0, NULL, flags, 0x000000ff, 1.0f, 0);


Quote:

Are you sure its not alternating green/pink? That's the debug runtime's way of telling you you're rendering to an uninitialized/uncleared buffer...

Try running a PIX capture as that should allow you to see each frame without you trying to grab a screenshot.

hth
Jack


no, it's definatly blue, or whatever color I choose for the back buffer color.

I'll try and get a screen shot and then post back.
every screen capture tool I've used doesn't work, I tried capturing a video aswell but the blue flickering just doesn't show up.

I've noticed that it doesn't flicker if I don't set a texture before calling device->DrawIndexedPrimitive(), the way I've set it up is that the texture class holds a separate pointer to the device so that I can just call Texture->set(int stage), here's what My render code looks like:

void Object::render(){	if(!m_pDevice || !m_pVertexBuffer || !m_pIndexBuffer || m_vertexCount < 3 || m_indexCount < 3)		return;	m_pDevice->SetMaterial(&m_material);	if(m_textures[0])		m_textures[0]->set(0);	m_pDevice->SetFVF(Vertex::FVF);	m_pDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(Vertex));	m_pDevice->SetIndices(m_pIndexBuffer);	m_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_vertexCount, 0, m_indexCount/3);	// unset the texture	pDevice->SetTexture(0, NULL);}void Texture::set(int stage){   if(m_pDevice)   {      m_pDevice->SetTexture(stage, m_pTexture);   }}



If I remove the m_textures[0]->set(0) part the the flicker dissapears. I also put all my render code in one function and call the SetTimer() function in windows, when I recieve the timer message I call this render function, could it be something to do with multithreading? if the two textures are trying to be set at the same time? (just a guess)


edit:

sorry, the setting of the texture has nothing to do with it, I've tried it without setting any textures and it still flickers.

Quote:
Are you sure its not alternating green/pink? That's the debug runtime's way of telling you you're rendering to an uninitialized/uncleared buffer...


It's now showing a pink/green strip along the top when it flickers, I was using the retail version before, thats why. how do I fix this?

[Edited by - staticVoid2 on March 19, 2009 6:17:22 PM]
Could definitely be a multithreading issue. It doesn't sound like you have a normal render loop. Are you clearing in one thread and rendering in another? Where are your BeginScene, EndScene and Present done?
here's most of the code, this also 'jumps' a lot when I switch to windowed mode(I call GetClientRect on the window handle after it's created and then use rect.right - rect.left and rect.bottom - rect.top for the back buffer width and height) but in fullscreen mode whole objects just switch between being visible and not.

RECT g_Screen;char szClassName[] = "WindowsApp";int  __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd){	GetClientRect(GetDesktopWindow(), &g_Screen);	WNDCLASSEX wincl;	HWND hWnd;	MSG msg;   wincl.hInstance = hInst;   wincl.lpszClassName = szClassName;   wincl.lpfnWndProc = WndProc;   wincl.style = CS_DBLCLKS;   wincl.cbSize = sizeof(WNDCLASSEX);   wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);   wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);   wincl.hCursor = LoadCursor(NULL, IDC_ARROW);   wincl.lpszMenuName = NULL;   wincl.cbClsExtra = 0;   wincl.cbWndExtra = 0;   wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;	RegisterClassEx(&wincl);	hWnd = CreateWindowEx(				0,				szClassName,				"Direct3D 9 demo",				WS_POPUP,				0,				0,				g_Screen.right,				g_Screen.bottom,				HWND_DESKTOP,				NULL,				hInst,				NULL);	SetTimer(hWnd, 0,1, 0);	ShowWindow(hWnd, 1);	ShowCursor(0);	while (GetMessage (&msg, NULL, 0, 0))	{		TranslateMessage(&msg);		DispatchMessage(&msg);	}	return 0;}void render(void){	if(FAILED(pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0)))	{		exit(0);	}	if(FAILED(pDevice->BeginScene()))	{		exit(0);	}	pDevice->SetTransform(D3DTS_VIEW, /*ViewMatrix*/);        object->render();        object->render();	pDevice->EndScene();        pDevice->Present(NULL, NULL, NULL, NULL);}LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){	switch(msg)	{		case WM_KEYDOWN:		{			if(LOWORD(wParam) == VK_ESCAPE)				PostQuitMessage(0);		}		break;		case WM_TIMER:		{			render();		}		break;		default:			return DefWindowProc(hWnd, msg, wParam, lParam);	}	return 0;}
What if you use the reference rasterizer?
Quote:Original post by Evil Steve
What if you use the reference rasterizer?


it goes too slow for me to get the camera into a position where it would flicker, it takes about 5 seconds to render one frame, even though it is only one cube(24 vertices and 36 indices) being rendered twice.
Quote:Original post by staticVoid2
Quote:Original post by Evil Steve
What if you use the reference rasterizer?


it goes too slow for me to get the camera into a position where it would flicker, it takes about 5 seconds to render one frame, even though it is only one cube(24 vertices and 36 indices) being rendered twice.
Yes, it's supposed to. If the reference rasterizer doesn't flicker, it's almost definitely a driver bug.

Can you not hack your code to warp you to a place that the screen would flicker?

This topic is closed to new replies.

Advertisement