Loki Posted March 15, 2004 Posted March 15, 2004 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. Quote
RobyDx Posted March 15, 2004 Posted March 15, 2004 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 Quote Come to visit
Loki Posted March 16, 2004 Author Posted March 16, 2004 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. Quote
ThePentiumGuy Posted March 16, 2004 Posted March 16, 2004 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 Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Loki Posted March 16, 2004 Author Posted March 16, 2004 I'm using a DirectDraw surface. No 3D stuff in this one. Quote
RobyDx Posted March 19, 2004 Posted March 19, 2004 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 Quote Come to visit
wyrd Posted March 21, 2004 Posted March 21, 2004 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. :) Quote Gamer extraordinaire. Programmer wannabe.
ThePentiumGuy Posted March 21, 2004 Posted March 21, 2004 now that i think about it, what is the point of locking it? all i knopw is that you have to do this: lock set positions of the vertiecs unlock - i'm just curious, pent Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
wyrd Posted March 21, 2004 Posted March 21, 2004 Locking a surface gives you direct access to the data for manipulation. It also prevents multiple threads from manipulating it at the same time. Quote Gamer extraordinaire. Programmer wannabe.
ThePentiumGuy Posted March 21, 2004 Posted March 21, 2004 oh, i see, thanks a lot, -pent- Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.