summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-04-07 20:20:43 +0200
committerHampusM <hampus@hampusmat.com>2023-04-07 20:22:07 +0200
commit966ebb03abd8ae5ed4f47f4b53c00222269a56b4 (patch)
tree24e3325f1657bef89005583e9650b5c8e57459df /src/lib.rs
parentc7efbb55f075748d88e25735c6d7e85ba768fd15 (diff)
refactor: replace usage of opengl-registry-macros
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs45
1 files changed, 2 insertions, 43 deletions
diff --git a/src/lib.rs b/src/lib.rs
index cd2e4d0..88eb0a3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,20 +1,9 @@
//! OpenGL bindings.
#![deny(clippy::all, clippy::pedantic, missing_docs)]
-use opengl_registry_macros::for_each_opengl_command;
-
-for_each_opengl_command! {
- #[doc = stringify!(#gl_command_name)]
- #[allow(non_snake_case, clippy::too_many_arguments)]
- pub unsafe fn #gl_command_name_noprefix(#gl_command_args) -> #gl_command_ret_type {
- type GLFunc =
- unsafe extern "C" fn(#gl_command_arg_types) -> #gl_command_ret_type;
-
- let gl_func = std::mem::transmute::<_, GLFunc>(functions::#gl_command_name);
+pub use ffi::*;
- gl_func(#gl_command_arg_names)
- }
-}
+include!(concat!(env!("OUT_DIR"), "/generated.rs"));
mod ffi
{
@@ -29,33 +18,3 @@ mod ffi
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
-
-pub use ffi::*;
-
-/// Loads OpenGL function pointers using the given function address retriever function.
-pub fn load_with<GetProcAddrFn>(get_proc_addr: GetProcAddrFn)
-where
- GetProcAddrFn: Fn(&str) -> unsafe extern "C" fn(),
-{
- for_each_opengl_command! {
- unsafe {
- functions::#gl_command_name = get_proc_addr(stringify!(#gl_command_name));
- }
- };
-}
-
-mod functions
-{
- use opengl_registry_macros::for_each_opengl_command;
-
- for_each_opengl_command!(
- #[doc = stringify!(#gl_command_name)]
- #[allow(non_upper_case_globals)]
- pub static mut #gl_command_name: unsafe extern "C" fn() = function_not_loaded;
- );
-
- extern "C" fn function_not_loaded()
- {
- panic!("OpenGL function not loaded");
- }
-}