DEV Community

Calin Baenen
Calin Baenen

Posted on

I made my first GL project using Piston.

So, I made a Tweet not too long before I made this post, and it was me showing off my first OpenGL project using Piston.

And I attached two images.

One of the target folder, with the program over it:
Image of program and  raw `target` endraw  folder.
And the other of the src folder, so you could see how the app was structured:
The  raw `src` endraw  folder.

The point of this post is to talk about how my experience was, and even as someone who just started, would recommend Piston.

So. What was the project I made in Rust?
A game in-development.

I'm working on RuntDeale, a game inspired by (but NOT an AU of) Undertale, an 2.5D RPG bullet-hell game.
What do I have so far? -- I have a white background with a purple square that can be moved using the W, A, S, and D keys.

So far, my experience has been okay.
I've been able to create a window of a variable size and title, have been able to draw a shape to the screen, provide custom colors, and rotate a shape.

Now, how much code does it take to do all that?
With Piston, this much:

                   # Total lines: 234
                   #     Compact: 135
                   #     CptLns:  (12, 28, 2, 11, 1, 27, 54)
                   #
                   # Avg lines:   033
                   #     Compact: 019
src/
  rd_events/
    gameloop.rs    # Lines: 23
    buttons.rs     # Lines: 49
    mod.rs         # Lines: 02

  rd_utils/
    colors.rs      # Lines: 27 (not all lines are required)
    mod.rs         # Lines: 01

  main.rs          # Lines: 39 (some lines are whitespace)
  app.rs           # Lines: 93
Enter fullscreen mode Exit fullscreen mode

So relative to what I've seen before, that's not a lot of code.
Just a few lines for making the window and event register, a fair bit of lines to rendering the the background and drawing the shape at its given X, Y position, and a small bit for detecting the key-presses and updating the X and Y position.


So. Why do I like Piston so far?
It's concise, and it's been (for the most part) straightforward.

Check out their homepage, https://piston.rs, they even show off some great examples of how their library has been used!

Thanks for reading.
Cheers.

Top comments (1)

Collapse
 
calinzbaenen profile image
Calin Baenen

Check out the Piston crate on crates.io: crates.io/crates/piston.