OpenGl multi texturing with C#

I’m trying to use glmultitexcoord3f, but when I try to use this function in C#, I get the following error:

“Unable to find an entry point named ‘glMultiTexCoord3f’ in DLL ‘opengl32’.”

In my Gl class, I include the following code:

[DllImport(DLL.OPENGL, EntryPoint = “glMultiTexCoord3f”, ExactSpelling = false)]
public extern static void MultiTexCoord(int id, Single s, Single t, Single r);

The error results in my main class after this line:
GL.MultiTexCoord(0, 0F, 0F, 0F);

I get the same error for any of the ARB functions I try to use. My computer supports opengl’s multi-texturing. I verified this by downloading a sample program written in c++. But I can’t figure out how to avoid the error mentioned above when using c#. If anyone can help, I would be so happy; I’d be willing to pay.

You probably should use a wrapper such as opentk (
Other than that, all I can say is that glMultiTexCoord3f is not defined in opengl32.dll. It is defined in the real driver (nVidia or whatever you have) and we get a pointer to that using wglGetProcAddress. I’m sure that opentk does a lot of wglGetProcAddress calls to get all the functions beyong GL 1.1

Thanks for the reply! I had looked into opentk, but it didn’t seem to call ARB functions (I might check again). Your comment about using wglGetProcAddress might be the key. I’ll look into that!

Rather than using wglGetProcAddress, you can also use GLEW (importing glew32.dll in your project), but I guess OpenTK would be a better option for C#.

What is it about ARB functions not being there?

Why would you want to use ARB multitexturing?
All that stuff is core OpenGL since a decade.

You can find all ARB functions under ‘GL.Arb’ (EXT functions under ‘GL.Ext’ and so on and so forth).

If you wish to bind the method yourself, you’ll need to use wglGetProcAddress() and Marshal.GetDelegateForFunctionPointer(). I wouldn’t recommend that, though. You might as well use OpenTK and focus on creating your application rather than fighting with p/invokes! :slight_smile:

I’d be willing to pay.

PM me afterwards so we can work out the details (how does $250 sound?). Here is your answer:

Copy this code into your OpenGL class.

   internal delegate void MultiTexCoord3f(Int32 id, Single s, Single t, Single r);
   internal static MultiTexCoord3f MultiTexCoord;

   [DllImport(DLL.OPENGL, EntryPoint = "wglGetProcAddress", ExactSpelling = true)]
   private static extern MultiTexCoord3f GetProcAddress(string function_name);

   internal static void Setup()
      MultiTexCoord = GetProcAddress("glMultiTexCoord3f");

You’ll need to call the setup function before you use MultiTexCoord (i.e. GL.Setup()). You will then be able to call MultiTexCoord the same way you were before.

This loads the function using a delegate. Enjoy ;).

Dear Newbie,

Your solution is the most helpful (though I see that it builds off the others) and solves my problem. Since it’s the most helpful, I will abide to your payment terms. I’ll put the check in the mail tonight.

Well done.

Thanks all.