kaphu
Posts: 8
Joined: Wed Oct 25, 2017 10:59 pm

Cross-compiling Rust programs that use OpenGLES2

Mon Mar 16, 2020 11:07 pm

Hello,

There seems to be many tutorials on the internet about cross-compiling Rust to RPI using just few commands with rustup. Does anybody know does this apply to programs that are using OpenGLES2 stuff to render 3D graphics as well or will things get more compilicated?

Heater
Posts: 17135
Joined: Tue Jul 17, 2012 3:02 pm

Re: Cross-compiling Rust programs that use OpenGLES2

Mon Mar 16, 2020 11:25 pm

Oddly enough when I type "OpenGLES2 Rust raspberry pi" into google search about the first thing I find is this: https://github.com/seankerr/rust-rpi-examples which will probably get you started.

I suggest you install Rust onto your Pi and do your Rust experiments on the Pi itself. I have had success with that. Much easier than getting cross compilation working.

The Rust compiler can be slow for the edit->run->edit development cycle, so remember you can use "cargo check" to have a quick check for your syntax and other errors as you write code.

I use Visual Studio Code running on my Win 10 PC to edit the Rust source on my Pi over sshfs. That makes life very comfortable.
Memory in C++ is a leaky abstraction .

User avatar
PeterO
Posts: 6070
Joined: Sun Jul 22, 2012 4:14 pm

Re: Cross-compiling Rust programs that use OpenGLES2

Tue Mar 17, 2020 7:57 am

That's 5 year old code so it's going to have issues with the new ways of accessing the 3D hardware and with the various flavours of drivers.
However, you should be able to get ideas on how to update it by looking at any up to date OpenGL/OpenGLES examples in C that use the mesa provided standard interfaces.
HTH
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Heater
Posts: 17135
Joined: Tue Jul 17, 2012 3:02 pm

Re: Cross-compiling Rust programs that use OpenGLES2

Tue Mar 17, 2020 10:33 am

Good point.

If it does not work with recent hardware/software perhaps raising some issues on seankerr's github repos might get it updated.
Memory in C++ is a leaky abstraction .

User avatar
PeterO
Posts: 6070
Joined: Sun Jul 22, 2012 4:14 pm

Re: Cross-compiling Rust programs that use OpenGLES2

Tue Mar 17, 2020 11:04 am

Heater wrote:
Tue Mar 17, 2020 10:33 am
Good point.

If it does not work with recent hardware/software perhaps raising some issues on seankerr's github repos might get it updated.
If you remember I had a very short "affair" with Rust that ended when the Gtk interface developers declared that wrong rust-gtk documentation was not their problem :evil:

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Heater
Posts: 17135
Joined: Tue Jul 17, 2012 3:02 pm

Re: Cross-compiling Rust programs that use OpenGLES2

Tue Mar 17, 2020 1:35 pm

I get that kind of problem a lot with Open Source projects in whatever language. On a good day the developer(s) appreciates a bug report/issue/discussion and things get fixed.
Memory in C++ is a leaky abstraction .

User avatar
paddyg
Posts: 2602
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Cross-compiling Rust programs that use OpenGLES2

Sat Mar 21, 2020 11:13 pm

Feel free to rummage through https://github.com/paddywwoof/rust_pi3d/ It's an attempt by me to get to grips with Rust by programming something I understood reasonably. I've subsequently tried to add on a pyo3 wrapper to make it back into a python module!

PS it works reasonably vanilla on ubuntu laptop, Pi2, 3 and 4 (and windows but I don't have one to hand at the moment so not tested the last few months' iterations)

PPS yes rust_pi3d uses the sdl2 and gl crates and I've not managed to cross compile it. (Normal command line number crunching things cross-compile fine for the RPi)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

kaphu
Posts: 8
Joined: Wed Oct 25, 2017 10:59 pm

Re: Cross-compiling Rust programs that use OpenGLES2

Fri Mar 27, 2020 2:59 pm

Thanks for the replies.

As I was afraid, since the cross-compiling seems not to be trivial at this point, I have little interest in starting a project that would have to be compiled on rpi every time. "cargo check" sounds like a reasonable improvement over traditional c/c++ building cycle, but I don't know if it is going to help with the eventually growing build times on rpi. I'll check out rust_pi3d regardless.

Return to “Graphics programming”