pub struct EmbeddedRender {}

Implementations§

source§

impl EmbeddedRender

source

pub fn new( object: &mut Object, cc: &mut Renderer, renderer: &mut Renderer ) -> Option<Self>

Examples found in repository?
examples/custom_3d.rs (line 32)
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
98
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, &engine.window);

    // 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");
}
source

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 56)
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
98
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, &engine.window);

    // 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");
}
source

pub fn paint(&mut self, ui: &mut Ui)

Examples found in repository?
examples/custom_3d.rs (line 65)
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
98
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, &engine.window);

    // 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§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,