Locking DirectDraw Surfaces

Loki

Newcomer
Joined
Dec 27, 2003
Messages
15
Has anyone had any luck with the Lock method on the DirectDraw Surface object?

Every time I lock a surface, application just freezes and eventually throws an exception, I have tried everything, cant seem to get it to work properly.
 
Loki said:
Has anyone had any luck with the Lock method on the DirectDraw Surface object?

Every time I lock a surface, application just freezes and eventually throws an exception, I have tried everything, cant seem to get it to work properly.

yes I do


Dim dati As Integer(,)

Dim i As Integer
Dim j As Integer

dati = CType(superficie.Lock(LockFlags.Wait), Integer(,))

For i = 0 To 639
For j = 0 To 479
dati(i, j) = Color.Red.ToArgb
Next
Next

superficie.Unlock(dati)


where superficie is a surface of 640 x 480

works only on summer update and .net 2003
 
I think the Lock() method is just crap to be honest. I have it working, but the bigger surface you lock, the longer the lock takes to begin. I am guessing this has something to do with mapping to an array in .NET. But either way, it makes the method pretty useless for any realtime effects. Which is pretty much what it is there for.

Thanks for the help.
 
what's the point of even locking it? all i use it for is getting the array back from the vertex buffer to store into the vertices..

vertices = vertbuffer.lock(0,0) :-p
or
vertices = directcast(vertexbuffer.lock(0,0),customvertex.PositionTexturedorwhatever))

i do this before setting the vertices coordinates and stuff (and then unlock it of course)

seems to work for me
 
Loki said:
I'm using a DirectDraw surface. No 3D stuff in this one.
if you need a quick access to memory is impossible, memory acces is show
if you need simple modification use pixel shader in direct3D. If you use 2.0 version you can obtain many effect but you can't do what ever you want.
In directDraw this is the best you can do
 
Just thought I'd mention that you can use D3D to create 2D stuff (not to mention you get better performance AND it's easier to use). There's a Sprite class in D3D that makes this all too easy. :)
 
Locking a surface gives you direct access to the data for manipulation. It also prevents multiple threads from manipulating it at the same time.
 
Back
Top