Archived

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

IOFILE

Stupid DDraw lock problem

Recommended Posts

IOFILE    122
Ok. I''m probably going to feel like an idiot after asking this but... I have a problem with locking a surface in my game. Ok, the surface is created fine, and blting to the thing works perfectly. However, I''m trying to lock the surface, which has worked before in other apps of mine, and I get a returned DDERR_INVALIDPARAMS. What''s up with that. My code is perfectly normal. Here is what my lock looks like: LPDIRECTDRAWSURFACE7 pDDS; // surface is created, blah, blah, blah... // Now I try to lock it DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd, sizeof(ddsd)); pDDS->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); // the lock returns DDERR_INVALIDPARAMS, like I said. Please, someone help

Share this post


Link to post
Share on other sites
Ironblayde    130
You have forgotten to set the dwSize member of the DDSURFACEDESC2 structure.

ddsd.dwSize = sizeof(ddsd);

Also, if you want a pointer to manipulate the pixels with, be sure to specify the DDLOCK_SURFACEMEMORYPTR flag in addition to DDLOCK_WAIT.

-Ironblayde
 Aeon Software

The following sentence is true.
The preceding sentence is false.

Share this post


Link to post
Share on other sites
IOFILE    122
hehe... What did I say, I feel really really stupid now, hehe. *Sigh*, oh well. Thanks man. I''m glad that someone knows what they''re doing. Once again, thank''s for the help.

Share this post


Link to post
Share on other sites
Ironblayde    130
No problem, we all do it once in awhile. Last night while I was rather tired I wrote a function that used = instead of == not once, but THREE times. Once I caught that I decided that any more programming without a bit of sleep first might be dangerous, hehe.

-Ironblayde
 Aeon Software

The following sentence is true.
The preceding sentence is false.

Share this post


Link to post
Share on other sites
IOFILE    122
Yep, I guess it''s true, we all do it at some time ...
Although when it happens, wea ll then feel really dumb

I hear ya. I''ve done the if (a = b) before instead of the == and it was a killer. It took me a while to realize that I wasn''t comparing a to b, but setting them equal. I practically had to comment out my whole program to isolate the bug, grrr. Oh well, at least ever since I''ve been careful never to do it again because I am now aware of the pain and suffering it can cause...

Share this post


Link to post
Share on other sites
DekuTree64    1168
I was warned so many times about mixing up = and == when I first learned to program, I never made that mistake, but I did make a very similar mistake to IOFILE''s a while ago, except mine was with creating a surface. I did set the dwSize member of my DDSURFACEDESC2, but forgot to zero it out first. I ended up trying everything I could think of for the next few days before I gave up and posted here for help... Guess it''s just part of being a programmer. And besides, it''s pretty darn funny if you think about it^^



-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

"I'm dropping like flies!" - me, playing Super Smash Bros. (and losing)
"What fun!" - me, playing Super Smash Bros. (and beating the crap out of somebody)

Share this post


Link to post
Share on other sites