Losing exclusive mode after calling SetDisplayMode
I am currently learning Direct3D, but when I go to set the display mode (640x480x16bpp) my app loses exclusive mode status. I tracked down where I lost it using TestCooperativeLevel. Because of this I can''t create my primary surface. Any ideas on what caused this?
Here is the Section of Code that is happens:
//Quick note, OutDebug is my debugging function, and how I found out what my problem was
//Create the DirectDraw Interface
hr = DirectDrawCreateEx(NULL, (void **)&lpDD, IID_IDirectDraw7, NULL);
if (FAILED(hr))
{
OutDebug("DDCreateEx failed");
return 0;
}
//Set the Coop mode
hr = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE / DDSCL_FULLSCREEN);
if (FAILED(hr))
{
OutDebug("SetCoopLvl failed");
if (hr == DDERR_EXCLUSIVEMODEALREADYSET) OutDebug("===>DDERR_EXCLUSIVEMODEALREADYSET");
if (hr == DDERR_HWNDALREADYSET) OutDebug("===>DDERR_HWNDALREADYSET");
if (hr == DDERR_HWNDSUBCLASSED) OutDebug("===>DDERR_HWNDSUBCLASSED");
if (hr == DDERR_INVALIDOBJECT) OutDebug("===>DDERR_INVALIDOBJECT");
if (hr == DDERR_INVALIDPARAMS) OutDebug("===>DDERR_INVALIDPARAMS");
if (hr == DDERR_OUTOFMEMORY) OutDebug("===>DDERR_OUTOFMEMORY");
return 0;
}
hr = lpDD->TestCooperativeLevel();
if (hr == DDERR_NOEXCLUSIVEMODE)
{
OutDebug("Test Coop Failed (after SetCoop)");
OutDebug("===>DDERR_NOEXCLUSIVEMODE");
}
//I get past here without any problems
//Set the DisplayMode
hr = lpDD->SetDisplayMode(640, 480, 16, 0, NULL);
if (FAILED(hr))
{
OutDebug("SetDisplayMode failed");
return 0;
}
//after the display mode is set, I lost exclusive
hr = lpDD->TestCooperativeLevel();
if (hr == DDERR_NOEXCLUSIVEMODE)
{
OutDebug("Test Coop Failed (after Display)");
OutDebug("===>DDERR_NOEXCLUSIVEMODE");
}
:End Code
It is fine after I set the Cooperative mode, but fails on the second test making CreateSurface fail later on. Any ideas on what caused this?
Thanks,
Omalacon
It looks like the error is occuring at the 5th parameter of your SetDisplayMode function. You have a NULL and I think it should be zero. That should clear things up.
It's not reverse engineering, unless you get caught.
NULL is defined to be 0.
i.e.
in C++
#define NULL ((void *)0)
and in C
#define NULL 0
i.e.
in C++
#define NULL ((void *)0)
and in C
#define NULL 0
January 16, 2000 03:39 AM
Actually I did later try 0 and it still didn''t work. For some reason when I change the display mode I lose exclusive mode. Don''t know how, but that is what happens. Note I also tried switching the order of things... example
How I have it know
1 Create DD object
2 Set Coop mode
3 Set Display mode
4 Create Surface
I tried it this way too
1 Create DD
2 Set Coop
3 Create Surface
4 Set Display
In this scenario I don''t lose exclusive when the surface is created, but the surface is lost when I change the mode. I tried using Restore() but that didn''t work either... I am all out of ideas...
-Omalacon
How I have it know
1 Create DD object
2 Set Coop mode
3 Set Display mode
4 Create Surface
I tried it this way too
1 Create DD
2 Set Coop
3 Create Surface
4 Set Display
In this scenario I don''t lose exclusive when the surface is created, but the surface is lost when I change the mode. I tried using Restore() but that didn''t work either... I am all out of ideas...
-Omalacon
I had this problem for a short time - and I had to reinstall Directx for it to work. I don''t know why, but that''s how it was. Only thing was, at the time I had installed dx7 and was still coding dx6.1, but it should not have been an issue anyway.
Try reinstalling, and see if it works.
Try reinstalling, and see if it works.
A polar bear is a rectangular bear after a coordinate transform.
If you haven''t guessed, I accidentally forgot to enter my password on my last post, whoops 
-Omalacon

-Omalacon
Thanks, reinstalling actually worked. Something must be funky with the DirectDraw 7. Because I have made several DD apps previously and they all worked. But then again they all used earlier interfaces. More specifically there has to be something strange with the new SetDisplayMode function. Because it is the only one I use that has new parameters since the last version of DirectX, and it seems to have been the cause of my problem.
-Omalacon
-Omalacon
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement