Norris's picture

Help with syntax in VB.net for types and pointers

Hi !
First, sorry for my bad english.
I'm a little programmer and I don't know C or C++ language. So, I prefer VB to C# and try to understand how OpenTK works. That's very cool!
But I find hard converting C# syntax for some code about pointers or "sizeof" since I dont know C++.

I can easily showing a cube or loading vertices for showing a point cloud (from scanner) ... but that's in direct mode. I have read that's deprecated and no longer exists in future OpenGL versions. I have understand that I must use VBO and IBO. So, I try to implement the code from tutorial on this page.

http://www.opentk.com/doc/chapter/2/opengl/geometry/vbo

I can read this:

(IntPtr) ( Vertices.Length * 8 * sizeof( float ) )
I can understand a little of the concept, but can't make an equivalent in VB.Net


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
iliak's picture

Look here.

Norris's picture

Thanks for your link. I have spent more time and I successfully make VBO working under C#, but I tried to convert my project with SharpDevelop and I have only one error that I can't repair.
That's about .... BlittableValueType.StrideOf(vertices)
This is for the GL.BufferData function. I don't very understand this unmanaged world, but, isn't it the same as get the "size" ... the same as the Marshall.SizeOf ???

This is more code with error:

GL.BufferData(BufferTarget.ArrayBuffer, _
	CType(vertices.Length * BlittableValueType.StrideOf(vertices), IntPtr), _
	vertices, _
	BufferUsageHint.StaticDraw)

Thanks for your help for a newbie in the real world of programmers :D

iliak's picture

You can compile your code in C# and open the generated .exe with Reflector. With this tool you can convert any .Net assembly to C#, VB.Net and so on...

the Fiddler's picture
Quote:

Thanks for your link. I have spent more time and I successfully make VBO working under C#, but I tried to convert my project with SharpDevelop and I have only one error that I can't repair.
That's about .... BlittableValueType.StrideOf(vertices)
This is for the GL.BufferData function. I don't very understand this unmanaged world, but, isn't it the same as get the "size" ... the same as the Marshall.SizeOf ???

BlittableValueType.StrideOf() is the same as Marshal.SizeOf, only faster (the latter evaluates the size every time, while the former caches the value and returns it instantly).

You can construct an IntPtr directly, no need to cast:

New IntPtr(vertices.Length * BlittableValueType.StrideOf(vertices))

(In this case, the IntPtr is not used as pointer but rather as a "native int" type to match what OpenGL expects).

What error are you getting?