https://github.com/rtbo/gldgen
OpenGL D bindings generation
https://github.com/rtbo/gldgen
Last synced: 5 months ago
JSON representation
OpenGL D bindings generation
- Host: GitHub
- URL: https://github.com/rtbo/gldgen
- Owner: rtbo
- License: mit
- Created: 2018-12-31T09:56:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-15T22:33:07.000Z (over 6 years ago)
- Last Synced: 2025-01-30T19:27:02.812Z (over 1 year ago)
- Language: D
- Size: 430 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# gldgen
OpenGL D binding generation.
This module has Khronos' OpenGL and EGL registries as submodule. They are used
to update local registry files and to keep track of the Khronos' commits.
As they are pretty heavy (> 120Mb) you may only want to check them out to update
to a newer version of the API. For basic use, recommendation is to __not__ clone
recursively. Everything needed to generate the D files is copied in the
`registry` folder.
This is not a Dub package and is not intended to become one. Users can copy
the files they need from the `d` folder, or generate their own with
`gen_d_files.py`:
```sh
$ ./gen_d_files.py -h
usage: gen_d_files.py [-h] [--package PACKAGE] [--dest DEST]
OpenGL D bindings generator
optional arguments:
-h, --help show this help message and exit
--package PACKAGE D package of generated modules [gld]
--dest DEST Destination folder for generated files [(gldgen)/d]
```
The generated bindings do not include any global symbol such as `glDrawElements`.
Instead there is the following definition:
```d
final class Gl {
this (SymbolLoader loader) {
// blindly attempt to load all Gl symbols and extensions
// ...
}
// ...
public void DrawElements (GLenum mode, GLsizei count, GLenum type, const(void)* indices) const {
assert(_DrawElements !is null, "OpenGL command glDrawElements was not loaded");
return _DrawElements (mode, count, type, indices);
}
// ...
private PFN_glDrawElements _DrawElements;
// ...
}
```
Client usage could be as follow
```d
void fun(Gl gl) {
gl.DrawElements(...);
}
```
Context creation is not part yet of gldgen. It may be part of it in a near
future. `SymbolLoader` is a `void* delegate (in string name)`. It must forward
to platform specific loader function such as `glXGetProcAddressARB`
(obtained during context creation).
The `Gl` class does not report which version or extensions are actually loaded
as this is generally known from the context creation and can be queried with
`Gl.GetString`.
Included APIs:
- Desktop OpenGl (all versions)
- GlX
- Wgl
- Egl
GLES is missing at the moment.
One can test if everything compiles fine by running
```sh
$ dmd @dmd_args.txt
```
`dmd_args.txt` is generated by `gen_d_files.py`. It is not checked-in because
it contains absolute paths to the D files.