pub struct GraphicsContext { /* private fields */ }

Implementations§

source§

impl GraphicsContext

source

pub fn new(is_gles2: bool) -> GraphicsContext

source

pub fn features(&self) -> &Features

source§

impl GraphicsContext

source

pub fn apply_pipeline(&mut self, pipeline: &Pipeline)

source

pub fn set_cull_face(&mut self, cull_face: CullFace)

source

pub fn set_color_write(&mut self, color_write: (bool, bool, bool, bool))

source

pub fn set_blend( &mut self, color_blend: Option<BlendState>, alpha_blend: Option<BlendState> )

source

pub fn set_stencil(&mut self, stencil_test: Option<StencilState>)

source

pub fn apply_viewport(&mut self, x: i32, y: i32, w: i32, h: i32)

Set a new viewport rectangle. Should be applied after begin_pass.

source

pub fn apply_scissor_rect(&mut self, x: i32, y: i32, w: i32, h: i32)

Set a new scissor rectangle. Should be applied after begin_pass.

source

pub fn apply_bindings(&mut self, bindings: &Bindings)

source

pub fn apply_uniforms<U>(&mut self, uniforms: &U)

source

pub fn clear( &self, color: Option<(f32, f32, f32, f32)>, depth: Option<f32>, stencil: Option<i32> )

source

pub fn begin_default_pass(&mut self, action: PassAction)

start rendering to the default frame buffer

source

pub fn begin_pass( &mut self, pass: impl Into<Option<RenderPass>>, action: PassAction )

start rendering to an offscreen framebuffer

source

pub fn end_render_pass(&mut self)

source

pub fn commit_frame(&mut self)

source

pub fn draw(&self, base_element: i32, num_elements: i32, num_instances: i32)

Draw elements using currently applied bindings and pipeline.

  • base_element specifies starting offset in index_buffer.
  • num_elements specifies length of the slice of index_buffer to draw.
  • num_instances specifies how many instances should be rendered.

NOTE: num_instances > 1 might be not supported by the GPU (gl2.1 and gles2). features.instancing check is required.

source§

impl Context

source

pub fn display(&self) -> &dyn NativeDisplay

source

pub fn display_mut(&mut self) -> &mut dyn NativeDisplay

source

pub fn screen_size(&self) -> (f32, f32)

The current framebuffer size in pixels NOTE: High DPI Rendering

source

pub fn dpi_scale(&self) -> f32

The dpi scaling factor (window pixels to framebuffer pixels) NOTE: High DPI Rendering

source

pub fn high_dpi(&self) -> bool

True when high_dpi was requested and actually running in a high-dpi scenario NOTE: High DPI Rendering

source

pub fn order_quit(&mut self)

This function simply quits the application without giving the user a chance to intervene. Usually this might be called when the user clicks the ‘Ok’ button in a ‘Really Quit?’ dialog box Window might not be actually closed right away (exit(0) might not happen in the order_quit implmentation) and execution might continue for some time after But the window is going to be inevitably closed at some point.

source

pub fn request_quit(&mut self)

Calling request_quit() will trigger “quit_requested_event” event , giving the user code a chance to intervene and cancel the pending quit process (for instance to show a ‘Really Quit?’ dialog box). If the event handler callback does nothing, the application will be quit as usual. To prevent this, call the function “cancel_quit()”“ from inside the event handler.

source

pub fn cancel_quit(&mut self)

Cancels a pending quit request, either initiated by the user clicking the window close button, or programmatically by calling “request_quit()”. The only place where calling this function makes sense is from inside the event handler callback when the “quit_requested_event” event has been received

source

pub fn set_cursor_grab(&mut self, grab: bool)

Capture mouse cursor to the current window On WASM this will automatically hide cursor On desktop this will bound cursor to windows border NOTICE: on desktop cursor will not be automatically released after window lost focus so set_cursor_grab(false) on window’s focus lost is recommended. TODO: implement window focus events

source

pub fn show_mouse(&mut self, shown: bool)

Show or hide the mouse cursor

source

pub fn set_mouse_cursor(&mut self, cursor_icon: CursorIcon)

Set the mouse cursor icon.

source

pub fn set_window_size(&mut self, new_width: u32, new_height: u32)

Set the application’s window size.

source

pub fn set_fullscreen(&mut self, fullscreen: bool)

source

pub fn clipboard_get(&mut self) -> Option<String>

Get current OS clipboard value

source

pub fn clipboard_set(&mut self, data: &str)

Save value to OS clipboard

source

pub fn dropped_file_count(&mut self) -> usize

source

pub fn dropped_file_bytes(&mut self, index: usize) -> Option<Vec<u8>>

source

pub fn dropped_file_path(&mut self, index: usize) -> Option<PathBuf>

source

pub fn quit(&mut self)

Shortcut for order_quit. Will add a legacy attribute at some point.

source

pub fn show_keyboard(&mut self, show: bool)

Show/hide onscreen keyboard. Only works on Android right now.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.