Crate gl_generator

source ·
Expand description

An OpenGL bindings generator. It defines a function named generate_bindings which can be used to generate all constants and functions of a given OpenGL version.



extern crate gl_generator;

use gl_generator::{Registry, Api, Profile, Fallbacks, GlobalGenerator};
use std::env;
use std::fs::File;
use std::path::Path;

fn main() {
    let dest = env::var("OUT_DIR").unwrap();
    let mut file = File::create(&Path::new(&dest).join("")).unwrap();

    Registry::new(Api::Gl, (4, 5), Profile::Core, Fallbacks::All, [])
        .write_bindings(GlobalGenerator, &mut file)

In your project:

include!(concat!(env!("OUT_DIR"), "/"));

About EGL

When you generate bindings for EGL, the following platform-specific types must be declared at the same level where you include the bindings:

  • khronos_utime_nanoseconds_t
  • khronos_uint64_t
  • khronos_ssize_t
  • EGLNativeDisplayType
  • EGLNativePixmapType
  • EGLNativeWindowType
  • EGLint
  • NativeDisplayType
  • NativePixmapType
  • NativeWindowType