Would the D3D debug runtime component help me fix this problem? I enabled it, but I'm not sure how to use it. Anyway, in CPP:
init_finish.h:
struct D3DInitialization_Destruction {
//last 13 parameters are for D3DPRESENT_PARAMETERS
void d3d_init ( IDirect3D9* pDObj,
IDirect3DDevice9* pDObjDev,
HWND hwnd,
UINT buffW,
UINT buffH,
bool wind,
D3DFORMAT buffF = D3DFMT_R8G8B8,
UINT buffC = 1,
D3DSWAPEFFECT swapEffect = D3DSWAPEFFECT_COPY,
bool autoDnS = FALSE,
D3DFORMAT autoDnSFormat = D3DFMT_UNKNOWN,
UINT flags = 0,
UINT FS_PresInt = D3DPRESENT_INTERVAL_DEFAULT,
UINT FS_RefRate = D3DPRESENT_RATE_DEFAULT,
D3DMULTISAMPLE_TYPE MST = D3DMULTISAMPLE_NONE ){
D3DPRESENT_PARAMETERS p;
p.BackBufferWidth = buffW;
p.BackBufferHeight = buffH;
p.BackBufferFormat = buffF;
p.BackBufferCount = buffC;
p.MultiSampleType = MST;
p.SwapEffect = swapEffect;
p.hDeviceWindow = hwnd;
p.Windowed = wind;
p.EnableAutoDepthStencil = autoDnS;
p.AutoDepthStencilFormat = autoDnSFormat;
p.Flags = flags;
p.FullScreen_RefreshRateInHz = FS_RefRate;
p.PresentationInterval = FS_PresInt;
pDObj = Direct3DCreate9 (D3D_SDK_VERSION);
int msg;
msg = pDObj->CreateDevice (0, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &p, &pDObjDev);
if (msg == D3D_OK)
MessageBox (hwnd, "device created!", NULL, 0);
else if (msg == D3DERR_NOTAVAILABLE)
MessageBox (hwnd, "NOTAVAILABLE", NULL, 0);
else if (msg == D3DERR_INVALIDCALL)
MessageBox (hwnd, "INVALIDCALL", NULL, 0);
else if (msg == D3DERR_OUTOFVIDEOMEMORY)
MessageBox (hwnd, "OUTOFVIDEOMEMORY", NULL, 0);
else
MessageBox (hwnd, "unknown error", NULL, 0);
}
}hafta;
main.cpp:
#include <assert.h>
#include <afxwin.h>
#include "d3d9.h"
#include "init_finish.h"
//inside WinMain:
IDirect3D9* DObj = NULL;
IDirect3DDevice9* DObjDev = NULL;
hafta.d3d_init (DObj, DObjDev, hwnd, 640, 480, TRUE);
I get the INVALIDCALL messagebox, but my window doesn't crash as I've seen happens to others'. I think one of the last two parameters in pDObj->CreateDevice is the problem due to the fact that hwnd works with the message boxes, and the other parameters are pretty straightforward.
By the way, does any Windows message box (I also mean stuff like assert) halt a program until it goes away again?
--------------------Configuration: error maker - Win32 Debug--------------------Compiling...error maker.cppLinking...error maker.exe - 1 error(s), 0 warning(s)