Generating bindings

This is a rough overview of the binding generation process.

  1. Convert.exe converts .spec files into a custom xml file, called signatures.xml.
  2. The generator loads signatures.xml, overrides.xml and gl.tm into a custom in-memory representation.
  3. The generator then applies a number of hard-coded rules. These include stripping the prefixes and suffixes of functions, escaping for tokens that start with digits, generation of safe/unsafe overloads for functions taking pointers and handling of CLS-compliance.
  4. Finally, it generates compilable code for C# or C++.

Several command-line switches can influence the generation process: GL vs ES, namespaces, generated code.

What is the best way for you to proceed depends on (a) the amount of functions you wish to add, and (b) whether these functions are available in the old .spec files or the new xml format.

If you only wish to add a handful of functions, the easiest approach might be to define them by hand at the bottom of the signatures.xml file, which can be found under Source/Bind/Specifications/GL2. The format is relatively simple:

<function name="VertexPointer" extension="Core" category="VERSION_1_1_DEPRECATED" version="1.1" deprecated="3.1">
      <returns type="void" />
      <param name="size" type="Int32" flow="in" />
      <param name="type" type="VertexPointerType" flow="in" />
      <param name="stride" type="SizeI" flow="in" />
      <param name="pointer" type="Void*" flow="in" />
    </function>

In this case, VertexPointerType is an enumeration that must be defined in either signatures.xml or overrides.xml. If this enumeration is not found, the generator will fall back to the "All" enumeration, which is equivalent to the non-typesafe GLenum used in the regular C headers.

If you wish to bind a significant amount of functions, such as a whole new OpenGL version, then your best bet is to execute the Converter utility to generate a new signatures.xml file from the latest spec:

cd Binaries/OpenTK/Debug
wget https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/oldspecs/gl.spec
Convert.exe -p=gl -v=4.3 -o=../../../Source/Bind/Specifications/GL2 gl.spec
Bind.exe

Now you can recompile OpenTK and take a look at the generated specs - the new functions should be there. If they use enums, these will probably appear as "All". You can use overrides.xml to define type-safe enums and improve the generated API.


Comments

Comment viewing options

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

From what I understand, Convert.exe converts gl.spec to xml files (signatures.xml and gloverrides.xml). Then Bind.exe converts thoses xml into .cs files (GL.cs, GLCore.cs, GLDelegates.cs, GLEnums.cs & GLHelpers.cs (more ??)).

Now that OpenGL provides .xml instead of .spec files, does convert.exe still usefull ? Wouldn't it be a better way to make Bind.exe process directly OpenGL's xml files ?

Iliak

www.mimicprod.net
www.dungeoneye.net : Open source remake of Eye of the Beholder II

the Fiddler's picture

A converter for the new xml specs is on the way. The format is different from the one used by the binding generator, so convert.exe will still be required.

iliak's picture

I made a small program importing OpenGL specification and outping in a format parsable by Bind.exe.
I can give it to you il needed !

Iliak

www.mimicprod.net
www.dungeoneye.net : Open source remake of Eye of the Beholder II

the Fiddler's picture

That would be much appreciated!

iliak's picture

Where / how can I send it to you (mail, ftp, ...) ?

Iliak

www.mimicprod.net
www.dungeoneye.net : Open source remake of Eye of the Beholder II

the Fiddler's picture

Apologies, I somehow missed your post. Best way would be to upload the code to github and post a link. Alternatively, check your PMs for my email address.