SetDisplayMode() woes...

Started by
10 comments, last by slick_shoes 20 years, 10 months ago
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]
Advertisement
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.
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!
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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]
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.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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]
have you tried DirectDrawCreateEx??
and is your lpdd7

LPDIRECTDRAW7 ??
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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
that is really strange, cause if I remember correctly, both of those were the proper DX7 functions.

huh.....
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Thanks anyway for trying...
Im sure its something simple im neglecting to do.
I''ll work on it some more.

Thanks again!
slick_shoes

This topic is closed to new replies.

Advertisement