I have some legacy DirectX code that always returns DDERR_UNSUPPORTED
.
I originally developed the code using DirectX3, and I am porting it to DirectX7 after spending years away from programming.
The following line is returning DDERR_UNSUPPORTED
rather than DD_OK
:
hrRetVal = pDDraw->SetDisplayMode(dwWidth, dwHeight, dwBPP, 0, 0);
Could someone please take a quick peek and respond if you see why this might be the case? This is not a commercial application... just something to do for fun.
Based on the Microsoft on-line documents, the SetDisplayMode
method is not deprecated, and should work. A compiled version of my legacy program written with DirectX3 renders graphics on newer OS's such as Windows 10, without issue. I am interested in making some changes.
This Video compilation unit:
- Sets the video mode to 1024 X 768
- Create a DirectX instance, set the cooperative level.
- Which when destroyed will Restore video to original mode, and flip to GDI
void Video::Initialize(void)
{
TRACE("Video::Initialize invoked\n");
hrRetVal = {0};
DWORD dwDefaultRefreshRate = 0x0;
DWORD dwWidth = 1024, dwHeight = 768, dwBPP = 8, dwRefreshRate = dwDefaultRefreshRate, dwFlags = 0x0;
try
{
Check(hrRetVal); // check for DD_OK
TRACE("Video: using emulation mode, no hardware\n"); // debugging
TRACE("Video: DirectDrawCreateEx invoked\n");
hrRetVal = DirectDrawCreateEx((GUID*)DDCREATE_EMULATIONONLY, (LPVOID*)&pDDraw, IID_IDirectDraw7, NULL);
Check(hrRetVal); // TRACE value of hrRetVal
if (DD_OK == hrRetVal)
{
TRACE("Video SetCooperativeLevel invoked\n");
hrRetVal = pDDraw->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
Check(hrRetVal);
if (DD_OK == hrRetVal)
{
// Lets see if the video is supported
hrRetVal = QueryVideoCapability();
Check(hrRetVal);
if (DD_OK == hrRetVal)
{
TRACE("Attempting to set video resolution to: %d %d \n", dwWidth, dwHeight);
hrRetVal = pDDraw->SetDisplayMode(dwWidth, dwHeight, dwBPP, 0, 0); // this line always returns DDERR_UNSUPPORTED
// hrRetVal == DDERR_UNSUPPORTED after call to SetDisplayMode
Check(hrRetVal);
if (DD_OK != hrRetVal)
throw (VIDEO_EXCEPTION); // with throw an exception since hrRetVal == DDERR_UNSUPPORTED
}
}
else
{
Check(hrRetVal);
throw (VIDEO_EXCEPTION);
}
}
else
{
Check(hrRetVal);
throw (VIDEO_EXCEPTION);
}
}
catch(int exception)
{
TRACE("%Xh exception caught by Video::Initialize\n", exception);
Video::Check(hrRetVal);
if (exception == VIDEO_EXCEPTION)
{
char message[80];
strcpy_s ( message, "Unable to initialize video. ");
strcat_s ( message, "\nApplication will now terminate.");
FatalMessageBox( message );
TRACE("APP_EXCEPTION thrown by Video::Initialize\n");
throw (APP_EXCEPTION);
}
}
}
I'm using Visual Studio 2017 Pro v15.7.2, on Windows 10 Build 1803.
DDCREATE_EMULATIONONLY
? \$\endgroup\$