Skip to main content
gamedev.net
🔒 Locked

Error on Lock()

Started by Jer_plusplus May 21, 2002 at 1:22 AM 5 replies 550+ views
Original Post
Jer_plusplus
Jer_plusplus
Hello. My program freezes and the compiler points to the error on the Lock() function call. memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); //lock the whole primary surface if (FAILED(lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) Am I doing anything wrong here? Please help me out.
Jer_plusplus
Jer_plusplus
I think it might be due to my SetDisplayMode() call. It''s suppose to take in 5 params (width, height, bpp, refresh rate, extra flag) but my compiler is only accepting 3. It says SetDisplayMode does not take 5 params.....???
S1CA
S1CA
1. Run the DEBUG DirectX runtimes (you get the option when installing the SDK) with the debug output level set to maximum. This will allow you to any DirectX errors and warnings and their reasons in the debug output window.

2. Use the NOSYSLOCK flag on the Lock() call - particularly if you''re single stepping through the code in the debugger.

3. Don''t "step into" the Lock() - some pretty low level KERNEL mode nastiness goes on inside their - nastiness which your USER mode debugger won''t be able to handle.

4. The problem is quite likely to be in the code after the lock than the lock itself.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Hippie Hunter
Hippie Hunter
THis is the same problem as another persons i just answered but no one knows it so here goes. you options are as follows

1.get vs.net
2.put you init code in a differnet place
3.pull out a big gun and blast your computer
4.repeat

the problem is not in the code after but in the code before as it always is if somthing unexplainabley dosent work.


Great White Hunter Hunt to kill, kill to live, live to hunt.

[edited by - hippie Hunter on May 22, 2002 1:40:20 AM]
Great White Hunter Hunt to kill, kill to live, live to hunt.
S1CA
S1CA
Hippie Hunter:

True, it *might* be before the lock - but it isn''t at all definate, and in this case unlikely!

Lets just say for a moment that the original posters program crashed *somewhere* so he ran again in the debugger and single stepped into the lock to try and trace it. Which without the NOSYSLOCK flag will have locked his user mode debugger up. - Which actually sounds likely from his description - "freezed".

Also since he posted the lines of code above the Lock() I don''t see manu candidates - unless ddsd is the wrong type for the version of DD or its really a pointer rather than an object.

Another thing I didn''t mention is it could be the lpddsprimary pointer - it might not be valid.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
DirectAndy8
DirectAndy8
Aha! I just had this same problem, or at least one very similar to it.

For me, it was because I was using an old version of LPDIRECTDRAW. If you right click on SetDisplayMode and "Go To Definition of SetDisplayMode", you''ll get a list of different versions... IDirectDraw::SetDisplayMode takes 3 parameters, and that''s the one you''re (inadvertantly) using. The others (at least IDirectDraw4 and IDirectDraw7, anyway) take 5 parameters, and that''s the one you want.

For me it was a case of using LPDIRECTDRAW7 instead of LPDIRECTDRAW as my pointer to the interface. I also needed to use DirectDrawCreate followed by QueryInterface, because for some reason DirectDrawCreateEx didn''t set it up properly.

Try those sorts of changes, see what happens.
Hippie Hunter
Hippie Hunter
shure he need sto use nosyslock but the error in the program isnt in the lock it is in the code before but he wont know that diffinitivly untill he uses nosyslock
Great White Hunter Hunt to kill, kill to live, live to hunt.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.