Programming

GUI programming drags on for third week

Checking off some items from the to-do list mentioned in my previous post, my OpenGL GUI panels can now have rounded corners (although they still need a bit of work as they’re not quite as circular as I’d like), they can have shadows of arbitrary size and color, they can have linear and radial gradient coloring, and the text dynamically word-wraps as necessary, with the scroll bar appearing only when needed.

Ain’t that nice? Next I need to work on vertical resizing and making sure multiple panels will overlap correctly when on the screen; a panel should be brought to the front “layer” when clicked on.

Then I will move on to adding the GUI elements I mentioned in the last post.

A fellow programmer on twitch mentioned a GUI library for LWJGL the he had programmed called legui. Looks quite nice so I might play around with it and see if I can integrate any of it with my panels. Another advantage of streaming on twitch: meeting other programmers and discovering new things!

(P.S. I don’t really know if this is my third week of working on it or not, but it’s probably around there. The title of this post is a reference to a film in which people carry in the banner.)

By S P Hannifin, ago
Programming

My GUI programming efforts continue

I’ve been continuing my efforts to program a custom simple 2D/3D engine in Java with OpenGL with which to create a more user-friendly standalone version of my MIDI animator (and hopefully some games in the future). Lately I’ve been focusing on creating a GUI system. In terms of free open-source 3D engines in Java, I don’t much like most of the GUI implementations, so creating my own has been fun. Granted, I still run in to bugs that are tricky to fix while trying to accomplish relatively simple things, but trying to solve such problems is educational and always a bit addicting, like solving a puzzle, especially as I’m doing it for myself.

So here’s my latest progress update. I’ve settled on using STBTT (included in lwjgl) font rendering for the GUI text and the underutilized Nvidia path rendering (included in OpenGL in general) for the panels (and hopefully more in the future, including possible note shapes in the actual MIDI animator). The panels are movable and can contain an arbitrary amount of word-wrapped text. You can scroll through the text, and the panel can include a y-axis scrollbar of arbitrary size. You’ll also notice that the text fades in and out at the top and bottom, a nice little touch in my opinion that I probably spent too long programming:

I’ve also been streaming my programming efforts on twitch, which is also addicting. It turns what is usually a pretty solitary activity into something at least a little more social, and it’s fun watching the viewer count tick up now and then. Shout out to twitch user Subtixx who has even offered helpful points and advice allowing me to fix problems my eyes don’t catch (such as null-checking the darn scrollbar!); many thanks Subtixx!

My current to-do list includes (but is not limited to):

  • allow gradient coloring on the panels and text
  • allow rounded corners on the panels
  • allow panels to have shadows (render a semi-transparent panel behind)
  • allow panels to be resized dynamically
  • allow panels to be closed (and maybe shrunk?)
  • allow panels to contain some select common GUI elements, such as:
    • buttons
    • text fields (short and long)
    • radio buttons
    • check boxes
    • sliders (continuous and quantified)
    • menus (pop-up and drop-down)
    • tabs on the top or side of panels (which perhaps are just specialized buttons?)

So there’s still quite a bit to do. But I must do it, for this is my quest.


In other unrelated news, a 4th album from symphonic / power metal band Ancient Bards is finally happening! I love this band and I can’t wait for their new album!

By S P Hannifin, ago
Programming

Font rendering: stb oversampling vs NV path rendering

I told you I wanted to try stb oversampling in my last post, and I did! Here is the result (stb 2×2 oversampling on top, nanovg in middle (which is based on stb anyway, but no oversampling), and NV path rendering on bottom, screen size then 5x zoom):

So stb oversampling definitely looks the best, although it is still pretty fuzzy. And moving it around by subpixels looks very decent; it doesn’t get very much of the “shimmer” effect. (Still a bit, but not much to be bothersome.)

Here’s stb oversampling (top) vs NV path rendering (bottom) with a bigger font size (screen size then 2x zoom):

Here, I think NV path rendering looks better; it’s definitely less fuzzy. (The trade-off is that it does suffer from more “shimmer” when translated by subpixels, but it doesn’t bother me too much.)

You can also see that NV path rendering is able to utilize proper kerning: the ‘e’ is slightly below the capital ‘T’, as it should be. Each letter isn’t being drawn on a textured quad, so overlapping is trivial. (Well, for the end library user, at least.)

