Compatibility problem

Started by
2 comments, last by DrunkenHyena 19 years, 7 months ago
Here is my code for initializing Direct3D:

bool InitD3D(HWND *hWnd, HINSTANCE hInst, bool Windowed)
{
WNDCLASSEX wndclass;
wndclass.cbSize         = sizeof(wndclass);
wndclass.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
wndclass.lpfnWndProc    = MsgProc;
wndclass.cbClsExtra     = 0;
wndclass.cbWndExtra     = 0;
wndclass.hInstance      = hInst;
wndclass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor        = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground  = (HBRUSH)(COLOR_WINDOW);
wndclass.lpszMenuName   = NULL;
wndclass.lpszClassName  = TEXT("SampleClass");
wndclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);
// register the window class
if ( RegisterClassEx( &wndclass ) == 0 )
{
MessageBox(NULL,"could not register the window class","error",MB_OK);
return false;
}
// create new window
if (Windowed == true)
*hWnd = CreateWindowEx( NULL, TEXT("SampleClass"), TEXT("Game"),WS_OVERLAPPEDWINDOW | WS_VISIBLE,GetSystemMetrics(SM_CXSCREEN)/2 - 250,GetSystemMetrics(SM_CYSCREEN)/2 - 187,500,375,NULL,NULL,hInst,NULL );
else
*hWnd = CreateWindowEx( NULL, TEXT("SampleClass"), TEXT("Game"),NULL,0,0,0,0, NULL, NULL, hInst, NULL );
		
if (!hWnd)
{
MessageBox(NULL,"unable to create hwnd","error",MB_OK);
return false;
}

D3DPRESENT_PARAMETERS PP;
memset(&PP,0,sizeof(D3DPRESENT_PARAMETERS));
if ( !(D3DObject = Direct3DCreate9(D3D_SDK_VERSION))) 
{
MessageBox(NULL,"unable to create D3DObject","error",MB_OK);
return false;
}

if (Windowed == true)
{
PP.BackBufferWidth  = GetSystemMetrics(SM_CXSCREEN);
PP.BackBufferHeight = GetSystemMetrics(SM_CYSCREEN);
}
else
{
PP.BackBufferWidth = 1024;
PP.BackBufferHeight = 768;
}
		
// misc parameters 
PP.Windowed           = Windowed;
PP.hDeviceWindow      = *hWnd;
PP.SwapEffect         = D3DSWAPEFFECT_DISCARD;
PP.MultiSampleType    = D3DMULTISAMPLE_NONE;
PP.BackBufferCount    = 1;
		
// depth- and stencil- buffer
PP.EnableAutoDepthStencil = true;
PP.AutoDepthStencilFormat = D3DFMT_D24S8; //depth stencil
PP.BackBufferFormat       = D3DFMT_X8R8G8B8;
		
HRESULT Error;
if(FAILED( Error = D3DObject->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,NULL,D3DCREATE_MIXED_VERTEXPROCESSING,&PP,&D3DDevice)))
{
if ( Error == D3DERR_INVALIDCALL)
MessageBox(NULL,"unable to use mixed rendering, Invalid Call; attempting to use hardware rendering","error",MB_OK);
if ( Error == D3DERR_NOTAVAILABLE)
MessageBox(NULL,"unable to use mixed rendering, Not Available; attempting to use hardware rendering","error",MB_OK);
if ( Error == D3DERR_OUTOFVIDEOMEMORY)
MessageBox(NULL,"unable to use mixed rendering, Out of video memory; attempting to use hardware rendering","error",MB_OK);
if(FAILED( Error = D3DObject->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,NULL,D3DCREATE_HARDWARE_VERTEXPROCESSING,&PP,&D3DDevice)))
{
if ( Error == D3DERR_INVALIDCALL)
MessageBox(NULL,"unable to use hardware rendering, Invalid Call; attempting to use software rendering","error",MB_OK);
if ( Error == D3DERR_NOTAVAILABLE)
MessageBox(NULL,"unable to use hardware rendering, Not Available; attempting to use software rendering","error",MB_OK);
if ( Error == D3DERR_OUTOFVIDEOMEMORY)
MessageBox(NULL,"unable to use hardware rendering, Out of video memory; attempting to use software rendering","error",MB_OK);
if(FAILED( Error = D3DObject->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,NULL,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,&PP,&D3DDevice)))
{
if ( Error == D3DERR_INVALIDCALL)
MessageBox(NULL,"unable to use software rendering, Invalid Call; exiting application","error",MB_OK);
if ( Error == D3DERR_NOTAVAILABLE)
MessageBox(NULL,"unable to use software rendering, Not Available; exiting application","error",MB_OK);
if ( Error == D3DERR_OUTOFVIDEOMEMORY)
MessageBox(NULL,"unable to use software rendering, Out of video memory; exiting application","error",MB_OK);
return false;
}
}
}
return true;
}

It works just fine on my system, with no errors. I tried it on 3 computers, 2 running windows xp home, and one running windows 98. They both had directx 9.0c installed on them. They all came out with the same errors: Mixed vertex processing invalid call hardware vertex processing not available software vertex processing not available Even if the graphics card does not support hardware rendering, it should still be able to render in software right? I am out of ideas, if anyone could provide some kind of answer, that would be greatly appreciated. -Dev578 [Edited by - Coder on September 16, 2004 11:32:20 PM]
Advertisement
Quote:
Even if the graphics card does not support hardware rendering, it should still be able to render in software right?


No. Direct3d does not come with a software rendering component.

Alan

ps, use [source][/source] tags to put your code into a colour-coded window.
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Software rendering is not what you want your code to do. Software vertex processing is what you want. The rendering itself - rasterizing and shading - will be done in hardware by pretty much any post-Voodoo card.

The problem is your use of the REF device. It's not available on consumer machines, only on development machines. It's something that you never, never, never want to use, unless you suspect a driver bug and want to have Direct3D do everything by hand to see if the problem goes away (or unless you're debugging a pixel shader). Use the HAL device at all times, and when doing a CreateDevice like that, try it with D3DCREATE_HARDWARE_VERTEXPROCESSING, then D3DCREATE_MIXED_VERTEXPROCESSING, and then D3DCREATE_SOFTWARE_VERTEXPROCESSING. If the last of those fails then you're screwed and have to exit.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

D3DCREATE_MIXED_VERTEXPROCESSING indicates that you will be using BOTH software and hardware vertex processing in your app, which means that it will only work on a device capable of HW processing.
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement