#### Archived

This topic is now archived and is closed to further replies.

# SetDisplayMode() woes...

This topic is 5301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to get a grasp of some DirectX, but have ran into a wall here. I'm simply trying to get fullscreen 1024x768 resolution, but get an error (posted below). Here is the actual code of the problem area, althogh i posted the full source here-> http://extraball.sunsite.dk/notepad.php?ID=1240. (I posted it there to save space here.) This is using the DirectX 9 SDK.
if(FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
return FAILURE;

if(FAILED(lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID *)&lpdd7)))
return FAILURE;

lpdd->Release();
lpdd = NULL;

if(FAILED(lpdd7->SetCooperativeLevel(hwnd_global,
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX |
DDSCL_EXCLUSIVE  | DDSCL_ALLOWREBOOT)))	return FAILURE;

if(FAILED(lpdd7->SetDisplayMode(1024,768,32))) return FAILURE;

// return success

return SUCCESS;

The error i recieve is as follows: File: i386\chkesp.c Line: 42 The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. Please help! s1icksho3s [edited by - slick_shoes on June 3, 2003 10:18:22 PM]

##### Share on other sites
Start by finding an example that uses IDirectDraw7 interfaces. These use the newest and final version of direct draw. It will probably save you some trouble in the long run if you base you app off them.

##### Share on other sites
First off, use IID_IDirectDraw7, NOT 4. You will not get a returned interface for DX7 if you pass the DX4 parameter in the function.

Then the correct function (if I remember DX7, ) is

lpdd7->SetDisplayMode(1024,768,32,0,0);

If it is only a matter of a calling convention error also, just use casting!

##### Share on other sites
RhoneRanger: The IID_IDirectDraw4 was actually a IID_IDirectDraw7 before, but since it didn't run correctly, i used dd4 to get my code to match the code in the book i am using. that was the only difference that i could see, so i assumed that was the problem, and made the switch to test that. sorry for the misunderstanding...

also, the syntax you mentioned for the SetDisplayMode function matches that of my book, but the DirectX 9SDK documentation only mentions the three parameters for width, height, and bpp. even when i try to pass the two additional parameters, it flags it as an error for having too many arguments.

There are no type conflicts, so i don't believe a cast would work.

i hope i am being clear.
do you have any other ideas?

slick_shoes

PS: I edited the above source code to change it from dd4 to dd7. once again, sorry for the error

[edited by - slick_shoes on June 3, 2003 10:19:19 PM]

##### Share on other sites
well, for dx7 the actual set display mode code was 5 parms.

Please post the line(s) of code that are causing the actual error.

##### Share on other sites
The problem line is in fact the lpdd7->SetDisplayMode line...
with that line commented out, the programs runs as expected.

That is what i used as a reference. They must have changed the interface for directx 9, unless im missing something completely obvious.

Im losing faith in myself.
slick_sheos

[edited by - slick_shoes on June 3, 2003 10:47:02 PM]

##### Share on other sites
have you tried DirectDrawCreateEx??
and is your lpdd7

LPDIRECTDRAW7 ??

##### Share on other sites
I tried replace the current DirectDrawCreate(...) line with the following: DirectDrawCreatEx(NULL,(void**)&lpdd7,IID_IDirectDraw7,NULL). This did not work either.

And once again, yes, lpdd7 is infact a DirecDraw 7 device.
slick_shoes

##### Share on other sites
that is really strange, cause if I remember correctly, both of those were the proper DX7 functions.

huh.....

##### Share on other sites
Thanks anyway for trying...
Im sure its something simple im neglecting to do.
I''ll work on it some more.

Thanks again!
slick_shoes

##### Share on other sites
I doubt it has to do with your problem, but you might want to see if DDSCL_ALLOWMODEX is really necessary with that screen mode.

[JESUS SAVES|Planet Half-Life]

##### Share on other sites
Usually ESP error means, you have some header declaring the function wrong (different params etc.).

It sounds like you have linked the right ddraw libs but the wrong headers (the parameter count problem).

Did you move the directx includes on top of the list after you installed the SDK?

• ### Forum Statistics

• Total Topics
628676
• Total Posts
2984175

• 13
• 12
• 9
• 10
• 10