Advertisement

DirectDraw Surface->Lock question

Started by January 31, 2000 06:22 PM
2 comments, last by Jesse Chounard 25 years, 1 month ago
I''m trying to optimize my DD app for framerate, and one thing that is really bogging me down is the Lock/Unlock section of my code. I once read somewhere that if your surface is in system memory, you can save the pointer to the pixel data, and never need to Lock/Unlock (after the first), and save time. I tried it, and it seems to work on my machine, but I''m wary of of this technique, because it feels kind of like a hack, and I don''t want my code to fail on anyone''s machine. Does anybody have experience with this? Jesse Chounard jessec@umr.edu
You are probably right about just creating a pointer, but I'm not sure. If you got it to work, I'm sure it would work on everybody else's computers. Also, are you locking just once per frame and doing all your writing, or do you lock and unlock a bunch of times each game loop?

Edited by - CoolMike on 1/31/00 6:50:23 PM
Advertisement
Just once per frame, to perform blending and other similiar effects. But it still slows me down more than I''d like.

Jesse Chounard
jessec@umr.edu
Yes, it is a hack, and no, you shouldn''t save the pointer between locks(). It''s poor style, and can lead to bugs later (if you move the surface into video memory, you can really get things screwed up and have to track down all the cached pointers.)

And for sysmem surfaces, locks are quick(er) anyway.

This topic is closed to new replies.

Advertisement