RE: wrapping DX
- Posted by Matthew Lewis <matthewwalkerlewis at YAHOO.COM> May 29, 2001
- 427 views
I've run into something very strange in DirectX. I'm basically converting the C++ Tutorial on MSDN into Euphoria. I'm having trouble with the IDirect3DVertexBuffer8 interface. Everything else seems to work fine, but I can't get any calls to this interface to work in Euphoria. I've written a DLL in VC++ that will make the calls fine, but I get error R6025: Pure Virtual Function Call if I try to call QueryInterface. Any other call simply returns the 'this' pointer, and if any args are passed, the program crashes, because the stack pointer gets messed up since the called function didn't clean anything up. Here's a quick rundown of my DirectX calls (with everything else deleted): -- Get the Direct3D8 object direct3d8 = c_func( d3dc, {D3D_SDK_VERSION} ) -- Get Adapter info void = call_interface_ptr( direct3d8, d_vtbl, Direct3D8_GetAdapterDisplayMode, { D3DADAPTER_DEFAULT, d3dadapter } ) -- Create the device, and get pointer to Direct3DDevice8: void = call_interface_ptr( direct3d8, d_vtbl, Direct3D8_CreateDevice, {0, 2, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp, ppv }) -- Create the vertex buffer, and get pointer to Direct3DVertexBuffer8: void = call_interface_ptr( device, device_vtbl, Direct3DDevice8_CreateVertexBuffer, { 3 * sizeof_CUSTVERT, 0, CUSTVERT_flags, 1, ppv } ) For some reason, when I get the 'this' pointer, and the address of the vtbl, and call methods (which is exactly how I've done it with other interfaces), it doesn't work, unless I do it in VC: -- Euphoria (doesn't work): void = call_interface_ptr( vb, vb_vtbl, Direct3DVertexBuffer8_Lock, { 0, 3 * sizeof_CUSTVERT, pVertices, 0 } ) // C++ (works): extern "C" _declspec(dllexport) long __stdcall Lock( LPDIRECT3DVERTEXBUFFER8 pf, int a, int b, BYTE** c, int d) { return pf->Lock(a, b, c, d); }; I've also tried to call from C++ using an actual function pointer, the same way I do in Eu, but that fails. The only way seems to be to declare a 'proper' C++ interface object, and call the members. But only on this one interface. Any ideas? Matt Lewis > -----Original Message----- > From: martin.stachon at worldonline.cz > Please, post an URL when you will have somthing done. > > Martin