Why does this fail?

BlitzMax Forums/BlitzMax Programming/Why does this fail?

TartanTangerine (was Indiepath)(Posted 2005) [#1]
Read on...


TartanTangerine (was Indiepath)(Posted 2005) [#2]
OKay so can now make a Vertex buffer but I can't lock it.. ANyone got any ideas..
Type D3DVERTEXBUFFERDESC 
	Field dwSize
	Field dwNumVertices
	Field dwFVF
	Field dwCaps
End Type

Global pverts:Byte Ptr
Global verts:Float[12]

Global d3dVertexBuffer:IDirect3DVertexBuffer7
Global desc:D3DVERTEXBUFFERDESC = New D3DVERTEXBUFFERDESC

desc.dwSize =SizeOf(desc)
desc.dwNumVertices = 16*3
desc.dwFVF = D3DFVF_XYZRHW
desc.dwCaps = 0

primarydevice.d3d.CreateVertexBuffer(desc,d3dVertexBuffer,Null)

pVerts = verts
verts[0]=50
verts[1]=200
verts[2]=0
verts[3]=150
verts[4]=50.0
verts[5]=0.0
verts[6]=0
verts[7]=1
verts[8]=250.0
verts[9]=200.0
verts[10]=0
verts[11]=1

d3dVertexBuffer.lock(DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_NOOVERWRITE,Pverts,Null)' ********UNHANDLED MEMORY EXCEPTION ERROR HERE

Lock Method
Type IDirect3DVertexBuffer7 Extends IUnknown
	Method Lock(dwFlags,lplpData:Byte Ptr Var,Size Var)
End Type

This is the c++ code, I've probably got it all wrong
STDMETHOD(Lock)(THIS_ DWORD,LPVOID*,LPDWORD) PURE;



Shambler(Posted 2005) [#3]
Is it because size=0 ?

[edit] Oi you changed it lol...still, are you allowed to lock 0 verts?

[editedit] Also, did you check that the vertexbuffer exists?


TartanTangerine (was Indiepath)(Posted 2005) [#4]
The size parameter is actually returned by the Lock command. If you set Size to 0 or Null then no size is returned.

I think the issue is with LPVOID*, documentation says LPVOID* is the pointer to our pointer to the buffer. How the heck do I do that in BMax?

[edit]VertexBuffer is returning Null! What a waste of a day!


tonyg(Posted 2005) [#5]
Have no idea about any of this but Antony's post ...
here
uses lpvoid to lock storage.


TartanTangerine (was Indiepath)(Posted 2005) [#6]
Dang, he's compiled it as a module so I can't learn anything from that.

I'm sure Mark S could answer this one in 2 mins - or maybe there is a reason I can't do this? Anyone?


tonyg(Posted 2005) [#7]
Doesn't he give the source later in the thread?


TartanTangerine (was Indiepath)(Posted 2005) [#8]
Ohh nice, I had an idea I might have to include some C in there somewhere.

Where is Ant anyway?


tonyg(Posted 2005) [#9]
Starting a new project... I expect :)


TartanTangerine (was Indiepath)(Posted 2005) [#10]
ROFL. hey whats this 360 Game Creator on his site? One of the games he's saying that was made with it was actually made in D ?? whats the story there eh?


tonyg(Posted 2005) [#11]
I think it looks quite funky but not really sure what it is, what you can do and how it fits into Bmax. Nothing on the forums either


LarsG(Posted 2005) [#12]
I think he's keeping a low profile ta actually *do* something... (however incredible it sounds.. ;))


TartanTangerine (was Indiepath)(Posted 2005) [#13]
Anyway back to topic.

anyone got a danny?


Tom(Posted 2005) [#14]
VertexBuffer is returning Null! What a waste of a day!


A successful call in DirextX returns 0, which of course is null, so your buffer may be ok.


TartanTangerine (was Indiepath)(Posted 2005) [#15]
I was checking the memory address returned by the function, the address was null :(