Struct blue_engine_egui::EmbeddedRender
source · pub struct EmbeddedRender {}
Implementations§
source§impl EmbeddedRender
impl EmbeddedRender
sourcepub fn new(
object: &mut Object,
cc: &mut Renderer,
renderer: &mut Renderer
) -> Option<Self>
pub fn new( object: &mut Object, cc: &mut Renderer, renderer: &mut Renderer ) -> Option<Self>
Examples found in repository?
examples/custom_3d.rs (line 31)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
fn main() {
// Initialize the engine with default settings
let mut engine = Engine::new().expect("win");
// the object to display
cube("cube", &mut engine.renderer, &mut engine.objects).expect("Couldn't create the cube");
// Start the egui context
let mut gui_context = blue_engine_egui::EGUI::new(&engine.event_loop, &mut engine.renderer);
// here we only need object temporarily
let mut custom_rendering = {
let mut object = engine.objects.get_mut("cube").unwrap();
// this will not render the object in the background
object.is_visible = false;
// create our instance of graphics
EmbeddedRender::new(&mut object, &mut engine.renderer, &mut gui_context.renderer).unwrap()
};
// We add the gui as plugin, which runs once before everything else to fetch events, and once during render times for rendering and other stuff
engine.plugins.push(Box::new(gui_context));
let mut color = [1f32, 1f32, 1f32, 1f32];
let radius = 5f32;
let start = std::time::SystemTime::now();
// Update loop
engine
.update_loop(move |renderer, window, objects, _, camera, plugins| {
// obtain the plugin
let egui_plugin = plugins[0]
// downcast it to obtain the plugin
.downcast_mut::<blue_engine_egui::EGUI>()
.expect("Plugin not found");
// Get our object
let cube = objects.get_mut("cube").unwrap();
// and get current camera unifrom data
let camera_data = camera.update_view_projection_and_return(renderer).unwrap();
// and prepare the data for our graphics
custom_rendering.prepare(cube, renderer, &mut egui_plugin.renderer, camera_data);
// ui function will provide the context
egui_plugin.ui(
|ctx| {
// This window will contain our graphics
egui::Window::new("title").resizable(true).show(ctx, |ui| {
// We make a canvas to paint our graphics
egui::Frame::canvas(ui.style()).show(ui, |ui| {
// Paint our graphics
custom_rendering.paint(ui);
});
// to allocate space that is available after resize
ui.allocate_space(ui.available_size());
});
// We can also do our other GUI stuff as always,
egui::Window::new("Pick Color")
.resizable(true)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Pick a color");
ui.color_edit_button_rgba_unmultiplied(&mut color);
});
});
},
&window,
);
// we can normally apply changes to our graphics
cube.set_uniform_color(color[0], color[1], color[2], color[3])
.unwrap();
// and even other settings
let camx = start.elapsed().unwrap().as_secs_f32().sin() * radius;
let camy = start.elapsed().unwrap().as_secs_f32().sin() * radius;
let camz = start.elapsed().unwrap().as_secs_f32().cos() * radius;
camera
.set_position(camx, camy, camz)
.expect("Couldn't update the camera eye");
})
.expect("Error during update loop");
}
sourcepub fn prepare(
&self,
object: &mut Object,
brenderer: &mut Renderer,
erenderer: &mut Renderer,
camera_data: UniformBuffers
)
pub fn prepare( &self, object: &mut Object, brenderer: &mut Renderer, erenderer: &mut Renderer, camera_data: UniformBuffers )
Examples found in repository?
examples/custom_3d.rs (line 55)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
fn main() {
// Initialize the engine with default settings
let mut engine = Engine::new().expect("win");
// the object to display
cube("cube", &mut engine.renderer, &mut engine.objects).expect("Couldn't create the cube");
// Start the egui context
let mut gui_context = blue_engine_egui::EGUI::new(&engine.event_loop, &mut engine.renderer);
// here we only need object temporarily
let mut custom_rendering = {
let mut object = engine.objects.get_mut("cube").unwrap();
// this will not render the object in the background
object.is_visible = false;
// create our instance of graphics
EmbeddedRender::new(&mut object, &mut engine.renderer, &mut gui_context.renderer).unwrap()
};
// We add the gui as plugin, which runs once before everything else to fetch events, and once during render times for rendering and other stuff
engine.plugins.push(Box::new(gui_context));
let mut color = [1f32, 1f32, 1f32, 1f32];
let radius = 5f32;
let start = std::time::SystemTime::now();
// Update loop
engine
.update_loop(move |renderer, window, objects, _, camera, plugins| {
// obtain the plugin
let egui_plugin = plugins[0]
// downcast it to obtain the plugin
.downcast_mut::<blue_engine_egui::EGUI>()
.expect("Plugin not found");
// Get our object
let cube = objects.get_mut("cube").unwrap();
// and get current camera unifrom data
let camera_data = camera.update_view_projection_and_return(renderer).unwrap();
// and prepare the data for our graphics
custom_rendering.prepare(cube, renderer, &mut egui_plugin.renderer, camera_data);
// ui function will provide the context
egui_plugin.ui(
|ctx| {
// This window will contain our graphics
egui::Window::new("title").resizable(true).show(ctx, |ui| {
// We make a canvas to paint our graphics
egui::Frame::canvas(ui.style()).show(ui, |ui| {
// Paint our graphics
custom_rendering.paint(ui);
});
// to allocate space that is available after resize
ui.allocate_space(ui.available_size());
});
// We can also do our other GUI stuff as always,
egui::Window::new("Pick Color")
.resizable(true)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Pick a color");
ui.color_edit_button_rgba_unmultiplied(&mut color);
});
});
},
&window,
);
// we can normally apply changes to our graphics
cube.set_uniform_color(color[0], color[1], color[2], color[3])
.unwrap();
// and even other settings
let camx = start.elapsed().unwrap().as_secs_f32().sin() * radius;
let camy = start.elapsed().unwrap().as_secs_f32().sin() * radius;
let camz = start.elapsed().unwrap().as_secs_f32().cos() * radius;
camera
.set_position(camx, camy, camz)
.expect("Couldn't update the camera eye");
})
.expect("Error during update loop");
}
sourcepub fn paint(&mut self, ui: &mut Ui)
pub fn paint(&mut self, ui: &mut Ui)
Examples found in repository?
examples/custom_3d.rs (line 64)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
fn main() {
// Initialize the engine with default settings
let mut engine = Engine::new().expect("win");
// the object to display
cube("cube", &mut engine.renderer, &mut engine.objects).expect("Couldn't create the cube");
// Start the egui context
let mut gui_context = blue_engine_egui::EGUI::new(&engine.event_loop, &mut engine.renderer);
// here we only need object temporarily
let mut custom_rendering = {
let mut object = engine.objects.get_mut("cube").unwrap();
// this will not render the object in the background
object.is_visible = false;
// create our instance of graphics
EmbeddedRender::new(&mut object, &mut engine.renderer, &mut gui_context.renderer).unwrap()
};
// We add the gui as plugin, which runs once before everything else to fetch events, and once during render times for rendering and other stuff
engine.plugins.push(Box::new(gui_context));
let mut color = [1f32, 1f32, 1f32, 1f32];
let radius = 5f32;
let start = std::time::SystemTime::now();
// Update loop
engine
.update_loop(move |renderer, window, objects, _, camera, plugins| {
// obtain the plugin
let egui_plugin = plugins[0]
// downcast it to obtain the plugin
.downcast_mut::<blue_engine_egui::EGUI>()
.expect("Plugin not found");
// Get our object
let cube = objects.get_mut("cube").unwrap();
// and get current camera unifrom data
let camera_data = camera.update_view_projection_and_return(renderer).unwrap();
// and prepare the data for our graphics
custom_rendering.prepare(cube, renderer, &mut egui_plugin.renderer, camera_data);
// ui function will provide the context
egui_plugin.ui(
|ctx| {
// This window will contain our graphics
egui::Window::new("title").resizable(true).show(ctx, |ui| {
// We make a canvas to paint our graphics
egui::Frame::canvas(ui.style()).show(ui, |ui| {
// Paint our graphics
custom_rendering.paint(ui);
});
// to allocate space that is available after resize
ui.allocate_space(ui.available_size());
});
// We can also do our other GUI stuff as always,
egui::Window::new("Pick Color")
.resizable(true)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Pick a color");
ui.color_edit_button_rgba_unmultiplied(&mut color);
});
});
},
&window,
);
// we can normally apply changes to our graphics
cube.set_uniform_color(color[0], color[1], color[2], color[3])
.unwrap();
// and even other settings
let camx = start.elapsed().unwrap().as_secs_f32().sin() * radius;
let camy = start.elapsed().unwrap().as_secs_f32().sin() * radius;
let camz = start.elapsed().unwrap().as_secs_f32().cos() * radius;
camera
.set_position(camx, camy, camz)
.expect("Couldn't update the camera eye");
})
.expect("Error during update loop");
}
Auto Trait Implementations§
impl RefUnwindSafe for EmbeddedRender
impl Send for EmbeddedRender
impl Sync for EmbeddedRender
impl Unpin for EmbeddedRender
impl UnwindSafe for EmbeddedRender
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
Mutably borrows from an owned value. Read more
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.