Jump to content
  • Advertisement

Archived

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

Surface Locking Help!

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

Hi everyone-I''m new here. Here''s me problem. I''ve done all the DirectDraw initilization stuff-but when I try to Lock a surface the program just shuts down when I run it. If take that line out-the program runs fine-doesn''t do anything-but runs just fine? Any suggestions? The code is here: http://xrelix.tripod.com/program.htm The line thats causing the problem is this: DDS->Lock(NULL, &DDSD, DDLOCK_SURFACEMEMORYPTR / DDLOCK_WAIT, NULL); Thanks ALL! Oh and flame me if you wish! I am a supa NEWBIE!

Share this post


Link to post
Share on other sites
Advertisement
Well.. unless you wrote the line wrong in the message, the line should be

DDS->Lock(NULL, &DDSD, DDLOCK_SURFACEMEMORYPTR / DDLOCK_WAIT, NULL);

The / is supposed to be a /

/ is for dividing. / is for logically ORing two values together.

When you OR something you are comparing each of the bits in a number using a logical OR. Therefore if I ORed the two binary numbers 1010 and 1001 my result would be 1011. This is just because if you stick one number on top of the other and compare each bit anywhere there''s a 1, the answer is 1.

like this:

1010 OR
1001
----
1011

Then the value that comes out after the OR is performed is compared in some value list Microsoft has somewhere and that value references to what you want.

I know this is a ton of information but when I ask a question I like the answer yes, but I also like the person to explain exactly why the answer is what it is. Thus, in order to not be a hypocrite, I''m going to do the same.

hope I helped.. and I hope I didn''t just explain something you already knew. =)

-shpook

Share this post


Link to post
Share on other sites
That pisses me off. You can pretty much disregard my entire previous message. I didn''t know the board automatically converts the vertical lines to divide lines.

So my entire above message was based on a problem that didn''t even exist.

The only problem I can see is the way you may have declared some of your parameters. The call to Lock() is fine. It''s your DDS (surface) or DDSD (surface desc) that may have been declared wrong or maybe your DDSD has a member set wrong or something. Look them over and make sure you don''t have a pointer problem or something.

-shpook

I hope THAT helped.

Share this post


Link to post
Share on other sites
Make sure you zeroed out DDSD before using it. Also remember to set the dwSize variable.

Add these 2 lines before your lock

    
//init the DDSD Structure first

ZeroMemory(&DDSD, sizeof(DDSD));
DDSD.dwSize = sizeof(DDSD);

//now call the lock function

DDS->Lock(NULL,&DDSD, DDLOCK_SURFACEMEMORYPTR/DDLOCK_WAIT, NULL);



That should do the trick



========================================================
If something sounds stupid but works, it's not stupid

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
[bold]Always[/bold] check for NULL when your passing pointers to functions
and [bold]always[/bold] examine the HRESULT from DD calls if the call failed.

If your program crashes, my first guess would be that you tried using
a NULL pointer.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I wanna try that one more time!

Always check for NULL when your passing pointers to functions
and always examine the HRESULT from DD calls if the call failed.

If your program crashes, my first guess would be that you tried using
a NULL pointer.

Share this post


Link to post
Share on other sites
Guys, you can delete your useless/irrelevant posts Click on the edit icon and select the 'Delete this post' checkbox

(Well, unless you're Anonymous, that is )

Edited by - Kylotan on June 26, 2000 6:45:30 AM

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!