Surface Locking Help!

Started by
5 comments, last by Chipcrap 23 years, 9 months ago
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!
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

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.
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 firstZeroMemory(&DDSD, sizeof(DDSD));DDSD.dwSize = sizeof(DDSD);//now call the lock functionDDS->Lock(NULL,&DDSD, DDLOCK_SURFACEMEMORYPTR/DDLOCK_WAIT, NULL);    


That should do the trick



========================================================
If something sounds stupid but works, it's not stupid
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
[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.
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.
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

This topic is closed to new replies.

Advertisement