Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MadProgrammer

really wierd flicker in fullscreen

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a fullscreen d3d9 app that runs fine for the most part. on my laptop, it works great, but on my desktop, the underlying windows show through sometimes. the problem is a lot more pronounced when i turn on any form of anti-aliasing (not through code, but manually from windows). the desktop is running xp pro with a geforce fx 5600 and 512mb of ram. i AM running with 2 monitors, but that really **shouldnt** cause a problem. all i do is create a window, initialize d3d, and go. i did put in the code to initialize direct input in exclusive mode, but that didnt fix anything. =/ i AM creating and destroying windows some before i get to the fullscreen part of my code, but i dont think that''s the problem because i took that out once and it still did the flickering junk well, heres the code... thanks for reading such a long post... matt -----heres the code to create a window class-----
bool createTheWindowClass(HINSTANCE &hInstance, HWND &hWnd, MSG &msg)
{
	WNDCLASSEX winClass;		// window class structure (for creating a window)


	winClass.cbSize				= sizeof(WNDCLASSEX);				// the size of this structure

	winClass.style				= CS_HREDRAW | CS_VREDRAW;			// style of window - redraws on horizontal or vertical resizes (only in windowed mode)

	winClass.lpfnWndProc		= WndProc;							// address of the function that gets the messages - WndProc()

	winClass.cbClsExtra			= 0;								// crap we dont need

	winClass.cbWndExtra			= 0;								// (more) crap we dont need

	winClass.hInstance			= hInstance;						// handle to instance of app

	winClass.hIcon				= LoadIcon(0, IDI_APPLICATION);		// handle to the icon of the app (must be a resource)

	winClass.hIconSm			= LoadIcon(0, IDI_APPLICATION);		// handle to the small icon of the app (must be a resource)

	winClass.hCursor			= LoadCursor(0, IDC_ARROW);			// handle to the cursor of the app (must be a resource)

	winClass.hbrBackground		= 0;								// handle to a background brush (we dont need it)

	winClass.lpszMenuName		= 0;								// string holding name of menu resource (not needed)

	winClass.lpszClassName		= "excro";							// window class name; must be same as the one in CreateWindowEx()


	if(!RegisterClassEx(&winClass))    // register the class we described

		return false;    // that''s not good, we give up


	return true;
}
-----heres the code to create the window-----
bool createTheWindowFS(HINSTANCE &hInstance, HWND &hWnd, MSG &msg)
{
	hWnd = CreateWindowEx(WS_EX_TOPMOST, "excro", "Extreme Croquet", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, gScreenWidth, gScreenHeight, 0, 0, hInstance, 0);

	if(!hWnd)    // did we get a window?

		return false;    // no? that''s not good either, we give up


	ShowWindow(hWnd, SW_SHOW);	// show the window

	UpdateWindow(hWnd);			// update the window

	SetFocus(hWnd);				// focus on the window

	SetForegroundWindow(hWnd);	// make it the foreground window


	return true;
}
-----heres the code to init d3d----- (minus all the error checking for readability)
bool GRAPHICS::initD3D(HWND hWnd)
{
	D3DDISPLAYMODE			d3dDisplayMode;
	D3DPRESENT_PARAMETERS	d3dParams;
	D3DCAPS9				d3dCaps;

	// clear out our variables

	ZeroMemory(&d3dDisplayMode, sizeof(d3dDisplayMode));
	ZeroMemory(&d3dParams, sizeof(d3dParams));
	ZeroMemory(&d3dCaps, sizeof(d3dCaps));

	d3dObject = Direct3DCreate9(D3D_SDK_VERSION);	// create an instance of direct3d


	d3dObject->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3dDisplayMode);

	d3dObject->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps);

	// find out what kind of vertex processing we should use

	DWORD vertexProcessing = 0;
	if(d3dCaps.VertexProcessingCaps)
		vertexProcessing |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else
		vertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	d3dParams.Windowed					= !gFullscreen;
	d3dParams.BackBufferWidth			= gScreenWidth;
	d3dParams.BackBufferHeight			= gScreenHeight;
	d3dParams.SwapEffect				= D3DSWAPEFFECT_DISCARD;
	d3dParams.BackBufferFormat			= d3dDisplayMode.Format;
	d3dParams.BackBufferCount			= 1;
	d3dParams.EnableAutoDepthStencil	= true;
	d3dParams.AutoDepthStencilFormat	= D3DFMT_D16;

	d3dObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, vertexProcessing, &d3dParams, &d3dDevice);

	/* set rendering states */
	d3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);				// enable the z-buffer

	d3dDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(200, 200, 200));// disable ambient lighting

	d3dDevice->SetRenderState(D3DRS_LIGHTING, true);					// enable lighting

	d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);			// disable backface culling

	d3dDevice->SetRenderState(D3DRS_NORMALIZENORMALS, true);			// disable backface culling


	/* clamp textures so we dont get that crappy wrap-around */
	d3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
	d3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);

	/* set filtering settings */
	d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

	/* set up our directional light */
	ZeroMemory(&d3dLight, sizeof(d3dLight));
	d3dLight.Type			= D3DLIGHT_DIRECTIONAL;
	d3dLight.Diffuse.r		= 1.0f;
	d3dLight.Diffuse.g		= 1.0f;
	d3dLight.Diffuse.b		= 1.0f;
	d3dLight.Direction.x	= -0.75f;
	d3dLight.Direction.y	= -1.0f;
	d3dLight.Direction.z	= 0.0f;
	d3dDevice->SetLight(0, &d3dLight);
	d3dDevice->LightEnable(0, true);

	ZeroMemory(&d3dMaterial, sizeof(d3dMaterial));
	d3dMaterial.Diffuse.r	= 1.0f;
	d3dMaterial.Diffuse.g	= 1.0f;
	d3dMaterial.Diffuse.b	= 1.0f;

	setPerspective(); // call our setPerspective function

	
	return true; // yay! everything worked so far!

}

Share this post


Link to post
Share on other sites
Advertisement
I have the same problem, I also have two monitors.
What I did is to handle all the WindowMessages dealing with drawing the screen.
It would like something like this:

case WM_PAINT:
case WM_NCPAINT:
case WM_ERASEBKGND:
case WM_ICONERASEBKGND:
case WM_PAINTICON:
ValidateRgn (hWnd, NULL);
break;

That helped to reduce the amount of flicks I got, but it might caused other problems which I dont remember right now.

Share this post


Link to post
Share on other sites
When you''re creating the window, use WS_POPUP | WS_VISIBLE. That stopped my flickering problem anyway.

/*
I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)
*/

Share this post


Link to post
Share on other sites
yeah... for future reference, Programmer16 was right.... using WS_POPUP | WS_VISIBLE seems to have fixed the problem... wierd.

thanks :-)

matt the MadProgrammer


edit... see below

[edited by - MadProgrammer on February 10, 2004 11:14:51 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by MadProgrammer
yeah... for future reference, ''The C modest god'' was right.... using WS_POPUP | WS_VISIBLE seems to have fixed the problem... wierd.

thanks :-)

matt the MadProgrammer


Um, the ''The C modest god'' didn''t say that, I did.

quote:
Original post by Programmer16
When you''re creating the window, use WS_POPUP | WS_VISIBLE. That stopped my flickering problem anyway.

/*
I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)
*/


Just wanted to point that out!

/*
I use DirectX 8.1 and C++ (Microsoft Visual C++ 6.0 Professional edition)
*/

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!