What’s everyone working on this week (52/2017)?

Last week of the year! Holidays! That all means more Rust right? So what are you folks up to?

2 Likes

I got some basics of my UI lib up and running now which wraps Qt.

05

With this code

struct MyApp {
    ui: Ui,
    pressed_count: usize,
}

impl MyApp {
    fn new(ui: Ui) -> MyApp {
        MyApp {
            ui: ui,
            pressed_count: 0,
        }
    }

    fn pressed_button(&mut self) {
        self.pressed_count += 1;
        println!("Pressed button {} times", self.pressed_count);
    }

    fn run(&mut self) {
        let app = self.ui.create_application();
        let button = self.ui.create_push_button();

        button.set_text("Press me!");
        button.resize(100, 100);
        button.show();

        set_released_event!(button, self, MyApp, MyApp::pressed_button);

        app.exec();
    }
}

fn main() {
    let wrui_instance = SharedLibUi::new(get_wrui_path()).unwrap();
    let mut app = MyApp::new(wrui_instance.get_ui());
    app.run();
}

My approach to this is slightly different than other wrappers:

  • I generate all the C/C++ code into one SharedLib/DLL.
  • The SharedLib then exports a single function which returns a struct with C function pointers.
  • The function pointers struct has a matching FFI wrapper and then a Rust wrapper on top of this.

There are several upsides to this approach:

  • Reduced link-time on the Rust binary as the linker doesn't need to deal with all the C++ symbols.
  • In case your application uses more shared libs (like mine will in terms of plugins) it's now possible to pass this pointer down to the plugins instead of hard-linking the C++ code to each plugin.

My idea here is to just add things as I go and not to try to implement everything at once. Right now everything is auto-generated from a spec definition. The project is over here https://github.com/emoon/ui_gen and is very much WIP but if someone thinks this would be somewhat useful let me know.

This week will be to add more things and expand as I go.

1 Like

Continuing to explore and learn Rust by building a small experimental rendererer using metal-rs sys layer on Mac.

One of the use cases I'm working towards is to download shadertoy shaders over the REST API and cross-compile them from GLSL to SPIRV and Metal SL to display them. Mostly just for the fun of it, but also to to try hands on a variety of low-level and high-level components & concepts; some familiar and some new.

Very impressed by Rust so far! Both the language, the community and the ecosystem.

3 Likes

I started working on an operating system. Not going well though.

Brand new to the Rust language and community here. I decided to learn Rust after I made plans to start an OS project, because working in an entirely new environment with an entirely new programming language can't possibly go wrong (it's already going wrong).

Uh, sorry, got carried away there. Greetings to all!

1 Like

Things should be fine if you give it some time. I bet even Linus Torvalds struggled and thought of quitting at some stage :smile:

1 Like

Oh I am certain! :grin: I would be quite disappointed in myself if I gave up before getting a user-space hello world.

1 Like

Neat. If you want to see an existing example of operating systems written in Rust there is Redox.

Good luck :smile:

1 Like

There were a couple of requirements I had to deal with before I could start working on a new material (and test scene):

https://github.com/wahn/rs_pbrt/issues/34

Now I'm ready to work on the implementation of the material SubstrateMaterial itself. Let's see if I can finish it today or tomorrow ...

Done :sweat_smile:

2 Likes