Directx 8 with VB.net

Directx 8 with VB.net

Post by Armin Zingle » Wed, 09 Jan 2002 20:33:07




Quote:> Is it possible to use direct3d 8 with VB.net, as I get an
> error everytime I call the function
> direct3ddevice8.drawprimitiveup.  I was wondering if there
> is anyway to stop this error.  The error is that when
> trying to pass the first member of the vertex array, it
> can't be converted to type system.intptr.  I hope you can
> help figure this out.

VB.Net + DX is really not the best team. The "problem" is the managed code.
So getting real pointers is not a part of VB.Net at all and only limited in
C#. You can not get a pointer because it's said that the garbage collector
can rearrange memory and you can never be sure that a pointer is still valid
after passing it to DX. At the moment, in VB.Net you have three choices:
- Write a VB6 DLL and use it by your VB.Net app
- write unsafe code in C#
- Use the marshal class

In your case you probably mean the argument VertexStreamZeroDataArray. It's
declared "As Any" and that's converted to System.Intptr when importing the
type-library.

Using the Marshal class (System.Runtime.InteropServices.Marshal):
Have a look at it's functions: They are there to copy managed data to
previously reserved memory. This memory can be accessed by a "normal" Intptr
and therefore passed to DX. Simple Example:

dim Ptr as Intptr
dim Vertex as d3dvertex
Ptr = Marshal.AllocHGlobal(len(Vertex))
Marshal.StructureToPtr (Vertex, Ptr, True)

Now you can pass the Ptr to DirectX.

That's only an example (not sure if using the len function returns the
correct result for reserving memory) of what the Marshal class is for. Big
disadvantage: Copying everything is not an option for applications where
performance is a main issue, at all. So I'd prefer writing a C# library and
use unsafe code.

I'm rather new to this subject so I'm not sure if *everything* can be
achieved by working around, using C# or VB6-DLLs.

Armin

 
 
 

Directx 8 with VB.net

Post by Philip Taylor [MS » Thu, 10 Jan 2002 05:10:59


there are several samples that use Direct3D from .NET at
htt://www.gotdotnet.com.

--
Phil Taylor
PM : DirectX SDK, Managed DirectX, WindowsXP Inbox 3D Screensavers, and a
few more bits and bobs
http://msdn.microsoft.com/directx
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:> Is it possible to use direct3d 8 with VB.net, as I get an
> error everytime I call the function
> direct3ddevice8.drawprimitiveup.  I was wondering if there
> is anyway to stop this error.  The error is that when
> trying to pass the first member of the vertex array, it
> can't be converted to type system.intptr.  I hope you can
> help figure this out.


 
 
 

1. Directx 9 in VB.net, AnimationController

Hi there,

I need create new instance of AnimationController.
After two rows in my code system throws following exception ...
Cannot access a disposed object named
"Microsoft.DirectX.Direct3D.AnimationController"

***My code
Dim MyAnimationController As AnimationController
MyAnimationController = New AnimationController(47, 1, 2, 30) 'Here
apears the exception.
***

Does anybody know what I am doing wrong?

Thanks
Pavel

2. problem in "replaceChild"

3. VB.NET & DirectX

4. MGP card

5. DX VB.NET Vs DX VC++.NET

6. Problem: Actions and gif89a export plugin

7. wglUseFontOutlines & VB.NET

8. WANTED! NET ANIMATIN MAGAZINE

9. OpenGL & VB.NET

10. VB.NET, cards.dll, PictureBox

11. APIs and VB.net

12. Question on CreateDIBSection under VB .Net

13. bitblt in vb.net