Struct mini_gl_fb::core::Framebuffer [−][src]
The Framebuffer struct manages the framebuffer of a MGlFb window. Through this struct, you can
update the size and content of the buffer. Framebuffers are usually obtained through
MiniGlFb::glutin_breakout
, but they're also returned by
init_framebuffer
.
Basic usage
Firstly, one of the most important things to do when managing a Framebuffer manually is to make
sure that whenever the window is resized, the Framebuffer is the first to know. Usually, this is
handled for you by MiniGlFb
, but that isn't the case when using the
GlutinBreakout
.
Whenever you receive a resize event for your window, make sure to call
Framebuffer::resize_viewport
with the new physical dimensions of your window. You can also
figure out some logical dimensions and call Framebuffer::resize_buffer
too.
Additionally, when managing multiple framebuffers at once, you should make sure to call
GlutinBreakout::make_current
when appropriate, before calling any Framebuffer
methods.
Forgetting to call make_current
can cause OpenGL to get confused and draw to the wrong window,
which is probably not what you want.
Fields (Non-exhaustive)
Struct {{ .. }}
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.buffer_size: LogicalSize<i32>
The logical size of the buffer. When you update the buffer via
update_buffer
, it is expected to contain
buffer_size.width * buffer_size.height
pixels.
vp_size: PhysicalSize<i32>
The physical size of the viewport. This should always be kept up to date with the size of the window, and there is no reason to set it otherwise unless you're drawing multiple buffers to one window or something funky like that.
did_draw: bool
This is set to true
every time draw
is called. (or, by extension,
update_buffer
)
It's safe to set this to false
afterwards, it's just a flag to let you know if code you're
calling into has updated the buffer or not.
inverted_y: bool
True if the origin should be the bottom left of the screen instead of the top left. For
historical reasons, this is the default. This should only be configured by changing the
Config
passed to get_fancy
.
internal: FramebufferInternal
Contains internal OpenGL things.
Accessing fields directly is not the intended usage. If a feature is missing please open an issue. The fields are public, however, so that while you are waiting for a feature to be exposed, if you need something in a pinch you can dig in easily and make it happen.
The internal fields may change.
Implementations
impl Framebuffer
[src]
pub fn update_buffer<T>(&mut self, image_data: &[T])
[src]
pub fn use_vertex_shader(&mut self, source: &str)
[src]
pub fn use_fragment_shader(&mut self, source: &str)
[src]
pub fn use_post_process_shader(&mut self, source: &str)
[src]
pub fn use_geometry_shader(&mut self, source: &str)
[src]
pub fn use_grayscale_shader(&mut self)
[src]
pub fn change_buffer_format<T: ToGlType>(&mut self, format: BufferFormat)
[src]
pub fn resize_buffer(&mut self, buffer_width: u32, buffer_height: u32)
[src]
pub fn resize_viewport(&mut self, width: u32, height: u32)
[src]
pub fn redraw(&mut self)
[src]
pub fn draw<F: FnOnce(&Framebuffer)>(&mut self, f: F)
[src]
Draw the quad to the active context. Optionally issue other commands after binding everything but before drawing it.
You probably want redraw
(equivalent to .draw(|_| {})
).
pub fn relink_program(&mut self)
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Framebuffer
impl Send for Framebuffer
impl Sync for Framebuffer
impl Unpin for Framebuffer
impl UnwindSafe for Framebuffer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,