Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

gl

Directory actions

More options

Directory actions

More options

Latest commit

 

History

History

gl

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

VersionLicenseDownloads

An OpenGL function pointer loader for the Rust Programming Language.

[dependencies]gl ="0.14.0"

Basic usage

You can import the pointer style loader and type aliases like so:

externcrate gl;// include the OpenGL type aliasesuse gl::types::*;

You must load the function pointers into their respective function pointersusing theload_with function. You must supply a loader function from yourcontext library. This is how it would look usingglfw-rs:

// the supplied function must be of the type:// `&fn(symbol: &'static str) -> *const std::os::raw::c_void`// `window` is a glfw::Windowgl::load_with(|s| window.get_proc_address(s)as*const_);// loading a specific function pointergl::Viewport::load_with(|s| window.get_proc_address(s)as*const_);

Calling a function that has not been loaded will result in a failure like:panic!("gl::Viewport was not loaded"), which avoids a segfault. This featuredoes not cause any run time overhead because the failing functions areassigned only whenload_with is called.

All OpenGL function calls areunsafe.

// accessing an enumgl::TEXTURE_2D;// calling a functionunsafe{ gl::DrawArrays(gl::TRIANGLES,0,3)};

Each function pointer has an associated boolean value allowing you tocheck if a function has been loaded at run time. The function accesses acorresponding global boolean that is set whenload_with is called, so thereshouldn't be much overhead.

if gl::Viewport::is_loaded(){// do something...}

[8]ページ先頭

©2009-2025 Movatter.jp