summaryrefslogtreecommitdiffstats
path: root/third_party/rust/gleam/build.rs
blob: 6a15783a1b5fd0b75a76430202af0c378360a954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
extern crate gl_generator;

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

fn main() {
    let dest = env::var("OUT_DIR").unwrap();
    let mut file_gl_and_gles =
        File::create(&Path::new(&dest).join("gl_and_gles_bindings.rs")).unwrap();
    let mut file_gl = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
    let mut file_gles = File::create(&Path::new(&dest).join("gles_bindings.rs")).unwrap();

    // OpenGL 3.3 bindings
    let gl_extensions = [
        "GL_APPLE_client_storage",
        "GL_APPLE_fence",
        "GL_APPLE_texture_range",
        "GL_APPLE_vertex_array_object",
        "GL_ARB_blend_func_extended",
        "GL_ARB_buffer_storage",
        "GL_ARB_copy_image",
        "GL_ARB_get_program_binary",
        "GL_ARB_invalidate_subdata",
        "GL_ARB_texture_rectangle",
        "GL_ARB_texture_storage",
        "GL_EXT_debug_marker",
        "GL_EXT_texture_filter_anisotropic",
        "GL_KHR_debug",
        "GL_KHR_blend_equation_advanced",
        "GL_KHR_blend_equation_advanced_coherent",
        "GL_KHR_blend_equation_advanced_coherent",
        "GL_ARB_shader_storage_buffer_object",
    ];
    let gl_reg = Registry::new(
        Api::Gl,
        (3, 3),
        Profile::Compatibility,
        Fallbacks::All,
        gl_extensions,
    );
    gl_reg
        .write_bindings(gl_generator::StructGenerator, &mut file_gl)
        .unwrap();

    // GLES 3.0 bindings
    let gles_extensions = [
        "GL_EXT_buffer_storage",
        "GL_EXT_copy_image",
        "GL_EXT_debug_marker",
        "GL_EXT_disjoint_timer_query",
        "GL_EXT_shader_texture_lod",
        "GL_EXT_texture_filter_anisotropic",
        "GL_EXT_texture_format_BGRA8888",
        "GL_EXT_texture_storage",
        "GL_OES_EGL_image_external",
        "GL_OES_EGL_image",
        "GL_OES_texture_half_float",
        "GL_EXT_shader_pixel_local_storage",
        "GL_ANGLE_provoking_vertex",
        "GL_ANGLE_texture_usage",
        "GL_CHROMIUM_copy_texture",
        "GL_KHR_debug",
        "GL_KHR_blend_equation_advanced",
        "GL_KHR_blend_equation_advanced_coherent",
        "GL_ANGLE_copy_texture_3d",
    ];
    let gles_reg = Registry::new(
        Api::Gles2,
        // using 3.1 to get SSBO support
        (3, 1),
        Profile::Core,
        Fallbacks::All,
        gles_extensions,
    );
    gles_reg
        .write_bindings(gl_generator::StructGenerator, &mut file_gles)
        .unwrap();

    // OpenGL 3.3 + GLES 3.0 bindings. Used to get all enums
    let gl_reg = gl_reg + gles_reg;
    gl_reg
        .write_bindings(gl_generator::StructGenerator, &mut file_gl_and_gles)
        .unwrap();
}