Error with setting up hardware processing in DX8

Started by
3 comments, last by Brobanx 22 years, 5 months ago
Ok, I wrote a program that so far, sets up direct3d8, a vertex buffer, puts the vertices for a pyramid into the buffer, and draws it to scene. it works perfectly. my problem is that when i want to try using hardware acceleration (using the D3DCREATE_HARDWARE_VERTEXPROCESSING flag in direct3D->CreateDevice function) my program compiles the same, but i get a runtime error saying the "instruction at 0x00000000 cannot access memory at 0x00000000" I have no idea where this error is coming from, but when I create the d3ddevice with D3DCREATE_SOFTWARE_VERTEXPROCESSING I don''t get any errors whatsoever. The code for my calling the device looks like this: direct3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, cWnd->window, deviceflags, &presentParameters, &device )) ) cWnd->window is the HWND the program runs in, deviceflags is the global i made that is either D3DCREATE_SOFTWARE_VERTEXPROCESSING or D3DCREATE_HARDWARE_VERTEXPROCESSING.
Advertisement
Sounds like CreateDevice failed when you use D3DCREATE_SOFTWARE_VERTEXPROCESSING, which means that your LPDIRECT3DDEVICE8 object is NULL. Have you checked the return value from IDirect3D8->CreateDevice() to see if it returns D3D_OK? You should always check the return value from such class that create objects.... that is a minimum. It''s very bad programming practice to not detect failure of such calls and not respond to them. I suspect that either your video card doesn''t support TnL or you have faulty drivers.
Sorry, I meant that it sounds like it fails when you use D3DCREATE_HARDWARE_VERTEXPROCESSING, and not D3DCREATE_SOFTWARE_VERTEXPROCESSING. Sorry for the mixup.
  if ( D3D_OK != (direct3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, cWnd->window, deviceflags, &presentParameters, &device )) )return false;  


ok, that''s what i''ve got in my d3dinit() function to set up the device, it returns d3d_ok even when using D3DCREATE_HARDWARE_VERTEXPROCESSING (if it didn''t it would exit the program immediately upon trying to create it).

there must be something else in my program (maybe the vertex buffers, those are the only other DX components) that have a conflict with hardware processing? im really lost here, scrambling through every line of code =/
I''ve just solved my own problem. The problem was that I had two vertex buffer, one raw and one processed. The processed vertex buffer just had an extra RHW component. I processed the raw data into the other buffer using the ProcessVertices() function, and then used that as the streamsource for DrawPrimitive... This worked fine in software mode, but in hardware mode, it wants to process the raw data while doing the draw primitive, so... i got rid of the extra "processed buffer", and just made one raw buffer that the hardware can process itself while doing DrawPrimitive().

This topic is closed to new replies.

Advertisement