error handling for d3d8 and d3d9
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
037b8e2120
commit
bc0e90dbec
2 changed files with 49 additions and 17 deletions
|
|
@ -17,21 +17,33 @@ static int wcreate_d3d8(MwWidget handle) {
|
||||||
gdid3d8_t* o = malloc(sizeof(gdid3d8_t));
|
gdid3d8_t* o = malloc(sizeof(gdid3d8_t));
|
||||||
D3DPRESENT_PARAMETERS d3dpp;
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
D3DDISPLAYMODE dispMode;
|
D3DDISPLAYMODE dispMode;
|
||||||
|
HRESULT hr;
|
||||||
|
char errbuf[2048] = {0};
|
||||||
|
|
||||||
o->d3d8dll = LoadLibrary("d3d8.dll");
|
o->d3d8dll = LoadLibrary("d3d8.dll");
|
||||||
if(!o->d3d8dll) {
|
if(!o->d3d8dll) {
|
||||||
MessageBox(NULL, "d3d8.dll not found! Is DirectX8 installed?", "Error", MB_OK);
|
MwDispatchError(1, "d3d8.dll not found! Is DirectX8 installed?");
|
||||||
ExitProcess(-1);
|
return 1;
|
||||||
}
|
}
|
||||||
o->Direct3DCreate8 = (void*)GetProcAddress(o->d3d8dll, "Direct3DCreate8");
|
o->Direct3DCreate8 = (void*)GetProcAddress(o->d3d8dll, "Direct3DCreate8");
|
||||||
if(!o->Direct3DCreate8) {
|
if(!o->Direct3DCreate8) {
|
||||||
MessageBox(NULL, "Direct3DCreate8 not found! Is DirectX8 installed properly?", "Error", MB_OK);
|
MwDispatchError(1, "Direct3DCreate8 not found! Is DirectX8 installed properly?");
|
||||||
ExitProcess(-1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
o->d3d = o->Direct3DCreate8(D3D_SDK_VERSION);
|
o->d3d = o->Direct3DCreate8(D3D_SDK_VERSION);
|
||||||
|
if(!o->Direct3DCreate8) {
|
||||||
|
MwStringPrintIntoBuffer(errbuf, sizeof(errbuf) - 1, "Direct3DCreate8 NULL: %s", hr);
|
||||||
|
MwDispatchError(1, errbuf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
o->d3d->lpVtbl->GetAdapterDisplayMode(o->d3d, D3DADAPTER_DEFAULT, &dispMode);
|
hr = o->d3d->lpVtbl->GetAdapterDisplayMode(o->d3d, D3DADAPTER_DEFAULT, &dispMode);
|
||||||
|
if(hr != D3D_OK) {
|
||||||
|
MwStringPrintIntoBuffer(errbuf, sizeof(errbuf) - 1, "GetAdapterDisplayMode ERROR: %s", hr);
|
||||||
|
MwDispatchError(1, errbuf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
||||||
d3dpp.Windowed = TRUE;
|
d3dpp.Windowed = TRUE;
|
||||||
|
|
@ -49,8 +61,18 @@ static int wcreate_d3d8(MwWidget handle) {
|
||||||
D3DCREATE_MIXED_VERTEXPROCESSING,
|
D3DCREATE_MIXED_VERTEXPROCESSING,
|
||||||
&d3dpp,
|
&d3dpp,
|
||||||
&o->d3ddev);
|
&o->d3ddev);
|
||||||
|
if(hr != D3D_OK) {
|
||||||
|
MwStringPrintIntoBuffer(errbuf, sizeof(errbuf) - 1, "CreateDevice ERROR: %s", hr);
|
||||||
|
MwDispatchError(1, errbuf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
o->d3ddev->lpVtbl->SetRenderState(o->d3ddev, D3DRS_LIGHTING, FALSE);
|
o->d3ddev->lpVtbl->SetRenderState(o->d3ddev, D3DRS_LIGHTING, FALSE);
|
||||||
|
if(hr != D3D_OK) {
|
||||||
|
MwStringPrintIntoBuffer(errbuf, sizeof(errbuf) - 1, "SetRenderState ERROR: %s", hr);
|
||||||
|
MwDispatchError(1, errbuf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
handle->internal = o;
|
handle->internal = o;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,12 @@ typedef struct gdid3d9 {
|
||||||
} gdid3d9_t;
|
} gdid3d9_t;
|
||||||
|
|
||||||
static int wcreate_d3d9(MwWidget handle) {
|
static int wcreate_d3d9(MwWidget handle) {
|
||||||
void* r = NULL;
|
void* r = NULL;
|
||||||
MwWidget w = handle;
|
MwWidget w = handle;
|
||||||
gdid3d9_t* o = malloc(sizeof(gdid3d9_t));
|
gdid3d9_t* o = malloc(sizeof(gdid3d9_t));
|
||||||
|
HRESULT hr;
|
||||||
|
char errbuf[2048];
|
||||||
|
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
|
||||||
|
|
||||||
o->d3d9dll = LoadLibrary("d3d9.dll");
|
o->d3d9dll = LoadLibrary("d3d9.dll");
|
||||||
if(!o->d3d9dll) {
|
if(!o->d3d9dll) {
|
||||||
|
|
@ -24,8 +27,10 @@ static int wcreate_d3d9(MwWidget handle) {
|
||||||
o->Direct3DCreate9 = (void*)GetProcAddress(o->d3d9dll, "Direct3DCreate9");
|
o->Direct3DCreate9 = (void*)GetProcAddress(o->d3d9dll, "Direct3DCreate9");
|
||||||
|
|
||||||
o->d3d = o->Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
|
o->d3d = o->Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
|
||||||
|
if(hr != D3D_OK) {
|
||||||
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
|
MwDispatchError(1, "Direct3DCreate9 NULL");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
|
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
|
||||||
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
|
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
|
||||||
|
|
@ -33,13 +38,18 @@ static int wcreate_d3d9(MwWidget handle) {
|
||||||
d3dpp.hDeviceWindow = handle->lowlevel->gdi.hWnd; // set the window to be used by Direct3D
|
d3dpp.hDeviceWindow = handle->lowlevel->gdi.hWnd; // set the window to be used by Direct3D
|
||||||
|
|
||||||
// create a device class using this information and information from the d3dpp stuct
|
// create a device class using this information and information from the d3dpp stuct
|
||||||
o->d3d->lpVtbl->CreateDevice(o->d3d,
|
hr = o->d3d->lpVtbl->CreateDevice(o->d3d,
|
||||||
D3DADAPTER_DEFAULT,
|
D3DADAPTER_DEFAULT,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
handle->lowlevel->gdi.hWnd,
|
handle->lowlevel->gdi.hWnd,
|
||||||
D3DCREATE_MIXED_VERTEXPROCESSING,
|
D3DCREATE_MIXED_VERTEXPROCESSING,
|
||||||
&d3dpp,
|
&d3dpp,
|
||||||
&o->d3ddev);
|
&o->d3ddev);
|
||||||
|
if(hr != D3D_OK) {
|
||||||
|
MwStringPrintIntoBuffer(errbuf, sizeof(errbuf) - 1, "CreateDevice ERROR: %s", hr);
|
||||||
|
MwDispatchError(1, errbuf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
handle->internal = o;
|
handle->internal = o;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue