Home       About Me       Contact       Downloads       Part 49    Part 51   

Part 50: Spring Cleaning

March 10, 2012

Looking at all the pieces of code spread over my disk, and the months of time which have passed since the last update of the source code on GitHub, I realized it's time for some spring cleaning. I've also added a new download page to the site and changed the front page.

You can download all the demos in one big zip here:

For Windows, download Part 50 Demos - Windows.
For Linux, download Part 50 Demos - Linux.
For Mac, download Part 50 Demos - Mac.

You can download all the source code here: Part 50 Demos - Source.

Or get all the source from GitHub:

https://github.com/mgoodfel/mgFramework
https://github.com/mgoodfel/SeaOfMemes
https://github.com/mgoodfel/Crafty
https://github.com/mgoodfel/McrView

Changes

There are numerous small changes to the framework and demos. For UI, you can get help on all the demos with F1. The demos now start with an arrow cursor and you end the app by just closing the window. ESC toggles to a cross cursor which works shooter-style causing the mouse to turn the eye.

I've rebuilt the 2D text using the FreeType library, so we now have text on all three platforms. Yay! This may cause some problems:

  • I rely on the operating system to tell me the dots per inch of the display. This can be wrong. If the text is the wrong size, edit the options.xml file for the demo and change the dpi option. Zero is the default and means trust the OS. Reasonable values are around 100. Higher numbers will get you larger text.

  • Each operating system puts the fonts in a different directory, and spells them differently. On Windows, we look in c:\Windows\Fonts for georgiaz.ttf, and on the Mac we look in /Library/Fonts for Georgia Bold Italic.ttf. And so on. There's now a new file docs/fonts/fonts.xml which gives the framework font names to try. Rather than hardcode these for each platform, it just looks for all of them until it finds a font.

    If for some reason, your system is not finding any fonts, the app will put up an error dialog, or just crash (I don't have error dialogs working on Linux.) Send me the errors.txt file, or look there yourself to see if it's looking for the wrong font name on your system, or looking in the wrong place.

  • I'm not caching any of the character bitmaps produced by FreeType, so text is quite a bit slower than it was. I'll fix that soon. None of the demos use much text, so you shouldn't notice it.

The other big change in the framework is the internationalization code. I'll write a separate part on that. It still needs work.

Statistics

Readers have also asked me to update the statistics on how much code there is in the project. That's a bit of a problem. There's a lot of code duplicated in the framework -- between OpenGL 2.1 and OpenGL 3.3, and between the Linux initialization and the Mac initialization, etc. The demos have variations on the same code for their UI. It's a judgement call what to count.

When I last counted all the code (part 19), I was picking and choosing parts of each platform, based on how different I thought they were. I neglected to make a list of which files I counted! To get comparable counts from then to now, I've redone the Part 19 counts to just include OpenGL 3.3 on Windows, and nothing else. I've done the same for the Part 50 source. This is just lines of c/c++ source, with no include files and no shaders.

   Part 19     Part 50
Framework lines   7,402 9,405
Utilities lines 6,738 10,986
Application lines 8,631 41,421
Total 22,771 61,812

Coding hours 464.7 1,225.1
Writeup hours 90.2 243.3

Counted this way, the 3D framework hasn't grown much. Some function has actually moved out of the framework into the "Utilities" category -- all the covering classes for threads, events and timers moved, for example. The biggest growth has been in application code.

I've eliminated duplicate code in Crafty, McrView and SeaOfMemes, as well as duplicate classes in the little framework demos. I'm also not including any of the utilities I've written like the Collada importer, or side projects like ray tracing. So this is an underestimate of the project size at this point.

I don't plan to update the source totals very often, since it's kind of a nuisance. I have to combine the source from all the parts of the project, then eliminate any shared code and any library code. I'll do it again when I have some kind of significant milestone.

Next, let me run through each part of the project and give you the status.

SeaOfMemes

The demo shows the planet, moon and ring. You can sort of land on them by approaching until the range text turns red, then hitting "L". That should rotate the eye space until you are in the coordinate system of the object you land on. It doesn't quite work right. Hit "L" again to transition back to space.

The options file controls the rate of motion of all the system objects. You can change the rotation speeds if you like. The "DayLen" options at the end are in seconds. Don't use zero.

There's dead code in the project for asteroids and generation ships, etc. I'll get to work on cleaning that up soon. For now, this is the same as the Part 41 video.

To download SeaOfMemes alone, go to Download SeaOfMemes. Here's a video.

Crafty

I've thrown out the old Octree-based version and replaced it with the latest code from McrView. I'm generating the landscape procedurally and converting it into cubes as you move. There's no editing function yet. That will be the next item on this part of the project.

To download Crafty alone, go to Download Crafty.

McrView

There is nothing new in McrView since Part 37. I'll put putting an export dialog into this next.

I might also add code to read the location of your avatar from the Minecraft files. That's kept in a completely different table than the world data, and so I ignored it. Some of the worlds I download from the net have the buildings far away from the (0,0,0) position however, and I can't actually find the good stuff!

A map view would also be nice. So would a way to view nether areas.

Of course, as I was testing this, I happened to fire up the real Minecraft, and noticed they've changed the file format (again!) So now I have to add code to handle the new database. Sigh.

To download McrView alone, go to Download McrView. Here's a video.

Framework


TestCube

Trees

Landscape

SaucerMovie

There are now four framework demos -- TestCube, Trees, Landscape and SaucerMovie. To download these, go to Download Framework.

That's all for this week.

Home       About Me       Contact       Downloads       Part 49    Part 51   

blog comments powered by Disqus