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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// #![doc(html_logo_url = "https://rin.rs/logo.svg")]
// #![doc(html_favicon_url = "https://rin.rs/favicon.ico")]

#[cfg(enabled)]
pub use glin::*;
#[cfg(enabled)]
pub use glin::gl::*;
#[cfg(enabled)]
#[doc(hidden)]
pub use rin_graphics::PrimitiveTypeToGl;

#[cfg(enabled)]
#[doc(inline)]
pub use self::vao_mesh::VaoMesh;
#[cfg(enabled)]
#[doc(inline)]
pub use self::vao_path::{VaoPath, VaoPathFill, VaoPathContour};
#[cfg(enabled)]
#[doc(inline)]
pub use self::renderer::{Renderer, Render2d, Renderer2d, Render3d, Renderer3d, CreationContext, CreationProxy};
#[cfg(enabled)]
#[doc(inline)]
pub use self::material::Material;
#[cfg(enabled)]
#[doc(inline)]
pub use self::basic_material::BasicMaterial;
#[cfg(enabled)]
#[doc(inline)]
pub use self::shader_material::ShaderMaterial;
#[cfg(enabled)]
#[doc(inline)]
pub use self::outline_material::OutlineMaterial;
#[cfg(enabled)]
#[doc(hidden)]
pub use self::bitmap_font::BitmapFont;
#[cfg(enabled)]
#[doc(inline)]
pub use self::simple_fbo::SimpleFbo;
#[cfg(enabled)]
#[doc(inline)]
pub use self::object::Object;
#[cfg(enabled)]
#[doc(inline)]
pub use self::uniforms_cache::UniformsCache;
#[cfg(enabled)]
#[cfg(feature="ttf")]
#[doc(inline)]
pub use self::ttf::Ttf;
#[cfg(enabled)]
#[cfg(feature="ttf_rusttype")]
#[doc(inline)]
pub use self::ttf_rusttype as ttf;
#[cfg(enabled)]
#[cfg(feature="ttf_rusttype")]
#[doc(inline)]
pub use self::ttf::Ttf;
#[cfg(enabled)]

#[cfg(enabled)]
#[macro_use] pub mod macros;
#[cfg(enabled)]
pub mod renderer;
#[cfg(enabled)]
pub mod vao_mesh;
#[cfg(enabled)]
pub mod vao_path;
#[cfg(enabled)]
pub mod material;
#[cfg(enabled)]
pub mod basic_material;
#[cfg(enabled)]
mod shader_material;
#[cfg(enabled)]
pub mod outline_material;
#[cfg(enabled)]
pub mod image_based_light;
#[cfg(enabled)]
pub mod traits;
#[cfg(enabled)]
pub mod cubemap;
#[cfg(enabled)]
#[cfg(feature="ttf")]
pub mod ttf;
#[cfg(enabled)]
#[cfg(feature="ttf_rusttype")]
pub mod ttf_rusttype;
#[cfg(enabled)]
mod bitmap_font;
#[cfg(enabled)]
#[cfg(not(target_os="unknown"))]
pub mod autoload;
#[cfg(enabled)]
mod simple_fbo;
#[cfg(enabled)]
pub mod object;
#[cfg(enabled)]
mod uniforms_cache;
#[cfg(enabled)]
use std::path::PathBuf;

#[cfg(enabled)]
pub fn default_attribute_bindings() -> &'static glin::HashMap<String, u32>{
    lazy_static::lazy_static!{
        static ref DEFAULT_ATTRIBUTE_BINDINGS: glin::HashMap<String, u32> = glin::hash_map![
            "position".to_string() => 0,
            "color".to_string() => 1,
            "texcoord".to_string() => 2,
            "normal".to_string() => 3,
            "tangent".to_string() => 4,
            "modelMatrix".to_string() => 5,
            "normalMatrix".to_string() => 9,
        ];
    }

    &DEFAULT_ATTRIBUTE_BINDINGS
}

// #[repr(u32)]
// pub enum TextureBindingPoints {
//     BaseColor         = 0,
//     Normal            = 1,
//     Occlusion         = 2,
//     MetallicRoughness = 3,
//     Emissive          = 4,
//     Anisotropy        = 5,
//     DiffuseIbl        = 6,
//     SpecularIbl       = 7,
//     IblBrdf           = 8,
//     Shadow1           = 9,
//     Shadow2           = 10,
// }

#[cfg(enabled)]
#[cfg(feature="gles")]
pub const fn default_glsl_version() -> usize{
    300
}

#[cfg(enabled)]
#[cfg(feature="webgl")]
pub const fn default_glsl_version() -> usize{
    300
}

#[cfg(enabled)]
#[cfg(not(any(feature="gles", feature="webgl")))]
pub const fn default_glsl_version() -> usize{
    330
}

#[cfg(enabled)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum Shader{
    Path{
        path: PathBuf,
        replacements: Vec<(String, String)>,
        base_path: Option<PathBuf>,
        includes: Vec<(String, String)>,
        ty: glin::gl::types::GLenum,
    },
    Source{
        include_name: String,
        source: String,
        replacements: Vec<(String, String)>,
        base_path: Option<PathBuf>,
        includes: Vec<(String, String)>,
        ty: glin::gl::types::GLenum,
    },
}