Yep I''ve found the problem; you have to create the zbuffer before the device (thanks).
But, some a problem has popped up and I''ve got a problem with enumeration!:
New Problem #1 !! The zbuffer seems to be working VERY STRANGELY; in fact it seems to be working in inverse.
Basically, if there''s polygons behind the one being drawn, it might be not drawn at all, or distorted quite alot. In fact, sometimes it seems that the polys nearer the viewer are clipped!
Here''s some code I use to set it up (I copied the creation code almost exactly from the d3dim framework):
E(lpDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_TRUE), "SetRenderState(zenable,true)"); E(lpDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE), "SetRenderState(zwriteenable,true)"); E(lpDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL), "SetRenderState(zfunc,lessequal)"); E(lpDevice->SetRenderState(D3DRENDERSTATE_ZBIAS, 0), "SetRenderState(zbias,0)");
P.S. The "E" function is just a minimal error-checker.
Even with all this renderstate code (a lot of them are set like this by default anyway), the view is still distorted!!
New Problem #2 !! I''m have quite a serious problem with enumeration as well.
One of the first things I do is enumerate the DirectDraw drivers using this code:
BOOL WINAPI DriverEnumCallback(GUID* pGUID, TCHAR* strDesc, TCHAR* strName, VOID* pContext, HMONITOR hm){ LPDIRECTDRAW7 lpdd; char kb[1024]; /* * Store Information */ sprintf(kb, "Name: %s\nDescription: %s", strName, strDesc); MessageBox(GetForegroundWindow(), kb, "DirectDraw Driver", MB_ICONINFORMATION); memcpy(&DirectDrawGUID, pGUID, sizeof(GUID)); /* * Try it out */ DirectDrawCreateEx(&DirectDrawGUID, (LPVOID *)&lpdd, IID_IDirectDraw7, NULL); lpdd->Release(); return DDENUMRET_OK;}void CreateDirect3D(HWND hWnd, UINT nWidth, UINT nHeight, UINT nBPP){ /* * Sets up DirectDraw and Direct3D */ DDSURFACEDESC2 ddsd; D3DMATRIX mat; /* * Enumerate objects */ E(DirectDrawEnumerateEx(DriverEnumCallback, NULL, DDENUM_ATTACHEDSECONDARYDEVICES / DDENUM_DETACHEDSECONDARYDEVICES / DDENUM_NONDISPLAYDEVICES), "DirectDrawEnumerateEx");
After running this code, I first see a message box (from the enumeration func.) with the driver "Primary Display Driver" ("display"). Then the DirectDrawEnumerateEx function returns DDERR_INVALIDPARAMS; but
no message box with enumeration data for my "3dfx Interactive DirectX 5 Driver" ("mm3dfx"). All of the other applications I run enumerate this; and the SDK samples also appear to.
This also happens on the Direct3D enumeration: it enumerates RGB, Software, Reference, and HAL, but no
mm3dfx (this is probably because it wasn''t done in DD enumeration?).
Basically, it doesn''t enumerate my devices! Unfortunately, I don''t know whether it''s failing after the 1st enumeration due to a fault in the callback, or something else! (But i do know that the driver works, other apps use it).
Please, can you help?
!!Thanks!!