Skip to main content
GameDev.net gamedev.net
🔒 Locked

Locking...

Started by Ersvik Aug 8, 2002 at 5:10 AM 0 replies 150+ views
Original Post
Ersvik
Ersvik
Hi, is it safe to draw on a surface that is not locked. I thought it wasn''t, but then i tried to lock, get a pointer to surface, and unlock. It seemed to be no problems when usingthis pointer to draw. Could there be? Anyone knows or have an opinion? And how fast is Lock/Unlock by the way? Thanks for your help, Johan Ersvik
Johan
S1CA
S1CA
***Never*** use a locked surface pointer after the Unlock(),

While it works on *your* hardware, it definately will not work on certain other hardware configurations.

There''s nothing slow about the Lock()/Unlock() calls themselves -they''re there for safety reasons. The main reason why a Lock can take a while is when something else (e.g. the graphics chip) may be using the surface - the CPU cannot write to the surface while this is happening (contention issues, result often == machine freeze/blue screen).
Another thing which often takes place inside the Lock() is "swizzling" - graphics hardware usually stores surfaces in a different way than you thing, i.e. not linear - the pixels are rearranged for faster hardware access. When you lock, you expect linear RGB pixels, the Lock call converts from the internal format into this. The unlock call does the reverse.

In short, don''t use the pointer after the lock!

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

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

Sign in to reply to this topic.