• Announcements

Archived

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

DirectDraw & crashing

Recommended Posts

Rocket05    152
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 on other sites
Peon    276
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); lpdd4->SetCooperativeLevel(main_window_handle, DDSCL_ALLOWMODEX | DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); lpdd4->SetDisplayMode(SCREEN_WIDTH,SCREEN_LENGTH,8,0,0); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; lpdd4->CreateSurface(&ddsd, &lpddsprimary, NULL); //create our palette PALETTEENTRY palette[256]; //fill our palette with color //red palette[12].peRed = 255; palette[12].peGreen = 0; palette[12].peBlue = 0; palette[12].peFlags = PC_NOCOLLAPSE; lpdd4->CreatePalette(DDPCAPS_8BIT, palette, &lpddpal, NULL); lpddsprimary->SetPalette(lpddpal);

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 on other sites
Rocket05    152
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.