My first Rust: Hello OpenGL
My first Rust program is a port of Joe Groff’s “Hello World” sample from his Modern OpenGL tutorial. That’s here, and worth reading:
http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-2:-Hello-World:-The-Slideshow.html
My first trick was to port the original from GLUT and GL2 to somehing closer to what I would have available in Rust. That means SDL and GLES2. That was pretty straightforward, because I know SDL pretty well already. Here you go:
https://github.com/robn/hello-gl
So then I did something close to a straight port of that to Rust syntax. Along the way I had to add some stuff to rust-sdl and rust-opengles to make certain features available:
https://github.com/brson/rust-sdl/issues/created_by/robn https://github.com/mozilla-servo/rust-opengles/issues/created_by/robn
So don’t even think about compiling it without applying those five patches and writing your own draw_elements_buffered
, which I won’t be submitting in its current form because its entirely the wrong way to do it. Just read along if you’re interested.
So I’m sure I’m doing plenty of things in a non-Rusty way because its all still new. And some stuff I’m really having a hard time getting my head around, like the difference between the different kinds of pointers, and why I can’t convert a &mut[u8]
to a &[u8]
. But I’ll get there, I’m sure.
So next is to get this all cleaned up and try and write something a bit more real.