Jump to content
  • Advertisement

Archived

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

TheGamerHART

Problem with init D3D

This topic is 5540 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

Hey, i´ve the following code in VC++6
HRESULT InitD3D(HWND hWnd)
{
	lpD3D = Direct3DCreate9(D3D_SDK_VERSION);

	if(lpD3D==NULL)
		return E_FAIL;

	
	D3DPRESENT_PARAMETERS d3dPP;
	d3dPP.Windowed=TRUE;
	d3dPP.SwapEffect=D3DSWAPEFFECT_DISCARD;
	d3dPP.BackBufferFormat=D3DFMT_UNKNOWN;
	d3dPP.BackBufferCount=1;


	lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
							&d3dPP, &lpD3D_Device);

	if(lpD3D==NULL)
		return E_FAIL;

	
	lpD3D_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	lpD3D_Device->SetRenderState(D3DRS_LIGHTING, FALSE);

	return S_OK;
}
 
When I start the program it stops at
lpD3D_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
 
The debug output windows says:
Loaded ''ntdll.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\kernel32.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\user32.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\gdi32.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\advapi32.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\rpcrt4.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\d3d9.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\d3d8thk.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\msvcrt.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\version.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\winmm.dll'', no matching symbolic information found.
Loaded ''C:\WINDOWS\system32\d3d9d.dll'', no matching symbolic information found.
Direct3D9: :====> ENTER: DLLMAIN(00c034f0): Process Attach: 00000668, tid=00000fd8
Direct3D9: (WARN) :Executing processor detection code (benign first-chance exception possible)

Direct3D9: (INFO) :MMX detected

Direct3D9: (INFO) entium Pro CPU features (fcomi, cmov) detected

Direct3D9: (INFO) :dwCPUFamily = 6, dwCPUFeatures = 7

Direct3D9: (INFO) :szCPUString = AuthenticAMD

Direct3D9: :====> EXIT: DLLMAIN(00c034f0): Process Attach: 00000668
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (ERROR) :BackBufferCount must be less than D3DPRESENT_BACK_BUFFERS_MAX. ValidatePresentParameters fails.
First-chance exception in DirectX.exe: 0xC0000005: Access Violation.
The program ''E:\OLDPROJECTS\DirectXAttempt\Debug\DirectX.exe'' has exited with code 0 (0x0).
 
Whats the problem? Regards TheGamer

Share this post


Link to post
Share on other sites
Advertisement
I think you can´t set d3dPP.BackBufferFormat=D3DFMT_UNKNOWN in windowed mode. Use GetDisplayMode() to obtain the current format of the desktop. Furthermore you should set d3dPP.hDeviceWindow to your target window ( NULL for focus-window).

Share this post


Link to post
Share on other sites
Safety Code:
ZeroMemory( &d3dPP, sizeof(d3dPP) );

But, you should really learn the difference between setting up a fullscreen DirectX application and a windowed one.

.lick

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
now this appears on debugging


Direct3D9: :====> ENTER: DLLMAIN(00c034f0): Process Attach: 00000f0c, tid=00000f04
Direct3D9: (WARN) :Executing processor detection code (benign first-chance exception possible)

Direct3D9: (INFO) :MMX detected

Direct3D9: (INFO) entium Pro CPU features (fcomi, cmov) detected

Direct3D9: (INFO) :dwCPUFamily = 6, dwCPUFeatures = 7

Direct3D9: (INFO) :szCPUString = AuthenticAMD

Direct3D9: :====> EXIT: DLLMAIN(00c034f0): Process Attach: 00000f0c
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
First-chance exception in DirectX.exe: 0xC0000005: Access Violation.
The program ''E:\OLDPROJECTS\DirectXAttempt\Debug\DirectX.exe'' has exited with code 0 (0x0).

Share this post


Link to post
Share on other sites
sorry the guy above is me

with this code


D3DPRESENT_PARAMETERS d3dPP;

memset(&d3dPP, 0, sizeof(D3DPRESENT_PARAMETERS));

d3dPP.Windowed=TRUE;
d3dPP.SwapEffect=D3DSWAPEFFECT_DISCARD;
d3dPP.BackBufferFormat=DisplayMode.Format;
d3dPP.hDeviceWindow=NULL;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Has anyone a proposal??

Share this post


Link to post
Share on other sites
d3dPP.hDeviceWindow=NULL; ?????
You should pass this the handle to the window you created.

d3dPP.hDeviceWindow=hWnd;

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites
quote:
Original post by UltimaX
d3dPP.hDeviceWindow=NULL; ?????
You should pass this the handle to the window you created.

d3dPP.hDeviceWindow=hWnd;

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"


Don''t think that''s necessary.

.lick

Share this post


Link to post
Share on other sites
lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dPP, &lpD3D_Device);

if(lpD3D==NULL)
return E_FAIL;


Why are you checking lpD3D instead of lpD3D_Device?

.lick

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!