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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


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

[link] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/htm/idirectdrawsetdisplaymode.asp [/link]

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 this post


Link to post
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites