Building Comanche 3D in less than 100 lines of code (UPDATE)

I have tested both (LLVM) and (MemBlocks & Ptrs) and there is a huge difference winning LLVM by far… Much more fluid and responsive than the MB counterpart… hmm…

guess only the Xojo devs will be able to answer why the Xojoscript version runs better on OSX and worse on Windows, and why the Memoryblock one better on Windows and worse on OSX.

Because of all the processing to communicate outside XojoScript I would think this difference will change.

I am just curios but my question is will the LLVM compiler mean it takes a lot less processing than having XojoScript communicate with the outside.

Probably stating the obvious but doesn’t OS X process the MemoryBlock backwards to Windows. Excuse my ignorance but couldn’t you optimise the code so the memoryblock is used differently on Windows to Mac. You probably already done so but I am just checking.

Again, I am here to learn so I am ignorant.


Alright, it’s 02:20 am here in Germany and I’ve uploaded my result to Dropbox. Optimization for Mac is done and it runs pretty smooth even with huge NASA Marble Earth Map @ 10800x10800 Pixels.

Collision Detection works only theoretically. There are still some glitches, so I’ve commented the lines out.
SFX, HUD, MFDs and Cockpit are all work in progress and not implemented yet.

A nice new feature is to be found in the menu bar. Now you can load your custom surface/height map without Imitation to 1024x1024 Pixels. I’ve included my NASA Marple Earth Maps with 10800x10800 Pixels within the ZIP for testing.

You will also find the binares inside the /build folder, compiled with fresh XOJO 2.1release.

Download Link:

Have fun! More on this in the next days…

You’re think cowboys and Endians (see what I did there). It’s to do with processors. Motorola based chips are Big Endian, while Intel is little Endian. Intel based Macs read in the same order as Intel based Windows/Linux.

Although so of Apple’s older APIs still have to be used with Big Endians.

Gooooood morning, Vietnam! (sorry, watched the movie yesterday, RIP Robin Williams)

@Tomas Jakobs Have some sleep man! One thing I’ve noticed from the Windows side in your new version is a problem with the two timers. Using the UpdateTimer causes the screen to stutter, but once I remove that one and put the Update() into the KeyboardTimer, everything is smooth as hell again. Must be another difference between how OSX and Windows handle stuff in Xojo.

I find this project an interesting case study to find out what different programming approaches one must take on the different platforms to maximize speed. Even for the Xojo devs this could be valuable info to streamline their coding to make Xojo a true 1-Click-All-Platforms programming language, using the most optimized way for all platforms.

:slight_smile: RIP Robin…

The different behavoir made me check out threads and voil it seems that threads are far better for cross-platform developing than Timers. It now runs on both, Mac and Windows quite smoothly. Would be nice if somebody else could cross check Linux.

Would be nice feature for Xojo to address different cores than just sharing one CPU core.

The Files on are updated now.

I haven’t seen this mentioned but I just noticed these terrain maps wrap! The left is the same as the right, top same as the bottom, so they can be tiled seamlessly. Here’s just 2 side by side…

I think it should be relatively easy to implement tiling in the voxel engine (if only I understood it). Commenting out this line and it’s “end” in RayCast sorta does it.

if x1 > 0 and y1 > 0 and x1 < MapSize and y1 < MapSize then

Artifacts show up in the sky area along 2 edges of the terrain, but along the other it repeats and you can fly forever.

I thought this would do it, wrapping the sampling coordinate inside the map but instead it makes some fisheye effect.

x1 = (x1 + dx) mod MapSize y1 = (y1 + dy) mod MapSize

Hmmm, now that I think about it, commenting out that ‘if’ line should make it crash (out of bounds exception) but it doesn’t for me!? Tested in XOJOComancheMB.

Alain And Tomas, where are you guys getting these maps? They make all the difference. Flying over Europe is cool :slight_smile:

Nice find! I got my maps from the original game.

Some Depths are double but this is they work for both color maps.

I’ve got mine from NASA Blue Marble Collection:

You can create whole earth as 43.200x43.200 Pixel if you put all single pieces together :wink:

Ok, so I got it running on Ubuntu Linux 13.04 i386… unfortunately my VM itself is too slow for me to gauge the running speeds of the app… but it runs on Ubuntu 32-bit.

The latest version from Tomas:

  1. works on Windows 8.1 at about 2-4 frames per second
  2. works on OS X at about 5-7 frames per second
  3. does not work on Linux Ubuntu (32 bit) 14.04 (times out)

These are all authentic machines. No VM was used during testing, and all used Xojo 2014 r2.1 running in the IDE

Hi @Eugene Dakin !

I’m having about the same results. Haven’t looked into Tomas’ code yet, but I suspect the mix of timers and threads is causing the low FPS. Could you run your tests with my original version with memoryblocks and pointers?

btw. How is your new book doing? :slight_smile:

Okay I’ve googled a bit around and found this as best solution for further speed improvements:

It’s an open source, x-platform (Linux, Win, Mac OS) 3D engine and as far as I know there was already a wrapper for Realbasic named Franklin 3D. But the website seems to be down and I can’t find anything about this anymore. :frowning:

@Eugene: Have you tried compiled apps?

Hi Alain,

The Xojo Web book is coming along, and is getting big - thanks for asking :slight_smile:

I tried the Comanche 3D version with memoryblock and pointers on the three OS’s, and ran both of them in IDE and compiled mode. These are on real systems, no Virtual Machines. I also added a Frames-per-second measurement to accurately get the refresh rate, and here are the results:

Windows 8.1 IDE: 7 FPS
Windows 8.1 Compiled: 13 FPS

Maverick IDE: 7-8 FPS
Maverick Compiled: 13-14 FPS

Ubuntu 14.04 (32 bit): will not run. The screen appears with the first screen shot in full colour, and then Xojo times-out.

To increase the speed, I suggest using a thread-timer combination. Have the thread perform the lengthy calculations because the thread is extremely fast. Update the Canvas Graphics at a rate of about 30 FPS with the timer, which should give smoother looking graphics. The graphics timer number will need to be adjusted based on each system, and this method would work to improve the ‘feel’ of the game.

This Comanche 3D program looks GREAT!!

Thanks or the update!

Great to hear!

So analysing your benchmarks, I noticed OSX has a slightly higher range and Windows is consistent :slight_smile:

I think that’s what Tomas tried. If I find some time, I look further into this.


After trying some troubleshooting in Ubuntu 14.04, I found out the Xojo IDE does not like the method called Update, I changed the method and method calls to Update1 and will do some more troubleshooting.

Found something interesting - maybe something with Xojo in Ubuntu 32-bit?

The method ‘Update’ in Ubuntu wants to default to ‘UpdateNow()’ and will auto-change to this method name. Does anyone know why this may be significant in either Xojo or Ubuntu ?

In the method Raycast, if the entire ‘while i<r-20’ loop is commented, then the program runs fine on Ubuntu. If I uncomment ONLY this bit of code, the program refuses to work:

While i<r-20 i = i + 1 'other large blocks of code here are commented wend

What I don’t understand, is if the i = i+1 is changed to i = i + 10, then the program works (albeit, slowly).

For some reason, the Xojo IDE doesn’t seem to like i = i + 1.

Created feedback 34921

From another place on the internets comes this message.

Just wondering what’s happened to your other products,
Franklin 3D and Franklin audio. The web sites come up as
“Website disabled”.

They will come back eventually. We are in the middle of a huge, long overdue
site update for Paradigma Software’s main site.

The Franklin site got hacked in a big way some time ago, so when we get the
new Paradigma site done we will bring back Franklin.

That was posted by Lynn Fredricks, so if you want to know more about it, you need to ask him.