HRESULT hr=g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hWnd,D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice);
if(hr)
{
//get error string
MessageBox(NULL, "Failed to create D3D device!", "Error!",MB_ICONEXCLAMATION | MB_OK);
MessageBox(NULL, DXGetErrorString9(hr), "Error!",MB_ICONEXCLAMATION | MB_OK);
MessageBox(NULL, DXGetErrorDescription9(hr), "Error!",MB_ICONEXCLAMATION | MB_OK);
return E_FAIL;
}
IDirect3D9::CreateDevice call always results in "D3DERR_INVALIDCALL"
Whenever I call CreateDevice of IDirect3D9 it fails. When I call DXGetErrorString9 and DXGetErrorDescription9 I get "D3DERR_INVALIDCALL" and "Invalid call"
hWnd, &d3dpp, and &g_pD3DDevice arnt NULL
I've tried setting the 2nd param, D3DDEVTYPE_REF to D3DDEVTYPE_HAL
And the 3rd D3DCREATE_HARDWARE_VERTEXPROCESSING to D3DCREATE_MIXED_VERTEXPROCESSING and D3DCREATE_SOFTWARE_VERTEXPROCESSING
but all with the same error resulting.
I've encounted this problem on all the DX9 tutorial source I've found whenever CreateDevice is called.
Hey rkaganda,
Could you post the settings of d3dpp too, there might be a problem there, then we take a look at what you setup.
Xeile
Could you post the settings of d3dpp too, there might be a problem there, then we take a look at what you setup.
Xeile
Settings for d3dpp are:
Here is the complete source that im working with right now.
[Edited by - rkaganda on November 12, 2005 9:34:23 AM]
d3dpp.Windowed = TRUE;d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;d3dpp.BackBufferFormat = d3ddm.Format;
Here is the complete source that im working with right now.
#include <windows.h>#include <d3d9.h>//error header#include <dxerr9.h>LPDIRECT3D9 g_pD3D = NULL;LPDIRECT3DDEVICE9 g_pD3DDevice = NULL;HRESULT InitialiseD3D(HWND hWnd){ //First of all, create the main D3D object. If it is created successfully we //should get a pointer to an IDirect3D8 interface. g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); if(g_pD3D == NULL) { MessageBox(NULL, "E_FAIL Direct3DCreate9(D3D_SDK_VERSION) = NULL", "Error!",MB_ICONEXCLAMATION | MB_OK); return E_FAIL; } //Get the current display mode D3DDISPLAYMODE d3ddm; if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) { MessageBox(NULL, "FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))", "Error!",MB_ICONEXCLAMATION | MB_OK); return E_FAIL; } //Create a structure to hold the settings for our device D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); //Fill the structure. //We want our program to be windowed, and set the back buffer to a format //that matches our current display mode d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_COPY; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp.BackBufferFormat = d3ddm.Format; //Create a Direct3D device. HRESULT hr=g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice); if(hr) { //get error string MessageBox(NULL, "Failed to create D3D device!", "Error!",MB_ICONEXCLAMATION | MB_OK); MessageBox(NULL, DXGetErrorString9(hr), "Error!",MB_ICONEXCLAMATION | MB_OK); MessageBox(NULL, DXGetErrorDescription9(hr), "Error!",MB_ICONEXCLAMATION | MB_OK); return E_FAIL; } if(&g_pD3DDevice==NULL) { MessageBox(NULL, "g_pD3DDevice == NULL", "Error!", MB_ICONEXCLAMATION | MB_OK); } if(&d3dpp==NULL) { MessageBox(NULL, "d3dpp == NULL", "Error!", MB_ICONEXCLAMATION | MB_OK); } if(hWnd==NULL) { MessageBox(NULL, "hWnd == NULL", "Error!", MB_ICONEXCLAMATION | MB_OK); } return S_OK;}void Render(){ if(g_pD3DDevice == NULL) { return; } //Clear the backbuffer to a green color g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 255, 0), 1.0f, 0); //Begin the scene g_pD3DDevice->BeginScene(); //Rendering of our game objects will go here //End the scene g_pD3DDevice->EndScene(); //Filp the back and front buffers so that whatever has been rendered on the back buffer //will now be visible on screen (front buffer). g_pD3DDevice->Present(NULL, NULL, NULL, NULL);}void CleanUp(){ if(g_pD3DDevice != NULL) { g_pD3DDevice->Release(); g_pD3DDevice = NULL; } if(g_pD3D != NULL) { g_pD3D->Release(); g_pD3D = NULL; }}void GameLoop(){ //Enter the game loop MSG msg; BOOL fMessage; PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); while(msg.message != WM_QUIT) { fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE); if(fMessage) { //Process message TranslateMessage(&msg); DispatchMessage(&msg); } else { //No message to process, so render the current scene Render(); } }}//The windows message handlerLRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch(msg) { case WM_DESTROY: PostQuitMessage(0); return 0; break; case WM_KEYUP: switch (wParam) { case VK_ESCAPE: //User has pressed the escape key, so quit DestroyWindow(hWnd); return 0; break; } break; } return DefWindowProc(hWnd, msg, wParam, lParam);}//Application entry pointINT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT){ //Register the window class WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "DX Project 1", NULL}; if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!",MB_ICONEXCLAMATION | MB_OK); return 0; } //Create the application's window HWND hWnd = CreateWindow("DX Project 1", "www.andypike.com: Tutorial 1", WS_OVERLAPPEDWINDOW, 50, 50, 500, 500, GetDesktopWindow(), NULL, wc.hInstance, NULL); if(hWnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } //Initialize Direct3D if(SUCCEEDED(InitialiseD3D(hWnd))) { //Show our window ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); //Start game running: Enter the game loop GameLoop(); } CleanUp(); UnregisterClass("DX Project 1", wc.hInstance); return 0;}
[Edited by - rkaganda on November 12, 2005 9:34:23 AM]
The easiest solution to this problem: enable the DirectX debug runtime, and run the debugger past your Create() call. The DX runtime will spit information out into your 'Ouput' window telling you *exactly* why the call failed (for example your back buffer format is wrong or something).
I don't think you can ask for hardware vertex processing with the REF device. Anyway, whatever it is, learn to use the debug runtime like others have said.
What is the value of the HRESULT hr?
You need to look up the error code in the docs and post that.
--noone
You need to look up the error code in the docs and post that.
--noone
Quote:What is the value of the HRESULT hr?
Check the title of the thread ;) D3DERR_INVALIDCALL is an HRESULT.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement