tksuoran's picture

slim OpenTK version?

How do I remove all deprecated GL functions from OpenTK.dll to reduce the size?

OpenTK.Platform.Windows.WinGLContext.LoadAll() takes some considerable time at startup. How to filter out and prevent loading any deprecated functionality?


Comments

Comment viewing options

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

I have spent a lot of time researching this, to no obvious solution. Potential solutions:

  • Modify the binding generator to ignore deprecated functions (Source/Bind/CSharpSpecWriter.cs lines 179, 210 and 301, add something like (if (f.Deprecated) return;). Run it and recompile OpenTK (the examples will fail to compile, ignore them).
  • Modify GraphicsContext to avoid calling LoadAll() automatically. In this case, you will have to load all OpenGL functions you use manually.
  • Find a way to load entry points lazily (on first use). I've been able to do this with C# 3, but the setting up the process took more time than loading the entry points anyway.
  • Find a way to postprocess OpenTK.dll to replace Marshal.GetDelegateForFunctionPointer() with calli instructions. This way we could completely avoid the delegates/dllimports separation and the entry-point-to-delegate conversion code.

How much time does LoadAll() take on your system?

tksuoran's picture

I was looking at binding generator but I have no idea how to actually use it. The documentation is out of date, there is no more build exe in SVN and so on.

I'd like to get as close as possible instant startup but on some system getting GameWindow open takes around a second (Asus Eeebox that has GL3 NVIDIA Ion as GPU but poor Atom CPU..)

the Fiddler's picture

I'm at work now, but IIRC you can run the generator directly through the solution (right click -> "set as startup project" -> F5). It should output the results directly into Source/OpenTK/Graphics/OpenGL, so you can rebuild the solution directly.

tksuoran's picture

Thanks, I will give it a try. Do I need both Generator.Bind and Generator.Convert?

Edit: Simply running Generator.Bind() is enough. I also had to remove stuff from GLHelper.

Can I somehow also remove extensions, like, all non-ARB extensions?

the Fiddler's picture

You can use f.Extension in a similar fashion to remove the extensions you don't need. (Core functions return f.Extension = "" or "Core", can't remember off-hand).

tksuoran's picture

Oh yes, that worked well.

Is GLCore.cs also generated by something? It still has all deprecated and extension stuff. I commented out a lot of stuff that I don't need and my application still works, and it helped to get OpenTK.dll smaller.

I am now down to 1168 kb OpenTK.dll, which is almost there; I think I could live with it being 1MB or less :)

the Fiddler's picture

GLCore.cs is generated in the WriteImports() method. Just give it the same treatment.

One final thing you can do is comment out the [AutoGenerated] attributes in WriteMethod().