pub struct RaylibRender {
pub background_color: Color,
/* private fields */
}Expand description
Primary raylib-backed renderer for Cotis applications.
Owns the window handle (behind a mutex), the raylib drawing thread, loaded fonts, and a
path-keyed texture cache. Implements CotisRenderer for
crate::drawables::RaylibDrawable streams and Cotis context traits in crate::cotis.
§Construction
RaylibRender::auto_start— gray transparent background, 1000×1000 resizable window.RaylibRender::new— custom clear color, same window defaults.RaylibRender::new_custom— full control viaRaylibBuilder.
Fields§
§background_color: ColorClear color used at the start of each frame.
Implementations§
Source§impl RaylibRender
impl RaylibRender
Sourcepub fn auto_start() -> Self
pub fn auto_start() -> Self
Creates a renderer with a gray transparent background and a default 1000×1000 resizable window.
Sourcepub fn new(background_color: Color) -> Self
pub fn new(background_color: Color) -> Self
Creates a renderer with the given background clear color and a default 1000×1000 resizable window.
Sourcepub fn new_custom(
raylib_builder: RaylibBuilder<'_>,
background_color: Color,
) -> Self
pub fn new_custom( raylib_builder: RaylibBuilder<'_>, background_color: Color, ) -> Self
Creates a renderer from a custom RaylibBuilder.
Sourcepub fn get_handle(&mut self) -> MutexGuard<'_, RayRenderHandle>
pub fn get_handle(&mut self) -> MutexGuard<'_, RayRenderHandle>
Sourcepub fn lock_handle(&self) -> MutexGuard<'_, RayRenderHandle>
pub fn lock_handle(&self) -> MutexGuard<'_, RayRenderHandle>
Sourcepub fn get_thread(&self) -> &RaylibThread
pub fn get_thread(&self) -> &RaylibThread
Returns the raylib drawing thread.
Must be passed to drawing calls on the thread that created the window.
Sourcepub fn thread(&self) -> &RaylibThread
pub fn thread(&self) -> &RaylibThread
Returns the raylib drawing thread.
Alias for Self::get_thread.
Sourcepub fn get_raylib(
&mut self,
) -> (MutexGuard<'_, RayRenderHandle>, &mut RaylibThread)
pub fn get_raylib( &mut self, ) -> (MutexGuard<'_, RayRenderHandle>, &mut RaylibThread)
Returns the locked handle and drawing thread together for low-level drawing.
§Panics
Panics if the mutex is poisoned.
Sourcepub fn window_should_close(&self) -> bool
pub fn window_should_close(&self) -> bool
Sourcepub fn load_font_and_keep(
&mut self,
file_name: &str,
) -> Result<usize, RaylibError>
pub fn load_font_and_keep( &mut self, file_name: &str, ) -> Result<usize, RaylibError>
Loads a font at size 16 and registers it in the font table.
Returns a font ID to store in TextConfig::font_id.
IDs are assigned in load order starting at 0 and are never reused.
§Errors
Returns RaylibError if raylib cannot load the font file.
Sourcepub fn load_font_ex_and_keep(
&mut self,
file_name: &str,
font_size: i32,
chars: Option<&str>,
filter: Option<TextureFilter>,
) -> Result<usize, RaylibError>
pub fn load_font_ex_and_keep( &mut self, file_name: &str, font_size: i32, chars: Option<&str>, filter: Option<TextureFilter>, ) -> Result<usize, RaylibError>
Loads a font with custom size, optional character subset, and texture filter.
Returns a font ID (0-based, monotonic) for use in TextConfig::font_id.
Additional pixel sizes requested during drawing are queued and loaded at the start of the
next frame.
§Errors
Returns RaylibError if raylib cannot load the font file.
Sourcepub fn delta_time(&self) -> f32
pub fn delta_time(&self) -> f32
Returns the elapsed time between the previous and current frame, in seconds.
§Panics
Panics if the mutex is poisoned.
Returns a clone of the shared raylib handle for cross-thread input polling.
Pair with Self::thread when calling raylib drawing APIs from the owning thread.
Returns a clone of the shared raylib handle.
Alias for Self::get_shared_handle.
Sourcepub fn image_cache(&self) -> &HashMap<String, Arc<Texture2D>>
pub fn image_cache(&self) -> &HashMap<String, Arc<Texture2D>>
Returns the path-keyed texture cache populated by translate_generic_image.
Source§impl RaylibRender
impl RaylibRender
Sourcepub fn translate_generic_image(
&mut self,
image: &dyn RaylibLoadableImage,
) -> Box<dyn Texture2DHolder>
pub fn translate_generic_image( &mut self, image: &dyn RaylibLoadableImage, ) -> Box<dyn Texture2DHolder>
Loads a texture from a path-based image, caching the result by file path.
On cache hit, returns the existing texture. On miss, loads via raylib with
TextureFilter::TEXTURE_FILTER_POINT filtering.
§Panics
Panics if raylib cannot load the file at the given path.
Trait Implementations§
Source§impl CotisFrameContext for RaylibRender
impl CotisFrameContext for RaylibRender
Source§fn get_delta_time(&self) -> f32
fn get_delta_time(&self) -> f32
Source§impl<'b> CotisRenderer<Box<dyn RaylibDrawable + 'b>> for RaylibRender
impl<'b> CotisRenderer<Box<dyn RaylibDrawable + 'b>> for RaylibRender
fn draw_frame( &mut self, render_commands: impl Iterator<Item = Box<dyn RaylibDrawable + 'b>>, )
Source§impl<T: RaylibDrawable> CotisRenderer<RenderTList<T, ()>> for RaylibRender
impl<T: RaylibDrawable> CotisRenderer<RenderTList<T, ()>> for RaylibRender
fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, ()>>, )
Source§impl<T: RaylibDrawable, L: RaylibDrawable + IsRenderList> CotisRenderer<RenderTList<T, L>> for RaylibRender
impl<T: RaylibDrawable, L: RaylibDrawable + IsRenderList> CotisRenderer<RenderTList<T, L>> for RaylibRender
fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, L>>, )
Source§impl<'b> CotisRendererAsync<Box<dyn RaylibDrawable + 'b>> for RaylibRender
impl<'b> CotisRendererAsync<Box<dyn RaylibDrawable + 'b>> for RaylibRender
async fn draw_frame( &mut self, render_commands: impl Iterator<Item = Box<dyn RaylibDrawable + 'b>>, )
Source§impl<T: RaylibDrawable> CotisRendererAsync<RenderTList<T, ()>> for RaylibRender
impl<T: RaylibDrawable> CotisRendererAsync<RenderTList<T, ()>> for RaylibRender
async fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, ()>>, )
Source§impl<T: RaylibDrawable, L: RaylibDrawable + IsRenderList> CotisRendererAsync<RenderTList<T, L>> for RaylibRender
impl<T: RaylibDrawable, L: RaylibDrawable + IsRenderList> CotisRendererAsync<RenderTList<T, L>> for RaylibRender
async fn draw_frame( &mut self, render_commands: impl Iterator<Item = RenderTList<T, L>>, )
Source§impl CotisWindowContext for RaylibRender
impl CotisWindowContext for RaylibRender
Source§fn window_dimensions(&self) -> Dimensions
fn window_dimensions(&self) -> Dimensions
Source§impl MouseProvider for RaylibRender
impl MouseProvider for RaylibRender
Source§fn get_mouse_position(&self) -> Vector2
fn get_mouse_position(&self) -> Vector2
Source§fn get_mouse_wheel_move_v(&self) -> Vector2
fn get_mouse_wheel_move_v(&self) -> Vector2
Source§impl<Manager> RenderCompatibleWith<Manager> for RaylibRender
impl<Manager> RenderCompatibleWith<Manager> for RaylibRender
fn init(&mut self, _layout_manager: &mut Manager)
Source§impl RendererTextMeasuringProvider<TextConfig> for RaylibRender
impl RendererTextMeasuringProvider<TextConfig> for RaylibRender
Source§fn provide_measurer(&mut self) -> Box<TextMeasurer<'_, TextConfig>>
fn provide_measurer(&mut self) -> Box<TextMeasurer<'_, TextConfig>>
Source§impl SimpleKeyboardProvider for RaylibRender
impl SimpleKeyboardProvider for RaylibRender
Source§fn get_pressed_keys(&self) -> IndexSet<KeyboardKey>
fn get_pressed_keys(&self) -> IndexSet<KeyboardKey>
Source§impl SimpleTextProvider for RaylibRender
impl SimpleTextProvider for RaylibRender
Source§fn get_pressed_chars(&self) -> Vec<char>
fn get_pressed_chars(&self) -> Vec<char>
Auto Trait Implementations§
impl !Send for RaylibRender
impl !Sync for RaylibRender
impl Freeze for RaylibRender
impl RefUnwindSafe for RaylibRender
impl Unpin for RaylibRender
impl UnsafeUnpin for RaylibRender
impl UnwindSafe for RaylibRender
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CotisRenderContext for Twhere
T: CotisWindowContext + CotisFrameContext,
Source§impl<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Sourcewhere
TailTarget: IsRenderList,
Source: Embed<TailTarget, Idx>,
impl<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Sourcewhere
TailTarget: IsRenderList,
Source: Embed<TailTarget, Idx>,
Source§fn embed(self) -> RenderTList<H, TailTarget>
fn embed(self) -> RenderTList<H, TailTarget>
self into Target.