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?
Re: Cross-compiling Rust programs that use OpenGLES2
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.
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 .
Re: Cross-compiling Rust programs that use OpenGLES2
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
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
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
Re: Cross-compiling Rust programs that use OpenGLES2
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 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 .
Re: Cross-compiling Rust programs that use OpenGLES2
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

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
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
Re: Cross-compiling Rust programs that use OpenGLES2
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 .
Re: Cross-compiling Rust programs that use OpenGLES2
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)
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
Re: Cross-compiling Rust programs that use OpenGLES2
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.
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.