So, I think that completes my foray into font rendering for now. I’m too lazy to make bitmap fonts at the moment; stb oversampling will work for smaller fonts for now. Time to continue on to other GUI elements. I will try to design the GUI system in such a way that it will be able to utilize any font rendering system should I wish to create bitmap font support in the future.

By S P Hannifin, ago
Movies

More font fun and other random stuff

Font rendering in OpenGL

Haven’t done so much programming in the past week, but I did try rendering fonts with NanoVG (in lwjgl). Unfortunately it’s really not much better than just using OpenGL’s NV path rendering extension. Small fonts look slightly better, but not really good enough for me to want to use them. See the example below, a zoom-in of an 8-pixel high rendering of the font “Verdana”, NanoVG rendering it on top, NV path rendering below. NanoVG is better, but it’s still way too fuzzy to look any good.

So I might just use bitmap fonts for small text; I can’t see any alternative. (Bitmap fonts basically means loading in each letter as a pre-rendered picture and plopping it on the screen. The disadvantage is that they don’t look very good when resized or positioned between pixels, but they’ll at least be guaranteed to render small fonts clearly and crisply.) I’ll continue to use NV path rendering for larger fonts or fonts that need to be animated more dynamically or rendered with 3D perspective. I do want to try using oversampling with stb for small fonts before I move on from font rendering and further develop a GUI system; the demo doesn’t look too bad.


Kanopy film streaming service

I just realized our local library offers free access to the film streaming service Kanopy, and they’ve actually got a decent selection. Not the latest blockbusters, but some good foreign and classic cinema. (They’ve even got The Red Pill, the controversial anti-radical-feminist documentary which Netflix refuses to stream. (Though they did just recently finally add the DVD to their catalog.)) Since it’s free (for library card holders of participating library systems), we’re limited to 10 streams per month, but the streaming quality is decent. It’s not full HD (at least not on my PC), but it’s better than DVD quality. Interestingly they also allow you to embed videos. Here’s “Kumiko the Treasure Hunter”, which I really enjoyed (which I guess you won’t be able to see without an account, haha):

Interesting indeed!


Some metal music

Finally, I recently discovered the band Elvenking. I couldn’t quite get in to some of their older work, but their last album, released last year, is quite catchy. Disregarding the bizarre sense of fashion metal band members tend to share, this song is some power metal awesomeness:

I also came across the latest album from the symphonic metal band Leaves’ Eyes, and found it to be quite catchy as well. Love the use of choirs, the female lead’s operatic voice, and the cheesy fantasy lyrics. (I’m not a big fan of the growl singing, it sounds so gross and ugly and demonic, why is it so popular? It sounds so awful, so unmusical. Bah!)

OK, that’s all for now.

By S P Hannifin, ago
Programming

Font programming fun

So I’ve started working on GUI elements for my little engine that could. My quick list of things I’d like to include in a GUI system:

  • ability to create a menu bar
  • ability to create windows / panels with drop shadows
  • ability to create scroll bars for window content
  • ability to create buttons and button animations (hover, click)
  • ability to create text boxes and text fields

I started working on text today, i.e., font rendering. The NV path rendering extension actually does a pretty good job with larger text:

It’s not so good with smaller text:

Look at that ugly subpixel rendering:

Bleh! So I’ll have to figure out something else for smaller fonts. I’ll probably look into the Java AWT package, or perhaps look into NanoVG, especially since it looks like lwjgl already has bindings for it. (Maybe it already has everything I want?)

By S P Hannifin, ago
Programming

MIDI animator version 2 wishlist…

As I blogged a couple months ago, one of my goals for 2018 is to program a very simple 3D engine. I’ve been wanting to program a simple adventure game for a few years now, but the 3D and 2D engines I’ve played around with just don’t have quite the features I want, so I’m attempting to create my own little game engine with the Lightweight Java Game Library (lwjgl).

Here’s what I’ve got so far: I can render a textured box and some resolution independent vector graphics including true-type fonts, which can intersect with the box!

OK, so nothing special yet.

Anyway, another thing I’d like to create with lwjgl is a new version of my MIDI animator, using vector graphics (instead of custom shaders) to represent the MIDI notes. (On a side note, I’m using the OpenGL “NV path rendering” extension for vector graphics support, which was created by Nvidia. Does that mean it’ll only work on their GPUs? I don’t know.) This should easily allow many more possible note shapes to be created.

Here’s my current wishlist for “MIDI animator 2.0” (I should also come up with a more interesting name):

  • Should be able to run standalone (that is, users shouldn’t have to download and compile the code to use it)
  • A graphical user interface (GUI) that makes it easy to:
    • load MIDI files
    • change note styles / shapes / colors / animations
    • a scroll bar to make it easier to scroll through the MIDI
    • save files
  • Ability to add title / text animations (instead of having to do this in post)
  • Ability to change / animate background
  • Ability to load in an MP3 to sync with the visualization
  • Ability to add an MP3 visualization, such as one of those pulsing frequency bars or something
  • Ability to export a movie file automatically (if I can figure out how; I’ll save this for last)

Anything else I should include or look into?

So, yeah, this is probably what I’ll be working on in my free time for now. I’ll probably start working on a GUI system next as I’d need to do this for a future game anyway.

Hopefully I’ll get back to actually writing some new music afterwards.

By S P Hannifin, ago
Programming

Game programming…

Last year I learned the basics of jMonkeyEngine, and though I intended to create a 2D game with it, I only ended up creating the MIDI animator mentioned in my last post. But for a tile-based 2D game, it’s really not ideal. It’s certainly capable of producing such a game, but as an engine, it’s not really designed for it, and I realized I’d have to spend a considerable amount of time just programming a custom framework for such a project.

So last month I began learning LibGDX, which is certainly better suited for the sort of tile-based 2D adventure game I’d like to create.

So here’s what I’ve got so far (the art is temporary, simply a free tile set I found out there, though I think I’ll be aiming for tiles that are 16×16 pixels as well, so this represents the size I’m hoping for):

screenshot

Doesn’t look like much, but I’m still learning and programming the basics I’ll need before I actually start programming the actual game play. What I’ve learned and/or programmed so far includes:

  • loading and displaying a tilemap (a .tmx file from Tiled)
  • dynamic window resizing (or resolution changing) without completely screwing up the aspect ratio (trickier than it may sound)
    • basically it will always render with a resolution of 1280×720, which is then rendered as a texture to whatever resolution the user sets; handy for Android devices which may feature differing resolutions which cannot be changed
  • using Ashley as an entity framework
  • using Box2D for character movement and collision detection
  • animating the character as he walks (much easier with LibGDX; I had to program a custom shader with jMonkeyEngine)
  • real-time A* pathfinding (hope to use it with NPCs)
  • text (as you can see at the bottom there) to be used with menus, dialog, etc. (nice little font called Munro) (this is also much easier with LibGDX)
  • custom shader to make object tiles “light up”

Still lots to program, but I reckon that’s an OK start. The to-do list before I can actually begin programming the actual game-play logic includes:

  • have interactable objects “light up” as the player nears them, along with a small pop up menu with available actions (pick up, talk, examine, activate, etc.)
  • design and implement a menu panel / status bar (along the black panel along the bottom)
    • this menu will switch to a “dialog mode” when the character is talking with someone (as in The Secret of Monkey Island, for example)
  • pause menu with save, load, quit, settings, etc.
  • camera movement for when the player walks off the screen
  • loading another tilemap for when the character leaves a village or enters a house, for example
  • I need to try sticking an NPC in there and having it play through some scripted material, utilizing the aforementioned A* algorithm as necessary
  • real-time combat system
    • cast a spell or swing a sword to injure attacking enemies (the combat will be simple in this game, nothing fancy)

That’s all I can think of at the moment, but that’s plenty, isn’t it?

The game itself will be pretty short; I’ve tried to keep it short on purpose since even a short game is a lot of work, especially when you’ve never done it before and don’t have a pre-existing framework your familiar with to use. If I manage to actually succeed in this endeavor, I hope it will be easier to create new adventure games and/or RPGs in a similar style without having to reprogram these basics again, at least not from scratch.

The tentative title for the game is Memory of a Thousand Kings, which began as a half-plotted fantasy novel, but I think it will work better as an adventure game.

By S P Hannifin, ago
Programming

Source code for my MIDI animator

I recently uploaded the source code to the MIDI animator I programmed with jMonkeyEngine to github: midi-animator.

To use it, see the Readme there. You’ll need jMonkeyEngine, and understanding Java would probably help. (I’m not really interested in making a standalone user-friendly app at the moment; Stephen Malinowski’s “Music Animation Machine” is still available if you want that. I’m more interested in having something I can continually customize and play around with.)

In addition to perhaps being sloppy (as I never intended to share it), the source code is a bit bloated as it’s actually part of a larger project to create a MIDI editor that will feature my melody generator. But that’s a long way off; I’m not actively working on that at the moment, and probably won’t anytime soon.

So… there it is if anyone else wants to play around with it, or contribute their own improvements to it… feel free!

Also, it’s my first time uploading something to github, so I’m not very familiar with the platform yet… I hope I did it right.

By S P Hannifin, ago
Programming

Still programming…

Haven’t posted in a while, so here’s a little update on what I’ve been up to lately.

Basically, I’ve abandoned Unity for now, though I’d like to get back to learning it at some point. But I’m much more familiar with Java, so I looked around and found jMonkeyEngine, an open-source Java-based 3D engine, so I’ve been learning that. I’m currently working on a small 2D mystery game for PC and Android platforms. (Like a small adventure game, where you go around talking to suspects, searching for clues, collecting inventory and using it, etc.) It will use pixel art, since I can actually create pixel art with a bit of clicking around. Currently I’m using Pyxel Edit to create the pixel art, which is small and elegant and quite affordable (only $9 at the time of this writing). Pixel art actually isn’t too difficult for a non-artist like me. Well, OK, it’s still possible to create really crappy pixel art. What I mean is that it’s much more approachable for a non-artist; you can create an effective passable character (and walk-cycle for that matter) much more easily than, say, trying to draw something with pencil and paper or trying to actually model and texture something in 3D. And it’s not difficult to search for references online to see how other artists did things; everything is made of pixels anyway. So I’m confident I can create the sort of graphics I think this game will need. Still, if I had the money, I’d rather hire a free-lancer. After all, it’s still a time-consuming process, especially the animation.

Anyway, while I’m more familiar with Java programming, jMonkeyEngine has far far less online support than Unity (and their forums are difficult to navigate and contain many broken links). The engine also has far less features. For example, to achieve the animated textures I need for my 2D game, I had to program my own shader. Granted, that’s not too difficult to program once you know how to do it, but I spent over a week just focusing on how shaders work (and only scratched the surface, I’m sure).

Still, the advantage is that I’m working in a programming language I’m much more familiar with, and I’m not obligated to pay any license fees or anything when my game is released. So, while I’m sure I’ll switch back to Unity (or GameMaker) at some point, I do very much appreciate the option of jMonkeyEngine.

So that’s what I’m up to at the moment. I have no idea how long it will take to finish this game, assuming I don’t abandon it. Guess we’ll see. I’m crossing my fingers that it doesn’t take longer than March 2016. (Which means it will probably take until March 2017.)

By S P Hannifin, ago
Programming

Back to Unity 3D

So my Kickstarter quietly (but I suppose not unexpectedly) failed yesterday, though backers did pledge to contribute $785 of the requested $9,000. Which isn’t completely horrible for spending no time building an audience. But it wasn’t nearly enough, so unfortunately there won’t be a book on melody from me in 2016. Not sure yet if I’ll try to build an audience and try another Kickstarter later, or if I’ll find some other way to find the time. But it’s back to being on the back-burner for now.

Other than that, I’m still learning the ins and outs of Unity3D. I’m confident I can learn the programming side with more practice and experience; Unity is so much more convenient and intuitive than the engines I fooled around with a bit more than a decade ago in high school. (I could swear I used to understand quaternions when I was in high school. Not that I really need to understand them now, as Unity takes care of them, but I still want to understand them again, if I ever really did.)

I’m also not worried about game design. Though I don’t really have much practical experience with it (beyond daydreaming), it is the fun part of game development. Writing, designing puzzles, storytelling, etc… Those are what excite me about game development in the first place. I would never have bothered to learn GW-BASIC when I was in elementary school if storytelling through video games didn’t excite me.

What I don’t have any experience with is creating art for games. Modeling, texturing, or drawing in general. And since I can’t afford to hire freelancers, that’s something I’m going to have to learn, and a skill I’d love to have anyway. Though I may try programming a game that features purely abstract shapes to circumvent the need for art, I still want to create adventure games at some point, and those will require some modeling and texturing skills.

So there’s that fun stuff, and of course I’ve still got some novels I’m working on…

By S P Hannifin, ago