the answer is simple: the code is just wrong.
hard to believe it worked in C++, as the setstreamsource definitely broke it. There you normaly set sizeof(D3DVertex) in this case 20
the expanded code as well does correct checks for BeginScene succeeded before putting the triangle on it and end the scene.
Strict Local win:tGAdget = CreateWindow("test",32,32,832,632) Local hwnd:Int = QueryGadget(win,QUERY_HWND) Local d3d9Graphics:Direct3d = New Direct3d d3d9Graphics._Init(hwnd,800,600,False) Local lpD3DDevice:IDirect3DDevice9 = d3d9Graphics.GetDevice() Type _TriangleVertices Field x1:Float = 320.0 Field y1:Float = 150.0 Field z1:Float = 0.0 Field r1:Float = 1.0 Field c1:Int = $FF0000FF Field x2:Float = 400.0 Field y2:Float = 330.0 Field z2:Float = 0.0 Field r2:Float = 1.0 Field c2:Int = $FFFF0000 Field x3:Float = 240.0 Field y3:Float = 330.0 Field z3:Float = 0.0 Field r3:Float = 1.0 Field c3:Int = $FF00FF00 End Type Local TriangleVertices:_TriangleVertices = New _TriangleVertices Local D3D_CUSTOMVERTEX:Int = (D3DFVF_XYZRHW | D3DFVF_DIFFUSE) Local VertexBufferStart:Byte Ptr Local VB_Triangle:IDirect3DVertexBuffer9 = Null If lpD3DDevice.CreateVertexBuffer( 60,D3DUSAGE_WRITEONLY,D3D_CUSTOMVERTEX,D3DPOOL_MANAGED,VB_Triangle, Null) <> D3D_OK Then Notify "faild to create vb" End EndIf If VB_Triangle.Lock(0, 60, VertexBufferStart, 0) <> DD_OK Then Notify "cant lock vb" End End If MemCopy(VertexBufferStart, Byte Ptr ( TriangleVertices ), SizeOf(_TriangleVertices)) VB_Triangle.Unlock() lpD3DDevice.SetFVF(D3D_CUSTOMVERTEX) Repeat 'waitevent If d3d9Graphics.BeginScene() lpD3DDevice.SetStreamSource(0, VB_Triangle, 0, 20) ; lpD3DDevice.DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1) ; lpD3DDevice.EndScene() EndIf lpD3DDevice.Present(Null,Null,Null,Null); Until KeyHit(Key_Escape) End Type Direct3d Field clsColor :Int = $FF0000FF Field Direct3D9 :IDirect3D9 = Null Field Direct3DDevice9 :IDirect3DDevice9 = Null Field BackBuffer :IDirect3DSurface9 = Null Field PParams :D3DPRESENT_PARAMETERS = Null Field hwnd :Int = 0 Method _Init(hwnd:Int, w:Int, h:Int, bWindowed:Int = False) Self.hwnd = hwnd Direct3D9 = Direct3DCreate9( $900 ) If Not Direct3D9 Then Notify "error creating d3d9interface!" End EndIf PParams = New D3DPRESENT_PARAMETERS PParams.SwapEffect = D3DSWAPEFFECT_DISCARD; PParams.hDeviceWindow = hwnd; PParams.Windowed = bWindowed; PParams.BackBufferWidth = w; PParams.BackBufferHeight = h; PParams.BackBufferFormat = D3DFMT_A8R8G8B8; Local hr:Int hr = Direct3D9.CreateDevice( 0 ,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,PParams,Direct3DDevice9) <> D3D_OK If hr Then Notify "error creating d3d9device!" End EndIf Direct3DDevice9.GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO, BackBuffer ); End Method Method SetClsColor(r:Int,g:Int,b:Int) clsColor = Int(( 255 Shl 24)| (r Shl 16)| (g Shl 8)| b ) End Method Method BeginScene() Direct3DDevice9.Clear(0,Null,D3DCLEAR_TARGET,clsColor,0,0); Return Direct3DDevice9.BeginScene(); End Method Method EndScene() Direct3DDevice9.EndScene(); Direct3DDevice9.Present(Null,Null,Null,Null); End Method Method GetDevice:IDirect3DDevice9() Return Direct3DDevice9 End Method Method GetBackBuffer:IDirect3DSurface9() Return BackBuffer End Method End Type ¨
hard to believe it worked in C++, as the setstreamsource definitely broke it. There you normaly set sizeof(D3DVertex) in this case 20
the expanded code as well does correct checks for BeginScene succeeded before putting the triangle on it and end the scene.