gl33/
lib.rs

1#![cfg_attr(not(feature = "println_debug"), no_std)]
2#![allow(bad_style)]
3
4//! Makes the OpenGL 3.3 Core API (+GL_KHR_debug) available for use.
5//!
6//! The crate's interface is provided as a "struct" style loader. Construct a
7//! [`GlFns`] using an appropriate [`get_proc_address`] function, and then call
8//! methods on your `GlFns`.
9//!
10//! There's also a "global" style loader if the `global_loader` feature is
11//! enabled. This lets you load up functions pointers that can be freely
12//! accessed from anywhere.
13//!
14//! ## Inlining
15//!
16//! This crate does **not** use the `#[inline]` attribute. If you want full
17//! inlining just turn on Link-Time Optimization in your cargo profile:
18//!
19//! ```toml
20//! [profile.release]
21//! lto = "thin"
22//! ```
23//!
24//! ## `trace_caller`
25//!
26//! If the `trace_caller` feature is enables then this attribute is placed on
27//! any function that can panic. A panic will only happen if you call a function
28//! that is not loaded.
29
30use chlorine::*;
31
32pub mod get_proc_address;
33
34mod gl_command_types;
35pub(crate) use gl_command_types::*;
36
37pub mod gl_core_types;
38pub use gl_core_types::*;
39
40pub mod gl_enumerations;
41pub use gl_enumerations::*;
42
43pub mod gl_groups;
44pub use gl_groups::*;
45
46mod struct_loader;
47pub use struct_loader::*;
48
49#[cfg(feature = "global_loader")]
50pub mod global_loader;
51
52#[cfg(feature = "println_debug")]
53pub unsafe extern "system" fn println_debug_message_callback(source: GLenum, type_: GLenum, id: u32, severity: GLenum, length: i32, message: *const u8, _user_param: *const c_void) {
54  let src = match source {
55    GL_DEBUG_SOURCE_API => "API",
56    GL_DEBUG_SOURCE_WINDOW_SYSTEM => "WindowSystem",
57    GL_DEBUG_SOURCE_SHADER_COMPILER => "ShaderCompiler",
58    GL_DEBUG_SOURCE_THIRD_PARTY => "3rdParty",
59    GL_DEBUG_SOURCE_APPLICATION => "App",
60    GL_DEBUG_SOURCE_OTHER => "Other",
61    _ => "Unknown",
62  };
63  let ty = match type_ {
64    GL_DEBUG_TYPE_ERROR => "Error",
65    GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR => "DeprecatedBehavior",
66    GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR => "UndefinedBehavior",
67    GL_DEBUG_TYPE_PORTABILITY => "Portability",
68    GL_DEBUG_TYPE_PERFORMANCE => "Performance",
69    GL_DEBUG_TYPE_MARKER => "Marker",
70    GL_DEBUG_TYPE_PUSH_GROUP => "PushGroup",
71    GL_DEBUG_TYPE_POP_GROUP => "PopGroup",
72    GL_DEBUG_TYPE_OTHER => "Other",
73    _ => "Unknown",
74  };
75  let sev = match severity {
76    GL_DEBUG_SEVERITY_HIGH => "High",
77    GL_DEBUG_SEVERITY_MEDIUM => "Medium",
78    GL_DEBUG_SEVERITY_LOW => "Low",
79    GL_DEBUG_SEVERITY_NOTIFICATION => "Note",
80    _ => "Unknown",
81  };
82  let msg = String::from_utf8_lossy(core::slice::from_raw_parts(message, length as usize));
83  println!("GL>{id} [Src:{src}][Ty:{ty}][Severity:{sev}]> {msg}", id = id, src = src, ty = ty, sev = sev, msg = msg,);
84}