Jump to content
  • Advertisement


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


DirectDraw & crashing

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

Ive been having problems with direct draw (versions 2-7) For some reason, my program (which is very basic and routine, it just creates a DirectDraw object, sets coop mode for fullscreen, sets video at 640x480x8, and creates only a primary surface) is crashing. it works up to the point in my main event loop when i must lock the primary surface. It is crashing, because i am not even getting a return code -- the program exits right there, and thats it. heres my code: memset(&ddsd,0,sizeof(ddsd)) ddsd.dwSize = sizeof(ddsd); OutputDebugString("cleared ddsd"); // this is just so i can know that its the lock call if(FAILED(lpddsprimary->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) { OutputDebugString("Could not lock surface"); // im not getting this message } OutputDebugString("Lock surface"); // i do not get either of the messages, and at least this one should be showing up. None of this code gets executed because it exits at the lock call. i really have no idea. whats strange though, is that it was made on a computer with win98 and crashes, but it works on a win2k computer. the guy with the win2k computer said that it was a memory leak, and that win2k can handle them better and was able to run it. any help would be appreciated.

Share this post

Link to post
Share on other sites
This might be totally irrelevant but I usually fill the ddsd.dwFlags with DDSD_CAPS and then I do ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE. Forgive me if this has nothing to do with what yer trying to do

Just for reference, I'm using DirectX6.0 (cuz LaMothe teaches with it, I'll do D7, 8 later) here's the sourcecode from my GameInit():

/create main dd object
DirectDrawCreate(NULL, &lpdd, NULL);

//request interface

lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4);



ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;

lpdd4->CreateSurface(&ddsd, &lpddsprimary, NULL);

//create our palette

PALETTEENTRY palette[256];

//fill our palette with color


palette[12].peRed = 255;
palette[12].peGreen = 0;
palette[12].peBlue = 0;
palette[12].peFlags = PC_NOCOLLAPSE;

lpdd4->CreatePalette(DDPCAPS_8BIT, palette, &lpddpal, NULL);


And then I Lock when needed with lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL)

Hope it helps!

Peon [/source]

Edited by - Peon on January 25, 2001 11:01:37 PM

Share this post

Link to post
Share on other sites
that init code is pretty much the same as mine. i knew not many people would be able to help me, cause its just one of those mysterious things that is unexplainable and only happens to me
. If anybody knows why its not working, at this point ANY help would be GREATLY appreciated.

Share this post

Link to post
Share on other sites
While a surface is Lock()''d, you cannot write to a file; assuming thats what OutputDebugString() does.

Solution: Keep all debug strings in a memory buffer and write them to disk when the time is safe (outside of locks).


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!