Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/visualize_left_object.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 5 additions & 1 deletion src/functions/opengl_rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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:
///
Expand Down
6 changes: 4 additions & 2 deletions src/functions/visualization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down