I’m trying to do this without using a 3rd party DLL library solution, I can only find C++ and C# source code samples when converted to VB.NET just isn’t working, the function pointers are variables and seem like Delegates, I found this and tried it and not working:
http://www.codeproject.com/vb/net/Delegate.asp
The delegate (function pointer) is supposed to have the function address passed off to the variable using AddressOf, in which you can then call the function/method using the variables name and passing any parameters, optionally using Invoke.
C++ TYPE DEFINITION:
typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target);
Is said to be equivilant to VB.NET’s, which defines a type safe, method or function:
Public Delegate Sub PFNGLACTIVETEXTUREARBPROC(ByVal target As Int32)
C++ VARIABLE:
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
Is said to be equal to VB.NET’s variable declaration like so:
Public Shared glActiveTextureARB As PFNGLACTIVETEXTUREARBPROC = Nothing
C++ Assigning Reference to Function/Passing Function Pointer/Function Address to Invokable Variable:
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
VB.NET Assign Addresses/References to the Function Pointers:
glActiveTextureARB = wglGetProcAddress("glActiveTextureARB")
-OR-
glActiveTextureARB = AddressOf <FUNCTION POINTER>
See if Multi-Texturing is supported…
If IsNothing(glActiveTextureARB) = True Then MsgBox("Your version of OpenGL does not support multitexturing...", , "Error")
VB.NET’s Function Usage would be:
glActiveTextureARB(GL_TEXTURE0_ARB)
-OR-
glActiveTextureARB.Invoke(GL_TEXTURE0_ARB)
2 Other ways to declare the function are:
<Runtime.InteropServices.DllImport("opengl.dll", EntryPoint:="glActiveTextureARB", SetLastError:=True, CharSet:=System.Runtime.InteropServices.CharSet.Unicode, ExactSpelling:=True, CallingConvention:=System.Runtime.InteropServices.CallingConvention.StdCall)> Public Shared Function glActiveTextureARB(ByVal target As Int32) As Long
End Function
-OR-
Declare Auto Function glActiveTextureARB Lib "opengl.dll" (ByVal texture As Int32) As Long
One person named Fiddler mentioned
substituting this line:
glActiveTextureARB = wglGetProcAddress("glActiveTextureARB")
With
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glActiveTextureARB"), typeof(PFNGLACTIVETEXTUREARBPROC));