Jump to content
  • Advertisement

Archived

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

kapru

Why wont this work

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

Im trying to create a d3d window and it wont work ive compaired it to other things ive done and i cant see the problem INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) { //Set the application to active Active=true; WNDCLASSEX wc={sizeof(WNDCLASSEX), CS_CLASSDC,MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL,ApplicationName, NULL }; RegisterClassEx( &wc ); // Create the application''s window Apphwnd = CreateWindow( "APP","APP", WS_OVERLAPPEDWINDOW, 50, 50, iAppWidth+8, iAppHeight+34, GetDesktopWindow(), NULL, wc.hInstance, NULL); // Show the window ShowWindow( Apphwnd, SW_SHOWDEFAULT ); UpdateWindow( Apphwnd ); //Init every thing Ready=true; if(FAILED(InitDirect3D())) { goto error; } MSG msg; ZeroMemory( &msg, sizeof(msg) ); while(msg.message!=WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else if(HasFocus && Active) { } } error: //If we get here then the app is ending //run shut down stuff here ReleaseDirect3D(); DestroyWindow( Apphwnd ); UnregisterClass(ApplicationName, wc.hInstance ); return 0; } HRESULT InitDirect3D() { // Create the D3D object. if(NULL==(d3d=Direct3DCreate8(D3D_SDK_VERSION))) { MessageBox(Apphwnd,"Can not creat Direct 3D interface","ERROR",MB_OK); return E_FAIL; } D3DDISPLAYMODE d3ddm; if(FAILED(d3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) { MessageBox(Apphwnd,"Can not get display mode","ERROR",MB_OK); return E_FAIL; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); if(!Windowed) { d3dpp.Windowed = false; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.FullScreen_PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.BackBufferWidth=iAppWidth; d3dpp.BackBufferHeight=iAppHeight; } else { d3dpp.Windowed = true; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = TRUE; //if(iAppBpp==16) //{ d3dpp.AutoDepthStencilFormat = D3DFMT_D16; //} d3dpp.BackBufferWidth=iAppWidth; d3dpp.BackBufferHeight=iAppHeight; } if(FAILED(d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Apphwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp, &d3ddevice ))) { MessageBox(Apphwnd,"Failed to Create a Device","ERROR",MB_OK); return E_FAIL; } d3ddevice->GetRenderTarget(&backbuffer); d3ddevice->GetDepthStencilSurface(&zbuffer); return S_OK; } when it runs im getting the Failed to Create a Device error message any help would be apriciated

Share this post


Link to post
Share on other sites
Advertisement
Check the parameters you''re passing to CreateDevice() for validity. More specifically, make sure that the window handle is valid when calling the function. If it is and the call still fails, try D3DCREATE_SOFTWARE_VERTEXPROCESSING as the create flag.

What kind of gfx card are you using?

Share this post


Link to post
Share on other sites
Im using a GeForce3Ti200 and using software vertex processing still dosnt work, Im prittysure the windows is valid

Share this post


Link to post
Share on other sites
Here are a few things to try.

First of all, in full screen mode, you need

d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP; d3dpp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT;
d3dpp.BackBufferCount=1;

Secondly, a lot of times the windowed mode is not what you want for the backBufferFormat try d3dpp.BackBufferFormat =D3DFMT_A8R8G8B8; or D3DFMT_X8R8G8B8;


and lastly set your AutoDepthStencilFormat=D3DFMT_D24S8;


Try these things, and if the error is still there, it may be in the initialization of your window itself.

Share this post


Link to post
Share on other sites
- Install and select the debug runtime, and examine the debug output.
- Please use a descriptive topic title.
- Please use the [ source ][ / source ] (without the spaces) formatting tags for source code.

Muhammad Haggag

Share this post


Link to post
Share on other sites
Here is the debug output
irect3D8: :====> EXIT: DLLMAIN(00aec640): Process Attach: 0000096c
Direct3D8: (INFO) :Direct3D8 Debug Runtime selected.
Loaded ''C:\WINDOWS\system32\uxtheme.dll'', no matching symbolic information found.
Direct3D8: (ERROR) :Neither hDeviceWindow nor Focus window specified. CreateDevice Failed.
Direct3D8: :====> ENTER: DLLMAIN(00aec640): Process Detach 0000096c, tid=00000eb0
Direct3D8: (INFO) :MemFini!
Direct3D8: :====> EXIT: DLLMAIN(00aec640): Process Detach 0000096c
The thread 0xEB0 has exited with code 0 (0x0).
The program ''C:\Engine Dev\Frame Work\Debug\Frame Work.exe'' has exited with code 0 (0x0).

The problem is here
Direct3D8: (ERROR) :Neither hDeviceWindow nor Focus window specified. CreateDevice Failed.

I can''t see why this is happening

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!