Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateSurface fails after successful SetCooperativeLevel (hwnd, DDSCL_EXCLUSIVE...

127 views
Skip to first unread message

Harald Niesche

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

Hi,

I am working on DirectDraw code to implement page flipping:

In my code lpDD->CreateSurface fails with DDERR_NOEXCLUSIVEMODE after a
successful call of lpDD->SetCooperativeLevel (hwnd,
DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN).

The sequence goes like this:

// my DD_Assert macro prints the error code (if != DD_OK) into a file

LPDIRECTDRAW lpDD = CreateDirectDraw (0,0,0);
DD_Assert (lpDD->SetCooperativeLevel (hwnd,
DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN));
DD_Assert (lpDD->SetDisplayMode (640, 480, 8));
// at this point the screen switches visibly

DDSURFACEDESC desc;

desc.dwSize = sizeof (desc);

if (numBackBuffers) {
desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
desc.dwBackBufferCount = numBackBuffers;
desc.ddsCaps.dwCaps =
DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX;
} else {
desc.dwFlags = DDSD_CAPS;
desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
}

LPDIRECTDRAWSURFACE lpSurface;
DD_Assert (lpDD->CreateSurface (desc, &lpSurface, 0));


The last DD_Assert prints out the error code DDERR_NOEXCLUSIVEMODE.

This only happens:
- on Windows 95
- if the screen resolution is != 8 bits originally (ie. it happens in
800*600*16, but not in 800*600*8)

It doesn't happen on NT, no matter what the current display mode is (ie.
16 or 8 bits doesn't matter).


Any ideas any one? Helpful remarks?

I'd be really happy if you could email the answer as well as posting it.

Harald Niesche

Brian Johnson

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

Have you checked you Hardware Capabilities of your Display Adaptor? Check
your available video memory...

Harald Niesche <h...@mind.de> wrote in article <3324AB...@mind.de>...

Harald Niesche

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

I forgot to say the following:
if in the code below, the numBackBuffers variable is set to 0,
everything works fine at all times.

James Shaw

unread,
Mar 11, 1997, 3:00:00 AM3/11/97
to

Harald Niesche <h...@mind.de> wrote:

>Hi,
>
>I am working on DirectDraw code to implement page flipping:
>
>In my code lpDD->CreateSurface fails with DDERR_NOEXCLUSIVEMODE after a
>successful call of lpDD->SetCooperativeLevel (hwnd,
>DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN).
>

Yep, this happens on some of our machines too.
You set cooperative level to exclusive, and then ask for a full screen
exclusive surface and it fails!
My solution is:-

SetCooperativeLevel(exclusive/fullscreen);
SetDisplayMode();
SetCooperativeLevel(exclusive/fullscreen);
CreateSurface();

That works every time for me! Heaven knows why the second call to
SetCooperativeLevel is needed.

Jim

Harald Niesche

unread,
Mar 12, 1997, 3:00:00 AM3/12/97
to

Brian Johnson wrote:
>
> Have you checked you Hardware Capabilities of your Display Adaptor? Check
> your available video memory...
Sure. 1 Meg. Sufficient for 3 planes of 640 * 480.
Actually, I have fixed the problem by creating two surfaces in video
memory (one primary and ond one OFFSCREENPLAIN) and then attaching the
second surface to the primary...
Looks like DirectX sometimes plays dirty tricks on us.

>
> Harald Niesche <h...@mind.de> wrote in article <3324AB...@mind.de>...

> > Hi,
> >
> > I am working on DirectDraw code to implement page flipping:
> >
> > In my code lpDD->CreateSurface fails with DDERR_NOEXCLUSIVEMODE after a
> > successful call of lpDD->SetCooperativeLevel (hwnd,
> > DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN).
> >

0 new messages