Sign in to follow this  

Compatibility problem

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

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4837 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this