   Multithread with _beginthread()/_endthread() question
  Hello!I'm trying to run a Direct3D splashscreen animation on a separate thread so it doesn't get interrupted by other I/O and misc things going on in the background while the rest of the game is loading.Here's what I've done so far...  I've defined a Direct3D object in main.h and then created a Direct3D object in 'direct3D.cpp' on my main program thread.  I then created a handful of vertex buffers for my splashscreen stuff (simple 4-vertex quad buffers).  Finally, I created a struct in 'main.h' that defines my multithread parameters.  Here's that struct:typedef struct{HWND*hwnd;// DXStuff->hWnd.BOOLthreadDone;// TRUE if thread is done executingDirectStuff*DXStuff;// Pointer to DirectStuff struct (Direct3D object)GameEnts*DXEnts;// Pointer to GameEnts struct (vertex buffers)}PARAMS, *PPARAMS;My quad vertex buffers are found within the DXEnts struct, and the Direct3D object is located in the DXStuff struct.  Here's my multithread function:void SplashThread(PVOID pvoid){PPARAMS pparams;pparams = (PPARAMS) pvoid;if (pparams->threadDone)return;RenderSplash(pparams->DXStuff, pparams->DXEnts);_endthread();}You can see how I'm passing DXStuff and DXEnts to the 'RenderSplash()' function.  The 'RenderSplash()' function does the usual rendering stuff (DXStuff->g_pd3dDevice->BeginScene(), draw stuff, DXStuff->g_pd3dDevice->EndScene(), DXStuff->g_pd3dDevice->Present( NULL, NULL, NULL, NULL )).  Here's my problem...If I use this in my mainloop:_beginthread(SplashThread, 0, & params);the program pauses for a moment, draws a black screen, then crashes.  It's as if the structs DXStuff and DXEnts aren't being properly passed to the RenderSplash() function.However, if I do this in my mainloop:RenderSplash(&DXStuff, &DXEnts);it works perfectly (except for the horrible jerks and jitters caused by the RenderSplash() function operating on the same thread as the game loader functions).Anybody have any ideas why my multithread code doesn't work?  If so, how do I make it work?Thanks in advance for the help!   
  Ohhhh, I got it working.  Duh!  I forgot to create my Direct3D device with the D3DCREATE_MULTITHREADED flag, like this:// Create the D3DDeviceif( FAILED( DXStuff->g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DXStuff->hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,&d3dpp, &DXStuff->g_pd3dDevice ) ) ){return E_FAIL;}I was also accidently creating a new thread with each mainloop pass, which was messing up the 'g_pd3dDevice->BeginScene()' function because it didn't like another thread trying to render something while it was already rendering something else.  D'oh!  Anyways, this multithreading stuff is purty cool!  Now let's see if I can get the rest of my game engine to work...  Wish me luck!   