Jump to content
  • Advertisement

Archived

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

Tai-Pan

Debug Error when setting the video mode

This topic is 5474 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

Im learning DirectX, but Im having a problem when I try to set the video mode with SetVideoMode(640,480,8); The program compiles without any problem, but when I try to run or debug it, a big window (a Microsoft Visual C++ Debug Library, Debug Error window) shows up and it says something like: ... 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. (Press Retry to Debug the application) ... If I try to ignore the problem..the application eventually hangs.. This is the code that I use: ... //first create the base IDirectDraw interface if(FAILED(DirectDrawCreate(NULL,&lpdd,NULL))) { //error return(1); } //now query for DirectDraw 4 interface if(FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID*) &lpdd4))) { //error return(1); } lpdd->Release(); //set cooperation to full screen if(lpdd4->SetCooperativeLevel(main_window_handle, DDSCL_ALLOWMODEX | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT) != DD_OK) { //error return(1); } //set display mode to 640*480*8 if(FAILED(lpdd4->SetDisplayMode(640,480,8))) { //error return(1); } ... Keep in mind that I have tried querying for the DirectDraw7 interface (the latest) too, but I get the SAME problem. Any help guys? "Those who follow the path of the warrior must be ready to die, to stand for their convictions, live for one´s convictions, die for one´s convictions"

Share this post


Link to post
Share on other sites
Advertisement
Well, one thing I see is that you are passing "lpdd" to DirectDrawCreate and QueryInterface, but are using lpdd4 to set cooperative level and display mode.

Try this code:

LPDIRECTDRAW7 lpdd = NULL;

//create the directdraw object
if (FAILED(DirectDrawCreateEx(NULL,(void **)&lpdd,IID_IDirectDraw7,NULL)))
{
return false;
}

//set coop level
if (FAILED(lpdd->SetCooperativeLevel(hWndCoop,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)))
{
return false;
}

//set display mode
if (FAILED(lpdd->SetDisplayMode(640,480,8,0,0)))
{
return false;
}

This code works. I took it from my own game engine.

[edited by - ziggwarth on September 26, 2003 12:12:46 PM]

Share this post


Link to post
Share on other sites
Thanks dude!!
...I checked my pointer declarations and I found out that my directdraw pointers were declared like this:

LPDIRECTDRAW lpdd;
LPDIRECTDRAW lpdd4;

Stupid error..hehe

So I declared as:

LPDIRECTDRAW lpdd;
LPDIRECTDRAW4 lpdd4;

and now its working without problems

thanks!!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!