Crate mini_gl_fb[−][src]
Hardware accelerated library inspired by minifb and friends.
Basic Usage
Start with the function gotta_go_fast.
This will create a basic window and give you a buffer
that you can draw to in one line.
extern crate mini_gl_fb; fn main() { let mut fb = mini_gl_fb::gotta_go_fast("Hello world!", 800.0, 600.0); let buffer = vec![[128u8, 0, 0, 255]; 800 * 600]; fb.update_buffer(&buffer); fb.persist(); }
The default buffer format is 32bit RGBA, so every pixel is four bytes. Buffer[0] is the top left pixel.
Interlude: Library philosophy
All of the internals of this library are exposed. Any fields behind mini_gl_fb.internal
are not considered a part of the public API but are exposed in case the library is missing a
feature that you need "right now." This library is not here to box you in.
Likewise, by exposing as much as possible it allows you to grow what may have started as a
simple project without hassle. This allows you to slowly move away from mini_gl_fb
if
necessary, without requiring you to completely drop the library the second you need to do
something "advanced."
This also means there's a number of ways to do the same thing, but this seems like a fair compromise.
More advanced configuration
Use the get_fancy
function for more settings. See Config
for what's available. This allows
you to, for instance, create a window with a buffer of a different size than the window.
let config = Config { window_title: window_title.to_string(), window_size: (window_width, window_height), .. Default::default() }; let fb = get_fancy(config);
If you think something else should be exposed as an option, open an issue!
Bring your own context (and event handling)!
Default context is provided by glutin. If that's not good enough for you [grr! ;^)], there's
the function core::init_framebuffer
. Create your own OpenGL context, load the OpenGL
functions, and then call core::init_framebuffer
to get a framebuffer with a texture already
set up.
Note on possible context creation failure:
Currently uses the gl
crate for OpenGL loading. OpenGL context creation may fail if your
setup does not support the newest OpenGL. This bug needs to be verified and is be fixable.
OpenGL ~3 is currently required, but OpenGL 2.1 support should be feasible if requested.
Re-exports
pub extern crate rustic_gl; |
pub extern crate glutin; |
pub extern crate gl; |
Structs
Config |
Configuration for "advanced" use cases, when |
GlutinBreakout | |
Internal |
Hides away the guts of the library. |
MiniGlFb |
Main wrapper type. |
Enums
BufferFormat |
Functions
get_fancy |
Create a window with a custom configuration. |
gotta_go_fast |
Creates a non resizable window and framebuffer with a given size in pixels. |