Jump to content
  • Advertisement

Archived

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

D3D8 CreateDevice error

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

hi, i have a problem w/ D3d8. i''m going through the tutorials to c what has changed from DX7 and i''m trying to get this thing 2 work. this is what i have and it ALWAYS returns E_FAIL! if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) return E_FAIL; i have a 4mb ati rage pro. i know it''s not the best, but d3d7(or maybe 6) worked fine w/ my card, i can''t get it? can anyone help?

Share this post


Link to post
Share on other sites
Advertisement
I think what you need to do to find out the problem is to save the returned value from the CreateDevice function and then return that. Then you can see a bit more where the problem lies.

  
HRESULT hRetVal; // Holds return value


// Create the device

hRetVal = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice );

// Test for failure

if(FAILED(hRetVal))
return hRetVal;


Hope that helps!

"I kinda think, therefore, I kinda... am?"

Edited by - psychocatt on January 14, 2001 4:36:27 PM

Share this post


Link to post
Share on other sites
thx for the advise, i did it and now i''m stuck again. i''m getting an error-2005530516. how can i determine what this error is? ive found webpages but they only have the name of the error, not the number. can anyone help?

Share this post


Link to post
Share on other sites
Hi, it just so happens that I have that same crappy 3D card So here''s my init code, which works fine:



hr = lpD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dfmt, d3dfmt, FALSE);

if FAILED(hr) return(-1);

ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
d3dpp.BackBufferWidth=wid;
d3dpp.BackBufferHeight=hei;
d3dpp.BackBufferFormat = D3DFMT_R5G6B5; // This works
d3dpp.BackBufferCount = 1;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
d3dpp.hDeviceWindow = g_hWnd; // valid handle
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

hr = lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp, &lpDevice);



To handle the errors returned you need to compare them with the pre-defined constants in the D3D8 header. It explains valid return values in the SDK help. Example for the CreateDevice:..

 
hr = lpD3D->CreateDevice(blah, etc... )

switch(hr) {
case D3DERR_INVALIDCALL:
MessageBox(NULL, "Invalid parameters!", "Error", MB_OK);
break;

case D3DERR_NOTAVAILABLE:
MessageBox(NULL, "Device not available", "Error", MB_OK);
break;

case D3DERR_OUTOFVIDEOMEMORY:
MessageBox(NULL, "Out of video memory!", "Error", MB_OK);
break;
}





I''m guessing you''ll get the INVALIDCALL error. Check your Presentation parameters - that''s usually the problem.


Share this post


Link to post
Share on other sites
Just to let you know, there is a D3DX function that can translate the error codes for you. It is called D3DXGetErrorString. Here is the syntax :

   HRESULT D3DXGetErrorString( HRESULT hr, LPSTR pBuffer, UINT BufferLen);   


Basically, it takes the HRESULT value, a pointer to a string buffer and the size of the buffer. You then get a ''readable'' error. Good luck. Hope this helps!



"I kinda think, therefore, I kinda... am?"

Share this post


Link to post
Share on other sites
cgi joe, i noticed this line:
hr = lpD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dfmt, d3dfmt, FALSE);

it''s not in my program, this is:
hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);

i think this has a big part 2 do with my error. can anyone help? i''m using what''s supposed 2 be the bx8 sdk, it''s pissin me off!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
All that line does is check whether that format is available on that rendering device. I was initialising FullScreen...You use GetAdapterDisplayMode for windowed mode.

That code I posted works fine. Have you tried it?
Also, have you created a window first?

Share this post


Link to post
Share on other sites
i get the D3DERR_NOTAVAILABLE error after checkdevicetype. does it have anything 2 do w/ my desktop settings? dx8 is supposed to be so much easier, but it''s givin me a lot of headaches!

oh joe, a window was created first

Share this post


Link to post
Share on other sites
If you get a D3DERR_NOTAVAILABLE then either the video card doesn''t support the specified D3DDEVTYPE (which in this case is D3DDEVTYPE_HAL) or the pixel format that is specified in the present parameters. My guess is that you are specifying a 5,5,5 and your card supports 5,6,5 or vice versa. After you get the display mode, you do use that to fill in your d3dpp right? Example,
   hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);

ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;


That will make your buffer the same as what is currently set. Some cards can only use (5,6,5) mode, and some can only use (5,5,5) mode. Hope that helps

"I kinda think, therefore, I kinda... am?"

Share this post


Link to post
Share on other sites
quote:
Original post by Psychocatt

If you get a D3DERR_NOTAVAILABLE then either the video card doesn''t support the specified D3DDEVTYPE (which in this case is D3DDEVTYPE_HAL) or the pixel format that is specified in the present parameters. My guess is that you are specifying a 5,5,5 and your card supports 5,6,5 or vice versa. After you get the display mode, you do use that to fill in your d3dpp right? Example,

     hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);

ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;


That will make your buffer the same as what is currently set. Some cards can only use (5,6,5) mode, and some can only use (5,5,5) mode. Hope that helps

"I kinda think, therefore, I kinda... am?"

i started with that code, then i get the D3DERR_INVALIDCALL error. i think the card is 565. CGI Joe gave code he thought would work, but i can''t get it 2gether. for the width and height of bacbuffer, they have 2 be the same as primary right? i''m gonna try sommore when i get home. if this keeps up, i''ll just go back 2 dx7!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!