diff --git a/examples/visualize_left_object.rs b/examples/visualize_left_object.rs index 9a242e1..eba466d 100644 --- a/examples/visualize_left_object.rs +++ b/examples/visualize_left_object.rs @@ -1,5 +1,5 @@ -use rusty_mujoco::{mj_loadXML, mj_makeData, mj_step}; -use rusty_mujoco::{mjr_makeContext, mjr_render, mjrContext, mjrRect, mjtCatBit, mjtFontScale, mjv_makeScene, mjv_updateScene, mjvCamera, mjvOption, mjvScene}; +use rusty_mujoco::{mj_loadXML, mj_makeData, mj_step, mjr_render, mjv_updateScene}; +use rusty_mujoco::{mjrContext, mjrRect, mjtCatBit, mjtFontScale, mjvCamera, mjvOption, mjvScene}; struct Args { xml_path: String, @@ -49,11 +49,9 @@ fn main() { glfw::Context::make_current(&mut *window); let opt = mjvOption::default(); - let mut scn = mjvScene::default(); - let mut con = mjrContext::default(); + let con = mjrContext::new(&model, mjtFontScale::X150); + let mut scn = mjvScene::new(&model, 2000); let mut cam = mjvCamera::default(); - mjv_makeScene(&model, &mut scn, 2000); - mjr_makeContext(&model, &mut con, mjtFontScale::X150); camera_name.map(|name| cam.set_fixedcamid(model.object_id(&name).expect("No camera of such name in the model"))); while !window.should_close() { diff --git a/src/functions/opengl_rendering.rs b/src/functions/opengl_rendering.rs index c74d53f..da03885 100644 --- a/src/functions/opengl_rendering.rs +++ b/src/functions/opengl_rendering.rs @@ -27,6 +27,10 @@ pub fn mjr_defaultContext() -> mjrContext { unsafe { c.assume_init() } } impl Default for mjrContext { + /// Internally calls [`mjr_defaultContext`]. + /// + /// **note**: Be sure to call [`mjr_makeContext`] for the returned `mjrContext` to allocate resources + /// before using it in rendering. fn default() -> Self { mjr_defaultContext() } @@ -42,7 +46,7 @@ pub fn mjr_makeContext(m: &mjModel, con: &mut mjrContext, fontscale: mjtFontScal } } impl mjrContext { - /// Create a new `mjrContext` with the default font scale. + /// Create a new `mjrContext` with given font scale. /// /// This internally calls: /// diff --git a/src/functions/visualization.rs b/src/functions/visualization.rs index 407a46f..d043541 100644 --- a/src/functions/visualization.rs +++ b/src/functions/visualization.rs @@ -110,8 +110,10 @@ pub fn mjv_defaultScene() -> mjvScene { unsafe { c.assume_init() } } impl Default for mjvScene { - /// **note**: Call [`mjv_makeScene`] to allocate resources in abstract scene - /// before starting a simulation with the `mjvScene`. + /// Internally calls [`mjv_defaultScene`]. + /// + /// **note**: Be sure to call [`mjv_makeScene`] for the returned `mjvScene` to allocate resources in abstract scene + /// before using it in rendering. fn default() -> Self { mjv_defaultScene() }