All Projects → MasterQ32 → zig-opengl

MasterQ32 / zig-opengl

Licence: EUPL-1.2 License
OpenGL binding generator based on the opengl registry

Programming Languages

Zig
133 projects

Projects that are alternatives of or similar to zig-opengl

zetaframe
lightweight zig game framework.
Stars: ✭ 14 (-51.72%)
Mutual labels:  gamedev, ziglang, zig-package
SDL.zig
A shallow wrapper around SDL that provides object API and error handling
Stars: ✭ 102 (+251.72%)
Mutual labels:  gamedev, ziglang, zig-package
magnum-integration
Integration libraries for the Magnum C++11/C++14 graphics engine
Stars: ✭ 75 (+158.62%)
Mutual labels:  gamedev, opengl-es
Qfusion
Source code for cross-platform OpenGL gaming engine
Stars: ✭ 255 (+779.31%)
Mutual labels:  gamedev, opengl-es
Magnum Bootstrap
Bootstrap projects for Magnum C++11/C++14 graphics engine
Stars: ✭ 69 (+137.93%)
Mutual labels:  gamedev, opengl-es
qml zig
QML bindings for the Zig programming language
Stars: ✭ 25 (-13.79%)
Mutual labels:  ziglang, zig-package
Rabbittoolbox
🤸🏾‍♀️👗开源的动画渲染软件,提倡以简单、易用,高质量的物理演算以及渲染质量和性能,为喜爱二次元动画的用户降低视频制作门槛
Stars: ✭ 309 (+965.52%)
Mutual labels:  gamedev, opengl-es
Magnum Plugins
Plugins for the Magnum C++11/C++14 graphics engine
Stars: ✭ 66 (+127.59%)
Mutual labels:  gamedev, opengl-es
Diligentsamples
Sample projects demonstrating the usage of Diligent Engine
Stars: ✭ 138 (+375.86%)
Mutual labels:  gamedev, opengl-es
Magnum Examples
Examples for the Magnum C++11/C++14 graphics engine
Stars: ✭ 180 (+520.69%)
Mutual labels:  gamedev, opengl-es
zig-args
Simple-to-use argument parser with struct-based config
Stars: ✭ 106 (+265.52%)
Mutual labels:  ziglang, zig-package
ansi-term
Zig library for dealing with ANSI terminals
Stars: ✭ 25 (-13.79%)
Mutual labels:  ziglang, zig-package
IUPforZig
IUP (Portable User Interface Toolkit) bindings for the Zig language.
Stars: ✭ 56 (+93.1%)
Mutual labels:  ziglang, zig-package
mach-glfw
Ziggified GLFW bindings with 100% API coverage, zero-fuss installation, cross compilation, and more.
Stars: ✭ 186 (+541.38%)
Mutual labels:  ziglang, zig-package
Diligentengine
A modern cross-platform low-level graphics library and rendering framework
Stars: ✭ 2,142 (+7286.21%)
Mutual labels:  gamedev, opengl-es
zlm
Zig linear mathemathics
Stars: ✭ 67 (+131.03%)
Mutual labels:  ziglang, zig-package
zero-graphics
Application framework based on OpenGL ES 2.0. Runs on desktop machines, Android phones and the web
Stars: ✭ 72 (+148.28%)
Mutual labels:  ziglang, zig-package
ResourceCollection
A collection of handy resources, as recommended by Pharap
Stars: ✭ 18 (-37.93%)
Mutual labels:  gamedev
Zenject-2019
Dependency Injection Framework for Unity3D
Stars: ✭ 2,567 (+8751.72%)
Mutual labels:  gamedev
codingame
My solutions for https://www.codingame.com
Stars: ✭ 26 (-10.34%)
Mutual labels:  gamedev

Zig OpenGL Binding

This is a pragmatic binding to different OpenGL versions.

It uses the official OpenGL Registry by Khronos to generate the Zig code.

Right now, it does minimal adjustments like removing the gl prefix from functions or the GL_ prefix from constants. Everything else is the same as the C API.

There is a single non-OpenGL function exported:

pub fn load(load_ctx: anytype, get_proc_address: fn(@TypeOf(load_ctx), [:0]const u8) ?*const c_void) !void {

This function will load all OpenGL entry points with the help of get_proc_address. It receives the load_ctx as well as the function name.

NOTE: Please do not reference zig-opengl as a submodule or a package. Generate a binding and copy the output of that into your repository and update the file on demand. The OpenGL Registry is just too huge to be used conveniently.

Example

This example uses ZWL by @Aransentin.

const zwl = @import("zwl");

const Platform = zwl.Platform(…);

pub fn initAndDraw(window: Platform.Window) !void {
  try gl.load(window.platform, Platform.getOpenGlProcAddress);

  while(true) {
    gl.clearColor(1, 0, 1, 1);
    gl.clear(gl.COLOR_BUFFER_BIT);

    try window.present();
  }
}

Pregenerated Loaders

This repository contains pre-generated bindings for all extension-free OpenGL versions.

Generating your own loader

From source

To generate your own loader, you have to clone this repository and build the generator with dotnet:

user@machine:~/zig-opengl$ dotnet run
Usage: generator <registry> <result> <api_version> [<extension>] [<extension>] ...
user@machine:~/zig-opengl$ dotnet run OpenGL-Registry/xml/gl.xml gl3v3.zig GL_VERSION_3_3
Final API has 344 commands and 818 enums types.
user@machine:~/zig-opengl$
```

```sh-console
dotnet run \
  OpenGL-Registry/xml/gl.xml \ # path to the opengl registry
  my_binding.zig             \ # path to the generated file
  GL_VERSION_3_3             \ # feature level, options listed below
  …                            # Add your extensions here, each as a single arg. Or let them out, you don't need extensions

Possible feature levels (at the time of writing) are:

  • GL_VERSION_1_0
  • GL_VERSION_1_1
  • GL_VERSION_1_2
  • GL_VERSION_1_3
  • GL_VERSION_1_4
  • GL_VERSION_1_5
  • GL_VERSION_2_0
  • GL_VERSION_2_1
  • GL_VERSION_3_0
  • GL_VERSION_3_1
  • GL_VERSION_3_2
  • GL_VERSION_3_3
  • GL_VERSION_4_0
  • GL_VERSION_4_1
  • GL_VERSION_4_2
  • GL_VERSION_4_3
  • GL_VERSION_4_4
  • GL_VERSION_4_5
  • GL_VERSION_4_6
  • GL_VERSION_ES_CM_1_0
  • GL_ES_VERSION_2_0
  • GL_ES_VERSION_3_0
  • GL_ES_VERSION_3_1
  • GL_ES_VERSION_3_2
  • GL_SC_VERSION_2_0

Contribution

This library uses a small C# script that generates the Zig bindings. It is located in src/Generator.cs

What is missing right now?

  • Option to specify core or compatibility profile.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].