Struct miniquad::graphics::GraphicsContext
source · pub struct GraphicsContext { /* private fields */ }
Implementations§
source§impl GraphicsContext
impl GraphicsContext
pub fn apply_pipeline(&mut self, pipeline: &Pipeline)
pub fn set_cull_face(&mut self, cull_face: CullFace)
pub fn set_color_write(&mut self, color_write: (bool, bool, bool, bool))
pub fn set_blend( &mut self, color_blend: Option<BlendState>, alpha_blend: Option<BlendState> )
pub fn set_stencil(&mut self, stencil_test: Option<StencilState>)
sourcepub fn apply_viewport(&mut self, x: i32, y: i32, w: i32, h: i32)
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.
sourcepub fn apply_scissor_rect(&mut self, x: i32, y: i32, w: i32, h: i32)
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.
pub fn apply_bindings(&mut self, bindings: &Bindings)
pub fn apply_uniforms<U>(&mut self, uniforms: &U)
pub fn clear( &self, color: Option<(f32, f32, f32, f32)>, depth: Option<f32>, stencil: Option<i32> )
sourcepub fn begin_default_pass(&mut self, action: PassAction)
pub fn begin_default_pass(&mut self, action: PassAction)
start rendering to the default frame buffer
sourcepub fn begin_pass(
&mut self,
pass: impl Into<Option<RenderPass>>,
action: PassAction
)
pub fn begin_pass( &mut self, pass: impl Into<Option<RenderPass>>, action: PassAction )
start rendering to an offscreen framebuffer
pub fn end_render_pass(&mut self)
pub fn commit_frame(&mut self)
sourcepub fn draw(&self, base_element: i32, num_elements: i32, num_instances: i32)
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 inindex_buffer
.num_elements
specifies length of the slice ofindex_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
impl Context
pub fn display(&self) -> &dyn NativeDisplay
pub fn display_mut(&mut self) -> &mut dyn NativeDisplay
sourcepub fn screen_size(&self) -> (f32, f32)
pub fn screen_size(&self) -> (f32, f32)
The current framebuffer size in pixels NOTE: High DPI Rendering
sourcepub fn dpi_scale(&self) -> f32
pub fn dpi_scale(&self) -> f32
The dpi scaling factor (window pixels to framebuffer pixels) NOTE: High DPI Rendering
sourcepub fn high_dpi(&self) -> bool
pub fn high_dpi(&self) -> bool
True when high_dpi was requested and actually running in a high-dpi scenario NOTE: High DPI Rendering
sourcepub fn order_quit(&mut self)
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.
sourcepub fn request_quit(&mut self)
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.
sourcepub fn cancel_quit(&mut self)
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
sourcepub fn set_cursor_grab(&mut self, grab: bool)
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
sourcepub fn show_mouse(&mut self, shown: bool)
pub fn show_mouse(&mut self, shown: bool)
Show or hide the mouse cursor
sourcepub fn set_mouse_cursor(&mut self, cursor_icon: CursorIcon)
pub fn set_mouse_cursor(&mut self, cursor_icon: CursorIcon)
Set the mouse cursor icon.
sourcepub fn set_window_size(&mut self, new_width: u32, new_height: u32)
pub fn set_window_size(&mut self, new_width: u32, new_height: u32)
Set the application’s window size.
pub fn set_fullscreen(&mut self, fullscreen: bool)
sourcepub fn clipboard_get(&mut self) -> Option<String>
pub fn clipboard_get(&mut self) -> Option<String>
Get current OS clipboard value
sourcepub fn clipboard_set(&mut self, data: &str)
pub fn clipboard_set(&mut self, data: &str)
Save value to OS clipboard
pub fn dropped_file_count(&mut self) -> usize
pub fn dropped_file_bytes(&mut self, index: usize) -> Option<Vec<u8>>
pub fn dropped_file_path(&mut self, index: usize) -> Option<PathBuf>
sourcepub fn show_keyboard(&mut self, show: bool)
pub fn show_keyboard(&mut self, show: bool)
Show/hide onscreen keyboard. Only works on Android right now.