The project is built on top of the OpenGL bindings, defined in the namespace Derm.OpenGL. The namespace declares the classes:
All properties and routines declared in these classes are the fundation of the rendering capabilities of Deux Ex Render Machina.
The OpenGL specification files are the files located at BindGen/Specs directory. The specification files are retrieved from www.opengl.org/registry. They contains the definition of each enumeration and entry point necessary for iteracting with the OpenGL graphic library.
Specification files shall be updated once the OpenGL consortium has released new specifications. Actually the specification files implements OpenGL 3.2, sufficient for our purpose.
To make things work, some portions of the specification files are modified. In this cases the modification is noted with a diff notation, in order to acknoledge the modification done. Indeed, when updating the specification file, special case should be applied in order to not overwrite these special modifications.
Almost of classes declared in the namespace Derm.OpenGL are generated automatically by the BindGen project. This project implements an OpenGL specification parser, ad-hoc for C#. It could be adapted for other projects, but probably with some efforts.
Running BindGen from the build directory regenerate the Derm OpenGL bindings. It actually parse every specification file, extract enumerations, aliases, routines, parameters, and every information required for correct parameters marshalling. It classify routines as CORE routines and enumerations, ARB routines and enumerations, EXT routines and enumerations, and vendor specific routines and enuemrations.
It removes the routines and enumerations classified as deprecated, and alter the names in order to have a cleaner interface. It strip from the names extension suffixes (_ARB, _EXT, _NV, etc...) and platform prefixes (GL_, WGL_, GLX_, gl, wgl, xgl). It also removes routines overrides suffixes (v, f, i, ui, uiv, etc...), in order to support overloads when the same routines takes a different type of parameters.
It exclude enumerations and routines implemented in higher specifiecation levels; infact the "same" functionalities are implemented in CORE, ARB, EXT and vendor specific extentions. The CORE implementation has the maximum priority, then follow ARB implemenetation, then the EXT implementation and finally vendor specific implementations. The same functionality present in two or more categories result in an unique binding point, choose by the priorities described above. This mean that the OpenGL implementation used shall be CORE, ARB or EXT whenever is possible.
BindGen also generate overrides in the case the OpenGL routines takes an array argument. In some cases, where the array length is slaved to another parameter and it marshall out information, it possible to use a single out variable instead of an array. Generally the bindings avoid the IntPtr parameters, but try to used managed variables (object, arrays, basic types).
BindGen has many configuration files, some automatically generated and some not. Essentially these configuration files are dictionary files or string mapping files. The former type allow to parse routine names in order to exclude type suffixes, while the latter allow translations between names (sometimes too compilated to be automatically parsed, sometimes to force a different name for specific routines).
The file Cs.tm is a string map configuration. It defines the mapping between the OpenGL implementation types (C types) and C# builtin types. The OpenGL implementation types are derived from specification types, after having translated them using the relative .tm files included in the specifications.
This configuration is still incompleted, since the still unused types are mapped to IntPtr C# type.
The file Extensions.spec is a dictionary file, listing all known extensions suffixes (ARB, EXT, etc.). This file is required since it's not possible to list every extension suffix automatically. Normally this file doesn't change anymore.
The file Suffixes.spec is a dictionary file, listing all known routine suffixes, which are used by OpenGL specification to differntiate same routines taking different parameters types. Since C# allow the routines overload, these suffixes are not more necessary in Derm.OpenGL.
OpenGL tokens ending with one of the suffixes listed in this list will be removed.
The files {Gl|Wgl|Glx}Words.spec are dictionary files, listing all known tokens extracted from the specifications files. These dictionaries are used to enforce the specification parsing. If they don't exists, BindGen generates them automatically, but be aware to do this: the initial list is pratically unusable.
If these files exists, the tokens are collected and used to tokenize specification routines, for excluding in a robust way type suffixes and extension suffixes. In the case the parser find a new word, it will be appended to the relative dictionary file.
After this process, the files {Gl|Wgl|Glx}Functs.spec are updated to reflect the mapping between specification routines and Derm.Open names. These files are used for debugging purposes, and they are not used for OpenGL binding generation.
By default, BindGen bring every non deprecated enumeration and routine in the Derm.OpenGL namespace. But it's possible to rename and exclude specific routines and enumerations to have a fine control over the binding generation. The file Functions.spec specify which routines shall be renamed and which routines/enumerations shall be excluded.
After the special token rename:, are listed lines specifing the mapping between the OpenGL specification name and actual name to use in the binding definition. No preprocessing or postprocessing is done over this renaming operations; they are executed 'as is'.
After the special token exclude: are listed lines specifying the excluded symbols from the binding generation. The symbols can be a OpenGL function routine (for excluding a specific routine) or an OpenGL extention name (for excluding group of enumerations and routines implementing the specific extention).